示例#1
0
def route_community_guild(id):
    guild = Guild.query.filter(Guild.id == id).first()
    members = GuildMembership.query.filter(
        GuildMembership.guild_id == guild.id).all()
    invites = GuildInvite.query.filter(GuildInvite.guild_id == guild.id).all()
    wars = GuildWar.query.filter(
        or_(GuildWar.guild1 == id, GuildWar.guild2 == id)).filter(
            GuildWar.status == GuildWar.Active).all()

    user = current_user()
    if user:
        ids = []
        for player in user.players:
            ids.append(player.id)

        for invite in invites:
            if invite.player_id in ids:
                invite.own = True

        for member in members:
            if member.player_id in ids:
                member.own = True

    return render_template('community/guilds/view.htm',
                           guild=guild,
                           members=members,
                           invites=invites,
                           leader=is_guild_leader(id),
                           vice=is_guild_vice(id),
                           wars=wars)
示例#2
0
def route_community_guild_invite_post(id):
	if not is_guild_vice(id):
		return redirect(url_for('route_community_guild', id=id))

	name = request.form.get('name', '', type=str)
	error = False

	player = Player.query.filter(Player.name == name).first()
	if not player:
		flash('The player you are trying to invite does not exist.', 'error')
		return redirect(url_for('route_community_guild', id=id))

	membership = GuildMembership.query.filter(GuildMembership.guild_id == id).filter(GuildMembership.player_id == player.id).first()
	if membership:
		flash('The player is already a member of your guild.', 'error')
		error = True

	invite = GuildInvite.query.filter(GuildInvite.guild_id == id).filter(GuildInvite.player_id == player.id).first()
	if invite:
		flash('The player is already invited to your guild.', 'error')
		error = True

	if not error:
		invite = GuildInvite()
		invite.player_id = player.id
		invite.guild_id = id

		db.session().add(invite)
		db.session().commit()

		flash('The player has been invited.', 'success')

	return redirect(url_for('route_community_guild', id=id))
示例#3
0
def route_community_guild_kick(id):
	if not is_guild_vice(id):
		return redirect(url_for('route_community_guild', id=id))

	ranks = []
	for rank in GuildRank.query.filter(GuildRank.guild_id == id).all():
		ranks.append(rank.id)

	if len(ranks):
		members = GuildMembership.query.filter(GuildMembership.guild_id == id).filter(GuildMembership.rank_id.notin_(ranks)).all()
	else:
		members = []

	return render_template('community/guilds/kick.htm', id=id, members=members)
示例#4
0
def route_community_guild_kick_post(id):
	if not is_guild_vice(id):
		return redirect(url_for('route_community_guild', id=id))

	player = request.form.get('id', 0, type=int)
	membership = GuildMembership.query.filter(GuildMembership.guild_id).filter(GuildMembership.player_id == player).first()
	if not membership:
		return redirect(url_for('route_community_guild', id=id))

	db.session().delete(membership)
	db.session().commit()

	flash('The player has been kicked from the guild.', 'success')

	return redirect(url_for('route_community_guild', id=id))
示例#5
0
def route_community_guild_kick_post(id):
    if not is_guild_vice(id):
        return redirect(url_for('route_community_guild', id=id))

    player = request.form.get('id', 0, type=int)
    membership = GuildMembership.query.filter(GuildMembership.guild_id).filter(
        GuildMembership.player_id == player).first()
    if not membership:
        return redirect(url_for('route_community_guild', id=id))

    db.session().delete(membership)
    db.session().commit()

    flash('The player has been kicked from the guild.', 'success')

    return redirect(url_for('route_community_guild', id=id))
示例#6
0
def route_community_guild_kick(id):
    if not is_guild_vice(id):
        return redirect(url_for('route_community_guild', id=id))

    ranks = []
    for rank in GuildRank.query.filter(GuildRank.guild_id == id).all():
        ranks.append(rank.id)

    if len(ranks):
        members = GuildMembership.query.filter(
            GuildMembership.guild_id == id).filter(
                GuildMembership.rank_id.notin_(ranks)).all()
    else:
        members = []

    return render_template('community/guilds/kick.htm', id=id, members=members)
示例#7
0
def route_community_guild_invite_post(id):
    if not is_guild_vice(id):
        return redirect(url_for('route_community_guild', id=id))

    name = request.form.get('name', '', type=str)
    error = False

    player = Player.query.filter(Player.name == name).first()
    if not player:
        flash('The player you are trying to invite does not exist.', 'error')
        return redirect(url_for('route_community_guild', id=id))

    membership = GuildMembership.query.filter(
        GuildMembership.guild_id == id).filter(
            GuildMembership.player_id == player.id).first()
    if membership:
        flash('The player is already a member of your guild.', 'error')
        error = True

    invite = GuildInvite.query.filter(GuildInvite.guild_id == id).filter(
        GuildInvite.player_id == player.id).first()
    if invite:
        flash('The player is already invited to your guild.', 'error')
        error = True

    if not error:
        invite = GuildInvite()
        invite.player_id = player.id
        invite.guild_id = id

        db.session().add(invite)
        db.session().commit()

        flash('The player has been invited.', 'success')

    return redirect(url_for('route_community_guild', id=id))
示例#8
0
def route_community_guild(id):
	guild = Guild.query.filter(Guild.id == id).first()
	members = GuildMembership.query.filter(GuildMembership.guild_id == guild.id).all()
	invites = GuildInvite.query.filter(GuildInvite.guild_id == guild.id).all()
	wars = GuildWar.query.filter(or_(GuildWar.guild1 == id, GuildWar.guild2 == id)).filter(GuildWar.status == GuildWar.Active).all()

	user = current_user()
	if user:
		ids = []
		for player in user.players:
			ids.append(player.id)

		for invite in invites:
			if invite.player_id in ids:
				invite.own = True

		for member in members:
			if member.player_id in ids:
				member.own = True

	return render_template(
		'community/guilds/view.htm', guild=guild, members=members, invites=invites,
		leader=is_guild_leader(id), vice=is_guild_vice(id), wars=wars
	)
示例#9
0
def route_community_guild_invite(id):
    if not is_guild_vice(id):
        return redirect(url_for('route_community_guild', id=id))

    return render_template('community/guilds/invite.htm', id=id)
示例#10
0
def route_community_guild_invite(id):
	if not is_guild_vice(id):
		return redirect(url_for('route_community_guild', id=id))

	return render_template('community/guilds/invite.htm', id=id)