Exemplo n.º 1
0
    def provider_add(self, sid):
        form = ServerProviderForm()
        if request.method == 'POST' and form.validate_on_submit():
            provider = ProviderUser.objects(email=form.email.data).first()
            server = ServiceSettings.objects(id=sid).first()
            if server and provider:
                admin = ProviderPair(provider.id, form.role.data)
                server.add_provider(admin)
                provider.add_server(server)
                return jsonify(status='ok'), 200

        return render_template('service/provider/add.html', form=form)
Exemplo n.º 2
0
    def provider_add(self, sid):
        form = ServerProviderForm()
        if request.method == 'POST' and form.validate_on_submit():
            email = form.email.data.lower()
            provider = ProviderUser.get_by_email(email)
            server = ServiceSettings.get_by_id(ObjectId(sid))
            if server and provider:
                admin = ProviderPair(provider.id, form.role.data)
                server.add_provider(admin)
                server.save()

                provider.add_server(server)
                provider.save()
                return jsonify(status='ok'), 200

        return render_template('service/provider/add.html', form=form)