From: Charles Holbrow Date: Fri, 18 Jan 2013 22:28:50 +0000 (-0500) Subject: updated support for displaying a note in an iframe. X-Git-Tag: release-20150131~554 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e09c9866d95cf06d48ea89122ef099555486907b;p=oweals%2Fkarmaworld.git updated support for displaying a note in an iframe. --- diff --git a/karmaworld/apps/notes/views.py b/karmaworld/apps/notes/views.py index 36dd22e..c226f00 100644 --- a/karmaworld/apps/notes/views.py +++ b/karmaworld/apps/notes/views.py @@ -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) diff --git a/karmaworld/urls.py b/karmaworld/urls.py index 448e58f..0b45d1f 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, 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\d+)$', RawNoteDetailView.as_view(), name='note_raw'), + url(r'^raw/(?P\d+)$', raw_file, name='note_raw'), url(r'^(?P[^/]+)/(?P[^/]+)$', \ CourseDetailView.as_view(), name='course_detail'), url(r'^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$', \