[open-ils-commits] r75 - in servres/trunk/conifer: . syrup templates templates/components
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Dec 1 20:24:48 EST 2008
Author: gfawcett
Date: 2008-12-01 20:24:48 -0500 (Mon, 01 Dec 2008)
New Revision: 75
Modified:
servres/trunk/conifer/genshi_namespace.py
servres/trunk/conifer/syrup/models.py
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views.py
servres/trunk/conifer/templates/components/item.xhtml
servres/trunk/conifer/templates/course_detail.xhtml
servres/trunk/conifer/templates/search_results.xhtml
Log:
more work on Item class; refactoring and cleanup of template code.
Modified: servres/trunk/conifer/genshi_namespace.py
===================================================================
--- servres/trunk/conifer/genshi_namespace.py 2008-12-02 01:02:22 UTC (rev 74)
+++ servres/trunk/conifer/genshi_namespace.py 2008-12-02 01:24:48 UTC (rev 75)
@@ -6,3 +6,6 @@
from itertools import cycle
from conifer.syrup import models
+
+def item_url(item, suffix=''):
+ return '/syrup/course/%d/item/%d/%s' % (item.course_id, item.id, suffix)
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2008-12-02 01:02:22 UTC (rev 74)
+++ servres/trunk/conifer/syrup/models.py 2008-12-02 01:24:48 UTC (rev 75)
@@ -144,7 +144,7 @@
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()
@@ -208,16 +208,24 @@
# 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)
@@ -228,9 +236,8 @@
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')
@@ -272,9 +279,11 @@
# 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()
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2008-12-02 01:02:22 UTC (rev 74)
+++ servres/trunk/conifer/syrup/urls.py 2008-12-02 01:24:48 UTC (rev 75)
@@ -1,5 +1,11 @@
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'),
@@ -8,6 +14,7 @@
(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'),
)
Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py 2008-12-02 01:02:22 UTC (rev 74)
+++ servres/trunk/conifer/syrup/views.py 2008-12-02 01:24:48 UTC (rev 75)
@@ -98,6 +98,12 @@
return g.render('item_metadata.xhtml', course=item.course,
item=item)
+def item_edit(request, course_id, item_id):
+ """Edit an item."""
+ # For now, just pop to the Admin interface.
+ admin_url = '/admin/syrup/item/%s/' % item_id
+ return HttpResponseRedirect(admin_url)
+
def _heading_url(request, item):
return HttpResponseRedirect(item.url)
Modified: servres/trunk/conifer/templates/components/item.xhtml
===================================================================
--- servres/trunk/conifer/templates/components/item.xhtml 2008-12-02 01:02:22 UTC (rev 74)
+++ servres/trunk/conifer/templates/components/item.xhtml 2008-12-02 01:24:48 UTC (rev 75)
@@ -8,8 +8,8 @@
<li py:for="item, subs in tree">
<a href="/syrup/course/${item.course_id}/item/${item.id}/">${item}</a>
<span class="metalinks">
- [<a href="/syrup/course/${item.course_id}/item/${item.id}/meta">about</a>
- • <a href="/admin/syrup/item/${item.id}/">edit</a>
+ [<a href="${item_url(item)}meta/">about</a>
+ • <a href="${item_url(item)}edit/">edit</a>
]
</span>
${show_tree(subs)}
Modified: servres/trunk/conifer/templates/course_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/course_detail.xhtml 2008-12-02 01:02:22 UTC (rev 74)
+++ servres/trunk/conifer/templates/course_detail.xhtml 2008-12-02 01:24:48 UTC (rev 75)
@@ -1,6 +1,6 @@
<?python
title = '%s: %s (%s)' % (course.code, course.title, course.term)
-item_tree = course.item_tree(subtree=item)
+item_tree = course.item_tree()
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
Modified: servres/trunk/conifer/templates/search_results.xhtml
===================================================================
--- servres/trunk/conifer/templates/search_results.xhtml 2008-12-02 01:02:22 UTC (rev 74)
+++ servres/trunk/conifer/templates/search_results.xhtml 2008-12-02 01:24:48 UTC (rev 75)
@@ -22,7 +22,7 @@
hey ${foo.instr_name()}<br/>
hey ${foo.user.last_name}<br/>
<!-- need to figure out how to unescape this -->
- hey ${foo.instr_name_hl(norm_query)}<br/>
+ hey ${Markup(foo.instr_name_hl(norm_query))}<br/>
</p>
<tr py:def="pageheader()">
<th>Term</th><!-- <th>Code</th> --><th>Title</th>
More information about the open-ils-commits
mailing list