Пример #1
0
from flask import current_app
from flask.ext.script import Manager, prompt_bool
from cons import create_app

from cons.extensions import SQLAlchemy
from cons.models import User, Video, Stats

app = create_app('cons')
manager = Manager(app)

db = SQLAlchemy()


@manager.command
def create_user(name, email, password, brokernum=None):
    """
    Will create a user from supplied cli arguments.
    Since 'create_user' knows to check for an existing user first
    this will not create more than one of the same users.
    """

    try:
        user = User(name, email, password, brokernum)
        db.session.add(user)

        count = 0
        for v in db.session.query(Video).all():
            count += 1
            s = Stats(user, v)
            s.watched = 0
Пример #2
0
import sys
import os

here = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, here)

from cons import create_app

application = create_app('cons')