31 lines
873 B
Python
31 lines
873 B
Python
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
|