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)
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()
</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"