示例#1
0
    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'))
示例#2
0
    def remove(self):
        sid = request.form['sid']
        server = ServiceSettings.objects(id=sid).first()
        if server:
            return _remove_server(server)

        return jsonify(status='failed'), 404
示例#3
0
    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
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    def edit(self, sid):
        server = ServiceSettings.objects(id=sid).first()
        if server:
            return _edit_service(request.method, server)

        return jsonify(status='failed'), 404