Skip to content

Commit

Permalink
Merge pull request #4359 from magfest/remove-extra-path
Browse files Browse the repository at this point in the history
Remove c.PATH property for getting site section
  • Loading branch information
kitsuta committed May 9, 2024
2 parents dda34e6 + 7d7f3c0 commit b2034a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
11 changes: 0 additions & 11 deletions uber/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ class Config(_Overridable):
For all of the datetime config options, we also define BEFORE_ and AFTER_ properties, e.g. you can
check the booleans returned by c.BEFORE_PLACEHOLDER_DEADLINE or c.AFTER_PLACEHOLDER_DEADLINE
"""
def __init__(self):
self._PATH = cherrypy.request.path_info.replace(cherrypy.request.path_info.split('/')[-1], '').strip('/')

def get_oneday_price(self, dt):
return self.BADGE_PRICES['single_day'].get(dt.strftime('%A'), self.DEFAULT_SINGLE_DAY)

Expand Down Expand Up @@ -838,14 +835,6 @@ def PAGE_PATH(self):
def PAGE(self):
return cherrypy.request.path_info.split('/')[-1]

@property
def PATH(self):
return self._PATH

@PATH.setter
def PATH(self, value):
self._PATH = value

@request_cached_property
@dynamic
def ALLOWED_ACCESS_OPTS(self):
Expand Down
8 changes: 4 additions & 4 deletions uber/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,20 +707,20 @@ def restricted(func):
@wraps(func)
def with_restrictions(*args, **kwargs):
if not func.public:
if c.PATH == 'staffing':
if '/staffing/' in c.PAGE_PATH:
if not cherrypy.session.get('staffer_id'):
raise HTTPRedirect('../staffing/login?message=You+are+not+logged+in', save_location=True)

elif cherrypy.session.get('account_id') is None:
raise HTTPRedirect('../accounts/login?message=You+are+not+logged+in', save_location=True)

elif c.PATH == 'mivs_judging':
elif '/mivs_judging/' in c.PAGE_PATH:
if not uber.models.AdminAccount.is_mivs_judge_or_admin:
return 'You need to be a MIVS Judge or have access for either {} or {}'.format(c.PATH, c.PAGE_PATH)
return f'You need to be a MIVS Judge or have access to {c.PAGE_PATH}'

else:
if not c.has_section_or_page_access(include_read_only=True):
return 'You need access for either {} or {}.'.format(c.PATH, c.PAGE_PATH)
return f'You need access to {c.PAGE_PATH}.'

return func(*args, **kwargs)
return with_restrictions
Expand Down

0 comments on commit b2034a3

Please sign in to comment.