Commit 7784a29e by Arthur Barrett

add simple notes view

parent d636f4fa
......@@ -7,21 +7,11 @@ import logging
log = logging.getLogger(__name__)
def notes(request, course_id):
''' Displays a student's notes in a course.
$('body').annotator()
.annotator('addPlugin', 'Tags')
.annotator('addPlugin', 'Store', {
'prefix': /^(\/courses\/[^/]+\/[^/]+\/[^/]+)/.exec(window.location.href.toString().split(window.location.host)[1]
'annotationData': {
'uri': window.location.href.toString().split(window.location.host)[1]
}
});
'''
''' Displays a student's notes in a course. '''
course = get_course_with_access(request.user, course_id, 'load')
notes = Note.objects.filter(user_id=request.user.id)
notes = Note.objects.filter(course_id=course_id, user=request.user).order_by('-created', 'uri')
prettyprint = {'sort_keys':True, 'indent':2, 'separators':(',', ': ')}
json_notes = json.dumps([n.as_dict() for n in notes], **prettyprint)
......
......@@ -28,7 +28,6 @@ def index(request, course_id, book_index, page=None):
{'book_index': book_index, 'page': int(page),
'course': course,
'book_url': textbook.book_url,
'notes_api_url': reverse('notes_api_root', {'course_id': course_id}),
'table_of_contents': table_of_contents,
'start_page': textbook.start_page,
'end_page': textbook.end_page,
......@@ -105,7 +104,6 @@ def html_index(request, course_id, book_index, chapter=None, anchor_id=None):
return render_to_response('static_htmlbook.html',
{'book_index': book_index,
'course': course,
'notes_api_url': reverse('notes_api_root', kwargs={'course_id': course_id}),
'textbook': textbook,
'chapter': chapter,
'anchor_id': anchor_id,
......
......@@ -4,6 +4,43 @@
<%block name="headextra">
<%static:css group='course'/>
<%static:js group='courseware'/>
<style type="text/css">
blockquote {
background:#f9f9f9;
border-left:10px solid #ccc;
margin:1.5em 10px;
padding:.5em 10px;
}
blockquote:before {
color:#ccc;
content:'“';
font-size:4em;
line-height:.1em;
margin-right:.25em;
vertical-align:-.4em;
}
blockquote p {
display:inline;
}
.notes-wrapper {
padding: 32px 40px;
}
.note {
border-bottom: 1px solid #ccc;
padding: 0 0 1em 0;
}
.note .text {
margin-bottom: 1em;
}
.note ul.meta {
margin: .5em 0;
}
.note ul.meta li {
font-size: .9em;
margin-bottom: .5em;
}
</style>
</%block>
<%block name="js_extra">
......@@ -16,7 +53,20 @@
<section class="container">
<div class="notes-wrapper">
<h2>My Notes</h2>
<pre>${json_notes}</pre>
% for note in notes:
<div class="note">
<blockquote>${note.quote}</blockquote>
<div class="text">${note.text.replace("\n", "<br />") | n}</div>
<ul class="meta">
% if note.tags:
<li class="tags">Tags: ${note.tags|h}</li>
% endif
<li class="user">Author: ${note.user.username}</li>
<li class="time">Created: ${note.created.strftime('%m/%d/%Y %H:%m')}</li>
<li class="uri">Source: <a href="${note.uri}">${note.uri}</a></li>
</ul>
</div>
% endfor
</div>
</section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment