diff --git a/aleksis/core/migrations/0023_add_permissions_person.py b/aleksis/core/migrations/0023_add_permissions_person.py index 1840faca070ccaaa8c1c6002bb7c51a775f7e385..7b4ffb22f4f290b96ade618336808c0f25c08be2 100644 --- a/aleksis/core/migrations/0023_add_permissions_person.py +++ b/aleksis/core/migrations/0023_add_permissions_person.py @@ -1,4 +1,4 @@ -# 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'}, ), ] diff --git a/aleksis/core/models.py b/aleksis/core/models.py index 13fc602249c5a07d1be525ce29cdbb35890be28b..2481fcc2951e88caa4151cbec3f56aca554ae0fb 100644 --- a/aleksis/core/models.py +++ b/aleksis/core/models.py @@ -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" diff --git a/aleksis/core/rules.py b/aleksis/core/rules.py index 64cb05477f978b491f734f9c2441817bf342f3a0..dd969838dd07269028ca1d3df9cbcae13d63e161 100644 --- a/aleksis/core/rules.py +++ b/aleksis/core/rules.py @@ -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") diff --git a/aleksis/core/templates/core/person_full.html b/aleksis/core/templates/core/person_full.html index a95efea158232aec4130fa1cce4e50d6aca0ead9..e1f936efb7451b38d7164ef0233a31bb56ed58cd 100644 --- a/aleksis/core/templates/core/person_full.html +++ b/aleksis/core/templates/core/person_full.html @@ -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 %}