Example #1
0
def leave(env, game_ownership):
    if game_ownership:
        delete = get_or_none(
            env.api.game_ownerships.delete, token=flask_login.current_user.token, game_ownership_id=game_ownership.id)
        if delete and delete.success:
            Flash.success("Successfully leaved game")
    else:
        Flash.error("Unable to leave game")
Example #2
0
def remove_from_friends(env, friendship):
    if friendship:
        result = env.api.friendships.delete(
            token=flask_login.current_user.token, friendship_id=friendship.id)
        if result.ok:
            Flash.success(gettext("Friend removed"))
            return
    Flash.error(gettext("Unable to remove user from friends"))
Example #3
0
def accept_invite(env, friendship_invite):
    if friendship_invite:
        result = env.api.friendship_invites.accept(
            token=flask_login.current_user.token, friendship_invite_id=friendship_invite.id)
        if result.ok:
            Flash.success(gettext("Succesfully accepted invite to friends!"))
            return
    Flash.error(gettext("Unable to accept invitation"))
Example #4
0
def decline_invite(env, friendship_invite):
    if friendship_invite:
        result = env.api.friendship_invites.delete(
            token=flask_login.current_user.token, friendship_invite_id=friendship_invite.id)
        if result.ok:
            Flash.success(gettext("Invitation declined"))
            return
    Flash.success(gettext("Unable to decline invitation"))
Example #5
0
def remove_from_team(env, membership, team):
    if membership:
        response = env.api.team_memberships.delete(team_membership_id=membership.id, token=flask_login.current_user.token)
        if response.ok:
            Flash.success(gettext("Removed %(name)s from %(team)s", name=membership.user.name, team=membership.team.name))
            return flask.redirect(flask.url_for('teams.members_view', team_id=team.id))

    Flash.warning(gettext("Unable to remove user from team."))
    return flask.redirect(flask.url_for('teams.members_view', team_id=team.id))
Example #6
0
def invite_to_friends(env, user):
    me = flask_login.current_user
    result = get_or_500(env.api.friendship_invites.create, token=me.token, from_user_id=me.id, to_user_id=user.id)
    if result:
        Flash.success(gettext("Succesfully invited user to friends!"))
    else:
        Flash.error(gettext("Unable to add user to friends"))
    # TODO - return to referrer
    return flask.redirect(flask.url_for('users.user_view', user_id=user.id))
Example #7
0
def decline_proposition(env, team_proposition):
    # TODO - redicrect to referer
    token = flask_login.current_user.token
    response = env.api.team_propositions.delete(token=token, team_proposition_id=team_proposition.id)
    if response.ok:
        Flash.success(gettext("Operation successfull!"))
    else:
        Flash.error(gettext("Unable to perform operation"))
    return flask.redirect(flask.url_for('teams.teams_view'))
Example #8
0
def propose_user(env, team_id, user_id, type):
    # TODO - return to referrer
    token = flask_login.current_user.token
    response = env.api.team_propositions.create(token=token, team_id=team_id, user_id=user_id, type=type)
    if response.ok:
        if type == TEAM_PROPOSITION_TYPE.INVITE:
            Flash.success(gettext("Successfully invited user to team!"))
        else:
            Flash.success(gettext("Request sent!"))
    else:
        Flash.error("Unable to proceed!")
    return flask.redirect(flask.url_for('teams.team_view', team_id=team_id))
Example #9
0
def join(form):
    if form.validate_on_submit():
        Flash.success(gettext('Successfully updated!'))
        return dict(game_ownership=form.result)
Example #10
0
def change_basic(basic_form):
    if basic_form.validate_on_submit():
        Flash.success(gettext('Successfully changed basic data!'))
Example #11
0
def upload_avatar(avatar_form):
    if avatar_form.validate_on_submit():
        Flash.success("Succesfully updated image!")
Example #12
0
def upload_logo(logo_form):
    if logo_form.validate_on_submit():
        Flash.success(gettext("Logo updated"))
Example #13
0
def change_basic(basic_form):
    if basic_form.validate_on_submit():
        Flash.success(gettext("Team updated"))
Example #14
0
def create_team_view(env):
    form = CreateTeamForm(flask_login.current_user, env.api)
    if form.validate_on_submit():
        Flash.success(gettext("Succesfully created team!"))
        return flask.redirect(flask.url_for('teams.team_view', team_id=form.result.id))
    return dict(form=form)