示例#1
0
def create_version():
    """Create a version"""
    controller = VersionController
    return controller.create(MySQLFactory.get())
示例#2
0
def get_games():
    """Get the games"""
    controller = GameController
    return controller.get_list(MySQLFactory.get())
示例#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)
示例#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)
示例#5
0
def authenticate_user():
    """Returns the token of the given user"""
    controller = UserController
    return controller.authenticate(MySQLFactory.get())
示例#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)
示例#7
0
def delete_copy(entity_id):
    """Delete the copy according to its id"""
    controller = CopyController
    return controller.delete(MySQLFactory.get(), entity_id)
示例#8
0
def create_platform():
    """Create a platform"""
    controller = PlatformController
    return controller.create(MySQLFactory.get())
示例#9
0
def delete_platform(entity_id):
    """Delete the platform according to its id"""
    controller = PlatformController
    return controller.delete(MySQLFactory.get(), entity_id)
示例#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)
示例#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)
示例#12
0
def update_user(entity_id):
    """Updates a user"""
    controller = UserController
    return controller.update(MySQLFactory.get(), entity_id)
示例#13
0
def create_user():
    """Creates a user"""
    controller = UserController
    return controller.create(MySQLFactory.get())
示例#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', ''))
示例#15
0
def delete_version(entity_id):
    """Delete the version according to its id"""
    controller = VersionController
    return controller.delete(MySQLFactory.get(), entity_id)
示例#16
0
def get_platforms():
    """Get the platforms"""
    controller = PlatformController
    return controller.get_list(MySQLFactory.get())
示例#17
0
def get_versions():
    """Get the versions"""
    controller = VersionController
    return controller.get_list(MySQLFactory.get())
示例#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)
示例#19
0
def create_copy():
    """Create a copy"""
    controller = CopyController
    return controller.create(MySQLFactory.get())
示例#20
0
def create_game():
    """Create a game"""
    controller = GameController
    return controller.create(MySQLFactory.get())
示例#21
0
def get_copies():
    """Get the copies"""
    controller = CopyController
    return controller.get_list(MySQLFactory.get())
示例#22
0
def delete_game(entity_id):
    """Delete the game according to its id"""
    controller = GameController
    return controller.delete(MySQLFactory.get(), entity_id)
示例#23
0
def create_story():
    """Create a story"""
    controller = StoryController
    return controller.create(MySQLFactory.get())
示例#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']