From: gfawcett Date: Mon, 4 May 2009 01:17:16 +0000 (+0000) Subject: Users can now self-register for open-access courses. X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=833f44e9fb931a54ef6e6076a2d823aedc51183a;p=Syrup.git Users can now self-register for open-access courses. Previously, all users could view the contents of open-access courses, but could not register for them. Now there is an option to join an open-access course, which adds the course to the user's My Courses list. git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@446 6d9bc8c9-1ec2-4278-b937-99fde70a366f --- diff --git a/conifer/TODO b/conifer/TODO index 1fd8390..ce2fa15 100644 --- a/conifer/TODO +++ b/conifer/TODO @@ -2,16 +2,26 @@ CRITICAL: IMPORTANT: -* Z39.50 may return e-journal records (with 856u hyperlinks) and other non-physical items. - +* factor out hardcoded references to the EG server. + +* People should be able to register themselves into open courses. + That is, actually become a member of them. + +* Notify circulation of wanted items. What should it do? + * set up a proper issue-tracker? +* Z39.50 may return e-journal records (with 856u hyperlinks) and other + non-physical items. 859$9 is a definitive indicator in the Conifer + (Evergreen?) context. + +* opensrf alternatives for SIP calls? + * need more than 10 results on physical-item search results. * if someone has item checked out, show due date/time on item-about page. -* People should be able to register themselves into open courses. - That is, actually become a member of them. +* Send me email when my sites change? * Import of reserves data from Leddy voyager. Laurentian, others? @@ -19,8 +29,6 @@ IMPORTANT: * manage z3950 targets? Search z3950 targets? -* Send me email when my sites change? - MAYBE: * Generating barcodes in emails, printable screens? (3 of 9 enough?) @@ -39,11 +47,11 @@ FROM KGS: > Notify circulation of wanted items -- FAIL > Why is staff a member of a course? is that a requirement? (proxy -> instructor makes more sense). +> instructor makes more sense; but how to accomplish that?). + +> an alternate add-physical-item form, with a suitably-intimidating +> warning to encourage catalogue-use wherever possible. -> Okay, I'll add a TODO for an alternate add-physical-item form, with -> a suitably-intimidating warning to encourage catalogue-use wherever -> possible. RECENTLY DONE: diff --git a/conifer/syrup/models.py b/conifer/syrup/models.py index 79fcef9..03a3ea1 100644 --- a/conifer/syrup/models.py +++ b/conifer/syrup/models.py @@ -293,6 +293,14 @@ class Course(m.Model): return User.objects.filter(member__course__exact=self, member__role__exact='INSTR') \ .order_by('last_name', 'first_name') + def is_joinable_by(self, user): + """Return True if the user could feasibly register into this + course: she's not already in it, and the course allows open + registration.""" + return user.is_authenticated() and self.access in ('ANON', 'LOGIN') and \ + not Member.objects.filter(user=user, course=self) + + def _merge_sections(secs): delim = course_sections.sections_tuple_delimiter return delim.join(delim.join(sec) for sec in secs) diff --git a/conifer/syrup/urls.py b/conifer/syrup/urls.py index 0ad0ec0..cbcf027 100644 --- a/conifer/syrup/urls.py +++ b/conifer/syrup/urls.py @@ -32,6 +32,7 @@ urlpatterns = patterns('conifer.syrup.views', (r'^course/(?P\d+)/edit/delete/$', 'delete_course'), (r'^course/(?P\d+)/edit/permission/$', 'edit_course_permissions'), (r'^course/(?P\d+)/feeds/(?P.*)$', 'course_feeds'), + (r'^course/(?P\d+)/join/$', 'course_join'), (ITEM_PREFIX + r'$', 'item_detail'), (ITEM_PREFIX + r'dl/(?P.*)$', 'item_download'), (ITEM_PREFIX + r'meta$', 'item_metadata'), diff --git a/conifer/syrup/views/courses.py b/conifer/syrup/views/courses.py index 3f23728..8a778ce 100644 --- a/conifer/syrup/views/courses.py +++ b/conifer/syrup/views/courses.py @@ -241,3 +241,19 @@ def course_search(request, course_id): course = get_object_or_404(models.Course, pk=course_id) return search(request, in_course=course) +@login_required +def course_join(request, course_id): + """Self-register into an open-registration course.""" + course = get_object_or_404(models.Course, pk=course_id) + if not course.is_joinable_by(request.user): + # user should never see this. + return simple_message(_('You cannot join this course.'), + _('Sorry, but you cannot join this course at this time.')) + elif request.method != 'POST': + return g.render('course_join.xhtml', course=course) + else: + mbr = models.Member.objects.create(user=request.user, course=course, role='STUDT') + mbr.save() + return HttpResponseRedirect(course.course_url()) + + diff --git a/conifer/templates/course_detail.xhtml b/conifer/templates/course_detail.xhtml index 11dcaaf..293015e 100644 --- a/conifer/templates/course_detail.xhtml +++ b/conifer/templates/course_detail.xhtml @@ -2,6 +2,7 @@ title = '%s: %s (%s)' % (course.code, course.title, course.term) item_tree = course.item_tree() is_editor = course.can_edit(request.user) +is_joinable = course.is_joinable_by(request.user) ?> Edit course details + diff --git a/conifer/templates/course_join.xhtml b/conifer/templates/course_join.xhtml new file mode 100644 index 0000000..d8cbe47 --- /dev/null +++ b/conifer/templates/course_join.xhtml @@ -0,0 +1,24 @@ + + + + + + ${title} +