def delete_imaccount(request, account_id, user_id=None): """Delete an Instant Messenger Account from admin panel""" imaccount = IMAccount.query.get(account_id) if imaccount is None: raise NotFound() form = DeleteIMAccountForm(imaccount) if request.method == 'POST': if request.form.get('cancel'): return form.redirect('admin/edit_user', user_id=imaccount.user.id) elif request.form.get('confirm') and form.validate(request.form): account = str(imaccount.account) user_id = imaccount.user.id form.delete_account() db.commit() flash(_('IM account %s was deleted successfully') % account, 'remove') return form.redirect('admin/edit_user', user_id=user_id) return render_admin_response('admin/imaccount_delete.html', 'users_groups.users', form=form.as_widget())
def imaccount_delete(request, account_id): """Delete an InGame Account from user-account panel""" imaccount = IMAccount.query.get(account_id) if imaccount is None: raise NotFound() if imaccount.user != request.user: raise Forbidden() form = DeleteIMAccountForm(imaccount) if request.method == 'POST': if request.form.get('cancel'): return form.redirect('account/imaccount_list') elif request.form.get('confirm') and form.validate(request.form): accountname = str(imaccount.account) form.delete_account() db.commit() flash(_('IM account %s was deleted successfully') % accountname, 'remove') return redirect_to('account/imaccount_list') return render_account_response('account/imaccount_delete.html', 'imaccounts', form=form.as_widget())