self.students = students
-def run(basedir, course, original, message, person, subject,
+def run(basedir, course, message, person, subject,
trust_email_infrastructure=False,
use_color=None, dry_run=False, **kwargs):
"""
Unauthenticated messages are refused by default.
>>> process(
- ... basedir=course.basedir, course=course.course, original=message,
- ... message=message, person=person, subject='[get]', max_late=0)
+ ... basedir=course.basedir, course=course.course, message=message,
+ ... person=person, subject='[get]', max_late=0)
UnsignedMessage error:
unsigned message
Students without grades get a reasonable response.
>>> process(
- ... basedir=course.basedir, course=course.course, original=message,
- ... message=message, person=person, subject='[get]', max_late=0,
+ ... basedir=course.basedir, course=course.course, message=message,
+ ... person=person, subject='[get]', max_late=0,
... trust_email_infrastructure=True)
... # doctest: +ELLIPSIS, +REPORT_UDIFF
respond with:
>>> message.authenticated = True
>>> process(
- ... basedir=course.basedir, course=course.course, original=message,
- ... message=message, person=person, subject='[get]', max_late=0)
+ ... basedir=course.basedir, course=course.course, message=message,
+ ... person=person, subject='[get]', max_late=0)
... # doctest: +ELLIPSIS, +REPORT_UDIFF
respond with:
Content-Type: text/plain; charset="us-ascii"
... points=10, comment='Looks good.')
>>> course.course.grades.append(grade)
>>> process(
- ... basedir=course.basedir, course=course.course, original=message,
- ... message=message, person=person, subject='[get]',
- ... max_late=0)
+ ... basedir=course.basedir, course=course.course, message=message,
+ ... person=person, subject='[get]', max_late=0)
... # doctest: +ELLIPSIS, +REPORT_UDIFF
respond with:
Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="===============...=="
... course.course.find_people(email='eye@tower.edu'))[0]
>>> person.pgp_key = None
>>> process(
- ... basedir=course.basedir, course=course.course, original=message,
- ... message=message, person=person, subject='[get]',
- ... max_late=0)
+ ... basedir=course.basedir, course=course.course, message=message,
+ ... person=person, subject='[get]', max_late=0)
... # doctest: +ELLIPSIS, +REPORT_UDIFF
respond with:
Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="===============...=="
They can also request grades for a particular student.
>>> process(
- ... basedir=course.basedir, course=course.course, original=message,
- ... message=message, person=person,
- ... subject='[get] {}'.format(student.name),
+ ... basedir=course.basedir, course=course.course, message=message,
+ ... person=person, subject='[get] {}'.format(student.name),
... max_late=0)
... # doctest: +ELLIPSIS, +REPORT_UDIFF
respond with:
>>> try:
... _handle_submission(
... basedir=course.basedir, course=course.course,
- ... original=submission, message=submission, person=student,
+ ... message=submission, person=student,
... subject='[submit] Assignment 1')
... except _Response:
... pass
Now lets request the submissions.
>>> process(
- ... basedir=course.basedir, course=course.course, original=message,
- ... message=message, person=person,
+ ... basedir=course.basedir, course=course.course, message=message,
+ ... person=person,
... subject='[get] {}, {}'.format(student.name, 'Assignment 1'),
... max_late=0)
... # doctest: +ELLIPSIS, +REPORT_UDIFF
if trust_email_infrastructure:
authenticated = True
else:
- authenticated = hasattr(message, 'authenticated') and message.authenticated
+ authenticated = (
+ hasattr(message, 'authenticated') and message.authenticated)
if not authenticated:
raise _UnsignedMessage()
if 'assistants' in person.groups or 'professors' in person.groups:
email = _get_admin_email(
- basedir=basedir, course=course, original=original,
- person=person, subject=subject, use_color=use_color)
+ basedir=basedir, course=course, person=person, subject=subject,
+ use_color=use_color)
elif 'students' in person.groups:
email = _get_student_email(
- basedir=basedir, course=course, original=original,
- person=person, use_color=use_color)
+ basedir=basedir, course=course, person=person,
+ use_color=use_color)
else:
raise NotImplementedError(
'strange groups {} for {}'.format(person.groups, person))
raise _Response(message=email)
-def _get_student_email(basedir, course, original, person, student=None,
- use_color=None):
+def _get_student_email(basedir, course, person, student=None, use_color=None):
if student is None:
student = person
targets = None
return email
def _get_student_submission_email(
- basedir, course, original, person, assignments, student, use_color=None):
+ basedir, course, person, assignments, student, use_color=None):
subject = '{} assignment submissions for {}'.format(
course.name, student.name)
text = '{}:\n * {}\n'.format(
author=course.robot, targets=[person], subject=subject,
message=message)
-def _get_admin_email(basedir, course, original, person, subject,
- use_color=None):
+def _get_admin_email(basedir, course, person, subject, use_color=True):
lsubject = subject.lower()
students = [p for p in course.find_people()
if p.name.lower() in lsubject]
if a.name.lower() in lsubject]
if len(assignments) == 0:
email = _get_student_email(
- basedir=basedir, course=course, original=original,
- person=person, student=student, use_color=use_color)
+ basedir=basedir, course=course, person=person, student=student)
else:
email = _get_student_submission_email(
- basedir=basedir, course=course, original=original,
- person=person, student=student, assignments=assignments,
- use_color=use_color)
+ basedir=basedir, course=course, person=person, student=student,
+ assignments=assignments, use_color=use_color)
else:
raise InvalidStudent(students=students)
return email