From: Seth Woodworth Date: Thu, 17 Jan 2013 20:09:21 +0000 (-0500) Subject: adding raw note iframe view, route and template X-Git-Tag: release-20150131~557^2~3 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8a03356d56d35b6590a7dff1141706f3fea0437d;p=oweals%2Fkarmaworld.git adding raw note iframe view, route and template --- diff --git a/karmaworld/apps/notes/views.py b/karmaworld/apps/notes/views.py index b81af6d..36dd22e 100644 --- a/karmaworld/apps/notes/views.py +++ b/karmaworld/apps/notes/views.py @@ -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 index 0000000..8ad99fc --- /dev/null +++ b/karmaworld/templates/notes/note_raw.html @@ -0,0 +1 @@ +{{ note.html|safe }} diff --git a/karmaworld/urls.py b/karmaworld/urls.py index 330dfe7..448e58f 100644 --- a/karmaworld/urls.py +++ b/karmaworld/urls.py @@ -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[^/]+)/(?P[^/]+)$', CourseDetailView.as_view(), name='course_detail'), - url(r'^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$', 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\d+)$', RawNoteDetailView.as_view(), name='note_raw'), + url(r'^(?P[^/]+)/(?P[^/]+)$', \ + CourseDetailView.as_view(), name='course_detail'), + url(r'^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$', \ + NoteDetailView.as_view(), name='note_detail'), url(r'^$', ListView.as_view(model=Course), name='home'), )