[open-ils-commits] r162 - in servres/trunk/conifer: syrup templates (gfawcett)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Mar 9 19:49:37 EDT 2009


Author: gfawcett
Date: 2009-03-09 19:49:36 -0400 (Mon, 09 Mar 2009)
New Revision: 162

Modified:
   servres/trunk/conifer/syrup/models.py
   servres/trunk/conifer/syrup/views.py
   servres/trunk/conifer/templates/edit_course_permissions.xhtml
Log:
fixed bugs in add/drop sections; was leaving broken section identifiers behind.


Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py	2009-03-09 23:49:30 UTC (rev 161)
+++ servres/trunk/conifer/syrup/models.py	2009-03-09 23:49:36 UTC (rev 162)
@@ -265,11 +265,13 @@
             return set(inner())
 
     def add_sections(self, *sections):
+        assert all(len(s)==3 for s in sections), repr(sections)
         current = self.sections()
         sections = set(sections).union(current)
         self.enrol_codes = _merge_sections(sections)
 
     def drop_sections(self, *sections):
+        assert all(len(s)==3 for s in sections), repr(sections)
         current = self.sections()
         sections = current - set(sections)
         self.enrol_codes = _merge_sections(sections)

Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py	2009-03-09 23:49:30 UTC (rev 161)
+++ servres/trunk/conifer/syrup/views.py	2009-03-09 23:49:36 UTC (rev 162)
@@ -363,17 +363,19 @@
                 if new_sec:
                     course.add_sections(new_sec)
                 # remove the sections to be dropped
-                    to_remove = [models.section_decode_safe(name.rsplit('_',1)[1]) \
-                                     for name in POST \
-                                     if name.startswith('remove_section_')]
-                    course.drop_sections(*to_remove)
+                to_remove = [models.section_decode_safe(name.rsplit('_',1)[1]) \
+                                 for name in POST \
+                                 if name.startswith('remove_section_')]
+                course.drop_sections(*to_remove)
                 student_names = models.course_sections.students_in(*course.sections())
                 for name in student_names:
                     user = models.maybe_initialize_user(name)
                     if user:
-                        mbr = models.Member.objects.create(course=course, user=user, 
-                                                           role='STUDT', provided=True)
-                        mbr.save()
+                        if not models.Member.objects.filter(course=course, user=user):
+                            mbr = models.Member.objects.create(
+                                course=course, user=user, 
+                                role='STUDT', provided=True)
+                            mbr.save()
             else:
                 pass
             course.save()

Modified: servres/trunk/conifer/templates/edit_course_permissions.xhtml
===================================================================
--- servres/trunk/conifer/templates/edit_course_permissions.xhtml	2009-03-09 23:49:30 UTC (rev 161)
+++ servres/trunk/conifer/templates/edit_course_permissions.xhtml	2009-03-09 23:49:36 UTC (rev 162)
@@ -86,7 +86,7 @@
       </table>
       <p>Add section: 
       <select name="add_section">
-	<option>--------</option>
+	<option value="">--------</option>
 	<optgroup py:for="label, sections in ((_('My Courses'), my_sections), (_('%s in term %s') % (course.code, course.term), ct_sections))"
 		  label="${label}" py:if="sections">
 	  <option py:for="(term, code, sec) in sections"



More information about the open-ils-commits mailing list