From ad44b24ceaa3205906fd6d3c915cef0e15effda9 Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Fri, 1 May 2020 12:34:18 +0200 Subject: [PATCH] Add buttons for changing preferences to group and person templates --- aleksis/core/templates/core/group_full.html | 27 +++++++++++++++----- aleksis/core/templates/core/person_full.html | 21 +++++++++++---- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/aleksis/core/templates/core/group_full.html b/aleksis/core/templates/core/group_full.html index 2b1b9ae3f..0add6f1a3 100644 --- a/aleksis/core/templates/core/group_full.html +++ b/aleksis/core/templates/core/group_full.html @@ -1,6 +1,7 @@ {# -*- engine:django -*- #} {% extends "core/base.html" %} +{% load rules %} {% load i18n static %} {% load render_table from django_tables2 %} @@ -9,12 +10,26 @@ {% block content %} <h4>{{ group.name }} <small class="grey-text">{{ group.short_name }}</small></h4> - <p> - <a href="{% url 'edit_group_by_id' group.id %}" class="btn waves-effect waves-light"> - <i class="material-icons left">edit</i> - {% trans "Edit" %} - </a> - </p> + + {% has_perm 'core.edit_group' user group as can_change_group %} + {% has_perm 'core.change_group_preferences' user group as can_change_group_preferences %} + + {% if can_change_group or can_change_group_preferences %} + <p> + {% if can_change_group %} + <a href="{% url 'edit_group_by_id' group.id %}" class="btn waves-effect waves-light"> + <i class="material-icons left">edit</i> + {% trans "Edit" %} + </a> + {% endif %} + {% if can_change_group_preferences %} + <a href="{% url "preferences_group" group.id %}" class="btn waves-effect waves-light"> + <i class="material-icons left">settings</i> + {% trans "Change preferences" %} + </a> + {% endif %} + </p> + {% endif %} <h5>{% blocktrans %}Owners{% endblocktrans %}</h5> {% render_table owners_table %} diff --git a/aleksis/core/templates/core/person_full.html b/aleksis/core/templates/core/person_full.html index cf584d8ae..0a97dcedc 100644 --- a/aleksis/core/templates/core/person_full.html +++ b/aleksis/core/templates/core/person_full.html @@ -11,12 +11,23 @@ <h4>{{ person.first_name }} {{ person.last_name }}</h4> {% has_perm 'core.edit_person' user person as can_change_person %} - {% if can_change_person %} + {% has_perm 'core.change_person_preferences' user person as can_change_person_preferences %} + + {% if can_change_person or can_change_person_preferences %} <p> - <a href="{% url 'edit_person_by_id' person.id %}" class="btn waves-effect waves-light"> - <i class="material-icons left">edit</i> - {% trans "Edit" %} - </a> + {% if can_change_person %} + <a href="{% url 'edit_person_by_id' person.id %}" class="btn waves-effect waves-light"> + <i class="material-icons left">edit</i> + {% trans "Edit" %} + </a> + {% endif %} + + {% if can_change_person_preferences %} + <a href="{% url "preferences_person" person.id %}" class="btn waves-effect waves-light"> + <i class="material-icons left">settings</i> + {% trans "Change preferences" %} + </a> + {% endif %} </p> {% endif %} -- GitLab