From d4ba3a02cfd654969b511b11403417b819e3f12f Mon Sep 17 00:00:00 2001 From: gfawcett Date: Sun, 8 Mar 2009 01:49:15 +0000 Subject: [PATCH] improved display of courses without course codes. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@144 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/models.py | 8 +++++++- conifer/syrup/views.py | 2 +- conifer/templates/my_courses.xhtml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index f76f292..d9599cb 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -147,7 +147,7 @@ class Department(m.Model): 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) @@ -186,6 +186,12 @@ class Course(m.Model): 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() diff --git a/conifer/syrup/views.py b/conifer/syrup/views.py index 4412c52..1c3a658 100644 --- a/conifer/syrup/views.py +++ b/conifer/syrup/views.py @@ -164,7 +164,7 @@ if COURSE_CODE_LIST: 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 diff --git a/conifer/templates/my_courses.xhtml b/conifer/templates/my_courses.xhtml index a796ae5..c68e718 100644 --- a/conifer/templates/my_courses.xhtml +++ b/conifer/templates/my_courses.xhtml @@ -18,7 +18,7 @@ title = _('Welcome to Syrup E-Reserves!') ?>

You are not part of any courses at this time.

- ${course.term}: ${course.code}: ${course.title} + ${course.list_display()}

Add a new course

-- 2.11.0