class Course(m.Model):
"""An offering of a course."""
- # some courses may be ad-hoc and have no code?
+ # some courses may be ad-hoc and have no code.
code = m.CharField(max_length=64, blank=True, null=True)
department = m.ForeignKey(Department)
term = m.ForeignKey(Term)
def __unicode__(self):
return self.code or self.title
+ def list_display(self):
+ if self.code:
+ return '%s: %s [%s]' % (self.term, self.title, self.code)
+ else:
+ return '%s: %s' % (self.term, self.title)
+
def items(self):
return self.item_set.all()
choices = [(a,a) for a in course_list]
choices.sort()
empty_label = u'---------'
- choices.insert(0, (0, empty_label))
+ choices.insert(0, ('', empty_label))
NewCourseForm.base_fields['code'].widget = Select(
choices = choices)
NewCourseForm.base_fields['code'].empty_label = empty_label
?>
<p py:if="not my_courses">You are not part of any courses at this time.</p>
<p py:for="course in my_courses" style="font-size: large;">
- <a href="${course.id}/">${course.term}: ${course.code}: ${course.title}</a>
+ <a href="${course.id}/">${course.list_display()}</a>
</p>
<p><a href="new/">Add a new course</a></p>
<div class="gap"/>