fix #1085 maybe could be done better but for 1.5 integration this could be used . input 60< is converted to hh:mm
This commit is contained in:
parent
d889be6db6
commit
8e6269b495
@ -23,7 +23,7 @@ class ItemForm(CleanHtmlFormMixin, CssClassMixin, forms.ModelForm):
|
|||||||
queryset=Item.objects.all(), label=ugettext_lazy("Parent item"), required=False)
|
queryset=Item.objects.all(), label=ugettext_lazy("Parent item"), required=False)
|
||||||
|
|
||||||
duration = forms.RegexField(
|
duration = forms.RegexField(
|
||||||
regex=re.compile('[0-99]:[0-5][0-9]'),
|
regex=re.compile('^(?:[0-9]{1,2}:[0-5][0-9]|[0-9]+)$'),
|
||||||
error_message=ugettext_lazy("Invalid format. Hours from 0 to 99 and minutes from 00 to 59"),
|
error_message=ugettext_lazy("Invalid format. Hours from 0 to 99 and minutes from 00 to 59"),
|
||||||
max_length=5,
|
max_length=5,
|
||||||
required=False,
|
required=False,
|
||||||
|
@ -57,11 +57,19 @@ class Overview(TemplateView):
|
|||||||
duration = timedelta()
|
duration = timedelta()
|
||||||
|
|
||||||
for item in items:
|
for item in items:
|
||||||
if (item.duration is not None and
|
if item.duration is not None and len(item.duration) > 0:
|
||||||
len(item.duration) > 0):
|
if ':' in item.duration:
|
||||||
duration_list = item.duration.split(':')
|
duration_list = item.duration.split(':')
|
||||||
duration += timedelta(hours=int(duration_list[0]),
|
duration += timedelta(hours=int(duration_list[0]),
|
||||||
minutes=int(duration_list[1]))
|
minutes=int(duration_list[1]))
|
||||||
|
else:
|
||||||
|
hours = int(item.duration) / 60
|
||||||
|
minutes = int(item.duration) - (60 * hours)
|
||||||
|
duration += timedelta(hours=hours,
|
||||||
|
minutes=minutes)
|
||||||
|
if minutes < 10:
|
||||||
|
minutes = "%s%s" % (0, minutes)
|
||||||
|
item.duration = "%s:%s" % (hours, minutes)
|
||||||
if not start is None:
|
if not start is None:
|
||||||
item.tooltip = start + duration
|
item.tooltip = start + duration
|
||||||
|
|
||||||
@ -118,7 +126,7 @@ class Overview(TemplateView):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
Item.objects.rebuild()
|
Item.objects.rebuild()
|
||||||
# TODO: assure, that it is a valid tree
|
# TODO: assure, that it is a valid tree
|
||||||
context = self.get_context_data(**kwargs)
|
context = self.get_context_data(**kwargs)
|
||||||
transaction.commit()
|
transaction.commit()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user