Skip to content

Commit ca01bdd

Browse files
committed
Ajout de la colonne "users.departements"
1 parent 7d3ded3 commit ca01bdd

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Generated by Django 5.1.5 on 2025-12-03 16:40
2+
3+
from django.db import migrations
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [ # noqa: RUF012
8+
("core", "0007_alter_event_options"),
9+
]
10+
11+
operations = [ # noqa: RUF012
12+
migrations.RunSQL(
13+
sql=[("ALTER TABLE public.profiles ADD COLUMN departements text[]")],
14+
reverse_sql=[("ALTER TABLE public.profiles DROP COLUMN departements")],
15+
)
16+
]

django/core/users/models.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ class Profile(models.Model):
5858
# Departement should be a foreign key pointing to the departement table
5959
# but it's not the case today on Nuxt's side.
6060
departement = models.CharField(verbose_name="Département", blank=True)
61+
# PPA sides have rights depending on their departments. This is an ugly and quick fix
62+
# to link users to several departments (and not only one).
63+
# It should be refactored!
64+
departements = ArrayField(
65+
verbose_name="Départements",
66+
# CharField to allow departments starting with a zero. Otherwise, zero is erased.
67+
base_field=models.CharField(max_length=3, blank=True),
68+
size=50,
69+
blank=True,
70+
null=True,
71+
)
6172
collectivite = models.ForeignKey(
6273
Collectivite,
6374
on_delete=models.SET_NULL,
@@ -89,7 +100,7 @@ class Profile(models.Model):
89100
optin = models.BooleanField(verbose_name="Inscrit à l'infolettre", default=False)
90101
# No mention of this column on Nuxt's code. Dead code?
91102
updated_pipedrive = models.BooleanField(
92-
verbose_name="Mis à jour Pipedrive", blank=True
103+
verbose_name="Mis à jour Pipedrive", blank=True, null=True
93104
)
94105
is_admin = models.BooleanField(
95106
verbose_name="Est admin", default=False, db_comment="super admin bypass"

0 commit comments

Comments
 (0)