Exemplo n.º 1
0
def create_version():
    """Create a version"""
    controller = VersionController
    return controller.create(MySQLFactory.get())
Exemplo n.º 2
0
def get_games():
    """Get the games"""
    controller = GameController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 3
0
def get_version_by_id(entity_id):
    """Returns the version according to its id"""
    controller = VersionController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 4
0
def get_story_by_id(entity_id):
    """Returns the story according to its id"""
    controller = StoryController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 5
0
def authenticate_user():
    """Returns the token of the given user"""
    controller = UserController
    return controller.authenticate(MySQLFactory.get())
Exemplo n.º 6
0
def get_copy_by_id(entity_id):
    """Returns the copy according to its id"""
    controller = CopyController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 7
0
def delete_copy(entity_id):
    """Delete the copy according to its id"""
    controller = CopyController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 8
0
def create_platform():
    """Create a platform"""
    controller = PlatformController
    return controller.create(MySQLFactory.get())
Exemplo n.º 9
0
def delete_platform(entity_id):
    """Delete the platform according to its id"""
    controller = PlatformController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 10
0
def renew_token(current_user):
    """Renew the API token of the current user"""
    controller = UserController
    return controller.renew_token(MySQLFactory.get(), current_user)
Exemplo n.º 11
0
def get_platform_by_id(entity_id):
    """Returns the platform according to its id"""
    controller = PlatformController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 12
0
def update_user(entity_id):
    """Updates a user"""
    controller = UserController
    return controller.update(MySQLFactory.get(), entity_id)
Exemplo n.º 13
0
def create_user():
    """Creates a user"""
    controller = UserController
    return controller.create(MySQLFactory.get())
Exemplo n.º 14
0
def get_user():
    """Returns the user according to one filter"""
    controller = UserController
    return controller.get_by_filter(MySQLFactory.get(),
                                    request.args.get('filter', ''),
                                    request.args.get('value', ''))
Exemplo n.º 15
0
def delete_version(entity_id):
    """Delete the version according to its id"""
    controller = VersionController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 16
0
def get_platforms():
    """Get the platforms"""
    controller = PlatformController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 17
0
def get_versions():
    """Get the versions"""
    controller = VersionController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 18
0
def get_game_by_id(entity_id):
    """Returns the game according to its id"""
    controller = GameController
    return controller.get_by_id(MySQLFactory.get(), entity_id)
Exemplo n.º 19
0
def create_copy():
    """Create a copy"""
    controller = CopyController
    return controller.create(MySQLFactory.get())
Exemplo n.º 20
0
def create_game():
    """Create a game"""
    controller = GameController
    return controller.create(MySQLFactory.get())
Exemplo n.º 21
0
def get_copies():
    """Get the copies"""
    controller = CopyController
    return controller.get_list(MySQLFactory.get())
Exemplo n.º 22
0
def delete_game(entity_id):
    """Delete the game according to its id"""
    controller = GameController
    return controller.delete(MySQLFactory.get(), entity_id)
Exemplo n.º 23
0
def create_story():
    """Create a story"""
    controller = StoryController
    return controller.create(MySQLFactory.get())
Exemplo n.º 24
0
app = Flask(__name__)
app.config['JSON_SORT_KEYS'] = False

##############
# Load config
##############

with open('configuration.json', encoding='UTF-8') as json_file:
    configurationData = json.load(json_file)

################
# DB connection
################

MySQLFactory.init(configurationData['db_host'], configurationData['db_user'],
                  configurationData['db_password'],
                  configurationData['database'])

##################
# User management
##################


def token_required(decorated_function):
    @wraps(decorated_function)
    def decorator(*args, **kwargs):

        token = None

        if 'Authorization' in request.headers:
            header_value = request.headers['Authorization']