mirror of
https://github.com/PostHog/posthog.git
synced 2024-11-24 18:07:17 +01:00
5d2ad6c7bb
* chore(deps): Update `black` to `22.8.0` * Format
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from django.db import models
|
|
|
|
from posthog.models.dashboard import Dashboard
|
|
from posthog.models.utils import UUIDModel, sane_repr
|
|
|
|
|
|
# We call models that grant a user access to some resource (which isn't a grouping of users) a "privilege"
|
|
class DashboardPrivilege(UUIDModel):
|
|
dashboard: models.ForeignKey = models.ForeignKey(
|
|
"posthog.Dashboard", on_delete=models.CASCADE, related_name="privileges", related_query_name="privilege"
|
|
)
|
|
user: models.ForeignKey = models.ForeignKey(
|
|
"posthog.User",
|
|
on_delete=models.CASCADE,
|
|
related_name="explicit_dashboard_privileges",
|
|
related_query_name="explicit_dashboard_privilege",
|
|
)
|
|
level: models.PositiveSmallIntegerField = models.PositiveSmallIntegerField(
|
|
choices=Dashboard.RestrictionLevel.choices
|
|
)
|
|
added_at: models.DateTimeField = models.DateTimeField(auto_now_add=True)
|
|
updated_at: models.DateTimeField = models.DateTimeField(auto_now=True)
|
|
|
|
class Meta:
|
|
constraints = [
|
|
models.UniqueConstraint(fields=["dashboard", "user"], name="unique_explicit_dashboard_privilege")
|
|
]
|
|
|
|
__repr__ = sane_repr("dashboard", "user", "level")
|