Ignore:
Timestamp:
Dec 25, 2012, 4:15:16 AM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, space-access, stable, stage
Children:
532a8e9
Parents:
14f594b
git-author:
Alex Dehnert <adehnert@…> (12/25/12 04:15:16)
git-committer:
Alex Dehnert <adehnert@…> (12/25/12 04:15:16)
Message:

Add page showing non-student group officers

Adds a page non-students holding positions that are required to be held by
students. This is a partial fix to ASA-#6, though the eventual solution should
probably be more integrated than this is.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/groups/views.py

    r0a31846 r213dd57  
    12081208    }
    12091209    return render_to_response('groups/reporting.html', context, context_instance=RequestContext(request), )
     1210
     1211
     1212@permission_required('groups.view_group_private_info')
     1213def show_nonstudent_officers(request, ):
     1214    student_roles  = groups.models.OfficerRole.objects.filter(require_student=True, )
     1215    year = datetime.datetime.now().year
     1216    account_classes = ["G"] + [str(yr) for yr in range(year-5, year+10)]
     1217    students = groups.models.AthenaMoiraAccount.active_accounts.filter(account_class__in=account_classes)
     1218    office_holders = groups.models.OfficeHolder.current_holders.order_by('group__name', 'role', )
     1219    office_holders = office_holders.filter(role__in=student_roles)
     1220    office_holders = office_holders.exclude(person__in=students.values('username'))
     1221    office_holders = office_holders.select_related('group', 'role')
     1222
     1223    msg = None
     1224    msg_type = ""
     1225    if 'sort' in request.GET:
     1226        if request.GET['sort'] == 'group':
     1227            office_holders = office_holders.order_by('group__name', 'role', 'person', )
     1228        elif request.GET['sort'] == 'role':
     1229            office_holders = office_holders.order_by('role', 'group__name', 'person', )
     1230        elif request.GET['sort'] == 'person':
     1231            office_holders = office_holders.order_by('person', 'group__name', 'role', )
     1232        else:
     1233            msg = 'Unknown sort key "%s".' % (request.GET['sort'], )
     1234            msg_type = 'error'
     1235
     1236    context = {
     1237        'pagename': 'groups',
     1238        'roles': student_roles,
     1239        'holders': office_holders,
     1240        'msg': msg,
     1241        'msg_type': msg_type,
     1242    }
     1243
     1244    return render_to_response('groups/reporting/non-students.html', context, context_instance=RequestContext(request), )
     1245
     1246
Note: See TracChangeset for help on using the changeset viewer.