-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfig.py
73 lines (58 loc) · 3.35 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
""" Contains all the config values for this web app. """
# pylint: disable=line-too-long
from os import environ
from os.path import abspath, dirname, join as path_join
# -------------------------------------------------------------------------------------------------
TEST_SUBREDDIT = 'cubecomps'
DEFAULT_PROD_ACCOUNT = 'cubers_io'
DEFAULT_DEVO_ACCOUNT = 'cubers_io_test'
DEFAULT_ADMIN_REDDIT_USER = 'euphwes'
# -------------------------------------------------------------------------------------------------
class Config(object):
""" A config object whose attributes and their values get converted to key/value pairs
in the web app's config dict. """
FLASK_SECRET_KEY = environ.get('FLASK_SECRET_KEY')
# ------------------------------------------------------
# Reddit API config
# ------------------------------------------------------
REDDIT_CLIENT_ID = environ.get('CUBERS_CLIENT_ID')
REDDIT_CLIENT_SECRET = environ.get('CUBERS_SECRET')
REDDIT_REDIRECT_URI = environ.get('REDDIT_OAUTH_REDIRECT_URI')
PROD_CUBERSIO_ACCT = environ.get('PROD_CUBERSIO_ACCT', DEFAULT_PROD_ACCOUNT)
DEVO_CUBERSIO_ACCT = environ.get('DEVO_CUBERSIO_ACCT', DEFAULT_DEVO_ACCOUNT)
# ------------------------------------------------------
# WCA OAuth config
# ------------------------------------------------------
WCA_CLIENT_ID = environ.get('WCA_CLIENT_ID')
WCA_CLIENT_SECRET = environ.get('WCA_SECRET')
WCA_REDIRECT_URI = environ.get('WCA_OAUTH_REDIRECT_URI')
# ------------------------------------------------------
# Config related to notifying an admin of task status
# ------------------------------------------------------
TASK_STATUS_REDDIT_USER = environ.get('TASK_STATUS_REDDIT_USER', DEFAULT_ADMIN_REDDIT_USER)
# ------------------------------------------------------
# Config related which subreddit to target, the URL to
# the web app to drop into the Reddit comment body, etc
# ------------------------------------------------------
APP_URL = environ.get('APP_URL', 'http://localhost:5000/')
TARGET_SUBREDDIT = environ.get('TARGET_SUBREDDIT', TEST_SUBREDDIT)
IS_DEVO = TARGET_SUBREDDIT == TEST_SUBREDDIT
# ------------------------------------------------------
# Database config
# ------------------------------------------------------
SQLALCHEMY_TRACK_MODIFICATIONS = False
# Get the database URI. Assume there's a PostGRES DB connection URI in the env variables
# If there isn't, fall back to just pointing at a sqlite database in the app root directory
SQLALCHEMY_DATABASE_URI = environ.get('DATABASE_URL')
if SQLALCHEMY_DATABASE_URI and SQLALCHEMY_DATABASE_URI.startswith("postgres://"):
SQLALCHEMY_DATABASE_URI = SQLALCHEMY_DATABASE_URI.replace("postgres://", "postgresql://", 1)
if not SQLALCHEMY_DATABASE_URI:
basedir = abspath(dirname(__file__))
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + path_join(basedir, 'cube_competitions.sqlite')
# ------------------------------------------------------
# Other config
# ------------------------------------------------------
TEMPLATES_AUTO_RELOAD = True
# The factor by which we multiply current WRs to determine whether or not to automatically
# blacklist results we are assuming to be fake
AUTO_BL_FACTOR = float(environ.get('AUTO_BL_FACTOR', 1.0))