def PUT(self): x = web.input() master = models.Master.get(id=x.get('master_id')) if not master: return web.notfound() form = LocalParamForm() if form.validates(): idlocal = form.d.idlocal values = form.d del values['idlocal'] del values['save'] del values['ab_source'] if not int(idlocal): localparam = models.LocalParam.create(**values) master.idlocala = localparam.id return simplejson.dumps([{'val': localparam.id, 'idx': models.LocalParam.all().count() + 1, 'selected': True}]) else: models.LocalParam.update(id=idlocal, values=values) localparam = models.LocalParam.get(id=idlocal) master.idlocala = localparam.id return simplejson.dumps([])
def POST(self, name, glyphid): if not is_loggedin(): raise seeother('/login') master = models.Master.get(fontname=name) if not master: return web.notfound() x = web.input(idlocal_changed=False, idglobal_changed=False, ab_source='a') form = LocalParamForm() if x.idlocal_changed: # if dropdown value in form has been changed so just refresh # data in selected form attrs = Settings.get_local_params(x.idlocal_changed, x.ab_source) return simplejson.dumps(attrs) elif x.idglobal_changed: params = models.GlobalParam.get(idglobal=x.idglobal_changed) return simplejson.dumps(params.as_dict()) if 'ab_source' in form.d and form.validates(): idlocal = form.d.idlocal fontsource = form.d.ab_source models.Master.update(idmaster=master.idmaster, values={'idlocal{0}'.format(fontsource.lower()): idlocal}) master = models.Master.get(fontname=name) values = form.d del values['ab_source'] del values['save'] del values['idlocal'] models.LocalParam.update(idlocal=idlocal, values=values) formg = GlobalParamForm() if formg.validates(): idglobal = formg.d.idglobal models.Master.update(idmaster=master.idmaster, values={'idglobal': idglobal}) master = models.Master.get(fontname=name) values = formg.d del values['idglobal'] del values['save'] models.GlobalParam.update(idglobal=idglobal, values=values) writeGlyphlist(master, glyphid) if model.writeGlobalParam(master): makefont(working_dir(), master) raise seeother('/view/{0}/{1}/settings/'.format(master.fontname, glyphid))