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

Add permissions for confirming/weighting rounds #2564

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion tabbycat/tournaments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from results.models import BallotSubmission
from results.prefetch import populate_confirmed_ballots
from tournaments.models import Round
from users.permissions import has_permission
from users.permissions import has_permission, Permission
from utils.misc import redirect_round, redirect_tournament, reverse_round, reverse_tournament
from utils.mixins import (AdministratorMixin, AssistantMixin, CacheMixin, TabbycatPageTitlesMixin,
WarnAboutDatabaseUseMixin, WarnAboutLegacySendgridConfigVarsMixin)
Expand Down Expand Up @@ -128,6 +128,7 @@ class TournamentAdminHomeView(AdministratorMixin, BaseTournamentDashboardHomeVie

class CompleteRoundCheckView(AdministratorMixin, RoundMixin, TemplateView):
template_name = 'round_complete_check.html'
view_permission = True

def get_context_data(self, **kwargs):
prior_rounds_not_completed = self.tournament.round_set.filter(
Expand All @@ -152,6 +153,7 @@ def get_context_data(self, **kwargs):

class CompleteRoundToggleSilentView(AdministratorMixin, RoundMixin, PostOnlyRedirectView):
round_redirect_pattern_name = 'tournament-complete-round-check'
edit_permission = Permission.SILENCE_ROUND

def post(self, request, *args, **kwargs):
self.round.silent = request.POST["state"] != "True"
Expand All @@ -168,6 +170,7 @@ def post(self, request, *args, **kwargs):
class CompleteRoundView(RoundMixin, AdministratorMixin, LogActionMixin, PostOnlyRedirectView):

action_log_type = ActionLogEntry.ActionType.ROUND_COMPLETE
edit_permission = Permission.CONFIRM_ROUND

def post(self, request, *args, **kwargs):
self.round.completed = True
Expand Down Expand Up @@ -259,6 +262,9 @@ class SetCurrentRoundView(AdministratorMixin, TournamentMixin, FormView):
page_title = _('Set Current Round')
page_emoji = '🙏'

view_permission = True
edit_permission = Permission.CONFIRM_ROUND

def get_form_class(self):
if self.tournament.breakcategory_set.count() <= 1:
return SetCurrentRoundSingleBreakCategoryForm
Expand Down Expand Up @@ -308,6 +314,8 @@ def get_context_data(self, **kwargs):
class SetRoundWeightingsView(AdministratorMixin, TournamentMixin, FormView):
template_name = 'set_round_weights.html'
form_class = RoundWeightForm
view_permission = True
edit_permission = Permission.EDIT_ROUND

def get_form_kwargs(self):
kwargs = super().get_form_kwargs()
Expand Down
2 changes: 2 additions & 0 deletions tabbycat/users/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class Permission(TextChoices):
EDIT_ROUND = 'edit.round', _("edit round attributes")
DELETE_ROUND = 'delete.round', _("delete rounds")
CREATE_ROUND = 'add.round', _("create rounds")
CONFIRM_ROUND = 'confirm.round', _("confirm rounds")
SILENCE_ROUND = 'silence.round', _("silence rounds")

VIEW_EMAIL_STATUSES = 'view.emails', _("view email statuses")
SEND_EMAILS = 'send.emails', _("send participants email messages")
Expand Down
Loading