structure du projet + docker, back: mise en place BD et apps, front: début de dev pour le header et mise en place du thème et css global (override des variables bootstrap)

This commit is contained in:
2026-06-01 15:21:47 +02:00
parent b3c027794c
commit e8e6122a45
111 changed files with 6778 additions and 1 deletions
+15
View File
@@ -0,0 +1,15 @@
from .user import User
from .role import Role
from .team import Team
from .authorization import Authorization
from .user_team_role import UserTeamRole
from .m2m_role_authorization import M2M_RoleAuthorizations
__all__ = [
"User",
"Role",
"Team",
"Authorization",
"UserTeamRole",
"M2M_RoleAuthorizations",
]
+21
View File
@@ -0,0 +1,21 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from api.core.models.trackable_model import TrackableModel
class Authorization(TrackableModel):
"""
Model representing authorizations within the user account system.
These authorizations can be assigned to roles to control access permissions.
"""
name = models.CharField(verbose_name=_("nom"), max_length=100, unique=True)
code = models.CharField(verbose_name=_("code"), max_length=100, unique=True)
description = models.TextField(
verbose_name=_("description"), blank=True, default=""
)
class Meta:
verbose_name = _("Authorization")
verbose_name_plural = _("Authorizations")
@@ -0,0 +1,22 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from api.core.models.trackable_model import TrackableModel
from api.users.models.authorization import Authorization
from api.users.models.role import Role
class M2M_RoleAuthorizations(TrackableModel):
"""
Many to Many table for roles and authorizations.
"""
role = models.ForeignKey(Role, on_delete=models.CASCADE)
authorization = models.ForeignKey(Authorization, on_delete=models.CASCADE)
class Meta:
constraints = [
models.UniqueConstraint(
fields=["role", "authorization"], name="unique_role_authorization"
)
]
+30
View File
@@ -0,0 +1,30 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from api.core.models.trackable_model import TrackableModel
class Role(TrackableModel):
"""
Model representing a role that can be assigned to users within teams.
A user can have a different role in each team they are part of.
"""
name = models.CharField(verbose_name=_("nom"), max_length=100, unique=True)
description = models.TextField(
verbose_name=_("description"), blank=True, default=""
)
authorizations = models.ManyToManyField(
"users.Authorization",
verbose_name=_("authorisations"),
blank=True,
related_name="roles",
through="M2M_RoleAuthorizations",
)
class Meta:
verbose_name = _("role")
verbose_name_plural = _("roles")
def __str__(self):
return self.name
+23
View File
@@ -0,0 +1,23 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from api.core.models.trackable_model import TrackableModel
class Team(TrackableModel):
"""
Model representing a team within the user account system.
A team can contain multiple users that are linked together for collaboration.
"""
name = models.CharField(max_length=255, unique=True, verbose_name=_("nom"))
description = models.TextField(
blank=True, verbose_name=_("description"), default=""
)
class Meta:
verbose_name = _("Team")
verbose_name_plural = _("Teams")
def __str__(self):
return self.name
+34
View File
@@ -0,0 +1,34 @@
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.utils.translation import gettext_lazy as _
class User(AbstractUser):
"""
Custom user model for the project.
Inherits from Django's AbstractUser to leverage built-in authentication features.
Additional fields can be added here as needed.
"""
email = models.EmailField(verbose_name=_("email"), unique=True)
initials = models.CharField(verbose_name=_("initiales"), max_length=5, blank=True)
color = models.CharField(verbose_name=_("couleur"), max_length=7, blank=True) # hex
image = models.ImageField(
verbose_name=_("image"), upload_to="user_images/", blank=True, null=True
)
phone_number = models.CharField(
verbose_name=_("numéro de téléphone"), max_length=20, blank=True
)
c2c_extension = models.CharField(
verbose_name=_("extension click to call"), max_length=10, blank=True
)
USERNAME_FIELD = "email"
REQUIRED_FIELDS = ["username"]
class Meta:
verbose_name = _("user")
verbose_name_plural = _("users")
def __str__(self):
return f"{self.first_name} {self.last_name}"
@@ -0,0 +1,30 @@
from django.db import models
from django.utils.translation import gettext_lazy as _
from api.core.models.trackable_model import TrackableModel
class UserTeamRole(TrackableModel):
"""
Model representing the association of users, teams, and roles within the user account system.
This model links a user to a specific team with a designated role.
"""
user = models.ForeignKey(
"users.User",
on_delete=models.CASCADE,
related_name="team_roles",
verbose_name=_("utilisateur"),
)
team = models.ForeignKey(
"users.Team",
on_delete=models.CASCADE,
related_name="user_roles",
verbose_name=_("équipe"),
)
role = models.ForeignKey(
"users.Role",
on_delete=models.CASCADE,
related_name="user_teams",
verbose_name=_("rôle"),
)