diff --git a/Dockerfile b/Dockerfile index be1dec086..23c1e08d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,6 @@ MAINTAINER RAMS Project "code@magfest.org" LABEL version.rams-core ="0.1" # add our code -COPY . plugins/uber/ +COPY . /app/sideboard/plugins/uber/ # go ahead and install base dependencies RUN /app/env/bin/paver install_deps diff --git a/requirements.txt b/requirements.txt index 9b45c4161..edacab0ea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,19 +1,23 @@ cherrypy==17.3.0 -celery==4.1.1 +celery==5.2.7 python-dateutil==2.6.0 -psycopg2 +psycopg2-binary>=2.7.3.2 py3k-bcrypt==0.3 stripe==2.42.0 -pytz==2017.2 +pytz==2022.1 alembic==0.9.1 treepoem==1.0.1 email_validator==1.0.2 phonenumbers==8.8.1 -pockets==0.6.2 -residue==0.2.8 +pockets==0.9.1 + +# hotfix +# residue==0.2.8 +git+https://github.com/magfest/residue@update_to_latest_python#egg=residue + XlsxWriter==1.0.2 uszipcode==0.2.6 -geopy==1.11.0 +geopy==2.2.0 twilio==6.10.0 cherrys==0.4 redis==2.10.6 @@ -22,4 +26,4 @@ Pillow==8.3.2 fpdf==1.7.2 boto3==1.14.45 SQLAlchemy==1.3.0 -Jinja2==2.11.3 \ No newline at end of file +Jinja2==3.0.3 \ No newline at end of file diff --git a/setup.py b/setup.py index c3a3643f6..e1b1f5d8f 100644 --- a/setup.py +++ b/setup.py @@ -6,9 +6,8 @@ name='uber', packages=['uber'], version=__version__, - author='Eli Courtwright', - author_email='eli@courtwright.org', - description='The MAGFest Ubersystem', - url='https://github.com/EliAndrewC/magfest', - install_requires=open('requirements.txt').readlines() + author='Eli Courtwright and others', + author_email='code@magfest.org', + description='The MAGFest Ubersystem - Ticket/Management platform', + url='https://github.com/magfest/ubersystem', ) diff --git a/uber/_version.py b/uber/_version.py index c62c24eb9..c975b3685 100644 --- a/uber/_version.py +++ b/uber/_version.py @@ -1 +1 @@ -__version__ = '2017.07' +__version__ = '2022.01' diff --git a/uber/decorators.py b/uber/decorators.py index b0e9a4542..70d84de67 100644 --- a/uber/decorators.py +++ b/uber/decorators.py @@ -670,15 +670,25 @@ def with_check(*args, **kwargs): return func(*args, **kwargs) return with_check + +def cherrypy_session_get(key): + try: + session = cherrypy.session + except AttributeError: + return None + + return session.get(key) + + def restricted(func): @wraps(func) def with_restrictions(*args, **kwargs): if not func.public: if c.PATH == 'staffing': - if not cherrypy.session.get('staffer_id'): + 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: + 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': diff --git a/uber/errors.py b/uber/errors.py index fe8b3a127..52fc5d39f 100644 --- a/uber/errors.py +++ b/uber/errors.py @@ -41,7 +41,7 @@ def __init__(self, page, *args, **kwargs): # useful if we want to redirect the user back to the same # page after they complete an action, such as logging in # example URI: '/uber/registration/form?id=786534' - original_location = cherrypy.request.wsgi_environ['REQUEST_URI'] + original_location = self.get_cherrypy_wsgi_environ() # Note: python does have utility functions for this. if this # gets any more complex, use the urllib module @@ -51,5 +51,14 @@ def __init__(self, page, *args, **kwargs): cherrypy.HTTPRedirect.__init__(self, query) + @staticmethod + def get_cherrypy_wsgi_environ(): + original_location = '' + try: + original_location = cherrypy.request.wsgi_environ['REQUEST_URI'] + except AttributeError: + pass + return original_location + def quote(self, s): return quote(s) if isinstance(s, str) else str(s) diff --git a/uber/models/types.py b/uber/models/types.py index fb759aeae..6df4c6cf4 100644 --- a/uber/models/types.py +++ b/uber/models/types.py @@ -1,4 +1,5 @@ -from collections import Mapping, OrderedDict +from collections.abc import Mapping +from collections import OrderedDict from datetime import datetime, time, timedelta from dateutil.parser import parse import re diff --git a/uber/site_sections/statistics.py b/uber/site_sections/statistics.py index e5725439d..55479cf5a 100644 --- a/uber/site_sections/statistics.py +++ b/uber/site_sections/statistics.py @@ -1,6 +1,7 @@ from collections import Counter, defaultdict, OrderedDict +from os.path import exists -from geopy.distance import VincentyDistance +from geopy.distance import geodesic from pockets.autolog import log from pytz import UTC import six @@ -260,8 +261,13 @@ def badges_sold(self, session): zips_counter = Counter() zips = {} + center = None + + # TODO: use lazy loading instead of doing this here so it's only accessed on the first try. + # if /srv/reggie/data/ doesn't exist, this will barf loudly at startup. try: - center = SearchEngine(db_file_dir="/srv/reggie/data").by_zipcode(20745) + if exists("/srv/reggie/data"): + center = SearchEngine(db_file_dir="/srv/reggie/data").by_zipcode(20745) except Exception as e: log.error("Error calling SearchEngine: " + e) diff --git a/uber/tasks/email.py b/uber/tasks/email.py index a20434760..e00a1b9c2 100644 --- a/uber/tasks/email.py +++ b/uber/tasks/email.py @@ -1,4 +1,4 @@ -from collections import Mapping +from collections.abc import Mapping from datetime import timedelta from time import sleep