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
"""
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):
"""
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')
margin-right: 3px;
}
-#note_status, #note_pedigree, #note_tags
+#note_status, #note_pedigree, #note_tags, #note_keyword_link
{
text-align: center;
padding-top: 10px;
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 <i class="fa fa-arrow-right"></i></a>
+ </div><!-- /activity_details_status -->
</div><!-- /note_status -->
</div>
{% 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> 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>
<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 }}
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
# 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'),
)