Example #1
0
    def playlist(self, sid):
        server = ServiceSettings.get_by_id(ObjectId(sid))
        if server:
            return Response(server.generate_playlist(),
                            mimetype='application/x-mpequrl'), 200

        return jsonify(status='failed'), 404
Example #2
0
    def remove(self):
        sid = request.form['sid']
        server = ServiceSettings.get_by_id(ObjectId(sid))
        if server:
            server.delete()
            return jsonify(status='ok'), 200

        return jsonify(status='failed'), 404
Example #3
0
    def edit(self, sid):
        server = ServiceSettings.get_by_id(ObjectId(sid))
        form = ServiceSettingsForm(obj=server)

        if request.method == 'POST' and form.validate_on_submit():
            server = form.update_entry(server)
            server.save()
            return jsonify(status='ok'), 200

        return render_template('service/edit.html', form=form)
Example #4
0
    def provider_remove(self, sid):
        data = request.get_json()
        pid = data['pid']
        provider = ProviderUser.get_by_id(ObjectId(pid))
        server = ServiceSettings.get_by_id(ObjectId(sid))
        if provider and server:
            server.remove_provider(provider)
            server.save()

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

        return jsonify(status='failed'), 404
Example #5
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)
Example #6
0
    def providers(self, sid):
        server = ServiceSettings.get_by_id(ObjectId(sid))
        if server:
            return render_template('service/providers.html', server=server)

        return redirect(url_for('ProviderView:dashboard'))