updated support for displaying a note in an iframe.
authorCharles Holbrow <charlesholbrow@gmail.com>
Fri, 18 Jan 2013 22:28:50 +0000 (17:28 -0500)
committerCharles Holbrow <charlesholbrow@gmail.com>
Fri, 18 Jan 2013 22:28:50 +0000 (17:28 -0500)
karmaworld/apps/notes/views.py
karmaworld/urls.py

index 36dd22e2e3178eb1978d4bcc0a012fd1f924fa29..c226f001cc30c8f33e4b4cc463789ea2ac29888f 100644 (file)
@@ -3,6 +3,8 @@
 # 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):
@@ -16,3 +18,8 @@ class RawNoteDetailView(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)
index 448e58f9f4a4038c3fd078b2ccb4481c6dace098..0b45d1fc628fd43352d378f7e14eec57b5e4ce07 100644 (file)
@@ -5,7 +5,7 @@ from django.views.generic.simple import direct_to_template
 
 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()
@@ -21,7 +21,7 @@ urlpatterns = patterns('',
 
     # 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>[^/]+)$', \