symposion_app/symposion/reviews/utils.py

23 lines
732 B
Python
Raw Normal View History

from __future__ import unicode_literals
2012-08-14 07:54:45 +00:00
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.
2014-07-30 18:19:26 +00:00
If ``speaker`` is ``True`` then the user can be one of the speakers for the
2012-08-14 07:54:45 +00:00
proposal. If ``reviewer`` is ``True`` the speaker can be a part of the
reviewer group.
"""
if user.is_superuser:
return True
if speaker:
2014-07-30 18:19:26 +00:00
if user == proposal.speaker.user or \
proposal.additional_speakers.filter(user=user).exists():
2012-08-14 07:54:45 +00:00
return True
if reviewer:
if user.groups.filter(name="reviewers").exists():
return True
return False