[open-ils-commits] r950 - in servres/trunk/conifer: syrup templates (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 5 22:25:46 EDT 2010
Author: gfawcett
Date: 2010-08-05 22:25:44 -0400 (Thu, 05 Aug 2010)
New Revision: 950
Modified:
servres/trunk/conifer/syrup/models.py
servres/trunk/conifer/templates/edit_site.xhtml
Log:
Added Site.end_term attribute, for modelling multi-term course offerings.
Replaced 'term' with ('start_term', 'end_term'); 'term' is now a read-only
alias for 'start_term'.
Most sites will have the same value for their start- and end-terms.
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2010-08-04 14:23:31 UTC (rev 949)
+++ servres/trunk/conifer/syrup/models.py 2010-08-06 02:25:44 UTC (rev 950)
@@ -195,7 +195,8 @@
class Site(BaseModel):
"""A a list of materials for one (or more) course offering(s)."""
course = m.ForeignKey(Course)
- term = m.ForeignKey(Term)
+ start_term = m.ForeignKey(Term, related_name='start_term')
+ end_term = m.ForeignKey(Term, related_name='end_term')
owner = m.ForeignKey(User)
service_desk = m.ForeignKey(ServiceDesk)
@@ -207,11 +208,25 @@
('MEMBR', _('Accessible to course-site members')),
('CLOSE', _('Accessible only to course-site owners'))])
+ @property
+ def term(self):
+ """
+ Returns the start term (typically the term thought of as 'the' term of
+ the site).
+
+ Whenever possible, use the explicit 'start_term' attribute rather than
+ the 'term' property.
+ """
+ return self.start_term
+
class Meta:
- unique_together = (('course', 'term', 'owner'))
- ordering = ['-term__start', 'course__code', 'owner__last_name']
+ unique_together = (('course', 'start_term', 'owner'))
+ ordering = ['-start_term__start', 'course__code', 'owner__last_name']
def save(self, *args, **kwargs):
+ # Assert that the term-order is logical.
+ assert self.start_term.start <= self.end_term.start, \
+ 'The end-term cannot begin before the start-term.'
# Ensure there is always an internal Group.
super(Site, self).save(*args, **kwargs)
internal, just_created = Group.objects.get_or_create(
Modified: servres/trunk/conifer/templates/edit_site.xhtml
===================================================================
--- servres/trunk/conifer/templates/edit_site.xhtml 2010-08-04 14:23:31 UTC (rev 949)
+++ servres/trunk/conifer/templates/edit_site.xhtml 2010-08-06 02:25:44 UTC (rev 950)
@@ -34,7 +34,8 @@
</tr>
<table class="metadata_table">
${field_row(form.owner)}
- ${field_row(form.term)}
+ ${field_row(form.start_term)}
+ ${field_row(form.end_term)}
${field_row(form.course)}
${field_row(form.service_desk)}
More information about the open-ils-commits
mailing list