agendas: add fields to allow partial bookings (#78056)

This commit is contained in:
Valentin Deniaud 2023-05-31 10:16:16 +02:00
parent 12a1fbaa72
commit 640466742c
3 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,32 @@
# Generated by Django 3.2.18 on 2023-05-31 08:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agendas', '0153_event_index'),
]
operations = [
migrations.AddField(
model_name='agenda',
name='partial_bookings',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='booking',
name='end_time',
field=models.TimeField(null=True),
),
migrations.AddField(
model_name='booking',
name='start_time',
field=models.TimeField(null=True),
),
migrations.AddField(
model_name='event',
name='end_time',
field=models.TimeField(null=True, verbose_name='End time'),
),
]

View File

@ -289,6 +289,7 @@ class Agenda(models.Model):
null=True,
blank=True,
)
partial_bookings = models.BooleanField(default=False)
class Meta:
ordering = ['label']
@ -1934,6 +1935,7 @@ class Event(models.Model):
agenda = models.ForeignKey(Agenda, on_delete=models.CASCADE)
start_datetime = models.DateTimeField(_('Date/time'))
end_time = models.TimeField(_('End time'), null=True)
recurrence_days = ArrayField(
models.IntegerField(choices=WEEKDAY_CHOICES),
verbose_name=_('Recurrence days'),
@ -2429,6 +2431,7 @@ class Event(models.Model):
agenda=self.agenda,
primary_event=self,
slug=self.slug,
end_time=self.end_time,
duration=self.duration,
places=self.places,
waiting_list_places=self.waiting_list_places,
@ -2665,6 +2668,9 @@ class Booking(models.Model):
absence_callback_url = models.URLField(blank=True)
color = models.ForeignKey(BookingColor, null=True, on_delete=models.SET_NULL, related_name='bookings')
start_time = models.TimeField(null=True)
end_time = models.TimeField(null=True)
@property
def user_name(self):
return ('%s %s' % (self.user_first_name, self.user_last_name)).strip()

View File

@ -1245,7 +1245,7 @@ class ImportEventsForm(forms.Form):
raise ValidationError(_('Invalid file format. (duration, {event_no} event)'), i)
try:
event.full_clean(exclude=['desk', 'meeting_type', 'primary_event'])
event.full_clean(exclude=['desk', 'meeting_type', 'primary_event', 'end_time'])
except ValidationError as e:
errors = [_('Invalid file format:\n')]
for label, field_errors in e.message_dict.items():