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:
parent
ac7be43e82
commit
6947f3b787
4 changed files with 11 additions and 11 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue