Changeset a7d30ef
- Timestamp:
- Apr 10, 2012, 4:00:41 PM (14 years ago)
- Branches:
- master, space-access, stable, stage
- Children:
- 1898cc8
- Parents:
- 04a46ed
- git-author:
- Alex Dehnert <adehnert@…> (04/10/12 16:00:41)
- git-committer:
- Alex Dehnert <adehnert@…> (04/10/12 16:00:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
asadb/groups/format_groups.py
r31da85f ra7d30ef 11 11 os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' 12 12 13 from django.db import connection 13 14 from django.db.models import Q 14 15 from django.utils import html 15 16 16 17 import groups.models 18 import space.models 17 19 20 def space_Q(merged_acl=None, building=None, ): 21 Qspace = Q() 22 if merged_acl is not None: Qspace = Q(space__merged_acl=merged_acl) 23 if building: Qspace = Qspace & Q(space__number__startswith=building+'-') 24 return Q(spaceassignment__in=space.models.SpaceAssignment.current.filter(Qspace)) 18 25 19 26 Qsa = Q(group_status__slug__in=('active', 'suspended', )) 27 20 28 functions = { 21 29 'finboard' : { … … 43 51 'predicate' : Q(group_status__slug__in=['active', 'suspended', 'applying', 'nge'], group_class__gets_publicity=True, ), 44 52 }, 53 'w20-locker' : { 54 'format' : '%(officer_email)s;%(name)s', 55 'predicate' : Qsa & space_Q(merged_acl=True, building='W20'), 56 }, 57 'w20-office' : { 58 'format' : '%(officer_email)s;%(name)s', 59 'predicate' : Qsa & space_Q(merged_acl=False, building='W20'), 60 }, 61 'all-office' : { 62 'format' : '%(officer_email)s;%(name)s', 63 'predicate' : Qsa & space_Q(merged_acl=False), 64 }, 65 'all-space' : { 66 'format' : '%(officer_email)s;%(name)s', 67 'predicate' : Qsa & space_Q(), 68 }, 45 69 } 46 70 … … 49 73 format = spec['format'] 50 74 predicate = spec['predicate'] 51 gs = groups.models.Group.objects.filter(predicate) 75 gs = groups.models.Group.objects.filter(predicate).distinct() 52 76 static_args = {'script': 'groups/format_groups.py', 'mode':mode, } 53 77 if 'prefix' in spec: … … 61 85 if 'suffix' in spec: 62 86 print spec['suffix'] % static_args 87 #for q in connection.queries: print q 63 88 64 89 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.