agendas: add weekday indexes to time period (#45159)

This commit is contained in:
Valentin Deniaud 2022-01-20 16:34:08 +01:00
parent 839a578bd0
commit 6c067790e1
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,33 @@
# Generated by Django 2.2.19 on 2022-03-15 11:41
import django.contrib.postgres.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('agendas', '0110_person_sharedcustodyagenda_sharedcustodyperiod_sharedcustodyrule'),
]
operations = [
migrations.AddField(
model_name='timeperiod',
name='weekday_indexes',
field=django.contrib.postgres.fields.ArrayField(
base_field=models.IntegerField(
choices=[
(1, 'First of the month'),
(2, 'Second of the month'),
(3, 'Third of the month'),
(4, 'Fourth of the month'),
(5, 'Fifth of the month'),
]
),
blank=True,
null=True,
size=None,
verbose_name='Repeat',
),
),
]

View File

@ -1260,8 +1260,23 @@ class WeekTime(collections.namedtuple('WeekTime', ['weekday', 'time'])):
)
WEEK_CHOICES = [
(1, _('First of the month')),
(2, _('Second of the month')),
(3, _('Third of the month')),
(4, _('Fourth of the month')),
(5, _('Fifth of the month')),
]
class TimePeriod(models.Model):
weekday = models.IntegerField(_('Week day'), choices=WEEKDAYS_LIST)
weekday_indexes = ArrayField(
models.IntegerField(choices=WEEK_CHOICES),
verbose_name=_('Repeat'),
blank=True,
null=True,
)
start_time = models.TimeField(_('Start'))
end_time = models.TimeField(_('End'))
desk = models.ForeignKey('Desk', on_delete=models.CASCADE, null=True)