adding raw note iframe view, route and template
authorSeth Woodworth <seth@sethish.com>
Thu, 17 Jan 2013 20:09:21 +0000 (15:09 -0500)
committerSeth Woodworth <seth@sethish.com>
Thu, 17 Jan 2013 20:09:21 +0000 (15:09 -0500)
karmaworld/apps/notes/views.py
karmaworld/templates/notes/note_raw.html [new file with mode: 0644]
karmaworld/urls.py

index b81af6dd8547025e951a255c666e3f3a38e0c24e..36dd22e2e3178eb1978d4bcc0a012fd1f924fa29 100644 (file)
@@ -7,7 +7,12 @@ from karmaworld.apps.notes.models import Note
 
 class NoteDetailView(DetailView):
     """ Class-based view for the note html page """
-
     # name passed to template
     context_object_name = u"note"
     model = Note
+
+class RawNoteDetailView(DetailView):
+    """ Class-based view for the raw note html for iframes """
+    template_name = u'notes/note_raw.html'
+    context_object_name = u"note"
+    model = Note
diff --git a/karmaworld/templates/notes/note_raw.html b/karmaworld/templates/notes/note_raw.html
new file mode 100644 (file)
index 0000000..8ad99fc
--- /dev/null
@@ -0,0 +1 @@
+{{ note.html|safe }}
index 330dfe7cc54d7a8b731cd9f8a02e2bb1ea1df3bf..448e58f9f4a4038c3fd078b2ccb4481c6dace098 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
+from karmaworld.apps.notes.views import NoteDetailView, RawNoteDetailView
 
 # See: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf
 admin.autodiscover()
@@ -17,10 +17,15 @@ urlpatterns = patterns('',
     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
     url(r'^admin/', include(admin.site.urls)),
 
-    url(r'^about/$', direct_to_template, { 'template': 'about.html' }, name='about'), 
+    url(r'^about/$', direct_to_template, { 'template': 'about.html' }, name='about'),
 
-    url(r'^(?P<school_slug>[^/]+)/(?P<slug>[^/]+)$', CourseDetailView.as_view(), name='course_detail'),
-    url(r'^(?P<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<slug>[^/]+)$', NoteDetailView.as_view(), name='note_detail'),
+    # 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'^(?P<school_slug>[^/]+)/(?P<slug>[^/]+)$', \
+        CourseDetailView.as_view(), name='course_detail'),
+    url(r'^(?P<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<slug>[^/]+)$', \
+        NoteDetailView.as_view(), name='note_detail'),
 
     url(r'^$', ListView.as_view(model=Course), name='home'),
 )