You can provide a 'subtree', an item which is the top node in
a subtree of the item-tree. If subtree is provided, then
- return either a signle (Item, [Item]) pair, where Item is the
+ return either a single (Item, [Item]) pair, where Item is the
subtree element, or None if there is no match.
"""
items = self.items()
# dictates the sequencing of items within their parent group.
course = m.ForeignKey(Course)
- ITEM_TYPE_CHOICES = (('ITEM', 'Item'),
- ('HEADING', 'Heading'))
- item_type = m.CharField(max_length=7, choices=ITEM_TYPE_CHOICES,
- default='ITEM')
+ ITEM_TYPE_CHOICES = (
+ ('ELEC', 'Attached Electronic Document'), # PDF, Doc, etc.
+ ('PHYS', 'Physical Book or Document'),
+ ('URL', 'URL'),
+ ('HEADING', 'Heading'))
+ item_type = m.CharField(max_length=7, choices=ITEM_TYPE_CHOICES)
sort_order = m.IntegerField(default=0)
# parent must be a heading. could use ForeignKey.limit_choices_to,
# to enforce this in the admin ui.
parent_heading = m.ForeignKey('Item', blank=True, null=True)
- # Metadata
+ # Metadata.
+
+ # TODO: Are all these relevant to all item types? If not, which
+ # ones should be 'required' for which item-types? We cannot
+ # enforce these requirements through model constraints, unless we
+ # break Item up into multiple tables. But there are other ways we
+ # can specify the constraints.
title = m.CharField(max_length=255,db_index=True)
author = m.CharField(max_length=255,db_index=True)
source = m.CharField(max_length=255,db_index=True, blank=True, null=True)
volume_edition = m.CharField(max_length=255, blank=True, null=True)
pages_times = m.CharField(max_length=255, blank=True, null=True)
performer = m.CharField(max_length=255,db_index=True, blank=True, null=True)
+
local_control_key = m.CharField(max_length=30, blank=True, null=True)
- creation_date = m.DateField(auto_now=False)
- last_modified = m.DateField(auto_now=False)
url = m.URLField(blank=True, null=True)
mime_type = m.CharField(max_length=100,default='text/html')
# requested_loan_period: why is this a text field?
requested_loan_period = m.CharField(max_length=255,blank=True,default='', null=True)
+ # for items of type ELEC (attached electronic document)
fileobj = m.FileField(upload_to='uploads/%Y/%m/%d', max_length=255,
blank=True, null=True, default=None)
+
date_created = m.DateTimeField(auto_now_add=True)
last_modified = m.DateTimeField()
from django.conf.urls.defaults import *
+# I'm not ready to break items out into their own urls.py, but I do
+# want to cut down on the common boilerplate in the urlpatterns below.
+
+ITEM_PREFIX = r'^course/(?P<course_id>\d+)/item/(?P<item_id>\d+)/'
+
+
urlpatterns = patterns('conifer.syrup.views',
(r'^$', 'welcome'),
(r'^course/$', 'my_courses'),
(r'^search/$', 'search'),
(r'^instructors/$', 'instructors'),
(r'^course/(?P<course_id>\d+)/$', 'course_detail'),
- (r'^course/(?P<course_id>\d+)/item/(?P<item_id>\d+)/$', 'item_detail'),
- (r'^course/(?P<course_id>\d+)/item/(?P<item_id>\d+)/meta$', 'item_metadata'),
+ (ITEM_PREFIX + r'$', 'item_detail'),
+ (ITEM_PREFIX + r'meta/$', 'item_metadata'),
+ (ITEM_PREFIX + r'edit/$', 'item_edit'),
)