From 3021ec3c8a009b9f2be3170f2f0e97fff3935a30 Mon Sep 17 00:00:00 2001 From: gfawcett Date: Mon, 9 Mar 2009 23:49:24 +0000 Subject: [PATCH] constrain Member class: (course,user) must be unique. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@159 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- conifer/syrup/models.py | 3 +++ conifer/templates/edit_course_permissions.xhtml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index 673d642..44646c9 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -291,6 +291,9 @@ def section_encode_safe(section): return course_sections.sections_tuple_delimiter.join(section).encode('base64').strip() class Member(m.Model): + class Meta: + unique_together = (('course', 'user')) + course = m.ForeignKey(Course) user = m.ForeignKey(User) role = m.CharField( diff --git a/conifer/templates/edit_course_permissions.xhtml b/conifer/templates/edit_course_permissions.xhtml index ab8f15c..a921da7 100644 --- a/conifer/templates/edit_course_permissions.xhtml +++ b/conifer/templates/edit_course_permissions.xhtml @@ -28,7 +28,7 @@ instructors = [m for m in models.Member.objects.filter(course=course) if m.role [(u'INSTR',_(u'Instructor')), (u'PROXY', _(u'Proxy instructor'))]) .render('instructor_role_%d' % mbr.id, mbr.role))"/> - ${mbr.user.get_full_name() or mbr.user} + ${mbr.user.get_full_name() or ''} (${mbr.user.username}) ${select_role(mbr)} -- 2.11.0