forked from CGM_Public/pretix_original
Navigation and dashboard: Hide useless items (#5995)
* Navigation and dashboard: Hide useless items If a user has access to *no organizer teams*, hide a number of things from navigation and dashboard. This happens e.g. if a user only has permissions in scope of the pretix-resellers or pretix-scheduling plugins. * New mechanism
This commit is contained in:
@@ -49,6 +49,7 @@ from django.core.exceptions import BadRequest, PermissionDenied
|
||||
from django.db import IntegrityError, models, transaction
|
||||
from django.db.models import Q
|
||||
from django.utils.crypto import get_random_string, salted_hmac
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.timezone import now
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django_otp.models import Device
|
||||
@@ -667,6 +668,11 @@ class User(AbstractBaseUser, PermissionsMixin, LoggingMixin):
|
||||
self.session_token = generate_session_token()
|
||||
self.save(update_fields=['session_token'])
|
||||
|
||||
@cached_property
|
||||
@scopes_disabled()
|
||||
def is_in_any_teams(self):
|
||||
return self.teams.exists()
|
||||
|
||||
|
||||
class UserKnownLoginSource(models.Model):
|
||||
user = models.ForeignKey('User', on_delete=models.CASCADE, related_name="known_login_sources")
|
||||
|
||||
Reference in New Issue
Block a user