hasattr(message, 'authenticated') and message.authenticated)
if not authenticated:
raise _UnsignedMessage()
- if 'assistants' in person.groups or 'professors' in person.groups:
+ if person.is_admin():
email = _get_admin_email(
basedir=basedir, course=course, person=person, subject=subject)
elif 'students' in person.groups:
hasattr(message, 'authenticated') and message.authenticated)
if not authenticated:
raise _UnsignedMessage()
- if not ('professors' in person.groups or 'assistants' in person.groups):
+ if not person.is_admin():
raise _PermissionViolationMessage(
- person=person, allowed_groups=['professors', 'assistants'])
+ person=person, allowed_groups=person.admin_groups)
student = _get_subject_student(course=course, subject=subject)
assignment = _get_subject_assignment(course=course, subject=subject)
grade = _get_grade(
# pygrader. If not, see <http://www.gnu.org/licenses/>.
class Person (object):
+ admin_groups = ['professors', 'assistants']
+
def __init__(self, name, emails=None, pgp_key=None, aliases=None,
groups=None):
self.name = name
return self.aliases[0]
except KeyError:
return self.name
+
+ def is_admin(self):
+ """Is this person an administrator for this course? True/False.
+ """
+ for group in self.admin_groups:
+ if group in self.groups:
+ return True
+ return False