Ejemplo n.º 1
0
    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))
Ejemplo n.º 2
0
    def POST(self, id):
        gm = models.GlobalParam.get(id=id)
        if not gm:
            return web.notfound()

        formg = GlobalParamForm()
        if formg.validates():
            values = formg.d
            del values['idglobal']
            del values['save']

            models.GlobalParam.update(id=id, values=values)
            return seeother('/settings/globals/')

        gml = models.GlobalParam.all()
        return render.globals(gml, formg)
Ejemplo n.º 3
0
    def POST(self, id):
        if not is_loggedin():
            raise seeother('/login')

        gm = list(model.get_globalparam(id))
        if not gm:
            return web.notfound()

        formg = GlobalParamForm()
        if formg.validates():
            model.update_globalparam(id, formg.d.metapolation, formg.d.fontsize,
                                     formg.d.mean, formg.d.cap, formg.d.ascl,
                                     formg.d.des, formg.d.box)
            return seeother('/settings/globals/')

        gml = list(model.get_globalparams())
        return render.globals(gml, formg)