示例#1
0
def challenge(other=None):
    own_ais = AI.filtered().filter(AI.user == current_user).order_by(
        AI.last_modified.desc()).all()

    if len(own_ais) < 1:
        return error(403, body="Du hast nicht genug eigene KIs.")

    own_ais = [ai for ai in own_ais if ai.latest_frozen_version()]
    # TODO: ki workflow verbessern

    if len(own_ais) < 1:
        return error(
            403,
            body="Du hast keine KIs deren letzte Version freigegeben ist.")

    all_ais = AI.filtered().order_by(AI.id).all()
    if len(all_ais) < 2:
        return error(403, body="Es gibt noch nicht genug KIs.")

    all_ais = [ai for ai in all_ais if ai.latest_frozen_version()]
    if len(all_ais) < 2:
        return error(403, body="Es gibt nicht genug freigegebene KIs.")
    #roles = ["Rolle"+str(i) for i, r in enumerate(gametype.roles)]
    return render_template("challenge.html",
                           own=own_ais,
                           all=all_ais,
                           ownfirst=own_ais[0],
                           allfirst=all_ais[0])
示例#2
0
def ai_list():
	ais = AI.filtered().all()
	ais = [ai for ai in ais if ai.active_version()]
	if len(ais) == 0:
		flash("Es gibt keine KIs des aktuellen Spieltypen!")
		abort(403)
	if current_user and current_user.is_authenticated:
		data = [ai for ai in AI.filtered() if ai.user == current_user and ai.active_version()]
		if len(data):
			return render_template("ai_list.html", ais=ais, type=ais[0].type,
		                           own=data, own_user_id=current_user.id)
	return render_template("ai_list.html", ais=ais, type=ais[0].type)
示例#3
0
def create_ai():
    ai = AI(user=current_user,
            name="Unbenannte KI",
            desc="Unbeschriebene KI",
            lang=Lang.query.first(),
            type=GameType.selected())
    db.session.commit()
    return redirect(url_for("authenticated.edit_ai", id=ai.id))
示例#4
0
def current_profile():
    user = current_user
    ais = AI.filtered().filter(AI.user == user).all()
    columns = [ais[i:i + 3] for i in range(0, len(ais), 3)]
    return render_template("profile.html",
                           columns=columns,
                           user=user,
                           gametype=GameType.selected())
示例#5
0
def ai_list():
    ais = AI.filtered().all()
    ais = [ai for ai in ais if ai.active_version()]
    if len(ais) == 0:
        flash("Es gibt keine KIs des aktuellen Spieltypen!")
        abort(403)
    if current_user and current_user.is_authenticated:
        data = [
            ai for ai in AI.filtered()
            if ai.user == current_user and ai.active_version()
        ]
        if len(data):
            return render_template("ai_list.html",
                                   ais=ais,
                                   type=ais[0].type,
                                   own=data,
                                   own_user_id=current_user.id)
    return render_template("ai_list.html", ais=ais, type=ais[0].type)
示例#6
0
def profile_id(id):
    user = User.query.get(id)
    if not user:
        abort(404)
    if not current_user.can_access(user):
        abort(403)

    ais = AI.filtered().filter(AI.user == user).all()
    columns = [ais[i : i + 3] for i in range(0, len(ais), 3)]
    return render_template("profile.html", columns=columns, user=user, gametype=GameType.selected())
示例#7
0
def challenge(other=None):
    own_ais = AI.filtered().filter(AI.user == current_user).order_by(AI.last_modified.desc()).all()

    if len(own_ais) < 1:
        return error(403, body="Du hast nicht genug eigene KIs.")

    own_ais = [ai for ai in own_ais if ai.latest_frozen_version()]
    # TODO: ki workflow verbessern

    if len(own_ais) < 1:
        return error(403, body="Du hast keine KIs deren letzte Version freigegeben ist.")

    all_ais = AI.filtered().order_by(AI.id).all()
    if len(all_ais) < 2:
        return error(403, body="Es gibt noch nicht genug KIs.")

    all_ais = [ai for ai in all_ais if ai.latest_frozen_version()]
    if len(all_ais) < 2:
        return error(403, body="Es gibt nicht genug freigegebene KIs.")
        # roles = ["Rolle"+str(i) for i, r in enumerate(gametype.roles)]
    return render_template("challenge.html", own=own_ais, all=all_ais, ownfirst=own_ais[0], allfirst=all_ais[0])
示例#8
0
def profile_id(id):
    user = User.query.get(id)
    if not user:
        abort(404)
    if not current_user.can_access(user):
        abort(403)

    ais = AI.filtered().filter(AI.user == user).all()
    columns = [ais[i:i + 3] for i in range(0, len(ais), 3)]
    return render_template("profile.html",
                           columns=columns,
                           user=user,
                           gametype=GameType.selected())
示例#9
0
def current_profile():
    user = current_user
    ais = AI.filtered().filter(AI.user == user).all()
    columns = [ais[i : i + 3] for i in range(0, len(ais), 3)]
    return render_template("profile.html", columns=columns, user=user, gametype=GameType.selected())