diff --git a/common/convert.py b/common/convert.py index 6ba29cabb..8964fc3ed 100644 --- a/common/convert.py +++ b/common/convert.py @@ -1,4 +1,5 @@ from datetime import timedelta +from typing import Optional from typing import Tuple from django.core.exceptions import ValidationError @@ -6,7 +7,9 @@ from employees.common.strings import ReportValidationStrings -def timedelta_to_string(data: timedelta) -> str: +def timedelta_to_string(data: Optional[timedelta]) -> str: + if data is None: + return "" days = data.days hours = data.seconds // 3600 minutes = (data.seconds % 3600) // 60 diff --git a/employees/forms.py b/employees/forms.py index c4a1234b3..defe327b5 100644 --- a/employees/forms.py +++ b/employees/forms.py @@ -32,13 +32,13 @@ def __init__(self, queryset: QuerySet, *args: Any, **kwargs: Any) -> None: class DurationInput(TextInput): def format_value(self, value: Optional[str]) -> str: - if value is not None: + if value is not None and value != ":": return timedelta_to_string(parse_duration(value)) return "" class DurationFieldForm(forms.DurationField): - widget = DurationInput + widget = DurationInput(attrs={"data-mask": "09:99", "placeholder": "H:MM"}) def clean(self, value: str) -> str: if value is None: diff --git a/employees/templates/employees/author_report_list.html b/employees/templates/employees/author_report_list.html index b379ca336..4623a6f28 100644 --- a/employees/templates/employees/author_report_list.html +++ b/employees/templates/employees/author_report_list.html @@ -89,6 +89,6 @@

{{ object.email }} {{ title_date }}{{ UI_text.PAGE_TITLE.value }}

{% block extra_script %} {{ month_form.media }} - + {% endblock %} diff --git a/employees/templates/employees/project_report_list.html b/employees/templates/employees/project_report_list.html index 60b650051..764dbe728 100644 --- a/employees/templates/employees/project_report_list.html +++ b/employees/templates/employees/project_report_list.html @@ -84,6 +84,6 @@

{{ author.grouper }}

{% block extra_script %} {{ month_form.media }} - + {% endblock %} diff --git a/employees/templates/employees/report_detail.html b/employees/templates/employees/report_detail.html index d80092a38..9090fc349 100644 --- a/employees/templates/employees/report_detail.html +++ b/employees/templates/employees/report_detail.html @@ -33,7 +33,7 @@

{{ UI_text.PAGE_TITLE.value }}{{ report.project }} ({{ report.date }})

{% block extra_script %} {{ form.media }} - + + {{ form.media }} + {{ month_form.media }} - + {% endif %} diff --git a/users/templates/user_update.html b/users/templates/user_update.html index 46ef51464..d48b79c5e 100644 --- a/users/templates/user_update.html +++ b/users/templates/user_update.html @@ -64,7 +64,7 @@

Account details

{% block extra_script %} {{ form.media }} - + {% endblock %} diff --git a/users/templates/users_detail.html b/users/templates/users_detail.html index 9861cbbbd..3f1a5ce4e 100644 --- a/users/templates/users_detail.html +++ b/users/templates/users_detail.html @@ -71,7 +71,7 @@

{% block extra_script %} {{ form.media }} - +