Change URLs, add link to keywords
authorCharles Connell <charles@connells.org>
Mon, 17 Feb 2014 14:44:35 +0000 (09:44 -0500)
committerCharles Connell <charles@connells.org>
Mon, 17 Feb 2014 14:44:35 +0000 (09:44 -0500)
karmaworld/apps/notes/models.py
karmaworld/apps/quizzes/views.py
karmaworld/assets/css/note_course_pages.css
karmaworld/templates/notes/note_detail.html
karmaworld/templates/quizzes/keyword_edit.html
karmaworld/urls.py

index 3e58f4886aa3d23d2dc84d76afe33ecadea9d9de..b73e4cef25e3e700c78382b4441ca02c82c603fa 100644 (file)
@@ -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):
         """
index 68601ead6f648e458d993247c25c3649afc43106..6b5294c4660cb47c754e2cb7707d5e520dd7b7f3 100644 (file)
@@ -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')
index c23bedd34d3041c440ab1baf54abebd872918d4a..e374d86f05dc22312eac3c9e097daad20981b5df 100644 (file)
@@ -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;
index 4d20454f1ebb13b200ca1cb59a53729a40faf73f..02c1446d4769f227df9137c288726cdc55f38002 100644 (file)
     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 }}";
   </script>
   <script src="{{ STATIC_URL }}js/setup-ajax.js"></script>
+{% endblock %}
+
+{% block bodyscripts %}
   <script src="{{ STATIC_URL }}js/note-detail.js" ></script>
   <script src="{{ STATIC_URL }}js/pxem.jQuery.js"></script>
 {% endblock %}
           <div class="activity_details_status">
             So far, <span id="thank-number" class="activity_details_status_number">{{ note.thanks }}</span> people have completely fallen in love with with these notes.
           </div><!-- /activity_details_status -->
+          <div class="activity_details_status">
+
+          </div>
+        </div><!-- /note_status -->
+      </div>
+
+      <div class="row">
+        <div id="note_keyword_link" class="twelve columns">
+          <div class="activity_details_status">
+            <a href="{% url 'keyword_edit' note.course.school.slug note.course.slug note.slug %}">See key words and definitions&nbsp;<i class="fa fa-arrow-right"></i></a>
+          </div><!-- /activity_details_status -->
         </div><!-- /note_status -->
       </div>
 
index 19eeb9bf8458cf176569b6fed409b5a6698391dd..91b0b99457087090eb12712e5e114269e54b3f0b 100644 (file)
 {% block content %}
   <section id="dashboard_content">
     <div id="stats_container" class="hero_gradient_bar">
+
+      <div class="row">
+        <div class="twelve columns header_subhead">
+          <a href="{{ note.get_absolute_url}} ">
+            <i class="fa fa-arrow-left"></i>&nbsp;back to {{ note.name }}
+          </a>
+        </div>
+      </div>
+
       <div class="row">
         <div class="small-10 columns small-centered center header_title">
-          <p>Define keywords for the note</p>
-          <p><a href="{{ note.get_absolute_url }}">{{ note.name }}</a></p>
+          <p>Define keywords for the note<br/>
+          {{ note.name }}</p>
+        </div>
+      </div>
+
+      <div class="row">
+        <div class="small-10 columns small-centered center">
+          <p>(Press tab in the last definition for more rows)</p>
         </div>
       </div>
 
@@ -29,7 +44,7 @@
     <div id="activity_container">
       <div class="row">
         <div class="small-12 columns center">
-          <form id="keyword-form" action="{% url 'keyword_edit' note.id %}" method="post">
+          <form id="keyword-form" action="{% url 'keyword_edit' note.course.school.slug note.course.slug note.slug %}" method="post">
             {% csrf_token %}
             <div class="hide" id="keyword-form-prototype">
               {{ prototype_form.as_p }}
index b16f827f98b15dabedc952b14bbafe4c3118765c..769f3f93ff0bd92482f0a1fc9cdd82cb90fd081d 100644 (file)
@@ -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<pk>\d+)/$', QuizView.as_view(), name='quiz'),
-    url(r'^note/(?P<pk>\d+)/keywords/$', KeywordEditView.as_view(), name='keyword_edit'),
-
-    #url(r'^pdfview$', PDFView.as_view(), name='pdf'),
     url(r'^pdfview/(?P<pk>\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<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<pk>[\d^/]+)$', \
+    url(r'^note/(?P<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<pk>[\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<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<slug>[^/]+)$', \
-    #    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'),
 )