PonyConf/accounts/utils.py
Guilhem Saurel d9b3846cf1 Various Stuffs
- unified orga forms
- unified staff / orga | util / mixin / filter
- moved a signal into its signals.py
- profile edition now edits User / Profile / Participation
- topic can be edited
- orga can set topics reviewers
- removed view list-talks-by-speaker (his talks appears on his page)
- everybody can see topics (template show more stuff the more permissions you have)
2016-07-05 01:16:33 +02:00

20 lines
714 B
Python

from django.contrib.sites.shortcuts import get_current_site
from django.utils.crypto import get_random_string
def generate_user_uid():
return get_random_string(length=12, allowed_chars='abcdefghijklmnopqrstuvwxyz0123456789')
def is_orga(request, user):
return user.is_authenticated() and user.participation_set.get(site=get_current_site(request)).orga
def is_staff(request, user):
return user.is_authenticated() and user.participation_set.get(site=get_current_site(request)).is_staff()
def can_edit_profile(request, profile):
editor = request.user.participation_set.get(site=get_current_site(request))
return editor.orga or editor.topic_set.filter(talk__speakers=profile.user).exists()