def deliver_password_reset_email(user_id, reset_token): """ Send a reset password e-mail to a user. :param user_id: The user id :type user_id: int :param reset_token: The reset token :type reset_token: str :return: None if a user was not found """ app = create_app() with app.app_context(): user = User.query.get(user_id) if user is None: return ctx = {'user': user, 'reset_token': reset_token} send_template_message(subject='Password reset from Snake Eyes', recipients=[user.email], template='user/mail/password_reset', ctx=ctx) return None
def app(): params = {'DEBUG': False, 'TESTING': True} _app = create_app(settings_override=params) ctx = _app.app_context() ctx.push() yield _app ctx.pop()
def app(): """ Set up flask test app. [ This gets executed only once ] :return: Flask Test app """ params = {'DEBUG': False, 'TESTING': True} _app = create_app(settings_override=params) with _app.app_context(): # Establish application context before running the test yield _app
def app(): """ Setup our flask test app, this only gets executed once. :return: Flask app """ params = {'DEBUG': False, 'TESTING': True} _app = create_app(settings_override=params) # establish an application context before running the tests. ctx = _app.app_context() ctx.push() yield _app ctx.pop()
def deliver_contact_email(email, message): """ Send a contact e-mail. :param email: E-mail address of the visitor :type user_id: str :param message: E-mail message :type user_id: str :return: None """ app = create_app() with app.app_context(): ctx = {'email': email, 'message': message} send_template_message(subject='[Snake Eyes] Contact', sender=email, recipients=[celery.conf.get('MAIL_USERNAME')], reply_to=email, template='contact/mail/index', ctx=ctx) return None
def app(): """ Setup our flask test app, this only gets executed once. :return: Flask app """ params = { 'DEBUG': False, 'TESTING': True, 'WTF_CSRF_ENABLED': False } _app = create_app(settings_override=params) # Establish an application context before running the tests. ctx = _app.app_context() ctx.push() yield _app ctx.pop()
def app(): """ Setup our flask test app, this only gets executed once. :return: Flask app """ db_uri = '{0}_test'.format(settings.SQLALCHEMY_DATABASE_URI) params = { 'DEBUG': False, 'TESTING': True, 'WTF_CSRF_ENABLED': False, 'SQLALCHEMY_DATABASE_URI': db_uri } _app = create_app(settings_override=params) # Establish an application context before running the tests. ctx = _app.app_context() ctx.push() yield _app ctx.pop()
import click from sqlalchemy_utils import database_exists, create_database from snakeeyes.app import create_app from snakeeyes.extensions import db from snakeeyes.blueprints.contact2.models import Projects # Create an app context for the database connection. app = create_app() db.app = app @click.group() def cli(): """ Run PostgreSQL related tasks. """ pass @click.command() @click.option('--with-testdb3/--no-with-testdb3', default=False, help='Create a test db too?') def init3(with_testdb3): """ Initialize the database. :param with_testdb: Create a test database :return: None """ db.reflect() db.drop_all()
import click from snakeeyes.app import create_app from snakeeyes.extensions import db from snakeeyes.blueprints.billing.gateways.stripecom import Plan as PaymentPlan # Create an app context for the database connection. app = create_app() db.app = app @click.group() def cli(): """ Perform various tasks with Stripe's API. """ pass @click.command() def sync_plans(): """ Sync (upset) STRIPE_PLANS to Stripe. :return: None """ if app.config['STRIPE_PLANS'] is None: return None for _, value in app.config['STRIPE_PLANS'].items(): plan = PaymentPlan.retrieve(value.get('id')) if plan: