diff options
-rw-r--r-- | README.rst | 2 | ||||
-rw-r--r-- | app.json | 6 | ||||
-rw-r--r-- | conf.py | 22 | ||||
-rw-r--r-- | conf/conf.cfg-sample | 6 | ||||
-rwxr-xr-x | db_create.py | 5 | ||||
-rw-r--r-- | pyaggr3g470r/crawler.py | 2 | ||||
-rw-r--r-- | pyaggr3g470r/emails.py | 14 |
7 files changed, 30 insertions, 27 deletions
@@ -58,7 +58,7 @@ To enable account creation for users, you have to set some environment variables $ heroku config:set PLATFORM_URL=<URL-of-your-platform> $ heroku config:set RECAPTCHA_PUBLIC_KEY=<your-recaptcha-public-key> $ heroku config:set RECAPTCHA_PRIVATE_KEY=<your-recaptcha-private-key> - $ heroku config:set ADMIN_EMAIL=<administrator-email> + $ heroku config:set NOTIFICATION_EMAIL=<notification-email> $ heroku addons:add postmark:10k `Postmark <https://postmarkapp.com/>`_ is used to send account confirmation links. @@ -13,10 +13,10 @@ }, "env": { "HEROKU": "1", - "ADMIN_PLATFORM_EMAIL": "admin@no-reply.org", + "ADMIN_EMAIL": "root@pyAggr3g470r.localhost", + "ADMIN_PASSWORD": "password", "RECAPTCHA_PRIVATE_KEY": "REDACTED", - "RECAPTCHA_PUBLIC_KEY": "REDACTED", - "ADMIN_EMAIL": "admin@no-reply.org" + "RECAPTCHA_PUBLIC_KEY": "REDACTED" }, "addons": [ "heroku-postgresql:hobby-dev" @@ -34,6 +34,7 @@ if not ON_HEROKU: config.read(os.path.join(basedir, "conf/conf.cfg")) PLATFORM_URL = config.get('misc', 'platform_url') + ADMIN_EMAIL = config.get('misc', 'admin_email') RECAPTCHA_PUBLIC_KEY = config.get('misc', 'recaptcha_public_key') RECAPTCHA_PRIVATE_KEY = config.get('misc', 'recaptcha_private_key') LOG_PATH = config.get('misc', 'log_path') @@ -51,19 +52,20 @@ if not ON_HEROKU: WEBSERVER_PORT = int(config.get('webserver', 'port')) WEBSERVER_SECRET = config.get('webserver', 'secret') - ADMIN_EMAIL = config.get('mail', 'admin_email') - MAIL_ENABLED = int(config.get('mail', 'enabled')) == 1 - MAIL_HOST = config.get('mail', 'host') - MAIL_PORT = int(config.get('mail', 'port')) - MAIL_TLS = int(config.get('mail', 'tls')) == 1 - MAIL_SSL = int(config.get('mail', 'ssl')) == 1 - MAIL_USERNAME = config.get('mail', 'username') - MAIL_PASSWORD = config.get('mail', 'password') + NOTIFICATION_ENABLED = int(config.get('notification', 'enabled')) == 1 + NOTIFICATION_EMAIL = config.get('notification', 'email') + NOTIFICATION_HOST = config.get('notification', 'host') + NOTIFICATION_PORT = int(config.get('notification', 'port')) + NOTIFICATION_TLS = int(config.get('notification', 'tls')) == 1 + NOTIFICATION_SSL = int(config.get('notification', 'ssl')) == 1 + NOTIFICATION_USERNAME = config.get('notification', 'username') + NOTIFICATION_PASSWORD = config.get('notification', 'password') WEBZINE_ROOT = PATH + "/pyaggr3g470r/var/export/" else: PLATFORM_URL = os.environ.get('PLATFORM_URL', 'https://pyaggr3g470r.herokuapp.com/') + ADMIN_EMAIL = os.environ.get('ADMIN_EMAIL', '') RECAPTCHA_PUBLIC_KEY = os.environ.get('RECAPTCHA_PUBLIC_KEY', '') RECAPTCHA_PRIVATE_KEY = os.environ.get('RECAPTCHA_PRIVATE_KEY', '') LOG_PATH = os.environ.get('LOG_PATH', 'pyaggr3g470r.log') @@ -79,8 +81,8 @@ else: WEBSERVER_PORT = int(os.environ.get('PORT', 5000)) WEBSERVER_SECRET = os.environ.get('SECRET_KEY', None) - MAIL_ENABLED = True - ADMIN_EMAIL = os.environ.get('ADMIN_EMAIL', '') + NOTIFICATION_ENABLED = True + NOTIFICATION_EMAIL = os.environ.get('NOTIFICATION_EMAIL', '') POSTMARK_API_KEY = os.environ.get('POSTMARK_API_KEY', '') WEBZINE_ROOT = "/tmp/" diff --git a/conf/conf.cfg-sample b/conf/conf.cfg-sample index 8f0b7aec..2e36ba89 100644 --- a/conf/conf.cfg-sample +++ b/conf/conf.cfg-sample @@ -1,6 +1,6 @@ [misc] platform_url = https://pyaggr3g470r.herokuapp.com/ -admin_platform_email = +admin_email = recaptcha_public_key = recaptcha_private_key = log_path = ./pyaggr3g470r/var/pyaggr3g470r.log @@ -15,9 +15,9 @@ debug = 1 host = 0.0.0.0 port = 5000 secret = a secret only you know -[mail] +[notification] enabled = 0 -admin_email = pyAggr3g470r@no-reply.com +email = pyAggr3g470r@no-reply.com host = smtp.googlemail.com port = 465 tls = 0 diff --git a/db_create.py b/db_create.py index 03bbb7f0..8e743515 100755 --- a/db_create.py +++ b/db_create.py @@ -8,6 +8,7 @@ __revision__ = "$Date: 2014/04/12 $" __copyright__ = "Copyright (c) Cedric Bonhomme" __license__ = "AGPLv3" +import os import bootstrap from pyaggr3g470r import db @@ -70,8 +71,8 @@ role_admin = Role(name="admin") role_user = Role(name="user") user1 = User(nickname="admin", - email="root@pyAggr3g470r.localhost", - pwdhash=generate_password_hash("password"), + email=os.environ.get("ADMIN_EMAIL", "root@pyAggr3g470r.localhost"), + pwdhash=generate_password_hash(os.environ.get("ADMIN_PASSWORD", "password")), activation_key="") user1.roles.extend([role_admin, role_user]) diff --git a/pyaggr3g470r/crawler.py b/pyaggr3g470r/crawler.py index 59d357b4..d65d03bd 100644 --- a/pyaggr3g470r/crawler.py +++ b/pyaggr3g470r/crawler.py @@ -112,7 +112,7 @@ class FeedGetter(object): self.index(new_articles) # 5 - Mail notification - if not conf.ON_HEROKU and conf.MAIL_ENABLED: + if not conf.ON_HEROKU and conf.NOTIFICATION_ENABLED: self.mail_notification(new_articles) logger.info("All articles retrieved. End of the processus.") diff --git a/pyaggr3g470r/emails.py b/pyaggr3g470r/emails.py index aba0e3e6..7d4d4c55 100644 --- a/pyaggr3g470r/emails.py +++ b/pyaggr3g470r/emails.py @@ -35,8 +35,8 @@ logger = logging.getLogger(__name__) @async def send_async_email(mfrom, mto, msg): try: - s = smtplib.SMTP(conf.MAIL_HOST) - s.login(conf.MAIL_USERNAME, conf.MAIL_PASSWORD) + s = smtplib.SMTP(conf.NOTIFICATION_HOST) + s.login(conf.NOTIFICATION_USERNAME, conf.NOTIFICATION_PASSWORD) except Exception: logger.exception('send_async_email raised:') else: @@ -69,8 +69,8 @@ def send_email(mfrom, mto, feed, article): msg.attach(part2) try: - s = smtplib.SMTP(conf.MAIL_HOST) - s.login(conf.MAIL_USERNAME, conf.MAIL_PASSWORD) + s = smtplib.SMTP(conf.NOTIFICATION_HOST) + s.login(conf.NOTIFICATION_USERNAME, conf.NOTIFICATION_PASSWORD) except Exception: logger.exception("send_email raised:") else: @@ -88,10 +88,10 @@ def send_heroku(user=None, bcc="", subject="", plaintext=""): try: message = PMMail(api_key = conf.POSTMARK_API_KEY, subject = subject, - sender = conf.ADMIN_EMAIL, + sender = conf.NOTIFICATION_EMAIL, text_body = plaintext) if bcc != "": - message.to = conf.ADMIN_EMAIL + message.to = conf.NOTIFICATION_EMAIL message.bcc = bcc elif bcc == "": message.to = user.email @@ -157,4 +157,4 @@ def new_article_notification(user, feed, article): if conf.ON_HEROKU: pass else: - send_email(conf.ADMIN_EMAIL, user.email, feed, article) + send_email(conf.NOTIFICATION_EMAIL, user.email, feed, article) |