[open-ils-commits] r206 - in servres/trunk/conifer: syrup templates (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Mar 19 21:48:32 EDT 2009
Author: gfawcett
Date: 2009-03-19 21:48:30 -0400 (Thu, 19 Mar 2009)
New Revision: 206
Modified:
servres/trunk/conifer/syrup/models.py
servres/trunk/conifer/syrup/views.py
servres/trunk/conifer/templates/courses.xhtml
servres/trunk/conifer/templates/instructors.xhtml
Log:
cleanup of UserProfile model. Redefinition of active_instructors. updated Browse Instructors.
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2009-03-20 00:32:08 UTC (rev 205)
+++ servres/trunk/conifer/syrup/models.py 2009-03-20 01:48:30 UTC (rev 206)
@@ -48,6 +48,13 @@
def courses(self):
return Course.objects.filter(member__user=self.id)
+ @classmethod
+ def active_instructors(cls):
+ """Return a queryset of all active instructors."""
+ # We are using the Django is_active flag to model activeness.
+ return cls.objects.filter(member__role='INSTR', is_active=True) \
+ .order_by('-last_name','-first_name')
+
for k,v in [(k,v) for k,v in UserExtensionHack.__dict__.items() \
if not k.startswith('_')]:
setattr(User, k, v)
@@ -59,26 +66,10 @@
home_address = m.TextField(blank=True)
ils_userid = m.TextField("Alternate userid in the ILS, if any",
max_length=50, blank=True)
- access_level = m.CharField(max_length=5, blank=True, null=True,
- default=None,
- choices=(('CUST', _('custodian')),
- ('STAFF', _('staff')),
- ('ADMIN', _('system administrator'))))
- instructor = m.BooleanField(default=False)
- proxy = m.BooleanField(default=False)
- # n.b. Django's User has an active flag, maybe we should use that?
- active = m.BooleanField(default=True)
def __unicode__(self):
return 'UserProfile(%s)' % self.user
- @classmethod
- def active_instructors(cls):
- """Return a queryset of all active instructors."""
- return cls.objects.filter(instructor=True) \
- .select_related('user').filter(user__is_active=True) \
- .order_by('-user__last_name','-user__first_name')
-
#----------------------------------------------------------------------
# Initializing an external user account
Modified: servres/trunk/conifer/syrup/views.py
===================================================================
--- servres/trunk/conifer/syrup/views.py 2009-03-20 00:32:08 UTC (rev 205)
+++ servres/trunk/conifer/syrup/views.py 2009-03-20 01:48:30 UTC (rev 206)
@@ -198,7 +198,7 @@
count = int(request.GET.get('count', 5))
action = request.GET.get('action', 'browse')
if action == 'join':
- paginator = Paginator(models.UserProfile.active_instructors(), count)
+ paginator = Paginator(models.User.active_instructors(), count)
elif action == 'drop':
paginator = Paginator(models.Course.objects.all(), count) # fixme, what filter?
else:
@@ -241,8 +241,8 @@
count = int(request.GET.get('count', 5))
if browse_option == 'instructors':
- paginator = Paginator(models.UserProfile.active_instructors().
- order_by('user__last_name'), count)
+ paginator = Paginator(models.User.active_instructors(),
+ count)
return g.render('instructors.xhtml', paginator=paginator,
page_num=page_num,
@@ -275,22 +275,22 @@
i am not sure this is the best way to go from instructor
to course
'''
- members = models.Member.objects.get(user__id=instructor_id,
- role='INSTR')
- paginator = Paginator(models.Course.objects.
- filter(member__id=members.id).
- order_by('title'), count)
+ courses = models.Course.objects.filter(member__user=instructor_id,
+ member__role='INSTR')
+ paginator = Paginator(courses.order_by('title'), count)
'''
no concept of active right now, maybe suppressed is a better
description anyway?
'''
# filter(active=True).order_by('title'), count)
+ instructor = models.User.objects.get(pk=instructor_id)
+ return g.render('courses.xhtml',
+ custom_title=_('Courses taught by %s') % instructor.get_full_name(),
+ paginator=paginator,
+ page_num=page_num,
+ count=count)
- return g.render('courses.xhtml', paginator=paginator,
- page_num=page_num,
- count=count)
-
def department_detail(request, department_id):
page_num = int(request.GET.get('page', 1))
count = int(request.GET.get('count', 5))
Modified: servres/trunk/conifer/templates/courses.xhtml
===================================================================
--- servres/trunk/conifer/templates/courses.xhtml 2009-03-20 00:32:08 UTC (rev 205)
+++ servres/trunk/conifer/templates/courses.xhtml 2009-03-20 01:48:30 UTC (rev 206)
@@ -1,5 +1,5 @@
<?python
-title = _('Courses')
+title = defined('custom_title') and custom_title or _('Courses')
?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xi="http://www.w3.org/2001/XInclude"
Modified: servres/trunk/conifer/templates/instructors.xhtml
===================================================================
--- servres/trunk/conifer/templates/instructors.xhtml 2009-03-20 00:32:08 UTC (rev 205)
+++ servres/trunk/conifer/templates/instructors.xhtml 2009-03-20 01:48:30 UTC (rev 206)
@@ -18,8 +18,8 @@
<tr py:def="pageheader()">
<th>Name</th>
</tr>
- <span py:def="pagerow(item)">
- <td><a href="${instructor_url(item.user)}">${item.user.last_name}, ${item.user.first_name}</a></td>
+ <span py:def="pagerow(user)">
+ <td><a href="${instructor_url(user)}">${user.last_name}, ${user.first_name}</a></td>
</span>
${pagetable(paginator, count, pagerow, pageheader)}
</body>
More information about the open-ils-commits
mailing list