def deactivate_service(srvid): """ Used through AJAX to deactivate a service """ srv = Services.get({"_id":srvid}) srv.update({"$set":{srv.active.dbfield:False}}) return redirect(request.referrer)
def activate_service(srvid): """ Used through AJAX to activate an existing service """ srv = Services.get({"_id":srvid}) srv.update({"$set":{srv.active.dbfield:True}}) return redirect(request.referrer)
def delete_service(srvid): """ Used to delete an existing service """ srv = Services.get({"_id":srvid}) srv.delete() return redirect(request.referrer)
def edit_service(srvid): """ Used to edit a registered service """ class F(ServiceForm): pass srv = Services.get({"_id":srvid}) form = ServiceForm() if form.validate_on_submit(): try: srv.populate_from_form(form) print request.form srv.authentication.value = {"db":request.form.get('authdb'),"user":request.form.get('authuser'),"pswd":request.form.get("authpass")} srv.save() flash('Datele au fost modificate!', category='alert-success') return redirect(url_for('services.list_services')) except Exception as err: flash('Modificarile nu pot fi salvate!', category='alert-danger') if srv.authentication.value: if srv.authentication.value['db']: F.authdb = StringField(label="Db autentificare") if srv.authentication.value['user']: F.authuser = StringField(label="User") F.authpass = StringField(label="Parola") F.submit = SubmitField('Salveaza') form = srv.fill_form(_form=F()) del form.authentication if srv.authentication.value: if srv.authentication.value['db']: form.authdb.data = srv.authentication.value['db'] if srv.authentication.value['user']: form.authuser.data = srv.authentication.value['user'] form.authpass.data = srv.authentication.value['pswd'] return render_template('services/settings/edit.html', pagetitle='Detalii serviciu', form=form)