def remove(self): servers = ServiceSettings.objects() for server in servers: server.remove_user(current_user.id) current_user.delete() return redirect(url_for('HomeView:index'))
def remove(self): sid = request.form['sid'] server = ServiceSettings.objects(id=sid).first() if server: return _remove_server(server) return jsonify(status='failed'), 404
def remove(self): sid = request.form['sid'] server = ServiceSettings.objects(id=sid).first() if server: server.delete() return jsonify(status='ok'), 200 return jsonify(status='failed'), 404
def edit(self, sid): server = ServiceSettings.objects(id=sid).first() form = ServiceSettingsForm(request.form, obj=server) if request.method == 'POST' and form.validate_on_submit(): form.save() return jsonify(status='ok'), 200 return render_template('service/edit.html', form=form)
def user_add(self, sid): form = UserServerForm() if request.method == 'POST' and form.validate_on_submit(): user = User.objects(email=form.email.data).first() server = ServiceSettings.objects(id=sid).first() if server and user: admin = UserPair(user.id, form.role.data) server.add_user(admin) user.add_server(server) return jsonify(status='ok'), 200 return render_template('service/user/add.html', form=form)
def edit(self, sid): server = ServiceSettings.objects(id=sid).first() if server: return _edit_service(request.method, server) return jsonify(status='failed'), 404