def render_annotation(request, username, text_id): annotation_user = Profile.objects.get(username=username) text_info = Text.find_by_id(text_id) c = RequestContext(request) c['annotation_username'] = annotation_user.username c['annotation_user_id'] = annotation_user.id c['text_id'] = text_id c['text'] = text_info.get('text') annotation = Annotation.find_by_user_id_and_text_id(annotation_user.id, text_id) comments = [] if annotation: comments = annotation.get('comments') c['initial_comments'] = simplejson.dumps(comments) return render_to_response('annotation.html', c)
def edit_annotation(request, text_id): c = RequestContext(request) if text_id is not None and request.user.is_authenticated(): text_info = Text.find_by_id(text_id) else: return redirect('/') c['user'] = request.user c['annotation_username'] = request.user.username c['annotation_user_id'] = request.user.id c['text_id'] = text_id c['text'] = text_info.get('text') c['text_title'] = text_info.get('title') c['edit_mode'] = True annotation = Annotation.find_by_user_id_and_text_id(request.user.id, text_id) comments = [] if annotation: comments = annotation.get('comments') c['initial_comments'] = simplejson.dumps(comments) return render_to_response('annotation.html', c)