summaryrefslogtreecommitdiff
path: root/ishtar_common/management/commands/regenerate_permissions.py
diff options
context:
space:
mode:
authorValérie-Emma Leroux <emma@iggdrasil.net>2017-04-07 11:40:31 +0200
committerValérie-Emma Leroux <emma@iggdrasil.net>2017-04-07 11:40:31 +0200
commit7f22d3c20cc24debfe123425efa63ec5293e4b4c (patch)
treef773b80964981c231c892ee5255b94285bc5620a /ishtar_common/management/commands/regenerate_permissions.py
parent9127307734c85b816ac7dbb539b565ffb106d60f (diff)
parentda4af2ab5d105f6d2ce442b517e532b7570616e3 (diff)
downloadIshtar-7f22d3c20cc24debfe123425efa63ec5293e4b4c.tar.bz2
Ishtar-7f22d3c20cc24debfe123425efa63ec5293e4b4c.zip
Merge branch 'master' of git.iggdrasil.net:/srv/git/ishtar
Conflicts: archaeological_operations/templates/ishtar/sheet_operation.html
Diffstat (limited to 'ishtar_common/management/commands/regenerate_permissions.py')
-rw-r--r--ishtar_common/management/commands/regenerate_permissions.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/ishtar_common/management/commands/regenerate_permissions.py b/ishtar_common/management/commands/regenerate_permissions.py
index c2af8b353..599e64d64 100644
--- a/ishtar_common/management/commands/regenerate_permissions.py
+++ b/ishtar_common/management/commands/regenerate_permissions.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-# Copyright (C) 2013 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
+# Copyright (C) 2013-2017 Étienne Loks <etienne.loks_AT_peacefrogsDOTnet>
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
@@ -17,14 +17,13 @@
# See the file COPYING for details.
-import sys
-from django.db import models
-from django.core.management.base import BaseCommand, CommandError
+from django.core.management.base import BaseCommand
from django.contrib.contenttypes.models import ContentType
from django.contrib.auth.models import Permission
+
class Command(BaseCommand):
args = ''
help = 'Regenerate permissions'
@@ -35,6 +34,8 @@ class Command(BaseCommand):
if not model:
continue
for perm_slug, perm_label in model._meta.permissions:
- Permission.objects.get_or_create(content_type=ct,
- codename=perm_slug,
- defaults={'name':perm_label})
+ perm, c = Permission.objects.get_or_create(
+ content_type=ct, codename=perm_slug,
+ defaults={'name': perm_label})
+ if c:
+ print('Permission {} created.'.format(perm_label))