Skip to content

Commit cd76d45

Browse files
committed
Enable volunteer redirect to recap
1 parent 40e7ceb commit cd76d45

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

apps/volunteer/__init__.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,27 @@
7676
from decorator import decorator
7777
from flask import Blueprint, abort, redirect, request, url_for
7878
from flask import current_app as app
79+
from flask.typing import ResponseReturnValue
7980
from flask_login import current_user
8081

8182
from apps.common import feature_enabled
83+
from models.site_state import get_site_state
8284
from models.volunteer import Volunteer
8385

8486
volunteer = Blueprint("volunteer", __name__)
8587

8688

87-
# To be enabled once I'm happy the recap page is working.
88-
# @volunteer.before_app_request
89-
# def check_site_state() -> ResponseReturnValue | None:
90-
# if request.blueprint != "volunteer" or "recap" in request.path:
91-
# return None
89+
@volunteer.before_app_request
90+
def check_site_state() -> ResponseReturnValue | None:
91+
if request.blueprint != "volunteer" or "recap" in request.path:
92+
return None
9293

93-
# if get_site_state() == "after-event" and not Volunteer.get_for_user(current_user).is_volunteer_admin:
94-
# return redirect(url_for(".recap"))
94+
if get_site_state() == "after-event" and current_user:
95+
volunteer = current_user.volunteer
96+
if volunteer and not volunteer.is_volunteer_admin:
97+
return redirect(url_for(".recap"))
98+
99+
return None
95100

96101

97102
# This is like require_permission but redirects to volunteer sign-up/info depending

0 commit comments

Comments
 (0)