Esempio n. 1
0
def db_worker(mode):
    with app.app_context():
        if mode == 'init':
            app.config['DB_NAME'] = 'projects_test'
            create_database()
        elif mode == 'drop':
            drop_database()
Esempio n. 2
0
 def setUp(self):
     self.client = app.test_client()
     app.config['DB_NAME'] = 'test_api'
     with app.app_context():
         create_database()
Esempio n. 3
0
def drop_db():
    with app.app_context():
        drop_database()
Esempio n. 4
0
def init_db():
    with app.app_context():
        create_database()
Esempio n. 5
0
 def setUp(self) -> None:
     self.client = app.test_client()
     app.config['DB_NAME'] = 'projects_test'
     with app.app_context():
         create_database()
Esempio n. 6
0
from core.objects import Donation, DonationType
from core.database import db
from core.config import _cfg
from core.emails import send_thank_you, send_declined
from core.app import app
from flask_babel import _, ngettext

from datetime import datetime, timedelta
from babel.dates import format_date, format_time

import requests
import stripe
import subprocess

with app.app_context():

    stripe.api_key = _cfg("stripe-secret")

    date = format_date(datetime.now(), locale=_cfg("locale"))
    time = format_time(datetime.now(), locale=_cfg("locale"))
    print(_("Processing monthly donations on"), date, time)

    donations = (Donation.query.filter(
        Donation.type == DonationType.monthly).filter(Donation.active).all())

    limit = datetime.now() - timedelta(days=30)

    for donation in donations:
        if donation.updated < limit:
            print(_("Charging {}").format(donation))