Exemplo n.º 1
0
    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([])
Exemplo n.º 2
0
 def getform(self, localparam):
     form = LocalParamForm()
     form.fill({'px': localparam.px, 'width': localparam.width, 'space': localparam.space,
                'xheight': localparam.xheight, 'capital': localparam.capital,
                'boxheight': localparam.boxheight, 'ascender': localparam.ascender,
                'descender': localparam.descender, 'inktrap': localparam.inktrap,
                'stemcut': localparam.stemcut, 'skeleton': localparam.skeleton,
                'superness': localparam.superness, 'over': localparam.over})
     return form
Exemplo n.º 3
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))
Exemplo n.º 4
0
    def GET(self, name, glyphid):
        if not is_loggedin():
            raise seeother('/login')

        master = models.Master.get(fontname=name)
        if not master:
            return web.notfound()

        localparameters = models.LocalParam.all()
        globalparams = models.GlobalParam.all()

        globalparamform = GlobalParamForm()

        globalparam = models.GlobalParam.get(idglobal=master.idglobal)
        globalparamform.idglobal.args = [(o.idglobal, o.idglobal) for o in globalparams]
        if globalparam:
            globalparamform.fill(globalparam)

        localparamform_a = LocalParamForm()

        local_params = Settings.get_local_params(master.idlocala, 'a')
        localparamform_a.idlocal.args = [(o.idlocal, o.idlocal) for o in localparameters]
        localparamform_a.fill(local_params)

        localparamform_b = LocalParamForm()

        local_params = Settings.get_local_params(master.idlocalb, 'b')
        localparamform_b.idlocal.args = [(o.idlocal, o.idlocal) for o in localparameters]
        localparamform_b.fill(local_params)

        return render.settings(master, glyphid, localparameters, globalparams,
                               globalparamform, localparamform_a, localparamform_b)
Exemplo n.º 5
0
 def getform(self, localparam=None):
     form = LocalParamForm()
     if localparam:
         form.fill(localparam.as_dict())
     return form