[open-ils-commits] r1373 - servres/trunk/conifer/syrup (gfawcett)
svn at svn.open-ils.org
svn at svn.open-ils.org
Sat Apr 16 15:02:07 EDT 2011
Author: gfawcett
Date: 2011-04-16 15:02:02 -0400 (Sat, 16 Apr 2011)
New Revision: 1373
Modified:
servres/trunk/conifer/syrup/admin.py
servres/trunk/conifer/syrup/models.py
Log:
default-ordering tweaks. Mostly for making Django Admin more useable.
Modified: servres/trunk/conifer/syrup/admin.py
===================================================================
--- servres/trunk/conifer/syrup/admin.py 2011-04-16 19:02:00 UTC (rev 1372)
+++ servres/trunk/conifer/syrup/admin.py 2011-04-16 19:02:02 UTC (rev 1373)
@@ -1,13 +1,36 @@
from django.contrib import admin
import django.db.models
+from django import forms
from conifer.syrup.models import *
-for m in [ServiceDesk, Group, Membership, Course,
+for m in [ServiceDesk, Group, Course,
Department, Site, Term,
- UserProfile, Config, Z3950Target]:
+Config, Z3950Target]:
admin.site.register(m)
class ItemAdmin(admin.ModelAdmin):
model = Item
admin.site.register(Item, ItemAdmin)
+
+class MembershipAdminForm(forms.ModelForm):
+ user = forms.ModelChoiceField(queryset=User.objects.order_by('username'))
+
+ class Meta:
+ model = Membership
+
+class MembershipAdmin(admin.ModelAdmin):
+ form = MembershipAdminForm
+
+admin.site.register(Membership, MembershipAdmin)
+
+class UserProfileAdminForm(forms.ModelForm):
+ user = forms.ModelChoiceField(queryset=User.objects.order_by('username'))
+
+ class Meta:
+ model = UserProfile
+
+class UserProfileAdmin(admin.ModelAdmin):
+ form = UserProfileAdminForm
+
+admin.site.register(UserProfile, UserProfileAdmin)
Modified: servres/trunk/conifer/syrup/models.py
===================================================================
--- servres/trunk/conifer/syrup/models.py 2011-04-16 19:02:00 UTC (rev 1372)
+++ servres/trunk/conifer/syrup/models.py 2011-04-16 19:02:02 UTC (rev 1373)
@@ -40,8 +40,12 @@
# the User object (although UserProfile would be another logical
# candidate).
+
class UserExtensionMixin(object):
+ class Meta:
+ ordering = ['username']
+
def sites(self, role=None):
self.maybe_refresh_external_memberships()
sites = Site.objects.filter(group__membership__user=self.id).distinct()
@@ -146,7 +150,10 @@
def __unicode__(self):
return 'UserProfile(%s)' % self.user
+ class Meta:
+ ordering = ['user__username']
+
#----------------------------------------------------------------------
# Lookup tables
@@ -158,6 +165,9 @@
def __unicode__(self):
return self.name
+ class Meta:
+ ordering = ['name']
+
@classmethod
def default(cls):
return cls.objects.get(pk=Config.get('default.desk', 1))
@@ -210,7 +220,10 @@
def __unicode__(self):
return self.name
+ class Meta:
+ ordering = ['name']
+
class Course(BaseModel):
"""An abstract course (not a course offering.)"""
code = m.CharField(max_length=64, unique=True)
@@ -288,7 +301,7 @@
class Meta:
unique_together = (('course', 'start_term', 'owner'))
- ordering = ['-start_term__start', 'course__code', 'owner__last_name']
+ ordering = ['course__code', 'owner__last_name', '-start_term__start']
def save(self, *args, **kwargs):
# Assert that the term-order is logical.
@@ -519,11 +532,16 @@
def __unicode__(self):
return u"Group('%s', '%s')" % (self.site,
self.external_id or '(internal)')
+ class Meta:
+ ordering = ['site__course__code', 'site__course__name', 'external_id']
+
class Membership(BaseModel):
class Meta:
unique_together = (('group', 'user'))
+ ordering = ['user__username',
+ 'group__site__course__code', 'group__site__course__name', 'group__external_id']
user = m.ForeignKey(User)
group = m.ForeignKey(Group)
More information about the open-ils-commits
mailing list