diff options
-rwxr-xr-x | rater.py | 38 |
1 files changed, 20 insertions, 18 deletions
@@ -11,25 +11,8 @@ import json | |||
11 | # import urllib3.contrib.pyopenssl | 11 | # import urllib3.contrib.pyopenssl |
12 | # urllib3.contrib.pyopenssl.inject_into_urllib3() | 12 | # urllib3.contrib.pyopenssl.inject_into_urllib3() |
13 | 13 | ||
14 | parser = ArgumentParser(description="C3 rating helper") | 14 | db = SQLAlchemy() |
15 | parser.add_argument("-i", action="store_true", dest="pretalx_import", default=False, help="import events from pretalx") | ||
16 | parser.add_argument("-c", "--config", help="Config file location", default="./config.json") | ||
17 | args = parser.parse_args() | ||
18 | |||
19 | with open(args.config, mode="r", encoding="utf-8") as json_file: | ||
20 | config = json.load(json_file) | ||
21 | |||
22 | app = Flask(__name__) | 15 | app = Flask(__name__) |
23 | app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + config['pretalx-conference'] + '-' + config['track'] + '.db' | ||
24 | app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | ||
25 | app.config['SECRET_KEY'] = 'Silence is golden. Gerd Eist.' | ||
26 | app.jinja_env.trim_blocks = True | ||
27 | app.jinja_env.lstrip_blocks = True | ||
28 | |||
29 | db = SQLAlchemy(app) | ||
30 | |||
31 | config['pretalx-conf-url'] = config['pretalx-url'] + 'orga/event/' + config['pretalx-conference'] | ||
32 | config['pretalx-api-url'] = config['pretalx-url'] + 'api/events/' + config['pretalx-conference'] + '/submissions?track_id' + str(config['track-id']) | ||
33 | 16 | ||
34 | class Event(db.Model): | 17 | class Event(db.Model): |
35 | """An event as dumped from pretalx""" | 18 | """An event as dumped from pretalx""" |
@@ -157,6 +140,25 @@ def fetch_talks(): | |||
157 | 140 | ||
158 | 141 | ||
159 | if __name__ == "__main__": | 142 | if __name__ == "__main__": |
143 | |||
144 | parser = ArgumentParser(description="C3 rating helper") | ||
145 | parser.add_argument("-i", action="store_true", dest="pretalx_import", default=False, help="import events from pretalx") | ||
146 | parser.add_argument("-c", "--config", help="Config file location", default="./config.json") | ||
147 | args = parser.parse_args() | ||
148 | |||
149 | with open(args.config, mode="r", encoding="utf-8") as json_file: | ||
150 | config = json.load(json_file) | ||
151 | config['pretalx-conf-url'] = config['pretalx-url'] + 'orga/event/' + config['pretalx-conference'] | ||
152 | config['pretalx-api-url'] = config['pretalx-url'] + 'api/events/' + config['pretalx-conference'] + '/submissions?track_id' + str(config['track-id']) | ||
153 | |||
154 | app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + config['pretalx-conference'] + '-' + config['track'] + '.db' | ||
155 | app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False | ||
156 | app.config['SECRET_KEY'] = 'Silence is golden. Gerd Eist.' | ||
157 | app.jinja_env.trim_blocks = True | ||
158 | app.jinja_env.lstrip_blocks = True | ||
159 | |||
160 | db.init_app(app) | ||
161 | |||
160 | with app.app_context(): | 162 | with app.app_context(): |
161 | db.create_all() | 163 | db.create_all() |
162 | if args.pretalx_import: | 164 | if args.pretalx_import: |