init_employees(app)
    init_ping(app)
    init_products(app)
    init_sales_invoices(app)
    init_shifts(app)
    init_packings(app)
    init_users(app)
    init_reciprocal_payments(app)

    from expedition_merman_wrapper.apps.events.handler_task import (  # noqa F401
        events_handler_task)

    db.init_app(app)

    if BaseConfig.SWAGGER_ENABLED:
        Swagger(app)

    if app.config.get('SENTRY_DSN'):
        sentry_sdk.init(dsn=app.config.get('SENTRY_DSN'),
                        integrations=[FlaskIntegration()])

    celery.conf.update(app.config)

    getcontext().prec = 2

    return app


BigIntegerType = db.BigInteger()
BigIntegerType = BigIntegerType.with_variant(sqlite.INTEGER(), 'sqlite')
Beispiel #2
0
from datetime import datetime
import string
import random

from flask_sqlalchemy import SQLAlchemy

import common.constants as constants

db = SQLAlchemy()

# Association of users to permissions
permissions = db.Table('permissions',
                       db.Column('permission_id', db.Integer(), db.ForeignKey('user_permission.id')),
                       db.Column('user_id', db.BigInteger(), db.ForeignKey('user.id')))


class User(db.Model):
    """A user representation in the database, linked to a Steam ID.

    Attributes:
        id: Unique Steam Id (as 64 bits).
        nickname: Unique nickname of the user, None when not setup.
        avatar: URL of the user avatar in steam, updated at each login (small).
        avatar_medium: URL of the user avatar in steam, updated at each login (medium).
        avatar_full: URL of the user avatar in steam, updated at each login (full).

        verified: Boolean True if the user is known in the community with this username.
        ban_date: Date the user is ban to.

        current_match: match_id of the match the user is currently in.
        solo_mmr: player solo mmr updated after a scan.
Beispiel #3
0
import uuid
from datetime import datetime
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.dialects.postgresql import UUID

db = SQLAlchemy()
PK_TYPE = db.BigInteger().with_variant(db.Integer, "sqlite")


class GUID(db.TypeDecorator):
    """Platform-independent GUID type.

    Uses PostgreSQL's UUID type, otherwise uses
    CHAR(32), storing as stringified hex values.

    """
    impl = db.CHAR

    def load_dialect_impl(self, dialect):
        if dialect.name == 'postgresql':
            return dialect.type_descriptor(UUID())
        else:
            return dialect.type_descriptor(db.CHAR(32))

    def process_bind_param(self, value, dialect):
        if value is None:
            return value
        elif dialect.name == 'postgresql':
            return str(value)
        else:
            if not isinstance(value, uuid.UUID):