Using Meta Class for ordering assignments by name

This commit is contained in:
Norman Jäckel 2012-09-14 00:21:59 +02:00
parent 56e3fe7a37
commit 77ae543ff2
2 changed files with 4 additions and 3 deletions

View File

@ -253,6 +253,7 @@ class Assignment(models.Model, SlideMixin):
('can_nominate_self', ugettext_noop("Can nominate themselves")),
('can_manage_assignment', ugettext_noop("Can manage assignment")),
)
ordering = ('name',)
register_slidemodel(Assignment)

View File

@ -59,7 +59,7 @@ def get_overview(request):
if sort in ['name','status']:
query = query.order_by(sort)
except KeyError:
query = query.order_by('name')
pass
if 'reverse' in request.GET:
query = query.reverse()
@ -353,7 +353,7 @@ class AssignmentPDF(PDFView):
story.append(Paragraph("%s" % preamble.replace('\r\n', '<br/>'),
stylesheet['Paragraph']))
story.append(Spacer(0, 0.75 * cm))
assignments = Assignment.objects.order_by('name')
assignments = Assignment.objects.all()
if not assignments: # No assignments existing
story.append(Paragraph(_("No assignments available."),
stylesheet['Heading3']))
@ -675,5 +675,5 @@ def get_widgets(request):
Widget(
name=_('Assignments'),
template='assignment/widget.html',
context={'assignments': Assignment.objects.all().order_by('name')},
context={'assignments': Assignment.objects.all()},
permission_required='assignment.can_manage_assignment')]