mirror of
https://github.com/jazzband/django-ddp.git
synced 2026-05-05 14:14:48 +00:00
23 lines
526 B
Python
23 lines
526 B
Python
|
|
from dddp import THREAD_LOCAL as this
|
||
|
|
from dddp.api import API, Publication
|
||
|
|
from django.contrib import auth
|
||
|
|
|
||
|
|
|
||
|
|
class Logs(Publication):
|
||
|
|
|
||
|
|
users = auth.get_user_model()
|
||
|
|
|
||
|
|
def get_queries(self):
|
||
|
|
user_pk = getattr(this, 'user_id', False)
|
||
|
|
if user_pk:
|
||
|
|
if self.users.objects.filter(
|
||
|
|
pk=user_pk,
|
||
|
|
is_active=True,
|
||
|
|
is_superuser=True,
|
||
|
|
).exists():
|
||
|
|
return []
|
||
|
|
raise ValueError('User not permitted.')
|
||
|
|
|
||
|
|
|
||
|
|
API.register([Logs])
|