Esempio n. 1
0
def adm_delete_gameaccount(request, account_id):
    """Delete an InGame Account from admin panel"""

    gameaccount = GameAccount.query.get(account_id)
    if gameaccount is None:
        raise NotFound()
    form = DeleteGameAccountForm(gameaccount)

    if request.method == 'POST':
        if request.form.get('cancel'):
            return form.redirect('admin/edit_user', user_id=gameaccount.user.id)
        elif request.form.get('confirm') and form.validate(request.form):
            account = str(gameaccount.account)
            form.delete_account()
            db.commit()
            admin_flash(_('The game account %s was deleted successfully') % account, 'remove')
            return redirect_to('admin/edit_user', user_id=gameaccount.user.id)

    return render_admin_response('admin/gameaccount_delete.html', 'users_groups.users',
                                 form=form.as_widget())
Esempio n. 2
0
def acc_delete_gameaccount(request, account_id):
    """Delete an InGame Account from user-account panel"""

    gameaccount = GameAccount.query.get(account_id)
    if gameaccount is None:
        raise NotFound()
    form = DeleteGameAccountForm(gameaccount)
    if gameaccount.user != request.user:
        raise Forbidden()

    if request.method == 'POST':
        if request.form.get('cancel'):
            return form.redirect('account/gameaccounts')
        elif request.form.get('confirm') and form.validate(request.form):
            accountname = str(gameaccount.account)
            form.delete_account()
            db.commit()
            account_flash(_('The game account %s was deleted successfully') % accountname, 'remove')
            return redirect_to('account/gameaccounts')

    return render_account_response('account/gameaccount_delete.html', 'gameaccounts',
                                   form=form.as_widget())