Projet

Général

Profil

0002-agendas-add-weekday-indexes-to-time-period-45159.patch

Valentin Deniaud, 15 mars 2022 13:39

Télécharger (2,67 ko)

Voir les différences:

Subject: [PATCH 2/5] agendas: add weekday indexes to time period (#45159)

 .../0111_timeperiod_weekday_indexes.py        | 33 +++++++++++++++++++
 chrono/agendas/models.py                      | 15 +++++++++
 2 files changed, 48 insertions(+)
 create mode 100644 chrono/agendas/migrations/0111_timeperiod_weekday_indexes.py
chrono/agendas/migrations/0111_timeperiod_weekday_indexes.py
1
# Generated by Django 2.2.19 on 2022-03-15 11:41
2

  
3
import django.contrib.postgres.fields
4
from django.db import migrations, models
5

  
6

  
7
class Migration(migrations.Migration):
8

  
9
    dependencies = [
10
        ('agendas', '0110_person_sharedcustodyagenda_sharedcustodyperiod_sharedcustodyrule'),
11
    ]
12

  
13
    operations = [
14
        migrations.AddField(
15
            model_name='timeperiod',
16
            name='weekday_indexes',
17
            field=django.contrib.postgres.fields.ArrayField(
18
                base_field=models.IntegerField(
19
                    choices=[
20
                        (1, 'First of the month'),
21
                        (2, 'Second of the month'),
22
                        (3, 'Third of the month'),
23
                        (4, 'Fourth of the month'),
24
                        (5, 'Fifth of the month'),
25
                    ]
26
                ),
27
                blank=True,
28
                null=True,
29
                size=None,
30
                verbose_name='Repeat',
31
            ),
32
        ),
33
    ]
chrono/agendas/models.py
1190 1190
        )
1191 1191

  
1192 1192

  
1193
WEEK_CHOICES = [
1194
    (1, _('First of the month')),
1195
    (2, _('Second of the month')),
1196
    (3, _('Third of the month')),
1197
    (4, _('Fourth of the month')),
1198
    (5, _('Fifth of the month')),
1199
]
1200

  
1201

  
1193 1202
class TimePeriod(models.Model):
1194 1203
    weekday = models.IntegerField(_('Week day'), choices=WEEKDAYS_LIST)
1204
    weekday_indexes = ArrayField(
1205
        models.IntegerField(choices=WEEK_CHOICES),
1206
        verbose_name=_('Repeat'),
1207
        blank=True,
1208
        null=True,
1209
    )
1195 1210
    start_time = models.TimeField(_('Start'))
1196 1211
    end_time = models.TimeField(_('End'))
1197 1212
    desk = models.ForeignKey('Desk', on_delete=models.CASCADE, null=True)
1198
-