[open-ils-commits] r446 - in servres/trunk/conifer: . syrup syrup/views templates (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun May 3 21:17:17 EDT 2009
Author: gfawcett
Date: 2009-05-03 21:17:16 -0400 (Sun, 03 May 2009)
New Revision: 446
Added:
servres/trunk/conifer/templates/course_join.xhtml
Modified:
servres/trunk/conifer/TODO
servres/trunk/conifer/syrup/models.py
servres/trunk/conifer/syrup/urls.py
servres/trunk/conifer/syrup/views/courses.py
servres/trunk/conifer/templates/course_detail.xhtml
Log:
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.
Modified: servres/trunk/conifer/TODO
===================================================================
--- servres/trunk/conifer/TODO 2009-05-03 20:26:29 UTC (rev 445)
+++ servres/trunk/conifer/TODO 2009-05-04 01:17:16 UTC (rev 446)
@@ -2,16 +2,26 @@
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 @@
* 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,12 +47,12 @@
> 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?).
-> Okay, I'll add a TODO for an alternate add-physical-item form, with
-> a suitably-intimidating warning to encourage catalogue-use wherever
-> possible.
+> an alternate add-physical-item form, with a suitably-intimidating
+> warning to encourage catalogue-use wherever possible.
+
RECENTLY DONE:
> As prof, can't view Renaissance, 2009W -- why is it listed if I
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2009-05-03 20:26:29 UTC (rev 445)
+++ servres/trunk/conifer/syrup/models.py 2009-05-04 01:17:16 UTC (rev 446)
@@ -293,6 +293,14 @@
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)
Modified: servres/trunk/conifer/syrup/urls.py
===================================================================
--- servres/trunk/conifer/syrup/urls.py 2009-05-03 20:26:29 UTC (rev 445)
+++ servres/trunk/conifer/syrup/urls.py 2009-05-04 01:17:16 UTC (rev 446)
@@ -32,6 +32,7 @@
(r'^course/(?P<course_id>\d+)/edit/delete/$', 'delete_course'),
(r'^course/(?P<course_id>\d+)/edit/permission/$', 'edit_course_permissions'),
(r'^course/(?P<course_id>\d+)/feeds/(?P<feed_type>.*)$', 'course_feeds'),
+ (r'^course/(?P<course_id>\d+)/join/$', 'course_join'),
(ITEM_PREFIX + r'$', 'item_detail'),
(ITEM_PREFIX + r'dl/(?P<filename>.*)$', 'item_download'),
(ITEM_PREFIX + r'meta$', 'item_metadata'),
Modified: servres/trunk/conifer/syrup/views/courses.py
===================================================================
--- servres/trunk/conifer/syrup/views/courses.py 2009-05-03 20:26:29 UTC (rev 445)
+++ servres/trunk/conifer/syrup/views/courses.py 2009-05-04 01:17:16 UTC (rev 446)
@@ -241,3 +241,19 @@
course = get_object_or_404(models.Course, pk=course_id)
return search(request, in_course=course)
+ at 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())
+
+
Modified: servres/trunk/conifer/templates/course_detail.xhtml
===================================================================
--- servres/trunk/conifer/templates/course_detail.xhtml 2009-05-03 20:26:29 UTC (rev 445)
+++ servres/trunk/conifer/templates/course_detail.xhtml 2009-05-04 01:17:16 UTC (rev 446)
@@ -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)
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
@@ -21,6 +22,9 @@
<div py:if="is_editor" id="edit_course" class="little_action_panel">
<a href="${course.course_url()}edit/">Edit course details</a>
</div>
+ <div py:if="is_joinable">
+ <a href="${course.course_url()}join/">Join this course</a>
+ </div>
<div id="showtree_panel" class="little_action_panel">
<a href="javascript:doToggleItemTree();">Show/hide tree</a>
</div>
Added: servres/trunk/conifer/templates/course_join.xhtml
===================================================================
--- servres/trunk/conifer/templates/course_join.xhtml (rev 0)
+++ servres/trunk/conifer/templates/course_join.xhtml 2009-05-04 01:17:16 UTC (rev 446)
@@ -0,0 +1,24 @@
+<?python
+title = _('Join this course?')
+?>
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ xmlns:py="http://genshi.edgewall.org/">
+ <xi:include href="master.xhtml"/>
+ <xi:include href="components/course.xhtml"/>
+ <head>
+ <title>${title}</title>
+ <script type="text/javascript" src="${ROOT}/static/menublocks.js"/>
+ </head>
+ <body>
+ ${course_banner(course)}
+ <h2>${title}</h2>
+
+ <p>If you choose to join this course, it will be added to your "My
+ Courses" list.</p>
+ <form action="." method="POST">
+ <p><input type="submit" value="Yes, join this course"/> <a style="margin-left: 12px;" href="../">or go back</a></p>
+ </form>
+
+ </body>
+</html>
More information about the open-ils-commits
mailing list