Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

890 room duty committee rights #891

Merged
merged 17 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion amelie/activities/templates/activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h2 id="slider-carousel-title" class="h2-with-buttons">{% trans "Pictures of the
</div>

{% if obj.enrollment %}
{% if obj.organizer in request.person.current_committees or request.is_board %}
{% if obj.organizer in request.person.current_committees or request.is_board or is_rd %}
<div class="col-xs-12 col-md-12">
<div class="current">
<h2 class="expand" data-target="export_options">{% trans 'Export enrollments' %}</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{% for answer in participation.enrollmentoptionanswer_set.all %}
<td>{{ answer.display_answer }}</td>
{% endfor %}
{% if request.is_board %}
{% if request.is_board or is_rd %}
<td>{% if participation.has_paid %}<p class="icon pos">{{ participation.get_payment_method_display }}{% else %}<p class="icon icon-cancel"><a title="{% trans "By clicking here, you confirm to have received the full amount of money." %}" href="{% url 'calendar:pay_participation' participation.pk %}">{% trans "Register cash payment" %}</a>{% endif %}</p></td>
{% else %}
<td>{{ participation.get_payment_method_display }}</td>
Expand Down
15 changes: 10 additions & 5 deletions amelie/activities/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from amelie.members.forms import PersonSearchForm
from amelie.members.models import Person, Photographer
from amelie.members.query_forms import MailingForm
from amelie.members.utils import is_committee
from amelie.tools import amelie_messages, types
from amelie.tools.decorators import require_actief, require_lid, require_committee, require_board
from amelie.tools.forms import PeriodForm, ExportForm, PeriodKeywordForm
Expand Down Expand Up @@ -252,6 +253,7 @@ def activity(request, pk, deanonymise=False):

# Enable opengraph on this page
metadata_enable_opengraph = True
is_rd = is_committee(request, "RD")

return render(request, "activity.html", locals())

Expand Down Expand Up @@ -492,7 +494,7 @@ def activity_editenrollment_self(request, pk):
return render(request, "activity_enrollment_form.html", locals())


@require_board
@require_committee("RD")
SimplyPancake marked this conversation as resolved.
Show resolved Hide resolved
@transaction.atomic
def activity_editenrollment_other(request, pk, person_id):
"""
Expand Down Expand Up @@ -521,7 +523,7 @@ def activity_editenrollment_other(request, pk, person_id):
return render(request, "activity_enrollment_form.html", locals())


@require_board
@require_committee("RD")
@transaction.atomic
def activity_unenrollment(request, pk, person_id):
"""
Expand Down Expand Up @@ -568,7 +570,8 @@ def activity_enrollment_person_search(request, pk):
Search for a person to enroll for this activity.
"""
activity = get_object_or_404(Activity, pk=pk)
if not activity.can_edit(request.person):
is_rd = is_committee(request, "RD")
if not (activity.can_edit(request.person) or is_rd):
raise PermissionDenied

form = PersonSearchForm(request.POST if request.POST else None)
Expand Down Expand Up @@ -676,7 +679,8 @@ def activity_enrollment_form(request, activity, person=None):
# Django messages have been set in check_enrollment_allowed
return redirect(activity)

if indirect and not activity.can_edit(request.person):
is_rd = is_committee(request, "RD")
if indirect and not (activity.can_edit(request.person) or is_rd):
raise PermissionDenied

per_mandate = (request.is_board or settings.PERSONAL_TAB_COMMITTEE_CAN_AUTHORIZE) \
Expand Down Expand Up @@ -1306,8 +1310,9 @@ def test_requirement(self, request):

is_board = hasattr(request, 'is_board') and request.is_board
is_organization = obj.organizer in request.person.current_committees()
is_rd = is_committee(request, "RD")

return is_board or is_organization
return is_board or is_organization or is_rd

def post(self, request, pk=None):
if pk is None:
Expand Down
5 changes: 3 additions & 2 deletions amelie/calendar/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
from django.views.generic import TemplateView

from amelie.calendar.models import Participation
from amelie.tools.mixins import RequireBoardMixin
from amelie.tools.mixins import RequireBoardMixin, RequireCommitteeMixin


class PayParticipationView(RequireBoardMixin, TemplateView):
class PayParticipationView(RequireCommitteeMixin, TemplateView):
template_name = "confirm_payment.html"
abbreviation = "RD"

def get_context_data(self, **kwargs):
context = super(PayParticipationView, self).get_context_data()
Expand Down
18 changes: 9 additions & 9 deletions amelie/members/ajax_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from amelie.members.query_views import filter_member_list_public
from amelie.personal_tab.models import Authorization
from amelie.personal_tab.pos_views import require_cookie_corner_pos
from amelie.tools.decorators import require_ajax, require_board, require_actief
from amelie.tools.decorators import require_ajax, require_board, require_actief, require_committee


def person_data(request, obj, type, form_type, view_template=None, edit_template=None, *args, **kwargs):
Expand Down Expand Up @@ -113,7 +113,7 @@ def person_study_new(request, id):


@require_ajax
@require_board
@require_committee("RD")
def person_payments(request, id, membership):
obj = get_object_or_404(Person, id=id)
membership = get_object_or_404(Membership, id=membership)
Expand All @@ -135,14 +135,14 @@ def person_payments(request, id, membership):


@require_ajax
@require_board
@require_committee("RD")
def person_membership(request, id, option=None):
obj = get_object_or_404(Person, id=id)
return render(request, "person_membership.html", locals())


@require_ajax
@require_board
@require_committee("RD")
def person_membership_new(request, id):
obj = get_object_or_404(Person, id=id)
if request.method == "POST":
Expand All @@ -161,7 +161,7 @@ def person_membership_new(request, id):


@require_ajax
@require_board
@require_committee("RD")
def person_membership_end(request, id):
obj = get_object_or_404(Person, id=id)
if request.method == "POST":
Expand All @@ -178,14 +178,14 @@ def person_membership_end(request, id):


@require_ajax
@require_board
@require_committee("RD")
def person_mandate(request, id):
obj = get_object_or_404(Person, id=id)
return render(request, "person_mandate.html", locals())


@require_ajax
@require_board
@require_committee("RD")
def person_mandate_new(request, id):
obj = get_object_or_404(Person, id=id)
if request.method == "POST":
Expand All @@ -205,7 +205,7 @@ def person_mandate_new(request, id):


@require_ajax
@require_board
@require_committee("RD")
def person_mandate_activate(request, id, mandate):
obj = get_object_or_404(Person, id=id)
mandate = get_object_or_404(Authorization, id=mandate, person=obj,
Expand All @@ -220,7 +220,7 @@ def person_mandate_activate(request, id, mandate):


@require_ajax
@require_board
@require_committee("RD")
def person_mandate_end(request, id, mandate):
obj = get_object_or_404(Person, id=id)
mandate = get_object_or_404(Authorization, id=mandate)
Expand Down
4 changes: 2 additions & 2 deletions amelie/members/query_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
from amelie.members.query_forms import MailingForm, QueryForm, PushNotificationForm
from amelie.members.tasks import send_push_notification
from amelie.tools import types
from amelie.tools.decorators import require_board
from amelie.tools.decorators import require_board, require_committee
from amelie.tools.logic import current_association_year
from amelie.tools.mixins import RequireBoardMixin
from amelie.tools.paginator import RangedPaginator


@require_board
@require_committee("RD")
@never_cache
def query(request):
page = types.get_int(request.GET, 'page', default=1, min_value=1)
Expand Down
6 changes: 6 additions & 0 deletions amelie/members/templates/person.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h2 class="expand" data-target="person_employee">{% trans 'Employee data' %}</h2
</div>
</div></div>

{% if request.is_board %}
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><div class="ia">
<h2 class="expand" data-target="person_functions">{% trans 'Committees' %}</h2>
<div class="content">
Expand All @@ -57,7 +58,9 @@ <h2 class="expand" data-target="person_functions">{% trans 'Committees' %}</h2>
</div>
</div>
</div></div>
{% endif %}

{% if request.is_board %}
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><div class="ia">
<h2 class="expand" data-target="person_preferences">{% trans 'Preferences' %}</h2>
<div class="content">
Expand All @@ -66,6 +69,7 @@ <h2 class="expand" data-target="person_preferences">{% trans 'Preferences' %}</h
</div>
</div>
</div></div>
{% endif %}

{% if request.user.is_superuser %}
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"><div class="ia">
Expand All @@ -78,6 +82,7 @@ <h2 class="expand" data-target="person_accounts">{% trans 'User accounts and log
</div></div>
{% endif %}

{% if request.is_board %}
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12i"><div class="ia">
<h2 class="expand" data-target="person_anonymize">{% trans 'Anonymize person' %}</h2>
<div class="content">
Expand All @@ -99,5 +104,6 @@ <h2 class="expand" data-target="person_anonymize">{% trans 'Anonymize person' %}
</div>
</div>
</div></div>
{% endif %}
</div>
{% endblock content %}
4 changes: 2 additions & 2 deletions amelie/members/templates/person_mandate.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<th>{% trans 'Signed' %}</th>
<th>{% trans 'Starts on' %}</th>
<th>{% trans 'Ends on' %}</th>
{% if request.is_board %}<th></th>{% endif %}
{% if request.is_board or is_rd %}<th></th>{% endif %}
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -57,7 +57,7 @@
<td>
{{ mandate.end_date|default_if_none:"&mdash;" }}
</td>
{% if request.is_board %}
{% if request.is_board or is_rd %}
<td>
{% if not mandate.is_signed and not mandate.end_date %}
<a href="{% url 'members:mandate_form' mandate.id %}" class="icon icon-printer">{% trans 'Print' %}</a><br />
Expand Down
3 changes: 3 additions & 0 deletions amelie/members/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Defines if a member is in the room duty committee.
def is_committee(request, abbreviation):
SimplyPancake marked this conversation as resolved.
Show resolved Hide resolved
return request.person.function_set.filter(committee__abbreviation=abbreviation, end__isnull=True).exists()
Loading
Loading