Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗃️(dashboard) Add UUID primary key and Squash migrations #426

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# Generated by Django 5.1.3 on 2024-11-15 15:30
# Generated by Django 5.1.6 on 2025-03-07 13:00

import django.contrib.auth.models
import django.contrib.auth.validators
import django.utils.timezone
import uuid
from django.db import migrations, models


class Migration(migrations.Migration):

initial = True
replaces = [
("qcd_auth", "0001_initial"),
("qcd_auth", "0002_dashboarduser_siret"),
("qcd_auth", "0003_dashboarduser_is_validated"),
]

dependencies = [
("auth", "0012_alter_user_first_name_max_length"),
Expand All @@ -20,11 +25,11 @@ class Migration(migrations.Migration):
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
models.UUIDField(
default=uuid.uuid4,
editable=False,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("password", models.CharField(max_length=128, verbose_name="password")),
Expand Down Expand Up @@ -119,6 +124,20 @@ class Migration(migrations.Migration):
verbose_name="user permissions",
),
),
(
"siret",
models.CharField(
blank=True, default="", max_length=14, verbose_name="SIRET"
),
),
(
"is_validated",
models.BooleanField(
default=False,
help_text="Designates whether this user has been validated by the QualiCharge team.",
verbose_name="is validated",
),
),
],
options={
"verbose_name": "user",
Expand Down
20 changes: 0 additions & 20 deletions src/dashboard/apps/auth/migrations/0002_dashboarduser_siret.py

This file was deleted.

This file was deleted.

5 changes: 4 additions & 1 deletion src/dashboard/apps/auth/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Dashboard auth models."""

import uuid

import sentry_sdk
from anymail.exceptions import AnymailRequestsAPIError
from anymail.message import AnymailMessage
Expand All @@ -20,6 +22,7 @@ class DashboardUser(AbstractUser):
AbstractUser model in Django.
"""

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
siret = models.CharField(_("SIRET"), max_length=14, default="", blank=True)
is_validated = models.BooleanField(
_("is validated"),
Expand All @@ -34,7 +37,7 @@ def save(self, *args, **kwargs):
# Check if `is_validated` changes to True
if self.pk:
previous = DashboardUser.objects.filter(pk=self.pk).first()
if not previous.is_validated and self.is_validated:
if previous and not previous.is_validated and self.is_validated:
self.send_validation_email()

super().save(*args, **kwargs)
Expand Down
Loading