a95825ede8
- Things are suggested in python3 porting guide. https://docs.djangoproject.com/en/1.8/topics/python3/ 1. adding ```from django.utils.encoding import python_2_unicode_compatible``` 2. ``` __str__``` instead of ```__unicode__``` https://docs.djangoproject.com/en/1.8/topics/python3/#str-and-unicode-methods 3. Adding ```from __future__ import unicode_literals``` at the top of your Python modules https://docs.djangoproject.com/en/1.8/topics/python3/#unicode-literals 4. Removing the `u` prefix before unicode strings; https://docs.djangoproject.com/en/1.8/topics/python3/#unicode-literals - also closed #66 Signed-off-by: Hiroshi Miura <miurahr@linux.com>
22 lines
732 B
Python
22 lines
732 B
Python
from __future__ import unicode_literals
|
|
|
|
|
|
def has_permission(user, proposal, speaker=False, reviewer=False):
|
|
"""
|
|
Returns whether or not ther user has permission to review this proposal,
|
|
with the specified requirements.
|
|
|
|
If ``speaker`` is ``True`` then the user can be one of the speakers for the
|
|
proposal. If ``reviewer`` is ``True`` the speaker can be a part of the
|
|
reviewer group.
|
|
"""
|
|
if user.is_superuser:
|
|
return True
|
|
if speaker:
|
|
if user == proposal.speaker.user or \
|
|
proposal.additional_speakers.filter(user=user).exists():
|
|
return True
|
|
if reviewer:
|
|
if user.groups.filter(name="reviewers").exists():
|
|
return True
|
|
return False
|