Skip to content

Commit

Permalink
fixes #539. Added new group for chairs, po & data manager
Browse files Browse the repository at this point in the history
  • Loading branch information
EdoStorm96 committed Dec 19, 2023
1 parent 65337ed commit 4a19eef
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 22 deletions.
1 change: 1 addition & 0 deletions fetc/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
GROUP_PRIMARY_SECRETARY = 'Primaire secretaris'
GROUP_LINGUISTICS_CHAMBER = 'LK'
GROUP_GENERAL_CHAMBER = 'AK'
GROUP_CHAIR = 'Voorzitter'

# Route durations
PREASSESSMENT_ROUTE_WEEKS = 1
Expand Down
12 changes: 12 additions & 0 deletions main/templatetags/fetc_filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django import template
from django.conf import settings
from django.contrib.auth.models import Group
from django.db.models import Q

register = template.Library()

Expand Down Expand Up @@ -29,3 +30,14 @@ def is_secretary(current_user):
Check whether the current user is in the 'Secretary' group
"""
return Group.objects.get(name=settings.GROUP_SECRETARY) in current_user.groups.all()

@register.filter
def is_chair_or_secretary(current_user):
"""
Check whether the current user is in the 'Chair' group
"""
user_groups = current_user.groups.all()
return (
Group.objects.get(name=settings.GROUP_CHAIR) in user_groups
or Group.objects.get(name=settings.GROUP_SECRETARY) in user_groups
)
14 changes: 10 additions & 4 deletions reviews/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class BaseDecisionApiView(GroupRequiredMixin, CommitteeMixin, FancyListApiView):
serializer_class = DecisionSerializer
group_required = [
settings.GROUP_SECRETARY,
settings.GROUP_CHAIR,
settings.GROUP_GENERAL_CHAMBER,
settings.GROUP_LINGUISTICS_CHAMBER,
]
Expand Down Expand Up @@ -227,6 +228,7 @@ def get_queryset_for_secretary(self):
class OpenDecisionsApiView(BaseDecisionApiView):
group_required = [
settings.GROUP_SECRETARY,
settings.GROUP_CHAIR,
]

def get_queryset(self):
Expand Down Expand Up @@ -269,6 +271,7 @@ def get_queryset(self):
class OpenSupervisorDecisionApiView(BaseDecisionApiView):
group_required = [
settings.GROUP_SECRETARY,
settings.GROUP_CHAIR,
]

sort_definitions = [
Expand Down Expand Up @@ -369,7 +372,10 @@ def get_context(self):


class ToConcludeReviewApiView(BaseReviewApiView):
group_required = settings.GROUP_SECRETARY
group_required = [
settings.GROUP_SECRETARY,
settings.GROUP_CHAIR,
]

def get_queryset(self):
"""Returns all open Committee Decisions of all Users"""
Expand Down Expand Up @@ -412,7 +418,7 @@ class InRevisionApiView(BaseReviewApiView):
but for which a revision has not yet been submitted"""

default_sort = ('date_start', 'desc')
group_required = [settings.GROUP_SECRETARY]
group_required = [settings.GROUP_SECRETARY, settings.GROUP_CHAIR]

def get_queryset(self):
# 1. Find reviews of revisions:
Expand Down Expand Up @@ -448,7 +454,7 @@ class AllOpenReviewsApiView(BaseReviewApiView):
def get_group_required(self):
# Depending on committee kwarg we test for the correct group

group_required = [settings.GROUP_SECRETARY]
group_required = [settings.GROUP_SECRETARY, settings.GROUP_CHAIR]

if self.committee.name == 'AK':
group_required += [settings.GROUP_GENERAL_CHAMBER]
Expand Down Expand Up @@ -495,7 +501,7 @@ class AllReviewsApiView(BaseReviewApiView):
def get_group_required(self):
# Depending on committee kwarg we test for the correct group

group_required = [settings.GROUP_SECRETARY]
group_required = [settings.GROUP_SECRETARY, settings.GROUP_CHAIR]

if self.committee.name == 'AK':
group_required += [settings.GROUP_GENERAL_CHAMBER]
Expand Down
16 changes: 8 additions & 8 deletions reviews/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from menu import Menu, MenuItem

from main.templatetags.fetc_filters import in_general_chamber, \
in_linguistics_chamber, is_secretary
in_linguistics_chamber, is_secretary, is_chair_or_secretary


def create_committee_menu(commitee: str) -> List[MenuItem]:
Expand All @@ -21,37 +21,37 @@ def create_committee_menu(commitee: str) -> List[MenuItem]:
MenuItem(
_("Alle openstaande besluiten commissieleden"),
reverse("reviews:open", args=[commitee]),
check=lambda x: is_secretary(x.user),
check=lambda x: is_chair_or_secretary(x.user),
),
MenuItem(
_("Alle openstaande besluiten eindverantwoordelijken"),
reverse("reviews:open_supervisors", args=[commitee]),
check=lambda x: is_secretary(x.user),
check=lambda x: is_chair_or_secretary(x.user),
),
MenuItem(
_("Nog af te handelen aanvragen"),
reverse("reviews:to_conclude", args=[commitee]),
check=lambda x: is_secretary(x.user),
check=lambda x: is_chair_or_secretary(x.user),
),
MenuItem(
_("Aanvragen in revisie"),
reverse("reviews:in_revision", args=[commitee]),
check=lambda x: is_secretary(x.user),
check=lambda x: is_chair_or_secretary(x.user),
),
MenuItem(
_("Alle lopende aanvragen"),
reverse("reviews:all_open", args=[commitee]),
check=lambda x: is_secretary(x.user),
check=lambda x: is_chair_or_secretary(x.user),
),
MenuItem(
_("Alle ingezonden aanvragen"),
reverse("reviews:archive", args=[commitee]),
check=lambda x: is_secretary(x.user),
check=lambda x: is_chair_or_secretary(x.user),
),
MenuItem(
_("Overzicht werkverdeling commissieleden"),
reverse("reviews:workload", args=[commitee]),
check=lambda x: is_secretary(x.user),
check=lambda x: is_chair_or_secretary(x.user),
),
]

Expand Down
20 changes: 10 additions & 10 deletions reviews/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class BaseDecisionListView(GroupRequiredMixin, CommitteeMixin, generic.TemplateV
settings.GROUP_SECRETARY,
settings.GROUP_GENERAL_CHAMBER,
settings.GROUP_LINGUISTICS_CHAMBER,
settings.GROUP_CHAIR,
]

def get_context_data(self, **kwargs):
Expand Down Expand Up @@ -74,7 +75,7 @@ def get_context_data(self, **kwargs):


class DecisionOpenView(BaseDecisionListView):
group_required = settings.GROUP_SECRETARY
group_required = (settings.GROUP_SECRETARY, settings.GROUP_CHAIR)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
Expand All @@ -90,7 +91,7 @@ class CommitteeMembersWorkloadView(
GroupRequiredMixin, CommitteeMixin, generic.FormView
):
template_name = "reviews/committee_members_workload.html"
group_required = [settings.GROUP_SECRETARY]
group_required = (settings.GROUP_SECRETARY, settings.GROUP_CHAIR)
form_class = StartEndDateForm

def __init__(self, **kwargs):
Expand Down Expand Up @@ -192,7 +193,7 @@ class SupervisorDecisionOpenView(BaseDecisionListView):
This page displays all proposals to be reviewed by supervisors.
"""

group_required = settings.GROUP_SECRETARY
group_required = (settings.GROUP_SECRETARY, settings.GROUP_CHAIR)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
Expand All @@ -208,9 +209,7 @@ def get_context_data(self, **kwargs):

class BaseReviewListView(GroupRequiredMixin, CommitteeMixin, generic.TemplateView):
template_name = "reviews/ufl_list.html"
group_required = [
settings.GROUP_SECRETARY,
]
group_required = (settings.GROUP_SECRETARY, settings.GROUP_CHAIR)

def get_context_data(self, **kwargs):
context = super().get_context_data()
Expand All @@ -221,7 +220,7 @@ def get_context_data(self, **kwargs):


class ToConcludeProposalView(BaseReviewListView):
group_required = settings.GROUP_SECRETARY
group_required = (settings.GROUP_SECRETARY, settings.GROUP_CHAIR)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
Expand All @@ -233,7 +232,7 @@ def get_context_data(self, **kwargs):


class InRevisionReviewsView(BaseReviewListView):
group_required = [settings.GROUP_SECRETARY]
group_required = (settings.GROUP_SECRETARY, settings.GROUP_CHAIR)

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
Expand All @@ -258,7 +257,7 @@ def get_context_data(self, **kwargs):
def get_group_required(self):
# Depending on committee kwarg we test for the correct group

group_required = [settings.GROUP_SECRETARY]
group_required = [settings.GROUP_SECRETARY, settings.GROUP_CHAIR]

if self.committee.name == "AK":
group_required += [settings.GROUP_GENERAL_CHAMBER]
Expand All @@ -280,7 +279,7 @@ def get_context_data(self, **kwargs):
def get_group_required(self):
# Depending on committee kwarg we test for the correct group

group_required = [settings.GROUP_SECRETARY]
group_required = [settings.GROUP_SECRETARY, settings.GROUP_CHAIR]

if self.committee.name == "AK":
group_required += [settings.GROUP_GENERAL_CHAMBER]
Expand All @@ -303,6 +302,7 @@ def get_group_required(self):
obj = self.get_object()
group_required = [
settings.GROUP_SECRETARY,
settings.GROUP_CHAIR,
obj.proposal.reviewing_committee.name,
]

Expand Down

0 comments on commit 4a19eef

Please sign in to comment.