From: Charles Connell Date: Mon, 17 Feb 2014 14:44:35 +0000 (-0500) Subject: Change URLs, add link to keywords X-Git-Tag: release-20150131~148^2^2~12 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c3204d1351e820d10c5d242443cbac7cdcaf602e;p=oweals%2Fkarmaworld.git Change URLs, add link to keywords --- diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py index 3e58f48..b73e4ce 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -12,6 +12,7 @@ import logging from allauth.account.signals import user_logged_in from django.contrib.auth.models import User from django.contrib.sites.models import Site +from django.core.urlresolvers import reverse from django.utils.safestring import mark_safe from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned from django.core.files.storage import default_storage @@ -321,10 +322,10 @@ class Note(Document): """ if self.slug is not None: # return a url ending in slug - return u"/{0}/{1}/{2}".format(self.course.school.slug, self.course.slug, self.slug) + return reverse('note_detail', args=[self.course.school.slug, self.course.slug, self.slug]) else: # return a url ending in id - return u"/{0}/{1}/{2}".format(self.course.school.slug, self.course.slug, self.id) + return reverse('note_detail', args=[self.course.school.slug, self.course.slug, self.id]) def filter_html(self, html): """ diff --git a/karmaworld/apps/quizzes/views.py b/karmaworld/apps/quizzes/views.py index 68601ea..6b5294c 100644 --- a/karmaworld/apps/quizzes/views.py +++ b/karmaworld/apps/quizzes/views.py @@ -50,10 +50,10 @@ class KeywordEditView(FormView): return super(KeywordEditView, self).post(requests, *args, **kwargs) def lookup_note(self): - self.note = Note.objects.get(pk=self.kwargs['pk']) + self.note = Note.objects.get(slug=self.kwargs['slug']) def get_success_url(self): - return reverse('keyword_edit', args=(self.note.pk,)) + return reverse('keyword_edit', args=(self.note.course.school.slug, self.note.course.slug, self.note.slug)) def get_initial(self): existing_keywords = self.note.keyword_set.order_by('id') diff --git a/karmaworld/assets/css/note_course_pages.css b/karmaworld/assets/css/note_course_pages.css index c23bedd..e374d86 100644 --- a/karmaworld/assets/css/note_course_pages.css +++ b/karmaworld/assets/css/note_course_pages.css @@ -12,7 +12,7 @@ margin-right: 3px; } -#note_status, #note_pedigree, #note_tags +#note_status, #note_pedigree, #note_tags, #note_keyword_link { text-align: center; padding-top: 10px; diff --git a/karmaworld/templates/notes/note_detail.html b/karmaworld/templates/notes/note_detail.html index 4d20454..02c1446 100644 --- a/karmaworld/templates/notes/note_detail.html +++ b/karmaworld/templates/notes/note_detail.html @@ -16,14 +16,13 @@ var edit_note_tags_url = "{% url 'edit_note_tags' note.id %}" var note_downloaded_url = "{% url 'downloaded_note' note.id %}" var note_contents_url = "{{ S3_URL }}{{ note.get_relative_s3_path }}" - {% if pdf_controls %} - var pdfControls = true; - {% else %} - var pdfControls = false; - {% endif %} + var pdfControls = {% if pdf_controls %} true {% else %} false {% endif %}; var csrf_token = "{{ csrf_token }}"; +{% endblock %} + +{% block bodyscripts %} {% endblock %} @@ -74,6 +73,17 @@
So far, {{ note.thanks }} people have completely fallen in love with with these notes.
+
+ +
+ + + +
+
diff --git a/karmaworld/templates/quizzes/keyword_edit.html b/karmaworld/templates/quizzes/keyword_edit.html index 19eeb9b..91b0b99 100644 --- a/karmaworld/templates/quizzes/keyword_edit.html +++ b/karmaworld/templates/quizzes/keyword_edit.html @@ -17,10 +17,25 @@ {% block content %}
+ + +
-

Define keywords for the note

-

{{ note.name }}

+

Define keywords for the note
+ {{ note.name }}

+
+
+ +
+
+

(Press tab in the last definition for more rows)

@@ -29,7 +44,7 @@
-
+ {% csrf_token %}
{{ prototype_form.as_p }} diff --git a/karmaworld/urls.py b/karmaworld/urls.py index b16f827..769f3f9 100644 --- a/karmaworld/urls.py +++ b/karmaworld/urls.py @@ -67,11 +67,6 @@ urlpatterns = patterns('', url(r'^accounts/', include('allauth.urls')), url(r'^accounts/profile/', ProfileView.as_view(), name='accounts_profile'), - # Quizzes - url(r'^quiz/(?P\d+)/$', QuizView.as_view(), name='quiz'), - url(r'^note/(?P\d+)/keywords/$', KeywordEditView.as_view(), name='keyword_edit'), - - #url(r'^pdfview$', PDFView.as_view(), name='pdf'), url(r'^pdfview/(?P\d+)$', PDFView.as_view(), name='pdf'), # Media handling @@ -115,13 +110,17 @@ urlpatterns = patterns('', # b: school/course/id/slug # c: s../c../slug # note file as id, for notes without titles yet - url(r'^(?P[^/]+)/(?P[^/]+)/(?P[\d^/]+)$', \ + url(r'^note/(?P[^/]+)/(?P[^/]+)/(?P[\d^/]+)$', \ NoteView.as_view(), name='note_detail_pk'), # note file by note.slug - url(r'^' + SLUG.format('school_') + '/' + SLUG.format('course_') +'/'+ SLUG.format('') +'$', + url(r'^note/' + SLUG.format('school_') + '/' + SLUG.format('course_') +'/'+ SLUG.format('') +'$', NoteView.as_view(), name='note_detail'), - #url(r'^(?P[^/]+)/(?P[^/]+)/(?P[^/]+)$', \ - # NoteView.as_view(), name='note_detail'), + + # Quizzes + url(r'^note/' + SLUG.format('school_') + '/' + SLUG.format('course_') +'/'+ SLUG.format('') +'/quiz/$', + QuizView.as_view(), name='quiz'), + url(r'^note/' + SLUG.format('school_') + '/' + SLUG.format('course_') +'/'+ SLUG.format('') +'/keywords/$', + KeywordEditView.as_view(), name='keyword_edit'), url(r'^$', CourseListView.as_view(model=Course), name='home'), )