Skip to content
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
26 changes: 10 additions & 16 deletions users/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,6 @@
from flask import Flask
from flask_mail import Mail

from users.config import (
PROJECT_NAME,
PUBLIC_URL,
PROJECT_FAVICON_FILE,
MAIL_CONFIG,
SQLITE_DB_PATH,
USER_ICONS)


def add_handler_once(logger, handler):
"""A helper to add a handler to a logger, ensuring there are no duplicates.
Expand Down Expand Up @@ -75,16 +67,18 @@ def setup_logger():

APP = Flask(__name__)

# Load configuration
APP.config['PROJECT_NAME'] = PROJECT_NAME
APP.config['PUBLIC_URL'] = PUBLIC_URL
APP.config['PROJECT_FAVICON_FILE'] = PROJECT_FAVICON_FILE
APP.config.update(MAIL_CONFIG)
# Load configuration from ``users.config``.
# This will raise ``ImportError`` if such module isn't exist.
# Simply copy the contents of ``config.py.example`` file,
# and save it into a file named ``config.py``.
APP.config.from_object("users.config")
mail = Mail(APP)
APP.config['DATABASE'] = SQLITE_DB_PATH
APP.config['USER_ICONS'] = USER_ICONS

# backward-compat
APP.config['DATABASE'] = APP.config['SQLITE_DB_PATH']

# Don't import actual view methods themselves - see:
# http://flask.pocoo.org/docs/patterns/packages/#larger-applications
# Also views must be imported AFTER app is created above.
# noinspection PyUnresolvedReferences
import users.views
import users.views # noqa
27 changes: 16 additions & 11 deletions users/config.py.prod → users/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,24 @@ SQLITE_DB_PATH = os.path.abspath(
)
)

# MAIL SERVER
MAIL_CONFIG = dict(
MAIL_SERVER='smtp.gmail.com',
MAIL_PORT=587,
MAIL_USE_TLS=True,
MAIL_USE_SSL=False,
MAIL_USERNAME='',
MAIL_PASSWORD='',
MAIL_SUPPRESS_SEND=False,
)
# Alternatively, set to ``127.0.0.1`` for development/testing.
MAIL_SERVER = 'smtp.gmail.com'

# Alternatively, set to ``25`` for development/testing.
MAIL_PORT = 587

MAIL_USE_TLS = True
MAIL_USE_SSL = False
MAIL_USERNAME = ''
MAIL_PASSWORD = ''

# Set the value to ``True`` to suppress email sending.
# Useful for testing/development where machine doesn't have
# mail server installed in it.
MAIL_SUPPRESS_SEND = False

# MAIL ADMINISTRATOR
MAIL_ADMIN = ('InaSAFE User Map Administrator', MAIL_CONFIG['MAIL_USERNAME'])
MAIL_ADMIN = ('Python Indonesia User Map Administrator', MAIL_USERNAME)

# USER ICONS: All icon paths that are used.
USER_ICONS = dict(
Expand Down
45 changes: 0 additions & 45 deletions users/config.py.test

This file was deleted.