Pavel "LEdoian" Turinsky
4 years ago
7 changed files with 683 additions and 15 deletions
@ -0,0 +1,607 @@ |
|||
[ |
|||
{ |
|||
"codename": "org", |
|||
"ct_app_label": "auth", |
|||
"ct_model": "user" |
|||
}, |
|||
{ |
|||
"codename": "add_flatpage", |
|||
"ct_app_label": "flatpages", |
|||
"ct_model": "flatpage" |
|||
}, |
|||
{ |
|||
"codename": "change_flatpage", |
|||
"ct_app_label": "flatpages", |
|||
"ct_model": "flatpage" |
|||
}, |
|||
{ |
|||
"codename": "delete_flatpage", |
|||
"ct_app_label": "flatpages", |
|||
"ct_model": "flatpage" |
|||
}, |
|||
{ |
|||
"codename": "view_flatpage", |
|||
"ct_app_label": "flatpages", |
|||
"ct_model": "flatpage" |
|||
}, |
|||
{ |
|||
"codename": "add_galerie", |
|||
"ct_app_label": "galerie", |
|||
"ct_model": "galerie" |
|||
}, |
|||
{ |
|||
"codename": "change_galerie", |
|||
"ct_app_label": "galerie", |
|||
"ct_model": "galerie" |
|||
}, |
|||
{ |
|||
"codename": "delete_galerie", |
|||
"ct_app_label": "galerie", |
|||
"ct_model": "galerie" |
|||
}, |
|||
{ |
|||
"codename": "view_galerie", |
|||
"ct_app_label": "galerie", |
|||
"ct_model": "galerie" |
|||
}, |
|||
{ |
|||
"codename": "add_obrazek", |
|||
"ct_app_label": "galerie", |
|||
"ct_model": "obrazek" |
|||
}, |
|||
{ |
|||
"codename": "change_obrazek", |
|||
"ct_app_label": "galerie", |
|||
"ct_model": "obrazek" |
|||
}, |
|||
{ |
|||
"codename": "delete_obrazek", |
|||
"ct_app_label": "galerie", |
|||
"ct_model": "obrazek" |
|||
}, |
|||
{ |
|||
"codename": "view_obrazek", |
|||
"ct_app_label": "galerie", |
|||
"ct_model": "obrazek" |
|||
}, |
|||
{ |
|||
"codename": "add_komentar", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "komentar" |
|||
}, |
|||
{ |
|||
"codename": "change_komentar", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "komentar" |
|||
}, |
|||
{ |
|||
"codename": "delete_komentar", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "komentar" |
|||
}, |
|||
{ |
|||
"codename": "view_komentar", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "komentar" |
|||
}, |
|||
{ |
|||
"codename": "add_korekturovanepdf", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "korekturovanepdf" |
|||
}, |
|||
{ |
|||
"codename": "change_korekturovanepdf", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "korekturovanepdf" |
|||
}, |
|||
{ |
|||
"codename": "delete_korekturovanepdf", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "korekturovanepdf" |
|||
}, |
|||
{ |
|||
"codename": "view_korekturovanepdf", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "korekturovanepdf" |
|||
}, |
|||
{ |
|||
"codename": "add_oprava", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "oprava" |
|||
}, |
|||
{ |
|||
"codename": "change_oprava", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "oprava" |
|||
}, |
|||
{ |
|||
"codename": "delete_oprava", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "oprava" |
|||
}, |
|||
{ |
|||
"codename": "view_oprava", |
|||
"ct_app_label": "korektury", |
|||
"ct_model": "oprava" |
|||
}, |
|||
{ |
|||
"codename": "add_hlasovani", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "hlasovani" |
|||
}, |
|||
{ |
|||
"codename": "change_hlasovani", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "hlasovani" |
|||
}, |
|||
{ |
|||
"codename": "delete_hlasovani", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "hlasovani" |
|||
}, |
|||
{ |
|||
"codename": "view_hlasovani", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "hlasovani" |
|||
}, |
|||
{ |
|||
"codename": "add_prednaska", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "prednaska" |
|||
}, |
|||
{ |
|||
"codename": "change_prednaska", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "prednaska" |
|||
}, |
|||
{ |
|||
"codename": "delete_prednaska", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "prednaska" |
|||
}, |
|||
{ |
|||
"codename": "view_prednaska", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "prednaska" |
|||
}, |
|||
{ |
|||
"codename": "add_seznam", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "seznam" |
|||
}, |
|||
{ |
|||
"codename": "change_seznam", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "seznam" |
|||
}, |
|||
{ |
|||
"codename": "delete_seznam", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "seznam" |
|||
}, |
|||
{ |
|||
"codename": "view_seznam", |
|||
"ct_app_label": "prednasky", |
|||
"ct_model": "seznam" |
|||
}, |
|||
{ |
|||
"codename": "add_cislo", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "cislo" |
|||
}, |
|||
{ |
|||
"codename": "change_cislo", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "cislo" |
|||
}, |
|||
{ |
|||
"codename": "delete_cislo", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "cislo" |
|||
}, |
|||
{ |
|||
"codename": "view_cislo", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "cislo" |
|||
}, |
|||
{ |
|||
"codename": "add_clanek", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "clanek" |
|||
}, |
|||
{ |
|||
"codename": "change_clanek", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "clanek" |
|||
}, |
|||
{ |
|||
"codename": "delete_clanek", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "clanek" |
|||
}, |
|||
{ |
|||
"codename": "view_clanek", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "clanek" |
|||
}, |
|||
{ |
|||
"codename": "add_konfera", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "konfera" |
|||
}, |
|||
{ |
|||
"codename": "change_konfera", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "konfera" |
|||
}, |
|||
{ |
|||
"codename": "delete_konfera", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "konfera" |
|||
}, |
|||
{ |
|||
"codename": "view_konfera", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "konfera" |
|||
}, |
|||
{ |
|||
"codename": "add_konfery_ucastnici", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "konfery_ucastnici" |
|||
}, |
|||
{ |
|||
"codename": "change_konfery_ucastnici", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "konfery_ucastnici" |
|||
}, |
|||
{ |
|||
"codename": "delete_konfery_ucastnici", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "konfery_ucastnici" |
|||
}, |
|||
{ |
|||
"codename": "view_konfery_ucastnici", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "konfery_ucastnici" |
|||
}, |
|||
{ |
|||
"codename": "add_nastaveni", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "nastaveni" |
|||
}, |
|||
{ |
|||
"codename": "change_nastaveni", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "nastaveni" |
|||
}, |
|||
{ |
|||
"codename": "delete_nastaveni", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "nastaveni" |
|||
}, |
|||
{ |
|||
"codename": "view_nastaveni", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "nastaveni" |
|||
}, |
|||
{ |
|||
"codename": "add_novinky", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "novinky" |
|||
}, |
|||
{ |
|||
"codename": "change_novinky", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "novinky" |
|||
}, |
|||
{ |
|||
"codename": "delete_novinky", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "novinky" |
|||
}, |
|||
{ |
|||
"codename": "view_novinky", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "novinky" |
|||
}, |
|||
{ |
|||
"codename": "add_organizator", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "organizator" |
|||
}, |
|||
{ |
|||
"codename": "change_organizator", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "organizator" |
|||
}, |
|||
{ |
|||
"codename": "delete_organizator", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "organizator" |
|||
}, |
|||
{ |
|||
"codename": "view_organizator", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "organizator" |
|||
}, |
|||
{ |
|||
"codename": "add_osoba", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "osoba" |
|||
}, |
|||
{ |
|||
"codename": "change_osoba", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "osoba" |
|||
}, |
|||
{ |
|||
"codename": "delete_osoba", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "osoba" |
|||
}, |
|||
{ |
|||
"codename": "view_osoba", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "osoba" |
|||
}, |
|||
{ |
|||
"codename": "add_pohadka", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "pohadka" |
|||
}, |
|||
{ |
|||
"codename": "change_pohadka", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "pohadka" |
|||
}, |
|||
{ |
|||
"codename": "delete_pohadka", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "pohadka" |
|||
}, |
|||
{ |
|||
"codename": "view_pohadka", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "pohadka" |
|||
}, |
|||
{ |
|||
"codename": "add_prijemce", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "prijemce" |
|||
}, |
|||
{ |
|||
"codename": "change_prijemce", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "prijemce" |
|||
}, |
|||
{ |
|||
"codename": "delete_prijemce", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "prijemce" |
|||
}, |
|||
{ |
|||
"codename": "view_prijemce", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "prijemce" |
|||
}, |
|||
{ |
|||
"codename": "add_problem", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "problem" |
|||
}, |
|||
{ |
|||
"codename": "change_problem", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "problem" |
|||
}, |
|||
{ |
|||
"codename": "delete_problem", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "problem" |
|||
}, |
|||
{ |
|||
"codename": "view_problem", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "problem" |
|||
}, |
|||
{ |
|||
"codename": "add_resitel", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "resitel" |
|||
}, |
|||
{ |
|||
"codename": "change_resitel", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "resitel" |
|||
}, |
|||
{ |
|||
"codename": "delete_resitel", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "resitel" |
|||
}, |
|||
{ |
|||
"codename": "view_resitel", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "resitel" |
|||
}, |
|||
{ |
|||
"codename": "add_rocnik", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "rocnik" |
|||
}, |
|||
{ |
|||
"codename": "change_rocnik", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "rocnik" |
|||
}, |
|||
{ |
|||
"codename": "delete_rocnik", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "rocnik" |
|||
}, |
|||
{ |
|||
"codename": "view_rocnik", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "rocnik" |
|||
}, |
|||
{ |
|||
"codename": "add_skola", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "skola" |
|||
}, |
|||
{ |
|||
"codename": "change_skola", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "skola" |
|||
}, |
|||
{ |
|||
"codename": "delete_skola", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "skola" |
|||
}, |
|||
{ |
|||
"codename": "view_skola", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "skola" |
|||
}, |
|||
{ |
|||
"codename": "add_soustredeni", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni" |
|||
}, |
|||
{ |
|||
"codename": "change_soustredeni", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni" |
|||
}, |
|||
{ |
|||
"codename": "delete_soustredeni", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni" |
|||
}, |
|||
{ |
|||
"codename": "view_soustredeni", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni" |
|||
}, |
|||
{ |
|||
"codename": "add_soustredeni_organizatori", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni_organizatori" |
|||
}, |
|||
{ |
|||
"codename": "change_soustredeni_organizatori", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni_organizatori" |
|||
}, |
|||
{ |
|||
"codename": "delete_soustredeni_organizatori", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni_organizatori" |
|||
}, |
|||
{ |
|||
"codename": "view_soustredeni_organizatori", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni_organizatori" |
|||
}, |
|||
{ |
|||
"codename": "add_soustredeni_ucastnici", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni_ucastnici" |
|||
}, |
|||
{ |
|||
"codename": "change_soustredeni_ucastnici", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni_ucastnici" |
|||
}, |
|||
{ |
|||
"codename": "delete_soustredeni_ucastnici", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni_ucastnici" |
|||
}, |
|||
{ |
|||
"codename": "view_soustredeni_ucastnici", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "soustredeni_ucastnici" |
|||
}, |
|||
{ |
|||
"codename": "add_tema", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "tema" |
|||
}, |
|||
{ |
|||
"codename": "change_tema", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "tema" |
|||
}, |
|||
{ |
|||
"codename": "delete_tema", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "tema" |
|||
}, |
|||
{ |
|||
"codename": "view_tema", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "tema" |
|||
}, |
|||
{ |
|||
"codename": "add_uloha", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "uloha" |
|||
}, |
|||
{ |
|||
"codename": "change_uloha", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "uloha" |
|||
}, |
|||
{ |
|||
"codename": "delete_uloha", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "uloha" |
|||
}, |
|||
{ |
|||
"codename": "view_uloha", |
|||
"ct_app_label": "seminar", |
|||
"ct_model": "uloha" |
|||
}, |
|||
{ |
|||
"codename": "add_tag", |
|||
"ct_app_label": "taggit", |
|||
"ct_model": "tag" |
|||
}, |
|||
{ |
|||
"codename": "change_tag", |
|||
"ct_app_label": "taggit", |
|||
"ct_model": "tag" |
|||
}, |
|||
{ |
|||
"codename": "delete_tag", |
|||
"ct_app_label": "taggit", |
|||
"ct_model": "tag" |
|||
}, |
|||
{ |
|||
"codename": "view_tag", |
|||
"ct_app_label": "taggit", |
|||
"ct_model": "tag" |
|||
}, |
|||
{ |
|||
"codename": "add_taggeditem", |
|||
"ct_app_label": "taggit", |
|||
"ct_model": "taggeditem" |
|||
}, |
|||
{ |
|||
"codename": "change_taggeditem", |
|||
"ct_app_label": "taggit", |
|||
"ct_model": "taggeditem" |
|||
}, |
|||
{ |
|||
"codename": "delete_taggeditem", |
|||
"ct_app_label": "taggit", |
|||
"ct_model": "taggeditem" |
|||
}, |
|||
{ |
|||
"codename": "view_taggeditem", |
|||
"ct_app_label": "taggit", |
|||
"ct_model": "taggeditem" |
|||
} |
|||
] |
@ -0,0 +1,32 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from django.core.management.base import BaseCommand |
|||
from django.contrib.sessions.models import Session |
|||
from django.contrib.auth.models import Group, Permission |
|||
from django.contrib.contenttypes.models import ContentType |
|||
from django.core.exceptions import ObjectDoesNotExist |
|||
import json |
|||
import argparse |
|||
|
|||
class Command(BaseCommand): |
|||
""" |
|||
|
|||
""" |
|||
def add_arguments(self, parser): |
|||
parser.add_argument('file', nargs=1, type=argparse.FileType('r', encoding='utf8')) |
|||
|
|||
|
|||
def handle(self, *args, **options): |
|||
try: |
|||
orgroup = Group.objects.get(name='org') |
|||
except ObjectDoesNotExist: |
|||
orgroup = Group(name='org') |
|||
orgroup.save() |
|||
permissions = json.load(options['file'][0]) |
|||
orgroup.permissions.clear() |
|||
for jp in permissions: |
|||
ct = ContentType.objects.get(app_label = jp['ct_app_label'], model = jp['ct_model']) |
|||
perm = Permission.objects.get(content_type = ct, codename = jp['codename']) |
|||
orgroup.permissions.add(perm) |
|||
orgroup.save() |
|||
|
@ -0,0 +1,22 @@ |
|||
# -*- coding: utf-8 -*- |
|||
|
|||
from django.core.management.base import BaseCommand |
|||
from django.contrib.sessions.models import Session |
|||
from django.contrib.auth.models import Group, Permission |
|||
import json |
|||
|
|||
class Command(BaseCommand): |
|||
""" |
|||
Dump permissions for group 'org' such that them can be used on an other machine. |
|||
|
|||
""" |
|||
def handle(self, *args, **options): |
|||
orgroup = Group.objects.get(name='org') |
|||
permissions = [] |
|||
for p in orgroup.permissions.all(): |
|||
permissions.append({ |
|||
'codename': p.codename, |
|||
'ct_app_label': p.content_type.app_label, |
|||
'ct_model': p.content_type.model}) |
|||
print(json.dumps(permissions)) |
|||
|
Loading…
Reference in new issue