Update permissions and groups
This commit is contained in:
parent
45db242c8e
commit
0f324b8a17
32
billard/migrations/0020_auto_20170410_1853.py
Normal file
32
billard/migrations/0020_auto_20170410_1853.py
Normal file
@ -0,0 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.5 on 2017-04-10 18:53
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
def create_default_groups_permissions(apps, schema_editor):
|
||||
# We can't import the Person model directly as it may be a newer
|
||||
# version than this migration expects. We use the historical version.
|
||||
Permission = apps.get_model("auth", "Permission")
|
||||
Group = apps.get_model("auth", "Group")
|
||||
lg = Group(name='Location')
|
||||
lg.save()
|
||||
lg.permissions.add(Permission.objects.get(codename="add_locationdata"))
|
||||
ag = Group(name='Accounting')
|
||||
ag.save()
|
||||
ag.permissions.add(Permission.objects.get(codename="change_accounting"))
|
||||
|
||||
def delete_default_groups_permissions(apps, schema_editor):
|
||||
Group = apps.get_model("auth", "Group")
|
||||
Group.objects.get(name='Location').delete()
|
||||
Group.objects.get(name='Accounting').delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billard', '0019_merge_20170310_1941'),
|
||||
]
|
||||
operations = [
|
||||
migrations.RunPython(create_default_groups_permissions, delete_default_groups_permissions),
|
||||
]
|
@ -29,7 +29,9 @@
|
||||
<div id="navbar" class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="{% ifequal request.path '/billard/' %}active{% endifequal %}"><a href="{% url "carom_index" %}">Tische</a></li>
|
||||
{% if perms.billard.change_accounting %}
|
||||
<li class="{% ifequal request.path '/billard/accounting' %}active{% endifequal %}"><a href="{% url "accounting" %}">Abrechnung</a></li>
|
||||
{% endif %}
|
||||
{% if user.is_superuser %}
|
||||
<li class="{% ifequal request.path '/logout/' %}active{% endifequal %}"><a href="/admin/">Administration</a></li>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user