mirror of https://codeberg.org/dribdat/dribdat.git
Switch to flask-mailman
This commit is contained in:
parent
941d9ed316
commit
c7fc384e1d
|
@ -3,8 +3,8 @@
|
|||
|
||||
from flask import Flask, render_template
|
||||
from flask_cors import CORS
|
||||
from flask_mail import Mail # noqa: I005
|
||||
from flask_misaka import Misaka
|
||||
from flask_mailman import Mail
|
||||
from flask_talisman import Talisman
|
||||
from flask_dance.contrib import (slack, azure, github)
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
|
@ -69,15 +69,19 @@ def register_extensions(app):
|
|||
db.init_app(app)
|
||||
login_manager.init_app(app)
|
||||
migrate.init_app(app, db)
|
||||
init_mail(app)
|
||||
init_mailman(app)
|
||||
init_talisman(app)
|
||||
return None
|
||||
|
||||
|
||||
def init_mail(app):
|
||||
"""Initialize Flask Mail support."""
|
||||
def init_mailman(app):
|
||||
"""Initialize mailer support."""
|
||||
if 'MAIL_SERVER' in app.config and app.config['MAIL_SERVER']:
|
||||
mail = Mail(app)
|
||||
if not app.config['MAIL_DEFAULT_SENDER']:
|
||||
app.logger.warn('MAIL_DEFAULT_SENDER is required to send email')
|
||||
else:
|
||||
mail = Mail()
|
||||
mail.init_app(app)
|
||||
|
||||
|
||||
def init_talisman(app):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Helper for sending mail."""
|
||||
from flask import url_for
|
||||
from flask_mail import Message, Mail
|
||||
from flask_mailman import EmailMessage
|
||||
from dribdat.utils import random_password # noqa: I005
|
||||
|
||||
|
||||
|
@ -16,9 +16,10 @@ def user_activation(user):
|
|||
userid=user.id,
|
||||
userhash=act_hash,
|
||||
_external=True)
|
||||
mail = Mail()
|
||||
msg = Message('Your dribdat account')
|
||||
msg.recipients = [user.email]
|
||||
msg.body = "Thanks for signing up at %s\n\n" % base_url \
|
||||
+ "Tap here to activate your account:\n\n%s" % act_url
|
||||
mail.send(msg)
|
||||
msg = EmailMessage()
|
||||
msg.subject = 'Your dribdat account'
|
||||
msg.body = \
|
||||
"Thanks for signing up at %s\n\n" % base_url \
|
||||
+ "Tap here to activate your account:\n\n%s" % act_url
|
||||
msg.to = [user.email]
|
||||
msg.send()
|
||||
|
|
|
@ -133,7 +133,7 @@ def activate(userid, userhash):
|
|||
a_user.active = True
|
||||
a_user.save()
|
||||
login_user(a_user, remember=True)
|
||||
flash("Your user account has been activated.", 'success')
|
||||
flash("Welcome! Your user account has been activated.", 'success')
|
||||
return redirect(url_for('auth.user_profile'))
|
||||
flash("Activation not found. Try again, or ask an organizer.", 'warning')
|
||||
logout_user()
|
||||
|
|
|
@ -42,6 +42,8 @@ class Config(object):
|
|||
MAIL_USERNAME = os_env.get('MAIL_USERNAME', None)
|
||||
MAIL_PASSWORD = os_env.get('MAIL_PASSWORD', None)
|
||||
MAIL_DEFAULT_SENDER = os_env.get('MAIL_DEFAULT_SENDER', None)
|
||||
MAIL_USE_TLS = bool(strtobool(os_env.get('MAIL_USE_TLS', 'False')))
|
||||
MAIL_USE_SSL = bool(strtobool(os_env.get('MAIL_USE_SSL', 'False')))
|
||||
|
||||
# Application settings
|
||||
APP_DIR = os.path.abspath(os.path.dirname(__file__)) # This directory
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -49,7 +49,7 @@ whitenoise = "^5"
|
|||
wtforms = ">=2.1,<3"
|
||||
hiredis = "^2.0.0"
|
||||
SQLAlchemy-Continuum = "^1.3.12"
|
||||
Flask-Mail = "^0.9.1"
|
||||
flask-mailman = "^0.3.0"
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
factory-boy = "*"
|
||||
|
|
|
@ -5,7 +5,6 @@ async-timeout==4.0.2; python_version >= "3.6"
|
|||
attrs==22.1.0; python_version >= "3.7"
|
||||
bcrypt==4.0.0; python_version >= "3.6"
|
||||
bleach==5.0.1; python_version >= "3.7"
|
||||
blinker==1.5; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
|
||||
boto3==1.19.12; python_version >= "3.6"
|
||||
botocore==1.22.12; python_version >= "3.6"
|
||||
cachelib==0.9.0; python_version >= "3.7"
|
||||
|
@ -30,7 +29,7 @@ flask-cors==3.0.10
|
|||
flask-dance==5.1.0; python_version >= "3.6"
|
||||
flask-hashing==1.1
|
||||
flask-login==0.6.2; python_version >= "3.7"
|
||||
flask-mail==0.9.1
|
||||
flask-mailman==0.3.0; python_full_version >= "3.6.2" and python_full_version < "4.0.0"
|
||||
flask-migrate==3.1.0; python_version >= "3.6"
|
||||
flask-misaka==1.0.0
|
||||
flask-sqlalchemy==2.5.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
|
||||
|
@ -46,8 +45,8 @@ greenlet==1.1.3; python_version >= "3.7" and python_full_version < "3.0.0" or py
|
|||
gunicorn==20.1.0; python_version >= "3.5"
|
||||
hiredis==2.0.0; python_version >= "3.6"
|
||||
idna==3.4; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4" or python_full_version >= "3.5.0" and python_version >= "3.7" and python_version < "4"
|
||||
importlib-metadata==4.2.0; python_version < "3.8" and python_version >= "3.7" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.6") and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.7")
|
||||
importlib-resources==5.9.0; python_version < "3.9" and python_version >= "3.7"
|
||||
importlib-metadata==4.2.0; python_version < "3.8" and python_version >= "3.7" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.6") and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.7") and python_full_version >= "3.6.2" and python_full_version < "4.0.0" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.7")
|
||||
importlib-resources==5.10.0; python_version < "3.9" and python_version >= "3.7"
|
||||
isodate==0.6.1
|
||||
itsdangerous==2.1.2; python_version >= "3.7"
|
||||
jinja2==3.1.2; python_version >= "3.7"
|
||||
|
@ -60,11 +59,12 @@ marko==1.2.2; python_version >= "3.6"
|
|||
markupsafe==2.1.1; python_version >= "3.7"
|
||||
micawber==0.5.4
|
||||
misaka==2.1.1
|
||||
mkdocs-material-extensions==1.0.3; python_full_version >= "3.6.2" and python_full_version < "4.0.0" and python_version >= "3.6"
|
||||
oauthlib==3.2.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
|
||||
packaging==21.3; python_version >= "3.6"
|
||||
petl==1.7.11; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
|
||||
pkgutil-resolve-name==1.3.10; python_version < "3.9" and python_version >= "3.7"
|
||||
psycopg2-binary==2.9.3; python_version >= "3.6"
|
||||
psycopg2-binary==2.9.4; python_version >= "3.6"
|
||||
pycparser==2.21; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.4.0"
|
||||
pygments==2.13.0; python_full_version >= "3.6.3" and python_full_version < "4.0.0" and python_version >= "3.6"
|
||||
pyparsing==3.0.9; python_full_version >= "3.6.8" and python_version >= "3.6"
|
||||
|
@ -74,13 +74,13 @@ pystache==0.6.0; python_version >= "3.6"
|
|||
python-dateutil==2.8.2; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.3.0" and python_version >= "3.6"
|
||||
python-dotenv==0.21.0; python_version >= "3.7"
|
||||
python-slugify==6.1.2; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
|
||||
pytz==2022.2.1
|
||||
pytz==2022.4
|
||||
pyyaml==5.4.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
|
||||
redis==4.3.4; python_version >= "3.6"
|
||||
requests-oauthlib==1.3.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
|
||||
requests==2.28.1; python_version >= "3.7" and python_version < "4"
|
||||
rfc3986==2.0.0; python_version >= "3.7"
|
||||
rich==12.5.1; python_full_version >= "3.6.3" and python_full_version < "4.0.0" and python_version >= "3.6"
|
||||
rich==12.6.0; python_full_version >= "3.6.3" and python_full_version < "4.0.0" and python_version >= "3.6"
|
||||
s3transfer==0.5.2; python_version >= "3.6"
|
||||
shellingham==1.5.0; python_version >= "3.6"
|
||||
simpleeval==0.9.12
|
||||
|
@ -89,10 +89,10 @@ sqlalchemy-continuum==1.3.13
|
|||
sqlalchemy-utils==0.38.3; python_version >= "3.6" and python_version < "4.0"
|
||||
sqlalchemy==1.4.22; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.6.0")
|
||||
stringcase==1.2.0
|
||||
tabulate==0.8.10; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
|
||||
tabulate==0.9.0; python_version >= "3.7"
|
||||
text-unidecode==1.3; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.6.0"
|
||||
typer==0.6.1; python_version >= "3.6"
|
||||
typing-extensions==4.3.0; python_version < "3.8" and python_version >= "3.7" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.6") and python_full_version >= "3.6.3" and python_full_version < "4.0.0"
|
||||
typing-extensions==4.4.0; python_version < "3.8" and python_version >= "3.7" and (python_version >= "3.6" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.6.0" and python_version < "3.8" and python_version >= "3.6") and python_full_version >= "3.6.3" and python_full_version < "4.0.0"
|
||||
urllib3==1.26.12; python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "4" or python_full_version >= "3.6.0" and python_version < "4" and python_version >= "3.7"
|
||||
urlobject==2.4.3; python_version >= "3.6"
|
||||
validators==0.20.0; python_version >= "3.4"
|
||||
|
|
Loading…
Reference in New Issue