1
0
Fork 0

Uses class method to get list of instance admins

Re-writing this query over and over is a bad approach
This commit is contained in:
Mouse Reeve 2022-09-19 10:43:52 -07:00
parent ac7be43e82
commit 6947f3b787
4 changed files with 11 additions and 11 deletions

View file

@ -231,6 +231,14 @@ class User(OrderedCollectionPageMixin, AbstractUser):
queryset = queryset.exclude(blocks=viewer)
return queryset
@classmethod
def admins(cls):
"""Get a queryset of the admins for this instance"""
return cls.objects.filter(
models.Q(user_permissions__name__in=["moderate_user", "moderate_post"])
| models.Q(is_superuser=True)
)
def update_active_date(self):
"""this user is here! they are doing things!"""
self.last_active_date = timezone.now()