23 lines
683 B
Python
23 lines
683 B
Python
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"
|
|
)
|
|
]
|