# Copyright (C) 2012 FinalsClub Foundation
from django.views.generic import DetailView
+from django.shortcuts import get_object_or_404
+from django.http import HttpResponse
from karmaworld.apps.notes.models import Note
class NoteDetailView(DetailView):
template_name = u'notes/note_raw.html'
context_object_name = u"note"
model = Note
+
+def raw_file(request, pk):
+ """ Display the raw html from a Note object for embedding in an iframe """
+ note = get_object_or_404(Note, pk=pk)
+ return HttpResponse(note.html)
from karmaworld.apps.courses.models import Course
from karmaworld.apps.courses.views import CourseDetailView
-from karmaworld.apps.notes.views import NoteDetailView, RawNoteDetailView
+from karmaworld.apps.notes.views import NoteDetailView, RawNoteDetailView, raw_file
# See: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf
admin.autodiscover()
# the raw route must come before routes with a capture group after the
# first / of the url
- url(r'^raw/(?P<pk>\d+)$', RawNoteDetailView.as_view(), name='note_raw'),
+ url(r'^raw/(?P<pk>\d+)$', raw_file, name='note_raw'),
url(r'^(?P<school_slug>[^/]+)/(?P<slug>[^/]+)$', \
CourseDetailView.as_view(), name='course_detail'),
url(r'^(?P<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<slug>[^/]+)$', \