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

Returning errors generated by check_if_can_reg #4210

Merged
merged 1 commit into from
Aug 11, 2023
Merged
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
37 changes: 28 additions & 9 deletions uber/site_sections/preregistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def check_if_preregistered(self, session, message='', **params):
return {'message': message}

def index(self, session, message='', account_email='', account_password='', **params):
check_if_can_reg()
errors = check_if_can_reg()
if errors:
return errors

pending_preregs = PreregCart.pending_preregs.copy()
for id in pending_preregs:
Expand Down Expand Up @@ -223,7 +225,9 @@ def index(self, session, message='', account_email='', account_password='', **pa
}

def reapply(self, session, id, **params):
check_if_can_reg(is_dealer_reg=True)
errors = check_if_can_reg(is_dealer_reg=True)
if errors:
return errors

old_attendee = session.attendee(id)
old_attendee_dict = old_attendee.to_dict(c.UNTRANSFERABLE_ATTRS)
Expand All @@ -242,7 +246,10 @@ def reapply(self, session, id, **params):


def repurchase(self, session, id, skip_confirm=False, **params):
check_if_can_reg()
errors = check_if_can_reg()
if errors:
return errors

if skip_confirm or 'csrf_token' in params:
old_attendee = session.attendee(id)
old_attendee_dict = old_attendee.to_dict(c.UNTRANSFERABLE_ATTRS)
Expand All @@ -262,7 +269,9 @@ def repurchase(self, session, id, skip_confirm=False, **params):
@cherrypy.expose('post_dealer')
@requires_account()
def dealer_registration(self, session, message='', edit_id=None, **params):
check_if_can_reg(is_dealer_reg=True)
errors = check_if_can_reg(is_dealer_reg=True)
if errors:
return errors

if c.DEALER_INVITE_CODE and not edit_id:
if not params.get('invite_code'):
Expand Down Expand Up @@ -317,7 +326,9 @@ def dealer_registration(self, session, message='', edit_id=None, **params):
}

def finish_dealer_reg(self, session, id, **params):
check_if_can_reg(is_dealer_reg=True)
errors = check_if_can_reg(is_dealer_reg=True)
if errors:
return errors

group = self._get_unsaved(id, PreregCart.pending_dealers)
attendee = group.attendees[0]
Expand Down Expand Up @@ -365,7 +376,9 @@ def finish_dealer_reg(self, session, id, **params):
@requires_account()
def form(self, session, message='', edit_id=None, **params):
is_dealer_reg = 'dealer_id' in params
check_if_can_reg(is_dealer_reg)
errors = check_if_can_reg(is_dealer_reg)
if errors:
return errors
"""
Our production NGINX config caches the page at /preregistration/form.
Since it's cached, we CAN'T return a session cookie with the page. We
Expand Down Expand Up @@ -510,7 +523,9 @@ def form(self, session, message='', edit_id=None, **params):

def additional_info(self, session, message='', editing=None, **params):
is_dealer_reg = 'group_id' in params
check_if_can_reg(is_dealer_reg)
errors = check_if_can_reg(is_dealer_reg)
if errors:
return errors

attendee, group = self._get_attendee_or_group(params)

Expand Down Expand Up @@ -538,7 +553,9 @@ def additional_info(self, session, message='', editing=None, **params):
}

def duplicate(self, session, **params):
check_if_can_reg(is_dealer_reg='group_id' in params)
errors = check_if_can_reg(is_dealer_reg='group_id' in params)
if errors:
return errors

attendee, group = self._get_attendee_or_group(params)
orig = session.query(Attendee).filter_by(
Expand All @@ -554,7 +571,9 @@ def duplicate(self, session, **params):
}

def banned(self, **params):
check_if_can_reg(is_dealer_reg='group_id' in params)
errors = check_if_can_reg(is_dealer_reg='group_id' in params)
if errors:
return errors

attendee, group = self._get_attendee_or_group(params)
return {
Expand Down
4 changes: 3 additions & 1 deletion uber/site_sections/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,9 @@ def lost_badge(self, session, id):
@check_atd
@requires_account()
def register(self, session, message='', error_message='', **params):
check_if_can_reg()
errors = check_if_can_reg()
if errors:
return errors

params['id'] = 'None'
login_email = None
Expand Down
Loading