コード例 #1
0
ファイル: mods.py プロジェクト: CliftonMarien/SpaceDock
def autoupdate(mod_id):
    mod = Mod.query.filter(Mod.id == mod_id).first()
    if not mod:
        abort(404)
    game = Game.query.filter(Game.id == mod.game_id).first()
    session['game'] = game.id;
    session['gamename'] = game.name;
    session['gameshort'] = game.short;
    session['gameid'] = game.id;
    if not mod or not game:
        ga = Game.query.filter(Game.short == 'kerbal-space-program').order_by(desc(Game.id)).first()
        session['game'] = ga.id;
        session['gamename'] = ga.name;
        session['gameshort'] = ga.short;
        session['gameid'] = ga.id;
        abort(404)
    editable = False
    if current_user:
        if current_user.admin:
            editable = True
        if current_user.id == mod.user_id:
            editable = True
        if any([u.accepted and u.user == current_user for u in mod.shared_authors]):
            editable = True
    if not editable:
        abort(401)
    default = mod.default_version()
    default.gameversion_id = GameVersion.query.filter(GameVersion.game_id == mod.game_id).order_by(desc(GameVersion.id)).first().id
    send_autoupdate_notification(mod)
    notify_ckan.delay(mod_id, 'version-update')
    return redirect(url_for("mods.mod", id=mod.id, mod_name=mod.name,ga=game))
コード例 #2
0
ファイル: mods.py プロジェクト: ExtremeSitting/KerbalStuff
def autoupdate(mod_id):
    user = get_user()
    mod = Mod.query.filter(Mod.id == mod_id).first()
    if not mod:
        abort(404)
    editable = False
    if user:
        if user.admin:
            editable = True
        if user.id == mod.user_id:
            editable = True
    if not editable:
        abort(401)
    default = mod.default_version()
    default.ksp_version = GameVersion.query.order_by(desc(GameVersion.id)).first().friendly_version
    send_autoupdate_notification(mod)
    return redirect("/mod/" + mod_id)
コード例 #3
0
ファイル: mods.py プロジェクト: GenPage/KerbalStuff
def autoupdate(mod_id):
    mod = Mod.query.filter(Mod.id == mod_id).first()
    if not mod:
        abort(404)
    editable = False
    if current_user:
        if current_user.admin:
            editable = True
        if current_user.id == mod.user_id:
            editable = True
        if any([u.accepted and u.user == current_user for u in mod.shared_authors]):
            editable = True
    if not editable:
        abort(401)
    default = mod.default_version()
    default.ksp_version = GameVersion.query.order_by(desc(GameVersion.id)).first().friendly_version
    send_autoupdate_notification(mod)
    return redirect(url_for("mods.mod", id=mod.id, mod_name=mod.name))
コード例 #4
0
def autoupdate(mod_id):
    mod = Mod.query.filter(Mod.id == mod_id).first()
    if not mod:
        abort(404)
    editable = False
    if current_user:
        if current_user.admin:
            editable = True
        if current_user.id == mod.user_id:
            editable = True
        if any([u.accepted and u.user == current_user for u in mod.shared_authors]):
            editable = True
    if not editable:
        abort(401)
    default = mod.default_version()
    default.ksp_version = GameVersion.query.order_by(desc(GameVersion.id)).first().friendly_version
    send_autoupdate_notification(mod)
    return redirect(url_for("mods.mod", id=mod.id, mod_name=mod.name))
コード例 #5
0
def autoupdate(mod_id):
    mod = Mod.query.filter(Mod.id == mod_id).first()
    if not mod:
        abort(404)
    game = Game.query.filter(Game.id == mod.game_id).first()
    session['game'] = game.id
    session['gamename'] = game.name
    session['gameshort'] = game.short
    session['gameid'] = game.id
    if not mod or not game:
        ga = Game.query.filter(Game.short == 'kerbal-space-program').order_by(
            desc(Game.id)).first()
        session['game'] = ga.id
        session['gamename'] = ga.name
        session['gameshort'] = ga.short
        session['gameid'] = ga.id
        abort(404)
    editable = False
    if current_user:
        if current_user.admin:
            editable = True
        if current_user.id == mod.user_id:
            editable = True
        if any([
                u.accepted and u.user == current_user
                for u in mod.shared_authors
        ]):
            editable = True
    if not editable:
        abort(401)
    default = mod.default_version()
    default.gameversion_id = GameVersion.query.filter(
        GameVersion.game_id == mod.game_id).order_by(desc(
            GameVersion.id)).first().id
    send_autoupdate_notification(mod)
    notify_ckan.delay(mod_id, 'version-update')
    return redirect(url_for("mods.mod", id=mod.id, mod_name=mod.name, ga=game))