create_groups.py
2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
from django.contrib.auth.models import Permission, Group
from django.core.management.base import BaseCommand
class Command(BaseCommand):
args = 'none'
help = 'Creates default groups'
def handle(self, **options):
create_groups()
def get_permission(codename):
return Permission.objects.get(codename=codename)
def create_groups():
Group.objects.all().delete()
observers = Group.objects.create(name=u'Obserwator')
lexicographers = Group.objects.create(name=u'Leksykograf')
superlexicographers = Group.objects.create(name=u'Superleksykograf')
patternmakers = Group.objects.create(name=u'Wzorzysta')
managers = Group.objects.create(name=u'Wydawca')
admins = Group.objects.create(name=u'Administrator')
observers.permissions.add(get_permission('view_lexeme'))
# observers.permissions.add(get_permission('add_comment'))
observers.permissions.add(get_permission('view_pattern'))
lexicographers.permissions.add(get_permission('view_lexeme'))
lexicographers.permissions.add(get_permission('change_lexeme'))
lexicographers.permissions.add(get_permission('export_lexemes'))
lexicographers.permissions.add(get_permission('view_pattern'))
superlexicographers.permissions.add(get_permission('view_lexeme'))
superlexicographers.permissions.add(get_permission('change_lexeme'))
superlexicographers.permissions.add(get_permission('export_lexemes'))
superlexicographers.permissions.add(get_permission('lexeme_priority'))
superlexicographers.permissions.add(get_permission('view_pattern'))
# może dokonywać zmian w Banku błędów
# może dokonywać zmian w zakładce Etykiety
patternmakers.permissions.add(get_permission('view_pattern'))
patternmakers.permissions.add(get_permission('change_pattern'))
managers.permissions.add(get_permission('manage_vocabulary'))
managers.permissions.add(get_permission('view_lexeme'))
managers.permissions.add(get_permission('view_all_lexemes'))
managers.permissions.add(get_permission('view_pattern'))
managers.permissions.add(get_permission('add_user'))
managers.permissions.add(get_permission('export_lexemes'))
# zarządzanie rolami użytkowników:
managers.permissions.add(get_permission('change_group'))
admins.permissions.add(get_permission('add_user'))
admins.permissions.add(get_permission('change_group'))
admins.permissions.add(get_permission('create_admin'))
admins.permissions.add(get_permission('manage_vocabulary'))
admins.permissions.add(get_permission('manage_all_vocabularies'))