Skip to content

Commit 295c577

Browse files
committed
Remove staff/volunteer login
The staffing area now relies on an ID being passed between pages rather than having a separate login. This will allow those with attendee accounts to view shifts for any badge under their account. This does lock access to shifts to the account owner, which means we might want to add some way to grant access so people can bypass the account check to see their shifts. But most people likely won't run into that, so that's a Later Problem.
1 parent a7aad0a commit 295c577

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+207
-255
lines changed

uber/config.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,6 @@ def INDEXABLE_PAGE_PATHS(self):
10071007
via the meta tag for everything except these pages.
10081008
"""
10091009
index_pages = ['/landing/', '/landing/index', '/pregistration/form', '/accounts/login']
1010-
if c.SHIFTS_CREATED:
1011-
index_pages.append('/staffing/login')
10121010
if c.TRANSFERABLE_BADGE_TYPES:
10131011
index_pages.append('/preregistration/start_badge_transfer')
10141012
if not c.ATTENDEE_ACCOUNTS_ENABLED:
@@ -1042,18 +1040,6 @@ def CURRENT_ADMIN(self):
10421040
except Exception:
10431041
return {}
10441042

1045-
@request_cached_property
1046-
@dynamic
1047-
def CURRENT_VOLUNTEER(self):
1048-
try:
1049-
from uber.models import Session, Attendee
1050-
with Session() as session:
1051-
attrs = Attendee.to_dict_default_attrs + ['logged_in_name']
1052-
attendee = session.logged_in_volunteer()
1053-
return attendee.to_dict(attrs)
1054-
except Exception:
1055-
return {}
1056-
10571043
@request_cached_property
10581044
@dynamic
10591045
def CURRENT_KIOSK_SUPERVISOR(self):
@@ -1075,6 +1061,10 @@ def CURRENT_KIOSK_OPERATOR(self):
10751061
return attendee.to_dict()
10761062
except Exception:
10771063
return {}
1064+
1065+
@property
1066+
def LOCAL_ACCOUNTS_DISABLED(self):
1067+
return c.OIDC_ENABLED and not c.SSO_EMAIL_DOMAINS
10781068

10791069
@request_cached_property
10801070
@dynamic

uber/decorators.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,18 @@ def protected(*args, **kwargs):
170170
admin_account_id = cherrypy.session.get('account_id', getattr(cherrypy.request, 'admin_account', None))
171171
attendee_account_id = cherrypy.session.get('attendee_account_id', getattr(cherrypy.request, 'attendee_account', None))
172172
message = ''
173-
if not models and not attendee_account_id and c.PAGE_PATH != '/preregistration/homepage':
174-
# These should all be pages like the prereg form
173+
if c.LOCAL_ACCOUNTS_DISABLED and admin_account_id is None and attendee_account_id is None:
174+
ajax_or_redirect(func, '../accounts/login?message=', message, True)
175+
elif attendee_account_id is None and admin_account_id is None:
176+
message = 'You must log in to view this page.'
177+
message_add = ''
175178
if c.PAGE_PATH in ['/preregistration/form', '/preregistration/post_form']:
176179
message_add = 'register'
177-
else:
180+
elif c.PAGE_PATH != '/preregistration/homepage' and not models and 'staffing' not in c.PAGE_PATH:
178181
message_add = 'fill out this application'
179-
message = 'Please log in or create an account to {}!'.format(message_add)
182+
if message_add:
183+
message = f'Please log in or create an account to {message_add}!'
180184
ajax_or_redirect(func, '../landing/index?message=', message, True)
181-
elif attendee_account_id is None and admin_account_id is None or \
182-
attendee_account_id is None and c.PAGE_PATH == '/preregistration/homepage':
183-
message = 'You must log in to view this page.'
184185
elif kwargs.get('id') and models:
185186
model_list = [models] if not isinstance(models, list) else models
186187
attendee, error, model_id = None, None, None
@@ -759,11 +760,7 @@ def with_restrictions(*args, **kwargs):
759760
if not getattr(cherrypy.request, 'admin_account', getattr(cherrypy.request, 'attendee_account', None)):
760761
cherrypy.tools.oidc.redirect_to_keycloak()
761762

762-
if '/staffing/' in c.PAGE_PATH:
763-
if not cherrypy.session.get('staffer_id'):
764-
ajax_or_redirect(func, '../staffing/login?message=', "You are not logged in.", True)
765-
766-
elif cherrypy.session.get('account_id', getattr(cherrypy.request, 'admin_account', None)) is None:
763+
if cherrypy.session.get('account_id', getattr(cherrypy.request, 'admin_account', None)) is None:
767764
if getattr(func, 'kiosk_login', None):
768765
if not cherrypy.session.get('kiosk_supervisor_id'):
769766
cherrypy.session.pop('kiosk_operator_id', None)

uber/models/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,12 @@ def get_attendee_account_by_attendee(self, attendee):
915915
return logged_in_account
916916
elif len(attendee.managers) == 1:
917917
return attendee.managers[0]
918-
919-
def logged_in_volunteer(self):
920-
return self.query(Attendee).filter(Attendee.id == cherrypy.session.get('staffer_id')).options(
918+
919+
def volunteer_from_id(self, id):
920+
return self.query(Attendee).filter(Attendee.id == id).options(
921921
selectinload(Attendee.hotel_requests), selectinload(Attendee.food_restrictions),
922922
selectinload(Attendee.shifts)
923-
).one()
923+
).first()
924924

925925
def admin_has_staffer_access(self, staffer, access="view"):
926926
admin = self.current_admin_account()
@@ -1118,8 +1118,8 @@ def checklist_status(self, slug, department_id):
11181118
'completed': attendee.checklist_item_for_slug(conf.slug)
11191119
}
11201120

1121-
def jobs_for_signups(self, all=False):
1122-
jobs = self.logged_in_volunteer().possible
1121+
def jobs_for_signups(self, id, all=False):
1122+
jobs = self.volunteer_from_id(id).possible
11231123
restricted_minutes = set()
11241124
for job in jobs:
11251125
if job.required_roles:
@@ -1319,6 +1319,8 @@ def get_assigned_terminal_id(self):
13191319
return "", c.TERMINAL_ID_TABLE[lookup_key]
13201320

13211321
def get_receipt_by_model(self, model, include_closed=False, who='', create_if_none="", options=[]):
1322+
if not model:
1323+
return
13221324
receipt_select = self.query(ModelReceipt).filter_by(owner_id=model.id, owner_model=model.__class__.__name__)
13231325
if not include_closed:
13241326
receipt_select = receipt_select.filter(ModelReceipt.closed == None) # noqa: E711

uber/models/attendee.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ def _misc_adjustments(self):
608608
if self.promo_code and self.promo_code_groups:
609609
self.promo_code = None
610610

611-
if self.group and not self.is_group_save:
611+
if self.group and not getattr(self, 'is_group_save', False):
612612
self.group.presave_adjustments()
613613

614614
@presave_adjustment
@@ -2693,6 +2693,11 @@ def at_door_pending_attendees(self):
26932693
attendee.badge_status == c.NEW_STATUS and attendee.paid == c.PENDING],
26942694
key=lambda a: a.first_name)
26952695

2696+
@property
2697+
def volunteering_attendees(self):
2698+
return [attendee for attendee in self.attendees if attendee.has_badge
2699+
and attendee.staffing and attendee.badge_type != c.CONTRACTOR_BADGE]
2700+
26962701
@property
26972702
def invalid_attendees(self):
26982703
return [attendee for attendee in self.attendees if not attendee.is_valid and

uber/site_sections/preregistration.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,10 @@ def confirm(self, session, message='', return_to='confirm', undoing_extra='', **
22222222
else:
22232223
message = 'Your information has been updated'
22242224

2225-
page = ('badge_updated?id=' + attendee.id + '&') if return_to == 'confirm' else (return_to + '?')
2225+
if return_to == 'confirm':
2226+
page = ('badge_updated?id=' + attendee.id + '&')
2227+
else:
2228+
page = (return_to + '?') if '?' not in return_to else (return_to + '&')
22262229
if attendee.is_valid:
22272230
if not receipt:
22282231
receipt = session.get_receipt_by_model(attendee, create_if_none="DEFAULT")
@@ -2237,7 +2240,7 @@ def confirm(self, session, message='', return_to='confirm', undoing_extra='', **
22372240

22382241
attendee.placeholder = placeholder
22392242
if not message and attendee.placeholder:
2240-
message = 'You are not yet registered! You must fill out this form to complete your registration.'
2243+
message = 'You are not yet registered! Please fill out this form to complete your registration.'
22412244
elif not message and not c.ATTENDEE_ACCOUNTS_ENABLED and attendee.badge_status == c.COMPLETED_STATUS:
22422245
message = 'You are already registered but you may update your information with this form.'
22432246

@@ -2500,6 +2503,9 @@ def new_badge_payment(self, session, id, return_to, message=''):
25002503
if not c.ONLINE_PAYMENT_AVAILABLE:
25012504
raise HTTPRedirect('confirm?id={}&message={}', id, "Please go to Registration to pay for this badge.")
25022505
attendee = session.attendee(id)
2506+
receipt = session.get_receipt_by_model(attendee, who='non-admin', create_if_none="DEFAULT")
2507+
if not receipt.current_amount_owed:
2508+
raise HTTPRedirect('confirm?id={}', attendee.id)
25032509
return {
25042510
'attendee': attendee,
25052511
'receipt': session.get_receipt_by_model(attendee, who='non-admin', create_if_none="DEFAULT"),
@@ -2684,8 +2690,7 @@ def new_password_setup(self, session, account_email, token, message='', **params
26842690
def guest_food(self, session, id):
26852691
attendee = session.attendee(id)
26862692
assert attendee.badge_type == c.GUEST_BADGE, 'This form is for guests only'
2687-
cherrypy.session['staffer_id'] = attendee.id
2688-
raise HTTPRedirect('../staffing/food_restrictions')
2693+
raise HTTPRedirect('../staffing/food_restrictions?id={}', id)
26892694

26902695
def credit_card_retry(self):
26912696
return {}

uber/site_sections/shifts_admin.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ def staffers(self, session, department_id=None, message=''):
285285
}
286286

287287
def goto_volunteer_checklist(self, id):
288-
cherrypy.session['staffer_id'] = id
289-
raise HTTPRedirect('../staffing/index')
288+
raise HTTPRedirect('../staffing/index?id={}', id)
290289

291290
@ajax
292291
def update_shifts_info(self, session, id, nonshift_hours, admin_notes, for_review=None):

0 commit comments

Comments
 (0)