create_groups.py
15.7 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#-*- coding:utf-8 -*-
from django.contrib.auth.models import Permission, Group
from django.core.management.base import BaseCommand
from accounts.models import GroupSettings
from dictionary.models import Lemma_Status
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():
do_obrobki = Lemma_Status.objects.get(status=u'do obróbki')
w_obrobce = Lemma_Status.objects.get(status=u'w obróbce')
gotowe = Lemma_Status.objects.get(status=u'gotowe')
tymczasowy = Lemma_Status.objects.get(status=u'tymczasowy')
sprawdzone = Lemma_Status.objects.get(status=u'sprawdzone')
w_obrobce_f = Lemma_Status.objects.get(status=u'(F) w obróbce')
gotowe_f = Lemma_Status.objects.get(status=u'(F) gotowe')
sprawdzone_f = Lemma_Status.objects.get(status=u'(F) sprawdzone')
w_obrobce_s = Lemma_Status.objects.get(status=u'(S) w obróbce')
gotowe_s = Lemma_Status.objects.get(status=u'(S) gotowe')
sprawdzone_s = Lemma_Status.objects.get(status=u'(S) sprawdzone')
# Group.objects.all().delete()
#
## prawa gosci
guests, xx = Group.objects.get_or_create(name=u'Gość')
guests.permissions.clear()
guests.permissions.add(get_permission('view_lemma'))
guests.permissions.add(get_permission('add_notes'))
guests.permissions.add(get_permission('view_realization'))
guests_settings, xx = GroupSettings.objects.get_or_create(group=guests,
priority=30)
guests_settings.abort_statuses.clear()
guests_settings.next_statuses.clear()
guests_settings.active_statuses.clear()
#
#
## prawa gosci uprzywilejowanych
guests_plus, xx = Group.objects.get_or_create(name=u'Gość+')
guests_plus.permissions.clear()
guests_plus.permissions.add(get_permission('view_lemma'))
guests_plus.permissions.add(get_permission('add_notes'))
guests_plus.permissions.add(get_permission('download_vocabulary'))
guests_plus.permissions.add(get_permission('view_vocab_stats'))
guests_plus.permissions.add(get_permission('view_arg_stats'))
guests_plus.permissions.add(get_permission('view_realization'))
guests_plus_settings, xx = GroupSettings.objects.get_or_create(group=guests_plus,
priority=30)
guests_plus_settings.abort_statuses.clear()
guests_plus_settings.next_statuses.clear()
guests_plus_settings.active_statuses.clear()
#
## prawa frazeologow
phraseologists, xx = Group.objects.get_or_create(name=u'Frazeolog')
phraseologists.permissions.clear()
phraseologists.permissions.add(get_permission('view_lemma'))
phraseologists.permissions.add(get_permission('view_notes'))
phraseologists.permissions.add(get_permission('add_notes'))
phraseologists.permissions.add(get_permission('add_phraseologic_frames'))
phraseologists.permissions.add(get_permission('change_lemmas'))
phraseologists.permissions.add(get_permission('view_realization'))
phraseologists.permissions.add(get_permission('see_stats'))
# phraseologists.permissions.add(get_permission('modify_lemma_examples'))
phraseologists.permissions.add(get_permission('modify_all_examples'))
phraseologists_settings, xx = GroupSettings.objects.get_or_create(group=phraseologists,
priority=25)
phraseologists_settings.abort_statuses.clear()
phraseologists_settings.next_statuses.clear()
phraseologists_settings.active_statuses.clear()
phraseologists_settings.abort_statuses.add(w_obrobce_f)
phraseologists_settings.next_statuses.add(w_obrobce_f)
phraseologists_settings.next_statuses.add(gotowe_f)
phraseologists_settings.active_statuses.add(w_obrobce_f)
#
## prawa superfrazeologow
superphraseologists, xx = Group.objects.get_or_create(name=u'Superfrazeolog')
superphraseologists.permissions.clear()
superphraseologists.permissions.add(get_permission('view_lemma'))
superphraseologists.permissions.add(get_permission('view_notes'))
superphraseologists.permissions.add(get_permission('add_notes'))
superphraseologists.permissions.add(get_permission('add_phraseologic_frames'))
superphraseologists.permissions.add(get_permission('change_lemmas'))
superphraseologists.permissions.add(get_permission('change_all_lemmas'))
superphraseologists.permissions.add(get_permission('view_realization'))
superphraseologists.permissions.add(get_permission('confirm_lemma'))
superphraseologists.permissions.add(get_permission('see_stats'))
superphraseologists.permissions.add(get_permission('confirm_example'))
superphraseologists.permissions.add(get_permission('modify_all_examples'))
# superphraseologists.permissions.add(get_permission('modify_lemma_examples'))
superphraseologists_settings, xx = GroupSettings.objects.get_or_create(group=superphraseologists,
priority=23)
superphraseologists_settings.abort_statuses.clear()
superphraseologists_settings.next_statuses.clear()
superphraseologists_settings.active_statuses.clear()
superphraseologists_settings.abort_statuses.add(sprawdzone)
superphraseologists_settings.abort_statuses.add(w_obrobce_f)
superphraseologists_settings.next_statuses.add(w_obrobce_f)
superphraseologists_settings.next_statuses.add(gotowe_f)
superphraseologists_settings.next_statuses.add(sprawdzone_f)
superphraseologists_settings.active_statuses.add(w_obrobce_f)
superphraseologists_settings.active_statuses.add(gotowe_f)
superphraseologists_settings.active_statuses.add(sprawdzone_f)
#
## prawa leksykografow
lexicographers, xx = Group.objects.get_or_create(name=u'Leksykograf')
lexicographers.permissions.clear()
lexicographers.permissions.add(get_permission('view_lemma'))
lexicographers.permissions.add(get_permission('add_notes'))
lexicographers.permissions.add(get_permission('view_notes'))
lexicographers.permissions.add(get_permission('change_lemmas'))
lexicographers.permissions.add(get_permission('see_stats'))
lexicographers.permissions.add(get_permission('add_syntactic_frames'))
#lexicographers.permissions.add(get_permission('add_phraseologic_frames'))
lexicographers.permissions.add(get_permission('own_lemmas'))
lexicographers.permissions.add(get_permission('modify_lemma_examples'))
lexicographers.permissions.add(get_permission('change_lemma_version'))
lexicographers.permissions.add(get_permission('view_realization'))
lexicographers_settings, xx = GroupSettings.objects.get_or_create(group=lexicographers,
priority=20)
lexicographers_settings.abort_statuses.clear()
lexicographers_settings.next_statuses.clear()
lexicographers_settings.active_statuses.clear()
lexicographers_settings.abort_statuses.add(do_obrobki)
lexicographers_settings.abort_statuses.add(w_obrobce)
lexicographers_settings.abort_statuses.add(gotowe)
lexicographers_settings.next_statuses.add(w_obrobce)
lexicographers_settings.next_statuses.add(gotowe)
lexicographers_settings.active_statuses.add(w_obrobce)
#
## prawa superleksykografow
superlexicographers, xx = Group.objects.get_or_create(name=u'Superleksykograf')
superlexicographers.permissions.clear()
superlexicographers.permissions.add(get_permission('view_lemma'))
superlexicographers.permissions.add(get_permission('add_notes'))
superlexicographers.permissions.add(get_permission('view_notes'))
superlexicographers.permissions.add(get_permission('change_all_lemmas'))
superlexicographers.permissions.add(get_permission('change_lemmas'))
superlexicographers.permissions.add(get_permission('confirm_lemma'))
superlexicographers.permissions.add(get_permission('manage_vocabulary'))
superlexicographers.permissions.add(get_permission('download_vocabulary'))
superlexicographers.permissions.add(get_permission('view_vocab_stats'))
superlexicographers.permissions.add(get_permission('see_stats'))
superlexicographers.permissions.add(get_permission('see_all_stats'))
superlexicographers.permissions.add(get_permission('add_user'))
superlexicographers.permissions.add(get_permission('create_realization'))
superlexicographers.permissions.add(get_permission('confirm_example'))
superlexicographers.permissions.add(get_permission('manage_tool_configuration'))
#superlexicographers.permissions.add(get_permission('add_phraseologic_frames'))
superlexicographers.permissions.add(get_permission('add_syntactic_frames'))
superlexicographers.permissions.add(get_permission('own_lemmas'))
superlexicographers.permissions.add(get_permission('modify_lemma_examples'))
superlexicographers.permissions.add(get_permission('change_lemma_version'))
superlexicographers.permissions.add(get_permission('view_realization'))
superlexicographers.permissions.add(get_permission('modify_all_examples'))
superlexicographers_settings, xx = GroupSettings.objects.get_or_create(group=superlexicographers,
priority=10)
superlexicographers_settings.abort_statuses.clear()
superlexicographers_settings.next_statuses.clear()
superlexicographers_settings.active_statuses.clear()
superlexicographers_settings.abort_statuses.add(do_obrobki)
superlexicographers_settings.abort_statuses.add(w_obrobce)
superlexicographers_settings.abort_statuses.add(gotowe)
superlexicographers_settings.abort_statuses.add(sprawdzone)
#superlexicographers_settings.abort_statuses.add(gotowe_f)
superlexicographers_settings.next_statuses.add(w_obrobce)
superlexicographers_settings.next_statuses.add(gotowe)
superlexicographers_settings.next_statuses.add(tymczasowy)
superlexicographers_settings.next_statuses.add(sprawdzone)
#superlexicographers_settings.next_statuses.add(w_obrobce_f)
#superlexicographers_settings.next_statuses.add(gotowe_f)
#superlexicographers_settings.next_statuses.add(sprawdzone_f)
superlexicographers_settings.active_statuses.add(do_obrobki)
superlexicographers_settings.active_statuses.add(w_obrobce)
superlexicographers_settings.active_statuses.add(gotowe)
superlexicographers_settings.active_statuses.add(tymczasowy)
superlexicographers_settings.active_statuses.add(sprawdzone)
superlexicographers_settings.active_statuses.add(w_obrobce_f)
superlexicographers_settings.active_statuses.add(gotowe_f)
superlexicographers_settings.active_statuses.add(sprawdzone_f)
####################### semantyka ##################################
## prawa semantykow
semantics, xx = Group.objects.get_or_create(name=u'Semantyk')
semantics.permissions.clear()
semantics.permissions.add(get_permission('view_lemma'))
semantics.permissions.add(get_permission('add_notes'))
semantics.permissions.add(get_permission('view_notes'))
semantics.permissions.add(get_permission('view_realization'))
semantics.permissions.add(get_permission('see_stats'))
semantics.permissions.add(get_permission('add_examples')) # nowe
semantics.permissions.add(get_permission('semantically_own_lemmas')) # nowe
semantics.permissions.add(get_permission('add_semantic_frames')) # nowe
semantics_settings, xx = GroupSettings.objects.get_or_create(group=semantics,
priority=27)
semantics_settings.abort_statuses.clear()
semantics_settings.next_statuses.clear()
semantics_settings.active_statuses.clear()
semantics_settings.abort_statuses.add(sprawdzone_f)
semantics_settings.next_statuses.add(w_obrobce_s)
semantics_settings.next_statuses.add(gotowe_s)
semantics_settings.active_statuses.add(w_obrobce_s)
#
## prawa supersemantykow
supersemantics, xx = Group.objects.get_or_create(name=u'Supersemantyk')
supersemantics.permissions.clear()
supersemantics.permissions.add(get_permission('view_lemma'))
supersemantics.permissions.add(get_permission('add_notes'))
supersemantics.permissions.add(get_permission('view_notes'))
supersemantics.permissions.add(get_permission('view_realization'))
supersemantics.permissions.add(get_permission('see_stats'))
supersemantics.permissions.add(get_permission('add_examples')) # nowe
supersemantics.permissions.add(get_permission('semantically_own_lemmas')) # nowe
supersemantics.permissions.add(get_permission('add_semantic_frames')) # nowe
supersemantics.permissions.add(get_permission('change_all_semantics')) # nowe
supersemantics.permissions.add(get_permission('confirm_semantics')) # nowe
supersemantics_settings, xx = GroupSettings.objects.get_or_create(group=supersemantics,
priority=29)
supersemantics_settings.abort_statuses.clear()
supersemantics_settings.next_statuses.clear()
supersemantics_settings.active_statuses.clear()
supersemantics_settings.abort_statuses.add(sprawdzone_f)
supersemantics_settings.next_statuses.add(w_obrobce_s)
supersemantics_settings.next_statuses.add(gotowe_s)
supersemantics_settings.next_statuses.add(sprawdzone_s)
supersemantics_settings.active_statuses.add(w_obrobce_s)
supersemantics_settings.active_statuses.add(gotowe_s)
supersemantics_settings.active_statuses.add(sprawdzone_s)
#
## prawa administratorow
admins, xx = Group.objects.get_or_create(name=u'Administrator')
admins.permissions.clear()
admins.permissions.add(get_permission('view_lemma'))
admins.permissions.add(get_permission('add_notes'))
admins.permissions.add(get_permission('view_notes'))
admins.permissions.add(get_permission('change_all_lemmas'))
admins.permissions.add(get_permission('change_lemmas'))
admins.permissions.add(get_permission('confirm_lemma'))
admins.permissions.add(get_permission('manage_vocabulary'))
admins.permissions.add(get_permission('download_vocabulary'))
admins.permissions.add(get_permission('view_vocab_stats'))
admins.permissions.add(get_permission('see_stats'))
admins.permissions.add(get_permission('see_all_stats'))
admins.permissions.add(get_permission('add_user'))
admins.permissions.add(get_permission('create_realization'))
admins.permissions.add(get_permission('confirm_example'))
admins.permissions.add(get_permission('manage_tool_configuration'))
admins.permissions.add(get_permission('add_phraseologic_frames'))
admins.permissions.add(get_permission('add_syntactic_frames'))
admins.permissions.add(get_permission('own_lemmas'))
admins.permissions.add(get_permission('modify_lemma_examples'))
admins.permissions.add(get_permission('change_lemma_version'))
admins.permissions.add(get_permission('view_arg_stats'))
admins.permissions.add(get_permission('view_realization'))
admins_settings, xx = GroupSettings.objects.get_or_create(group=admins,
priority=40)
admins_settings.abort_statuses.clear()
admins_settings.next_statuses.clear()
admins_settings.active_statuses.clear()
admins_settings.abort_statuses.add(do_obrobki)
admins_settings.abort_statuses.add(w_obrobce)
admins_settings.abort_statuses.add(gotowe)
admins_settings.abort_statuses.add(sprawdzone)
admins_settings.abort_statuses.add(gotowe_f)
admins_settings.next_statuses.add(w_obrobce)
admins_settings.next_statuses.add(gotowe)
admins_settings.next_statuses.add(tymczasowy)
admins_settings.next_statuses.add(sprawdzone)
admins_settings.next_statuses.add(w_obrobce_f)
admins_settings.next_statuses.add(gotowe_f)
admins_settings.next_statuses.add(sprawdzone_f)
admins_settings.active_statuses.add(do_obrobki)
admins_settings.active_statuses.add(w_obrobce)
admins_settings.active_statuses.add(gotowe)
admins_settings.active_statuses.add(tymczasowy)
admins_settings.active_statuses.add(sprawdzone)
admins_settings.active_statuses.add(w_obrobce_f)
admins_settings.active_statuses.add(gotowe_f)
admins_settings.active_statuses.add(sprawdzone_f)