def get_absolute_url(self):
""" Resolve note url, use 'note' route and slug if slug
- otherwise use note and id
+ otherwise use note.id
"""
- return u"/{0}/{1}/{2}".format(self.course.school.slug, self.course.slug, self.slug)
+ if self.slug == None:
+ return u"/{0}/{1}/{2}".format(self.course.school.slug, self.course.slug, self.slug)
+ else:
+ return u"/{0}/{1}/{2}".format(self.course.school.slug, self.course.slug, self.id)
# FIXME: replace the following GOOGLE_USER in a settings.py
url(r'^raw/(?P<pk>\d+)$', raw_file, name='note_raw'),
url(r'^(?P<school_slug>[^/]+)/(?P<slug>[^/]+)$', \
CourseDetailView.as_view(), name='course_detail'),
+ # note file as id
+ url(r'^(?P<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<pk>[\d^/]+)$', \
+ NoteDetailView.as_view(), name='note_detail'),
+ # note file by note.slug
url(r'^(?P<school_slug>[^/]+)/(?P<course_slug>[^/]+)/(?P<slug>[^/]+)$', \
NoteDetailView.as_view(), name='note_detail'),