Ignore:
Timestamp:
Feb 9, 2013, 1:53:21 AM (13 years ago)
Author:
Alex Dehnert <adehnert@…>
Branches:
master, stable, stage
Children:
62f73df
Parents:
ea8e8b6
git-author:
Alex Dehnert <adehnert@…> (02/09/13 01:53:21)
git-committer:
Alex Dehnert <adehnert@…> (02/09/13 01:53:21)
Message:

Proof-of-concept reporting filters (ASA-#193)

Add proof-of-concept support for extensible filtering of the reporting page,
beyond just the fields on the Group object. At the moment, this is just a few
space-related filters, but in the future this might include groups missing
membership confirmations, groups whose presidents aren't students, groups who
have filled out the FYSM, etc..

File:
1 edited

Legend:

Unmodified
Added
Removed
  • asadb/space/models.py

    r7eea15c rd7557b8  
    126126
    127127
     128groups.models.filter_registry.register(
     129    group='space',
     130    slug='space:owners',
     131    name='Space owners',
     132    desc='Groups with space',
     133    qs_thunk=lambda: SpaceAssignment.current.values('group'),
     134)
     135
     136def building_filter(building):
     137    building_assignments = SpaceAssignment.current.filter(
     138        space__number__startswith="%s-" % (building, ),
     139    )
     140    owners = groups.models.Group.objects.filter(
     141        pk__in=building_assignments.values('group'),
     142    )
     143    return owners
     144
     145groups.models.filter_registry.register(
     146    group='space',
     147    slug='space:w20',
     148    name='W20 owners',
     149    desc='Owners of W20 space',
     150    qs_thunk=lambda: building_filter('W20'),
     151)
     152groups.models.filter_registry.register(
     153    group='space',
     154    slug='space:walker',
     155    name='Walker owners',
     156    desc='Owners of Walker space',
     157    qs_thunk=lambda: building_filter('50'),
     158)
     159
    128160class CurrentACLEntryManager(models.Manager):
    129161    def get_query_set(self, ):
Note: See TracChangeset for help on using the changeset viewer.