2017-05-29 20:48:49 +00:00
|
|
|
from django.utils.crypto import get_random_string
|
2017-11-05 15:38:35 +00:00
|
|
|
from django.db.models import Sum
|
2017-05-29 20:48:49 +00:00
|
|
|
from django.db.models.functions import Coalesce
|
|
|
|
|
|
|
|
|
|
|
|
def query_sum(queryset, field):
|
|
|
|
return queryset.aggregate(s=Coalesce(Sum(field), 0))['s']
|
|
|
|
|
|
|
|
|
2017-07-30 14:57:38 +00:00
|
|
|
def generate_user_uid():
|
|
|
|
return get_random_string(length=12, allowed_chars='abcdefghijklmnopqrstuvwxyz0123456789')
|
|
|
|
|
|
|
|
|
|
|
|
def is_staff(request, user):
|
2017-08-12 12:17:00 +00:00
|
|
|
return user.is_authenticated and (user.is_superuser or request.conference.staff.filter(pk=user.pk).exists())
|