views.py 1.13 KB
Newer Older
1
from django.contrib.auth.decorators import login_required
2
from django.http import Http404
David Baumgold committed
3
from edxmako.shortcuts import render_to_response
4
from opaque_keys.edx.locations import SlashSeparatedCourseKey
5
from courseware.courses import get_course_with_access
6
from notes.models import Note
7
from notes.utils import notes_enabled_for_course
8
from xmodule.annotator_token import retrieve_token
9

Arthur Barrett committed
10

11
@login_required
12
def notes(request, course_id):
13
    ''' Displays the student's notes. '''
14 15
    course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id)
    course = get_course_with_access(request.user, 'load', course_key)
16 17
    if not notes_enabled_for_course(course):
        raise Http404
Arthur Barrett committed
18

19
    notes = Note.objects.filter(course_id=course_key, user=request.user).order_by('-created', 'uri')
daniel cebrian committed
20 21 22

    student = request.user
    storage = course.annotation_storage_url
23 24
    context = {
        'course': course,
daniel cebrian committed
25 26
        'notes': notes,
        'student': student,
27 28
        'storage': storage,
        'token': retrieve_token(student.email, course.annotation_token_secret),
29
        'default_tab': 'myNotes',
30 31 32
    }

    return render_to_response('notes.html', context)