From 4284cbd35c73cbbe22f1a21e62b6b7a07577a9ed Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 16 Mar 2021 22:20:41 +0100 Subject: [PATCH] =?UTF-8?q?Bugfix=20-=20kdy=C5=BE=20skupina=20'org'=20neex?= =?UTF-8?q?istuje,=20p=C5=99idej=20ji.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/management/commands/load_org_permissions.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/seminar/management/commands/load_org_permissions.py b/seminar/management/commands/load_org_permissions.py index 58086601..c1e4a106 100644 --- a/seminar/management/commands/load_org_permissions.py +++ b/seminar/management/commands/load_org_permissions.py @@ -4,6 +4,7 @@ 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 @@ -16,7 +17,11 @@ class Command(BaseCommand): def handle(self, *args, **options): - orgroup = Group.objects.get(name='org') + 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: