Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions appointment/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def prepare_appointment_display_data(user, appointment_id):
return None, None, _("You are not authorized to view this appointment."), 403

# Prepare the data for display
page_title = _("Appointment Details for {client_name}").format(client_name=appointment.get_client_name())
page_title = _("Appointment details: {client_name}").format(client_name=appointment.get_client_name())
if user.is_superuser:
page_title += f' ({appointment.get_staff_member_name()})'
page_title += f' (by: {appointment.get_staff_member_name()})'

return appointment, page_title, None, 200

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h2>{% trans "Manage Working Hours" %}</h2>
</div>

<div class="form-group">
<label for="{{ working_hours_form.start_time.id_for_label }}">{% trans 'Start Time' %}:</label>
<label for="{{ working_hours_form.start_time.id_for_label }}">{% trans 'Start time' %}:</label>
<div class="input-group date" id="start-timepicker" data-target-input="nearest">
<input type="text" class="form-control datetimepicker-input" data-toggle="datetimepicker"
data-target="#start-timepicker" name="{{ working_hours_form.start_time.name }}"
Expand All @@ -50,7 +50,7 @@ <h2>{% trans "Manage Working Hours" %}</h2>
</div>

<div class="form-group">
<label for="{{ working_hours_form.end_time.id_for_label }}">{% trans 'End Time' %}:</label>
<label for="{{ working_hours_form.end_time.id_for_label }}">{% trans 'End time' %}:</label>
<div class="input-group date" id="end-timepicker" data-target-input="nearest">
<input type="text" class="form-control datetimepicker-input" data-toggle="datetimepicker"
data-target="#end-timepicker" name="{{ working_hours_form.end_time.name }}"
Expand Down
14 changes: 7 additions & 7 deletions appointment/templates/administration/user_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<h2>{% trans 'Personal Information' %}</h2>
<!-- Display fields from PersonalInformationForm -->
<div class="section-content">
<p><strong>{% trans 'First Name' %}:</strong> {{ user.first_name }}</p>
<p><strong>{% trans 'Last Name' %}:</strong> {{ user.last_name }}</p>
<p><strong>{% trans 'First name' %}:</strong> {{ user.first_name }}</p>
<p><strong>{% trans 'Last name' %}:</strong> {{ user.last_name }}</p>
<p><strong>{% trans 'Email' %}:</strong> {{ user.email }}</p>
</div>
<a href="{% url 'appointment:update_user_info' user.id %}"
Expand Down Expand Up @@ -94,8 +94,8 @@ <h2>{% trans 'Days Off' %}</h2>
<table>
<thead>
<tr>
<th>{% trans 'Start Date' %}</th>
<th>{% trans 'End Date' %}</th>
<th>{% trans 'Start date' %}</th>
<th>{% trans 'End date' %}</th>
<th>{% trans 'Description' %}</th>
<th>{% trans 'Action' %}</th>
</tr>
Expand Down Expand Up @@ -161,8 +161,8 @@ <h2>{% trans 'Working Hours' %}</h2>
<thead>
<tr>
<th>{% trans 'Day' %}</th>
<th>{% trans 'Start Time' %}</th>
<th>{% trans 'End Time' %}</th>
<th>{% trans 'Start time' %}</th>
<th>{% trans 'End time' %}</th>
<th>{% trans 'Action' %}</th>
</tr>
</thead>
Expand Down Expand Up @@ -229,7 +229,7 @@ <h2>{% trans 'Service Offered' %}</h2>
<th>{% trans 'Description' %}</th>
<th>{% trans 'Duration' %}</th>
<th>{% trans 'Price' %}</th>
<th>{% trans 'Down Payment' %}</th>
<th>{% trans 'Down payment' %}</th>
</tr>
</thead>
<tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1 class="description-title">{% trans "Tell us a bit about yourself" %}</h1>
</div>
<div class="phone-number">
<label for="{{ form.phone.id_for_label }}">
{% trans "Phone Number" %} *<br>
{% trans "Phone" %} *<br>
</label>
<div class="phone-input-container">
{{ form.phone }}
Expand Down
27 changes: 15 additions & 12 deletions appointment/utils/date_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import datetime

from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext_lazy as _, ngettext

from appointment.settings import APP_TIME_ZONE

Expand Down Expand Up @@ -43,23 +43,26 @@ def convert_minutes_in_human_readable_format(minutes: float) -> str:
return _("Not set.")
if minutes < 0:
raise ValueError("Minutes cannot be negative.")
days, minutes = divmod(int(minutes), 1440)
hours, minutes = divmod(int(minutes), 60)

def format_unit(value, single_name, plural_name):
return _("{value} {name}").format(value=value, name=single_name if value <= 1 else plural_name)
days, remaining_minutes = divmod(int(minutes), 1440)
hours, minutes = divmod(int(remaining_minutes), 60)

parts = []
if days:
parts.append(format_unit(days, "day", "days"))
days_display = ngettext("%(count)d day", "%(count)d days", days) % {'count': days}
parts.append(days_display)

if hours:
parts.append(format_unit(hours, "hour", "hours"))
hours_display = ngettext("%(count)d hour", "%(count)d hours", hours) % {'count': hours}
parts.append(hours_display)

if minutes:
parts.append(format_unit(minutes, "minute", "minutes"))
minutes_display = ngettext("%(count)d minute", "%(count)d minutes", minutes) % {'count': minutes}
parts.append(minutes_display)

if len(parts) == 1:
return parts[0]
elif len(parts) == 2:
return _(" and ").join(parts)
return _("{first_part} and {second_part}").format(first_part=parts[0], second_part=parts[1])
elif len(parts) == 3:
return _("{days}, {hours} and {minutes}").format(days=parts[0], hours=parts[1], minutes=parts[2])
else:
Expand All @@ -70,8 +73,8 @@ def convert_str_to_date(date_str: str) -> datetime.date:
"""Convert a date string to a datetime date object.

:param date_str: The date string.
Supported formats include '%Y-%m-%d' (like "2023-12-31") and '%Y/%m/%d' (like "2023/12/31").
:return: datetime.date, the converted date
Supported formats include `%Y-%m-%d` (like "2023-12-31") and `%Y/%m/%d` (like "2023/12/31").
:return: The converted `datetime.date`'s object.
"""
date_formats = ['%Y-%m-%d', '%Y/%m/%d', '%Y.%m.%d']

Expand Down