def download_file(request, course_slug, case_slug, fileid): course = get_object_or_404(CourseOffering, slug=course_slug) case = get_object_or_404(DisciplineCaseBase, slug=case_slug, offering__slug=course_slug) case = case.subclass() attach = get_object_or_404(CaseAttachment, case__slug=case_slug, case__offering__slug=course_slug, id=fileid) # allowed users: instructor/discipline admin, or student if they received the letter. if is_discipline_user(request, course_slug): is_student = False elif attach.public and request.user.username == case.student.userid and case.letter_sent == 'MAIL': is_student = True
def view_letter(request, course_slug, case_slug): """ Display current case status """ course = get_object_or_404(CourseOffering, slug=course_slug) case = get_object_or_404(DisciplineCaseBase, slug=case_slug, offering__slug=course_slug) case = case.subclass() # allowed users: instructor/discipline admin, or student if they received the letter. if is_discipline_user(request, course_slug): is_student = False messages.add_message(request, messages.INFO, "The student should be able to view the letter at this URL as well." ) elif request.user.username == case.student.userid and case.letter_sent == 'MAIL': is_student = True
def download_file(request, course_slug, case_slug, fileid): course = get_object_or_404(CourseOffering, slug=course_slug) case = get_object_or_404(DisciplineCaseBase, slug=case_slug, offering__slug=course_slug) case = case.subclass() attach = get_object_or_404(CaseAttachment, case__slug=case_slug, case__offering__slug=course_slug, id=fileid) # allowed users: instructor/discipline admin, or student if they received the letter. if is_discipline_user(request, course_slug): is_student = False elif attach.public and request.user.username == case.student.userid and case.letter_sent == 'MAIL': is_student = True else: return ForbiddenResponse(request) if is_student and (case.letter_sent != 'MAIL' or not case.letter_text): return ForbiddenResponse(request, errormsg="The letter for this case was not sent by this system.") attach.attachment.open() resp = HttpResponse(attach.attachment, content_type=attach.mediatype) resp['Content-Disposition'] = 'inline; filename="' + attach.filename() + '"' return resp
def view_letter(request, course_slug, case_slug): """ Display current case status """ course = get_object_or_404(CourseOffering, slug=course_slug) case = get_object_or_404(DisciplineCaseBase, slug=case_slug, offering__slug=course_slug) case = case.subclass() # allowed users: instructor/discipline admin, or student if they received the letter. if is_discipline_user(request, course_slug): is_student = False messages.add_message(request, messages.INFO, "The student should be able to view the letter at this URL as well." ) elif request.user.username == case.student.userid and case.letter_sent == 'MAIL': is_student = True else: return ForbiddenResponse(request) if case.letter_sent != 'MAIL' or not case.letter_text: return ForbiddenResponse(request, errormsg="The letter for this case was not sent by this system.") context = {'course': course, 'case': case, 'is_student': is_student} return render_to_response("discipline/view_letter.html", context, context_instance=RequestContext(request))