manager: allow separate arrival/departure check for partial bookings (#80047)
gitea/chrono/pipeline/head This commit looks good Details

This commit is contained in:
Valentin Deniaud 2023-08-02 16:56:51 +02:00
parent 5f14f2a47b
commit f94e46daf5
4 changed files with 16 additions and 9 deletions

View File

@ -12,11 +12,11 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='booking',
name='user_check_end_time',
field=models.TimeField(null=True, verbose_name='Departure'),
field=models.TimeField(null=True, blank=True, verbose_name='Departure'),
),
migrations.AddField(
model_name='booking',
name='user_check_start_time',
field=models.TimeField(null=True, verbose_name='Arrival'),
field=models.TimeField(null=True, blank=True, verbose_name='Arrival'),
),
]

View File

@ -2702,8 +2702,8 @@ class Booking(models.Model):
user_was_present = models.BooleanField(null=True)
user_check_type_slug = models.CharField(max_length=160, blank=True, null=True)
user_check_type_label = models.CharField(max_length=150, blank=True, null=True)
user_check_start_time = models.TimeField(_('Arrival'), null=True)
user_check_end_time = models.TimeField(_('Departure'), null=True)
user_check_start_time = models.TimeField(_('Arrival'), null=True, blank=True)
user_check_end_time = models.TimeField(_('Departure'), null=True, blank=True)
out_of_min_delay = models.BooleanField(default=False)
extra_emails = ArrayField(models.EmailField(), default=list)

View File

@ -66,7 +66,7 @@
>
<strong class="sr-only">{% trans "Checked period:" %}</strong>
<time datetime="{{ booking.user_check_start_time|time:"H:i" }}">{{ booking.user_check_start_time|time:"H:i" }}</time>
{% if booking.user_check_start_time and booking.user_check_end_time %}{% endif %}
<time datetime="{{ booking.user_check_end_time|time:"H:i" }}">{{ booking.user_check_end_time|time:"H:i" }}</time>
{% if booking.user_check_type_label %}<span>{{ booking.user_check_type_label }}</span>{% endif %}
</p>

View File

@ -1637,10 +1637,17 @@ class AgendaDayView(EventChecksMixin, AgendaDateView, DayArchiveView):
if booking.user_was_present is not None:
booking.check_css_class = 'present' if booking.user_was_present else 'absent'
booking.check_css_left = get_time_ratio(booking.user_check_start_time, start_time)
booking.check_css_width = get_time_ratio(
booking.user_check_end_time, booking.user_check_start_time
)
if booking.user_check_start_time and booking.user_check_end_time:
booking.check_css_left = get_time_ratio(booking.user_check_start_time, start_time)
booking.check_css_width = get_time_ratio(
booking.user_check_end_time, booking.user_check_start_time
)
elif booking.user_check_start_time:
booking.check_css_left = get_time_ratio(booking.user_check_start_time, start_time)
booking.check_css_width = 1
else:
booking.check_css_left = get_time_ratio(booking.user_check_end_time, start_time) - 1
booking.check_css_width = 1
agenda_day_view = AgendaDayView.as_view()