Skip to content

Commit e263540

Browse files
authored
Merge pull request #193 from pneumaticapp/backend/users/45421__vacation_users
45421 backend [ users ] Vacation users
2 parents e2fa5b6 + 4af386c commit e263540

109 files changed

Lines changed: 6401 additions & 201 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ services:
109109
CIO_TEMPLATE__MENTION: ${CIO_TEMPLATE__MENTION:-}
110110
CIO_TEMPLATE__TASK_REMINDER: ${CIO_TEMPLATE__TASK_REMINDER:-}
111111
CIO_TEMPLATE__COMPLETE_WORKFLOW: ${CIO_TEMPLATE__COMPLETE_WORKFLOW:-}
112+
CIO_TEMPLATE__VACATION_DELEGATION: ${CIO_TEMPLATE__VACATION_DELEGATION:-}
112113
EMAIL_HOST: ${EMAIL_HOST:-}
113114
EMAIL_PORT: ${EMAIL_PORT:-}
114115
EMAIL_HOST_USER: ${EMAIL_HOST_USER:-}
@@ -205,6 +206,7 @@ services:
205206
CIO_TEMPLATE__MENTION: ${CIO_TEMPLATE__MENTION:-}
206207
CIO_TEMPLATE__TASK_REMINDER: ${CIO_TEMPLATE__TASK_REMINDER:-}
207208
CIO_TEMPLATE__COMPLETE_WORKFLOW: ${CIO_TEMPLATE__COMPLETE_WORKFLOW:-}
209+
CIO_TEMPLATE__VACATION_DELEGATION: ${CIO_TEMPLATE__VACATION_DELEGATION:-}
208210
EMAIL_HOST: ${EMAIL_HOST:-}
209211
EMAIL_PORT: ${EMAIL_PORT:-}
210212
EMAIL_HOST_USER: ${EMAIL_HOST_USER:-}

backend/src/accounts/enums.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,29 @@ class Language:
316316
LITERALS = Literal[en, es, de, fr, ru]
317317
VALUES = (en, es, de, fr, ru)
318318
EURO_VALUES = (en, es, de, fr)
319+
320+
321+
class UserGroupType:
322+
323+
REGULAR = 'regular'
324+
PERSONAL = 'personal'
325+
326+
CHOICES = (
327+
(REGULAR, 'Regular'),
328+
(PERSONAL, 'Personal'),
329+
)
330+
331+
332+
class AbsenceStatus:
333+
334+
ACTIVE = 'active'
335+
VACATION = 'vacation'
336+
SICK_LEAVE = 'sick_leave'
337+
338+
CHOICES = (
339+
(ACTIVE, 'Active'),
340+
(VACATION, 'On vacation'),
341+
(SICK_LEAVE, 'Sick leave'),
342+
)
343+
344+
LITERALS = Literal[ACTIVE, VACATION, SICK_LEAVE]

backend/src/accounts/locale/de/LC_MESSAGES/django.po

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,22 @@ msgstr ""
172172

173173
msgid "You can't delete the account owner."
174174
msgstr ""
175+
176+
msgid "You cannot delegate to yourself."
177+
msgstr "Sie können nicht an sich selbst delegieren."
178+
179+
#, python-brace-format
180+
msgid "The following users were not found: {missing}"
181+
msgstr "Die folgenden Benutzer wurden nicht gefunden: {missing}"
182+
183+
msgid "Select at least one substitute."
184+
msgstr "Wählen Sie mindestens eine Vertretung aus."
185+
186+
msgid "The vacation is not active."
187+
msgstr "Die Abwesenheit ist nicht aktiv."
188+
189+
msgid "The status is already active."
190+
msgstr "Aktivierung nicht möglich: Der Status ist bereits aktiv."
191+
192+
msgid "The end date must be after the start date."
193+
msgstr "Das Enddatum muss nach dem Startdatum liegen."

backend/src/accounts/locale/django.pot

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,22 @@ msgstr ""
172172

173173
msgid "You can't delete the account owner."
174174
msgstr ""
175+
176+
msgid "You cannot delegate to yourself."
177+
msgstr ""
178+
179+
#, python-brace-format
180+
msgid "The following users were not found: {missing}"
181+
msgstr ""
182+
183+
msgid "Select at least one substitute."
184+
msgstr ""
185+
186+
msgid "The vacation is not active."
187+
msgstr ""
188+
189+
msgid "The status is already active."
190+
msgstr ""
191+
192+
msgid "The end date must be after the start date."
193+
msgstr ""

backend/src/accounts/locale/es/LC_MESSAGES/django.po

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,22 @@ msgstr ""
172172

173173
msgid "You can't delete the account owner."
174174
msgstr ""
175+
176+
msgid "You cannot delegate to yourself."
177+
msgstr "No puede delegarte a ti mismo."
178+
179+
#, python-brace-format
180+
msgid "The following users were not found: {missing}"
181+
msgstr "No se encontraron los siguientes usuarios: {missing}"
182+
183+
msgid "Select at least one substitute."
184+
msgstr "Seleccione al menos un sustituto."
185+
186+
msgid "The vacation is not active."
187+
msgstr "La ausencia no está activa."
188+
189+
msgid "The status is already active."
190+
msgstr "No se puede activar: el estado ya está activo."
191+
192+
msgid "The end date must be after the start date."
193+
msgstr "La fecha de fin debe ser posterior a la fecha de inicio."

backend/src/accounts/locale/fr/LC_MESSAGES/django.po

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,22 @@ msgstr ""
172172

173173
msgid "You can't delete the account owner."
174174
msgstr ""
175+
176+
msgid "You cannot delegate to yourself."
177+
msgstr "Vous ne pouvez pas déléguer à vous-même."
178+
179+
#, python-brace-format
180+
msgid "The following users were not found: {missing}"
181+
msgstr "Les utilisateurs suivants n'ont pas été trouvés : {missing}"
182+
183+
msgid "Select at least one substitute."
184+
msgstr "Sélectionnez au moins un remplaçant."
185+
186+
msgid "The vacation is not active."
187+
msgstr "L'absence n'est pas active."
188+
189+
msgid "The status is already active."
190+
msgstr "Impossible d'activer : le statut est déjà actif."
191+
192+
msgid "The end date must be after the start date."
193+
msgstr "La date de fin doit être postérieure à la date de début."

backend/src/accounts/locale/ru/LC_MESSAGES/django.po

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,22 @@ msgstr ""
172172

173173
msgid "You can't delete the account owner."
174174
msgstr ""
175+
176+
msgid "You cannot delegate to yourself."
177+
msgstr "Вы не можете делегировать самому себе."
178+
179+
#, python-brace-format
180+
msgid "The following users were not found: {missing}"
181+
msgstr "Следующие пользователи не найдены: {missing}"
182+
183+
msgid "Select at least one substitute."
184+
msgstr "Выберите хотя бы одного заместителя."
185+
186+
msgid "The vacation is not active."
187+
msgstr "Отпуск не активен."
188+
189+
msgid "The status is already active."
190+
msgstr "Невозможно активировать: статус уже активен."
191+
192+
msgid "The end date must be after the start date."
193+
msgstr "Дата окончания должна быть позже даты начала."

backend/src/accounts/managers.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from django.contrib.auth.base_user import BaseUserManager
22
from django.core.exceptions import MultipleObjectsReturned
3+
from django.db.models import Manager
34

4-
from src.accounts.enums import UserStatus, UserType
5+
from src.accounts.enums import UserGroupType, UserStatus, UserType
56
from src.generics.mixins.managers import NormalizeEmailMixin
67

78

@@ -49,3 +50,13 @@ def get_queryset(self):
4950
status=UserStatus.INACTIVE,
5051
)
5152
)
53+
54+
55+
class SoftDeleteGroupManager(Manager):
56+
57+
def get_queryset(self):
58+
return (
59+
super().get_queryset()
60+
.filter(is_deleted=False)
61+
.exclude(type=UserGroupType.PERSONAL)
62+
)

backend/src/accounts/messages.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,12 @@
101101
)
102102
MSG_A_0047 = _('You can\'t delete yourself.')
103103
MSG_A_0048 = _('You can\'t delete the account owner.')
104+
MSG_A_0049 = _('You cannot delegate to yourself.')
105+
MSG_A_0050 = lambda missing: format_lazy(
106+
_('The following users were not found: {missing}'),
107+
missing=missing,
108+
)
109+
MSG_A_0051 = _('Select at least one substitute.')
110+
MSG_A_0052 = _('The vacation is not active.')
111+
MSG_A_0053 = _('The status is already active.')
112+
MSG_A_0054 = _('The end date must be after the start date.')
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from django.db import migrations, models
2+
import django.db.models.deletion
3+
4+
5+
class Migration(migrations.Migration):
6+
7+
dependencies = [
8+
('accounts', '0141_notification_text_default'),
9+
]
10+
11+
operations = [
12+
# UserGroup.type
13+
migrations.AddField(
14+
model_name='usergroup',
15+
name='type',
16+
field=models.CharField(
17+
choices=[
18+
('regular', 'Regular'),
19+
('personal', 'Personal'),
20+
],
21+
default='regular',
22+
max_length=20,
23+
),
24+
),
25+
# UserVacation model (normalized vacation data)
26+
migrations.CreateModel(
27+
name='UserVacation',
28+
fields=[
29+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
30+
('is_deleted', models.BooleanField(default=False)),
31+
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='accounts.account')),
32+
('start_date', models.DateField(blank=True, null=True)),
33+
('end_date', models.DateField(blank=True, null=True)),
34+
('absence_status', models.CharField(choices=[('active', 'Active'), ('vacation', 'On vacation'), ('sick_leave', 'Sick leave')], default='vacation', max_length=20)),
35+
('substitute_group', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='vacation_owners', to='accounts.usergroup')),
36+
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='vacations', to='accounts.user')),
37+
],
38+
),
39+
migrations.AddConstraint(
40+
model_name='uservacation',
41+
constraint=models.UniqueConstraint(
42+
condition=models.Q(is_deleted=False),
43+
fields=['user'],
44+
name='unique_active_vacation_per_user',
45+
),
46+
),
47+
]
48+

0 commit comments

Comments
 (0)