Changeset 57beb94
- Timestamp:
- May 26, 2010, 8:23:37 PM (15 years ago)
- Branches:
- master, client
- Children:
- a1e4224
- Parents:
- 2fb5a35
- git-author:
- Alex Dehnert <adehnert@…> (05/26/10 05:10:30)
- git-committer:
- Alex Dehnert <adehnert@…> (05/26/10 20:23:37)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
remit/util/setup.py
re5caf62 r57beb94 15 15 import finance_core.util 16 16 17 from django.contrib.auth.models import Group, Permission 18 from django.contrib.contenttypes.models import ContentType 19 from django.db.models import Q 20 21 17 22 base_structure = ( 18 23 ('Assets', None, ), … … 20 25 ('Income', None, ), 21 26 ) 27 28 def get_or_create_group(name): 29 try: 30 group = Group.objects.get(name=name, ) 31 except Group.DoesNotExist: 32 group = Group(name=name, ) 33 group.save() 34 return group 35 36 def grant_by_codename(principal, codename): 37 principal.permissions.add(Permission.objects.get(codename=codename, )) 22 38 23 39 if __name__ == '__main__': … … 28 44 finance_core.util.mass_add_accounts(base, base_structure, sys.stdout, ) 29 45 util.add_gl_accounts.add_gl_accounts() 46 47 # Do the various auth setup 48 get_or_create_group('autocreated') 49 get_or_create_group('mit') 50 treasurers = get_or_create_group('treasurers') 51 treasurer_perms = Permission.objects.filter(content_type__app_label__in=['vouchers', 'finance_core', ],) 52 for perm in treasurer_perms: 53 treasurers.permissions.add(perm) 54 treasurers.save() 55 downloader = get_or_create_group('downloader') 56 grant_by_codename(downloader, 'generate_vouchers', ) 57 downloader.save()
Note: See TracChangeset
for help on using the changeset viewer.