示例#1
0
def create_test_models():
    from application.config.development import Config
    app.config.from_object(Config)
    init_database(app)

    salt = str(generator_salt())
    role1 = Role(name='admin')
    db.session.add(role1)

    user1 = User(email='admin', name='Admin', password=auth.encrypt_password('123456',salt), active=1, salt = salt)
    user1.roles.append(role1)
    db.session.add(user1)

    user2 = User(email='tw', name='Ban chỉ đạo TW', password=auth.encrypt_password('123456',salt), active=1, salt = salt)
    user2.roles.append(role1)
    db.session.add(user2)

    db.session.flush()
    db.session.commit()
示例#2
0
def add_tuyendonvi():
    #add  tuyen don vi
    from application.config.development import Config
    app.config.from_object(Config)
    init_database(app)
    try:
        SITE_ROOT = os.path.realpath(os.path.dirname(__file__))
        json_url_tuyendonvi = os.path.join(SITE_ROOT, "application/data", "TuyenDonViEnum.json")
        data_tuyendonvi = json.load(open(json_url_tuyendonvi))
        for item_tuyendonvi in data_tuyendonvi:
            print("tuyendonvi>>>",item_tuyendonvi)
            tuyendonvi_filter = db.session.query(TuyenDonVi).filter(TuyenDonVi.ma == item_tuyendonvi["value"]).first()
            if tuyendonvi_filter is None:
                tuyendonvi = TuyenDonVi()
                tuyendonvi.id = item_tuyendonvi["value"]
                tuyendonvi.ma = item_tuyendonvi["value"]
                tuyendonvi.ten = item_tuyendonvi.get('text', None)
                tuyendonvi.tenkhongdau = convert_text_khongdau(tuyendonvi.ten)
                db.session.add(tuyendonvi)
                db.session.commit()
    except Exception as e:
        print("TUYEN DON VI ERROR",e)
示例#3
0
""" App entry point. """

from gatco import Gatco
from gatco.sessions import CookieSessionInterface
from .config import Config

app = Gatco(name=__name__)
app.session_interface = CookieSessionInterface()
app.config.from_object(Config)

from application.database import init_database
from application.extensions import init_extensions
from application.controllers import init_views

static_endpoint = app.config.get("STATIC_URL", None)
if (static_endpoint
        is not None) and not ((static_endpoint.startswith('http://') or
                               (static_endpoint.startswith('https://')))):
    app.static(static_endpoint, './static')

init_database(app)
init_extensions(app)
init_views(app)