Skip to content
Snippets Groups Projects
Verified Commit 75f59c4c authored by Tom Teichler's avatar Tom Teichler :beers:
Browse files

Add permissions for view persons groups

parent 87bb772c
No related branches found
No related tags found
1 merge request!207Resolve "Roles and permissions"
Pipeline #1476 failed
# Generated by Django 3.0.5 on 2020-04-18 12:23
# Generated by Django 3.0.5 on 2020-04-18 12:52
from django.db import migrations
......@@ -12,6 +12,6 @@ class Migration(migrations.Migration):
operations = [
migrations.AlterModelOptions(
name='person',
options={'ordering': ['last_name', 'first_name'], 'permissions': (('view_address', 'Can view address'), ('view_contact_details', 'Can view contact details'), ('view_photo', 'Can view photo')), 'verbose_name': 'Person', 'verbose_name_plural': 'Persons'},
options={'ordering': ['last_name', 'first_name'], 'permissions': (('view_address', 'Can view address'), ('view_contact_details', 'Can view contact details'), ('view_photo', 'Can view photo'), ('view_person_groups', 'Can view persons groups')), 'verbose_name': 'Person', 'verbose_name_plural': 'Persons'},
),
]
......@@ -99,6 +99,7 @@ class Person(ExtensibleModel):
("view_address", _("Can view address")),
("view_contact_details", _("Can view contact details")),
("view_photo", _("Can view photo")),
("view_person_groups", _("Can view persons groups")),
)
icon_ = "person"
......
......@@ -42,6 +42,12 @@ view_photo_predicate = has_person_predicate & (
)
add_perm("core.view_photo", view_photo_predicate)
# View persons groups
view_groups_predicate = has_person_predicate & (
has_global_perm("core.view_person_groups") | has_object_perm("core.view_person_groups") | is_person
)
add_perm("core.view_person_groups", view_groups_predicate)
# Change person
change_person_predicate = has_person_predicate & (
has_global_perm("core.change_person") | has_object_perm("core.change_person")
......
......@@ -87,6 +87,9 @@
</div>
</div>
<h5>{% blocktrans %}Groups{% endblocktrans %}</h5>
{% render_table groups_table %}
{% has_perm 'core.view_person_groups' user person as can_view_groups %}
{% if can_view_groups %}
<h5>{% blocktrans %}Groups{% endblocktrans %}</h5>
{% render_table groups_table %}
{% endif %}
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment