예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
def delete_service(srvid):
    """
    Used to delete an existing service
    """
    
    srv = Services.get({"_id":srvid})
    srv.delete()

    return redirect(request.referrer)
예제 #4
0
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)