Пример #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 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())
Пример #4
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)
Пример #5
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())
Пример #6
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])
Пример #7
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())
Пример #8
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())