Ejemplo n.º 1
0
    def rend(self, context, data):
        context.remember(data, iformless.IBinding)

        from formless import configurable as conf

        configurable = conf.GroupConfigurable(data.boundTo, data.typedValue.iface)
        context.remember(configurable, iformless.IConfigurable)

        bindingNames = configurable.getBindingNames(context)

        def generateBindings():
            for name in bindingNames:
                bnd = configurable.getBinding(context, name)
                renderer = iformless.IBindingRenderer(bnd, defaultBindingRenderer)
                renderer.isGrouped = True
                renderer.needsSkin = True
                yield tags.invisible(
                    data=bnd,
                    render=renderer,
                    key=name)

        return getError(context), tags.form(
            id=keyToXMLID(context.key),
            enctype="multipart/form-data",
            action=calculatePostURL(context, data),
            method="post",
            **{'accept-charset':'utf-8'})[
                tags.fieldset[
                    tags.legend(_class="freeform-form-label")[data.label],
                    tags.input(type='hidden', name='_charset_'),
                    generateBindings(),
                    tags.input(type="submit")]]
Ejemplo n.º 2
0
    def render_genericCommand(self, ctx: WovenContext, data):

        employees = []
        self.l1 = l1 = List(employees, ["Employee ID", "Name"])
        self.l2 = l2 = List([], ["Entry Type", "Work Location", "Sub Account", "Start Time", "End Time", "Shift Duration", "Daily Total", "Approved", "Denied"])
        self.ltl = ltl = ListToListSelector(l1, l2)
        ltl.mappingReturnsNewElements = True
        ltl.prepare(self)
        ltl.visible = True
        ltl.closeable = False
        ltl.getMappingFor = self.getMappingFor
        ltl.setMappingFor = self.setMappingFor
        l2.setSelectable(False)

        startTime = tags.input(id='startTime', placeholder='Start Time')#[tags.Tag('athena:handler')(event='onchange', handler='timeWindowChanged')]
        endTime = tags.input(id='endTime', placeholder='End Time')
        addTime = [
            tags.input(id='addTime', type='button', value='Add Time Entry')[
                tags.Tag('athena:handler')(event='onclick', handler='addTime')],
            tags.select(id='newTimeType')[
                [tags.option(id=et.getTypeName())[et.getTypeName()] for et in self.entryTypes]
                ]
            ]
        if not IAdministrator(self.employee, None):
            addTime = ''

        self.preprocess([startTime, endTime, addTime])
        return [startTime, endTime, tags.br(), addTime, ltl]
Ejemplo n.º 3
0
 def render_childDel(self, context, xxx_todo_changeme):
     (name, _) = xxx_todo_changeme
     ret = T.form(action="./freeform_post!!deleteChild",
                  enctype="multipart/form-data", method="POST")[
            T.input(type="hidden", name="name", value=name),
            T.input(type="submit", value="Delete")]
     return ret
Ejemplo n.º 4
0
    def render_mkdir_form(self, ctx, data):
        # This is a form where users can create new directories.
        # Users can choose SDMF or MDMF from a radio button.

        mkdir_sdmf = T.input(type='radio',
                             name='format',
                             value='sdmf',
                             id='mkdir-sdmf',
                             checked='checked')
        mkdir_mdmf = T.input(type='radio',
                             name='format',
                             value='mdmf',
                             id='mkdir-mdmf')

        form = T.form(
            action="uri", method="post", enctype="multipart/form-data"
        )[T.fieldset[
            T.legend(class_="freeform-form-label")["Create a directory"],
            mkdir_sdmf,
            T.label(for_='mkdir-sdmf')[" SDMF"], SPACE, mkdir_mdmf,
            T.label(for_='mkdir-mdmf')[" MDMF (experimental)"], SPACE * 2,
            T.input(type="hidden", name="t", value="mkdir"),
            T.input(type="hidden", name="redirect_to_result", value="true"),
            T.input(type="submit", value="Create a directory"), ]]
        return T.div[form]
    def render_listRow(self, ctx: WovenContext, data=None):
        IEventBus("Web").register(self, ISubAccountChangedEvent)
        listCell = inevow.IQ(ctx).patternGenerator("listCell")
        self.expanded = False
        ctx.fillSlots('index', self._subAccount.sub)
        active = T.input(id='active', type='checkbox', checked=self._subAccount.active)
        name = T.input(id='name', value=self.name)
        sub = T.input(id='sub', value=self._subAccount.sub, disabled=True)

        if not self.employee.isAdministrator() or self.parent.selectable:
            active(disabled=True)
            name(disabled=True)
            sub(disabled=True)

        self.preprocess([active, name, sub])
        if self.length == 4:
            r = [listCell(data=dict(listItem='►'))(id='expand-button')[T.Tag("athena:handler")(event='onclick', handler='expand')],
                 listCell(data=dict(listItem='▼'))(style='display:none', id='unexpand-button')[T.Tag("athena:handler")(event='onclick', handler='expand')],
                 ]
        else:
            r = []
        r.extend([listCell(data=dict(listItem=sub))[Tag('athena:handler')(event='ondblclick', handler='expand')],
             listCell(data=dict(listItem=name)),
             listCell(data=dict(listItem=active))])
        return r
Ejemplo n.º 6
0
class StatusWidget(athena.LiveElement):
    jsClass = u'ControllerModule.StatusWidget'

    docFactory = loaders.stan(
        tags.div(render=tags.directive('liveElement'))[tags.div(
            id="statusWidget"
        )[tags.form(id="statusidform",
                    action="""javascript:
                var statusidform = document.getElementById('statusidform');
                var w = Nevow.Athena.Widget.get(statusidform);
                w.refreshStatus();
                """)
          [tags.input(id="statusidfield", type="text"), tags.br,
           tags.input(type="checkbox",
                      id="pending",
                      checked="true",
                      onChange="this.form.submit()")["pending"],
           tags.input(type="checkbox",
                      id="queue",
                      checked="true",
                      onChange="this.form.submit()")["queue"],
           tags.
           input(type="checkbox", id="history", onChange="this.form.submit()"
                 )["history"],
           tags.
           input(type="checkbox", id="locals", onChange="this.form.submit()"
                 )["locals"], tags.br,
           tags.input(type="submit", value="refresh status")],
          tags.div(id="statusOut")]])

    def __init__(self, controller):
        self.controller = controller
        reactor.callLater(.1, self.callRemote, 'getIDs')

    def status(self,
               targets,
               pending=True,
               queue=True,
               history=True,
               locals=True):
        args = (pending, queue, history, locals)
        idlist = parseTargets(targets)
        if idlist is False:
            return self.fail()
        d = self.controller.status(idlist)
        return d.addCallbacks(self.statusOK, self.fail, callbackArgs=args)

    athena.expose(status)

    def statusOK(self, resultList, *args):
        return self.finish(statusListToHTML(resultList, *args))

    def refreshStatus(self, *args):
        return self.callRemote('refreshStatus')

    def finish(self, s):
        return self.callRemote('updateStatus', unicode(s))

    def fail(self, f=None):
        return self.finish('Failure')
Ejemplo n.º 7
0
 def render_maybeEdit(self, ctx, _):
     """Render action buttons if available."""
     # pylint: disable-msg=E1101
     if manages_list(ctx, must_user(ctx), self.list):
         srv = IService(ctx)
         if srv.isReserved(self.item):
             notify = T.p[T.input(
                 type="checkbox", name="notify", value="1", checked=""),
                          u"\xa0Avertir la personne qui l'a réservé"]
         else:
             notify = []
         return ctx.tag(_class="editable bl")[T.div(_class="br")[T.div(
             _class="tl")[T.div(_class="tr")[T.form(
                 name='confirm',
                 action=url.here.child('confirm'),
                 method='POST',
                 _class="edcontent")[
                     notify,
                     T.input(type='submit',
                             name='confirm',
                             value=u"Confirmer l'effacement"),
                     T.input(type='submit', name='cancel', value=u"Annuler"
                             ), ]]]]]
     else:
         return ''
Ejemplo n.º 8
0
    def render(self, ctx, key, args, errors):

        if errors:
            value = args.get(key,[None])[0]
        else:
            if args is not None:
                value = iforms.IStringConvertible(self.original).fromType(args.get(key))

        def render_node(ctx, data):
            tag = ctx.tag
            data = self.nodeInterface(data)
            tag.fillSlots('value',data.value)
            tag.fillSlots('label',data.label)
            if str(data.value) == str(value):
                tag = tag(checked='checked')
            return tag

        template = T.div()[
            T.input(pattern='item', render=render_node, type='radio', name=key,
                    value=T.slot('value'))[
                T.slot('label')
                ],
            T.input(pattern='itemdisabled', render=render_node,
                    disabled="disabled", type='radio', name=key,
                    value=T.slot('value'))[
                T.slot('label')
                ]
            ]

        return T.invisible(data=self.tree, render=tree.render)[template]
Ejemplo n.º 9
0
    def _renderTag(self, ctx, tparser, tvalue, namer, readonly):
        tag=T.invisible()
        if len(self.parsers) > 1:
            tp = T.select(name=namer('tparser'),id=render_cssid(namer('tparser')))
            if readonly:
                tp(class_='disabled', disabled='disabled')        
            
            for k,v in self.parsers:
                if k == tparser:
                    tp[T.option(selected='selected',value=k)[ v ]]
                else:
                    tp[T.option(value=k)[ v ]]
        else:
            tp = T.input(type='hidden',name=namer('tparser'),id=render_cssid(namer('tparser')),value=self.parsers[0][0])
        tag[tp]     
               
        if self.itemTypes is not None:
            tag[ T.input(type='hidden',class_="itemTypes",name=namer('itemTypes'),id=render_cssid(namer('itemTypes')),value=encodeTypes(self.itemTypes)) ]
        if self.itemTemplates is not None:
            tag[ T.input(type='hidden',class_="itemTemplates",name=namer('itemTemplates'),id=render_cssid(namer('itemTemplates')),value=','.join(self.itemTemplates)) ]

        ta=T.textarea(name=namer('tvalue'), id=render_cssid(namer('tvalue')), cols=self.cols, rows=self.rows)[tvalue or '']
        if readonly:
            ta(class_='readonly', readonly='readonly')
        tag[ [T.br,ta ]]
        return tag
Ejemplo n.º 10
0
class Page(ManualFormMixin, rend.Page):
    
    addSlash = True
    docFactory = loaders.stan(
        t.html[
            t.head[
                t.title['Advanced Manualform']
            ],
            t.body[
                t.p['Use the form to find out how to easily and manually handle them'],
                t.form(action=url.here.child('_submit!!post'), 
                       enctype="multipart/form-data",
                       method='post'
                      )[
                          t.input(type='text', name='what'),
                          # the name attribute must be present and must be
                          # post_btn for all the buttons in the form
                          t.input(type='submit', value='btn1', name=BUTTON),
                          t.input(type='submit', value='btn2', name=BUTTON)
                        ]
            ]
        ]
    )
    
    def form_post_btn1(self, what=None):
        # 'what' is a keyword argument, and must be the same name that you
        # give to the widget.
        print "btn1:", what
    
    def form_post_btn2(self, what=None):
        # see above for 'what'.
        print "btn2:", what
Ejemplo n.º 11
0
    def rend(self, context, data):
        context.remember(data, iformless.IBinding)

        from formless import configurable as conf

        configurable = conf.GroupConfigurable(data.boundTo,
                                              data.typedValue.iface)
        context.remember(configurable, iformless.IConfigurable)

        bindingNames = configurable.getBindingNames(context)

        def generateBindings():
            for name in bindingNames:
                bnd = configurable.getBinding(context, name)
                renderer = iformless.IBindingRenderer(bnd,
                                                      defaultBindingRenderer)
                renderer.isGrouped = True
                renderer.needsSkin = True
                yield tags.invisible(data=bnd, render=renderer, key=name)

        return getError(context), tags.form(
            id=keyToXMLID(context.key),
            enctype="multipart/form-data",
            action=calculatePostURL(context, data),
            method="post",
            **{'accept-charset': 'utf-8'
               })[tags.fieldset[tags.legend(
                   _class="freeform-form-label")[data.label],
                                tags.input(type='hidden', name='_charset_'),
                                generateBindings(),
                                tags.input(type="submit")]]
Ejemplo n.º 12
0
 def render_childDel(self, context, xxx_todo_changeme):
     (name, _) = xxx_todo_changeme
     ret = T.form(action="./freeform_post!!deleteChild",
                  enctype="multipart/form-data", method="POST")[
            T.input(type="hidden", name="name", value=name),
            T.input(type="submit", value="Delete")]
     return ret
Ejemplo n.º 13
0
Archivo: edit.py Proyecto: drewp/photo
    def render_pics(self, ctx, data):
        rows = []
        d = URIRef(ctx.arg('dir'))
        for i, (pic, filename) in enumerate(sorted(picsInDirectory(self.graph, d))[:]):
            img = T.img(src=[localSite(pic), '?size=thumb'],
                        # look these up in the graph
                        width=75, height=56,
                        onclick='javascript:photo.showLarge("%s")' %
                        (localSite(pic) + "?size=large"))


            tableRow = T.table(class_="picRow")[T.tr[
                T.td[T.a(href=localSite(pic))[filename]],
                T.td[img],
                T.td[
                T.div["Depicts: ", T.input(type="text", class_="tags")],
                T.div["Comment: ", T.input(type="text")],
                ],
                ]]

            toCopy = "protoSectionSplitter"
            if i ==0:
                toCopy = "protoSectionBreak"
                

            rows.append([T.raw('<script type="text/javascript">document.write(document.getElementById("%s").innerHTML);</script>' % toCopy),
                         tableRow])
            
        return rows
    def render_listRow(self, ctx: WovenContext, data=None):
        IEventBus("Web").register(self, IWorkLocationChangedEvent)
        listCell = inevow.IQ(ctx).patternGenerator("listCell")
        self.expanded = False
        ctx.fillSlots('index', self._workLocation.workLocationID)
        active = T.input(id='active', type='checkbox', checked=self._workLocation.active)
        workLocationID = T.input(id='name', value=self._workLocation.workLocationID, disabled=True)
        descr = T.input(id='description', value=self._workLocation.description)

        if not self.employee.isAdministrator() or self.parent.selectable:
            active(disabled=True)
            workLocationID(disabled=True)
            descr(disabled=True)

        self.preprocess([active, workLocationID, descr])
        if self.length==4:
            r = [
                listCell(data=dict(listItem='►'))(id='expand-button')[
                    T.Tag("athena:handler")(event='onclick', handler='expand')],
                listCell(data=dict(listItem='▼'))(style='display:none', id='unexpand-button')[
                    T.Tag("athena:handler")(event='onclick', handler='expand')],
            ]
        else:
            r = []
        r.extend([listCell(data=dict(listItem=workLocationID))[T.Tag('athena:handler')(event='ondblclick', handler='expand')],
                  listCell(data=dict(listItem=descr)),
                  listCell(data=dict(listItem=active))])
        return r
Ejemplo n.º 15
0
 def _renderTag(self, ctx, year, month, namer, readonly):
     yearTag = T.input(type="text", name=namer('year'), value=year, size=2)
     monthTag = T.input(type="text", name=namer('month'), value=month, size=2)
     if readonly:
         tags=(yearTag, monthTag)
         for tag in tags:
             tag(class_='readonly', readonly='readonly')
     return monthTag, ' / ', yearTag, ' (mm/yy)'
Ejemplo n.º 16
0
 def render_booleanOption(self, ctx, boolean):
     if boolean.getValue():
         checked = "checked"
     else:
         checked = None
     return (
         T.input(type="checkbox", name=boolean.getName(), checked=checked),
         T.input(type="hidden", name=boolean.getName(), value="off"))
Ejemplo n.º 17
0
 def _renderTag(self, ctx, year, month, namer, readonly):
     yearTag = T.input(type="text", name=namer('year'), value=year, size=2)
     monthTag = T.input(type="text", name=namer('month'), value=month, size=2)
     if readonly:
         tags=(yearTag, monthTag)
         for tag in tags:
             tag(class_='readonly', readonly='readonly')
     return monthTag, ' / ', yearTag, ' (mm/yy)'
Ejemplo n.º 18
0
 def renderImmutable(self, ctx, key, args, errors):
     values = ('', '')
     return [
         T.input(type='password', name=key, id=render_cssid(key), value=values[0], class_='readonly', readonly='readonly'),
         T.br,
         T.label(for_=render_cssid(key, 'confirm'))[' Confirm '],
         T.input(type='password', name=key, id=render_cssid(key, 'confirm'),
                 value=values[1], class_='readonly', readonly='readonly')
     ]
Ejemplo n.º 19
0
    def render(self, ctx, key, args, errors):
        """
            Render the data.

            This either renders a link to the original file, if specified, and
            no new file has been uploaded. Or a link to the uploaded file.

            The request to get the data should be routed to the getResouce
            method.
        """
        form = iformal.IForm(ctx)

        namer = self._namer(key)
        resourceIdName = namer('resource_id')
        originalIdName = namer('original_id')

        # get the resource id first from the resource manager
        # then try the request
        resourceId = form.resourceManager.getResourceId(key)
        if resourceId is None:
            resourceId = self._getFromArgs(args, resourceIdName)
        resourceId = self._blankField(resourceId)

        # Get the original key from a hidden field in the request,
        # then try the request file.data initial data.
        originalKey = self._getFromArgs(args, originalIdName)
        if not errors and not originalKey:
            originalKey = args.get(key)
        originalKey = self._blankField(originalKey)

        if resourceId:
            # Have an uploaded file, so render a URL to the uploaded file
            tmpURL = widgetResourceURL(form.name).child(key).child(
                self.FROM_RESOURCE_MANAGER).child(resourceId)
            yield T.p[T.img(src=tmpURL)]
        elif originalKey:
            # The is no uploaded file, but there is an original, so render a
            # URL to it
            if self.originalKeyIsURL:
                tmpURL = originalKey
            else:
                tmpURL = widgetResourceURL(form.name).child(key).child(
                    self.FROM_CONVERTIBLE).child(originalKey)
            yield T.p[T.img(src=tmpURL)]
        else:
            # No uploaded file, no original
            yield T.p[T.strong['Nothing uploaded']]

        yield T.input(name=key, id=render_cssid(key), type='file')

        # Id of uploaded file in the resource manager
        yield T.input(name=resourceIdName, value=resourceId, type='hidden')
        if originalKey:
            # key of the original that can be used to get a file later
            yield T.input(name=originalIdName,
                          value=originalKey,
                          type='hidden')
Ejemplo n.º 20
0
 def renderImmutable(self, ctx, key, args, errors):
     values = ('', '')
     return [
         T.input(type='password', name=key, id=render_cssid(key), value=values[0], class_='readonly', readonly='readonly'),
         T.br,
         T.label(for_=render_cssid(key, 'confirm'))[' Confirm '],
         T.input(type='password', name=key, id=render_cssid(key, 'confirm'),
                 value=values[1], class_='readonly', readonly='readonly')
     ]
Ejemplo n.º 21
0
    def bool_widget(self, name, data):
        info = dict(name=name,
                    choices=[(True, 'True'), (False, 'False')],
                    selected=data)

        if data:
            return T.input(name=name, _type='checkbox', checked='checked')
        else:
            return T.input(name=name, _type='checkbox')
Ejemplo n.º 22
0
    def _renderTag(self, ctx, height, width, depth, namer, readonly):
        heightTag = T.input(type="text", name=namer('height'), value=height, size=8)
        widthTag = T.input(type="text", name=namer('width'), value=width, size=8)
        depthTag = T.input(type="text", name=namer('depth'), value=depth, size=8)
        if readonly:
            tags = (heightTag, widthTag, depthTag)
            for tag in tags:
                tag(class_='readonly', readonly='readonly')

        return heightTag, 'h ', widthTag, 'w ', depthTag, 'd '
Ejemplo n.º 23
0
 def rend(self, patterns, item, attribute):
     cell = patterns.patternGenerator(self.pattern)()
     id = item.getAttributeValue(attribute)
     tag = T.input(type="checkbox", name='%s-%s'%(self.name, id), value=id)
     value = item.getAttributeValue(self.name)
     if value:
         tag = tag(checked='checked')
     tag[ T.input(type='hidden', name='%s-%s-val'%(self.name, id), value=value) ]
     cell.fillSlots('value', tag)
     return cell
Ejemplo n.º 24
0
 def title(self, ctx, data):
     title = data.get('ptitle')
     if title == '':
         title = data.get('ttitle')
     title = clean(title)
     hd_inpt = t.input(type="hidden", id="reply_to",
                       name="reply_to", value=data.get('pid'))
     inpt = t.input(type="text", id="title_", name="title",
                    maxlength="70", size="60", value=title)
     return t.invisible[hd_inpt, inpt]
Ejemplo n.º 25
0
 def render_view_form(self, ctx, data):
     # this is a form where users can download files by URI, or jump to a
     # named directory
     form = T.form(
         action="uri", method="get", enctype="multipart/form-data")[
             T.fieldset[T.legend(
                 class_="freeform-form-label")["View a file or directory"],
                        "Tahoe-URI to view:" + SPACE,
                        T.input(type="text", name="uri"), SPACE * 2,
                        T.input(type="submit", value="View!"), ]]
     return T.div[form]
Ejemplo n.º 26
0
 def render_incident_button(self, ctx, data):
     # this button triggers a foolscap-logging "incident"
     form = T.form(
         action="report_incident",
         method="post",
         enctype="multipart/form-data")[T.fieldset[
             T.input(type="hidden", name="t", value="report-incident"),
             "What went wrong?" + SPACE,
             T.input(type="text", name="details"), SPACE,
             T.input(type="submit", value=u"Save \u00BB"), ]]
     return T.div[form]
Ejemplo n.º 27
0
 def input(self, context, slot, data, name, value):
     return [
         tags.input(id=keyToXMLID(context.key),
                    name=name,
                    type="password",
                    _class="freeform-input-password"),
         " Again ",
         tags.input(name="%s____2" % name,
                    type="password",
                    _class="freeform-input-password"),
     ]
Ejemplo n.º 28
0
 def render_mkdir_form(self, ctx, data):
     # this is a form where users can create new directories
     form = T.form(action="uri", method="post",
                   enctype="multipart/form-data")[
         T.fieldset[
         T.legend(class_="freeform-form-label")["Create a directory"],
         T.input(type="hidden", name="t", value="mkdir"),
         T.input(type="hidden", name="redirect_to_result", value="true"),
         T.input(type="submit", value="Create a directory"),
         ]]
     return T.div[form]
Ejemplo n.º 29
0
 def render_incident_button(self, ctx, data):
     # this button triggers a foolscap-logging "incident"
     form = T.form(action="report_incident", method="post",
                   enctype="multipart/form-data")[
         T.fieldset[
         T.input(type="hidden", name="t", value="report-incident"),
         "What went wrong?"+SPACE,
         T.input(type="text", name="details"), SPACE,
         T.input(type="submit", value=u"Save \u00BB"),
         ]]
     return T.div[form]
Ejemplo n.º 30
0
 def render_deep_stats_form(self, ctx, data):
     ophandle = base32.b2a(os.urandom(16))
     deep_stats = T.form(
         action=".", method="post",
         enctype="multipart/form-data")[T.fieldset[
             T.input(type="hidden", name="t", value="start-deep-stats"),
             T.legend(class_="freeform-form-label"
                      )["Run a deep-stats operation (EXPENSIVE)"],
             T.input(type="hidden", name="ophandle", value=ophandle),
             T.input(type="submit", value="Deep-Stats"), ]]
     return ctx.tag[deep_stats]
Ejemplo n.º 31
0
 def render(self, ctx, key, args, errors):
     if errors and not errors.getFieldError(key):
         values = args.get(key)
     else:
         values = ('', '')
     return [
         T.input(type='password', name=key, id=render_cssid(key), value=values[0]),
         T.br,
         T.label(for_=render_cssid(key, 'confirm'))[' Confirm '],
         T.input(type='password', name=key, id=render_cssid(key, 'confirm'), value=values[1]),
         ]
Ejemplo n.º 32
0
 def render_mkdir_form(self, ctx, data):
     # this is a form where users can create new directories
     form = T.form(action="uri", method="post",
                   enctype="multipart/form-data")[
         T.fieldset[
         T.legend(class_="freeform-form-label")["Create a directory"],
         T.input(type="hidden", name="t", value="mkdir"),
         T.input(type="hidden", name="redirect_to_result", value="true"),
         T.input(type="submit", value="Create a directory"),
         ]]
     return T.div[form]
Ejemplo n.º 33
0
 def render_repair(self, ctx, data):
     if data.is_healthy():
         return ""
     repair = T.form(
         action=".", method="post", enctype="multipart/form-data")[
             T.fieldset[T.input(type="hidden", name="t", value="check"),
                        T.input(type="hidden", name="repair", value="true"),
                        T.input(type="submit", value="Repair"), ]]
     return ""  # repair button disabled until we make it work correctly,
     # see #622 for details
     return ctx.tag[repair]
Ejemplo n.º 34
0
 def render_deep_stats_form(self, ctx, data):
     ophandle = base32.b2a(os.urandom(16))
     deep_stats = T.form(action=".", method="post",
                         enctype="multipart/form-data")[
         T.fieldset[
         T.input(type="hidden", name="t", value="start-deep-stats"),
         T.legend(class_="freeform-form-label")["Run a deep-stats operation (EXPENSIVE)"],
         T.input(type="hidden", name="ophandle", value=ophandle),
         T.input(type="submit", value="Deep-Stats"),
         ]]
     return ctx.tag[deep_stats]
Ejemplo n.º 35
0
 def render(self, ctx, key, args, errors):
     if errors and not errors.getFieldError(key):
         values = args.get(key)
     else:
         values = ('', '')
     return [
         T.input(type='password', name=key, id=render_cssid(key), value=values[0]),
         T.br,
         T.label(for_=render_cssid(key, 'confirm'))[' Confirm '],
         T.input(type='password', name=key, id=render_cssid(key, 'confirm'), value=values[1]),
         ]
Ejemplo n.º 36
0
    def render(self, ctx, key, args, errors):
        """
            Render the data.

            This either renders a link to the original file, if specified, and
            no new file has been uploaded. Or a link to the uploaded file.

            The request to get the data should be routed to the getResouce
            method.
        """
        form = iformal.IForm( ctx )

        namer = self._namer( key )
        resourceIdName = namer( 'resource_id' )
        originalIdName = namer( 'original_id' )

        # get the resource id first from the resource manager
        # then try the request
        resourceId = form.resourceManager.getResourceId( key )
        if resourceId is None:
            resourceId = self._getFromArgs( args, resourceIdName )
        resourceId = self._blankField( resourceId )

        # Get the original key from a hidden field in the request,
        # then try the request file.data initial data.
        originalKey = self._getFromArgs( args, originalIdName )
        if not errors and not originalKey:
            originalKey = args.get( key )
        originalKey = self._blankField( originalKey )

        if resourceId:
            # Have an uploaded file, so render a URL to the uploaded file
            tmpURL = widgetResourceURL(form.name).child(key).child( self.FROM_RESOURCE_MANAGER ).child(resourceId)
            yield T.p[T.img(src=tmpURL)]
        elif originalKey:
            # The is no uploaded file, but there is an original, so render a
            # URL to it
            if self.originalKeyIsURL:
                tmpURL = originalKey
            else:
                tmpURL = widgetResourceURL(form.name).child(key).child( self.FROM_CONVERTIBLE ).child( originalKey )
            yield T.p[T.img(src=tmpURL)]
        else:
            # No uploaded file, no original
            yield T.p[T.strong['Nothing uploaded']]

        yield T.input(name=key, id=render_cssid(key),type='file')

        # Id of uploaded file in the resource manager
        yield T.input(name=resourceIdName,value=resourceId,type='hidden')
        if originalKey:
            # key of the original that can be used to get a file later
            yield T.input(name=originalIdName,value=originalKey,type='hidden')
Ejemplo n.º 37
0
 def render_download_form(self, ctx, data):
     # this is a form where users can download files by URI
     form = T.form(
         action="uri", method="get",
         enctype="multipart/form-data")[T.fieldset[
             T.legend(class_="freeform-form-label")["Download a file"],
             T.div["Tahoe-URI to download:" + SPACE,
                   T.input(type="text", name="uri")],
             T.div["Filename to download as:" + SPACE,
                   T.input(type="text", name="filename")],
             T.input(type="submit", value="Download!"), ]]
     return T.div[form]
Ejemplo n.º 38
0
 def render_incident_button(self, ctx, data):
     # this button triggers a foolscap-logging "incident"
     form = T.form(
         action="report_incident",
         method="post",
         enctype="multipart/form-data")[T.fieldset[
             T.legend(class_="freeform-form-label")["Report an Incident"],
             T.input(type="hidden", name="t", value="report-incident"),
             "What went wrong?:" + SPACE,
             T.input(type="text", name="details"), SPACE,
             T.input(type="submit", value="Report!"), ]]
     return T.div[form]
Ejemplo n.º 39
0
 def render_view_form(self, ctx, data):
     # this is a form where users can download files by URI, or jump to a
     # named directory
     form = T.form(action="uri", method="get",
                   enctype="multipart/form-data")[
         T.fieldset[
         T.legend(class_="freeform-form-label")["View a file or directory"],
         "Tahoe-URI to view: ",
         T.input(type="text", name="uri"), " ",
         T.input(type="submit", value="View!"),
         ]]
     return T.div[form]
Ejemplo n.º 40
0
 def render_incident_button(self, ctx, data):
     # this button triggers a foolscap-logging "incident"
     form = T.form(action="report_incident", method="post",
                   enctype="multipart/form-data")[
         T.fieldset[
         T.legend(class_="freeform-form-label")["Report an Incident"],
         T.input(type="hidden", name="t", value="report-incident"),
         "What went wrong?: ",
         T.input(type="text", name="details"), " ",
         T.input(type="submit", value="Report!"),
         ]]
     return T.div[form]
Ejemplo n.º 41
0
class NotLoggedIn(rend.Page):
    """The resource that is returned when you are not logged in"""
    addSlash = True
    docFactory = loaders.stan(tags.html[
        tags.head[tags.title["Not Logged In"]],
        tags.body[tags.form(action=guard.LOGIN_AVATAR, method='post')[
            tags.table[
                tags.tr[tags.td["Username:"******"Password:"], tags.
                        td[tags.input(type='password', name='password')], ]],
            tags.input(type='submit'), tags.p, ]]])
Ejemplo n.º 42
0
    def _renderTag(self, ctx, year, month, day, namer, readonly):
        yearTag = T.input(type="text", name=namer('year'), value=year, size=4)
        monthTag = T.input(type="text", name=namer('month'), value=month, size=2)
        dayTag = T.input(type="text", name=namer('day'), value=day, size=2)
        if readonly:
            tags = (yearTag, monthTag, dayTag)
            for tag in tags:
                tag(class_='readonly', readonly='readonly')

        if self.dayFirst:
            return dayTag, ' / ', monthTag, ' / ', yearTag, ' ', _('(day/month/year)')
        else:
            return monthTag, ' / ', dayTag, ' / ', yearTag, ' ', _('(month/day/year)')
Ejemplo n.º 43
0
	def data_login_form(self, ctx, data):
		if(self.user):
			result = tags.p()[
				"You have been successfully logged in as %s" % self.user.username
			]
		else:
			result = tags.form(method="POST")[[
				tags.p()['Enter your OpenID identifier to login:'],
				tags.label(_for="openid-field")["id:"],
				tags.input(type="text", size="60", name="identity"),
				tags.input(type="submit", name="submit", value="login"),
			]]
		return result
Ejemplo n.º 44
0
    def input(self, context, slot, data, name, value):
        ## The only difference here is the "checked" attribute; the value is still the same because
        ## we want true to be passed to the server when the checkbox is checked and the form
        ## is posted.
        node = tags.input(id=keyToXMLID(context.key), type="checkbox", name=name, value='True', _class="freeform-input-checkbox")
        if value:
            node(checked="checked")

        # HTML forms are so weak. If the checkbox is not checked, no value at all will be
        # in request.args with the name data.name. So let's force the value False to always
        # be in request.args[data.name]. If the checkbox is checked, the value True will
        # be first, and we will find that.
        return slot[node, tags.input(type="hidden", name=name, value="False")]
Ejemplo n.º 45
0
 def render_repair(self, ctx, data):
     if data.is_healthy():
         return ""
     repair = T.form(action=".", method="post",
                     enctype="multipart/form-data")[
         T.fieldset[
         T.input(type="hidden", name="t", value="check"),
         T.input(type="hidden", name="repair", value="true"),
         T.input(type="submit", value="Repair"),
         ]]
     return "" # repair button disabled until we make it work correctly,
               # see #622 for details
     return ctx.tag[repair]
Ejemplo n.º 46
0
 def render_download_form(self, ctx, data):
     # this is a form where users can download files by URI
     form = T.form(action="uri", method="get",
                   enctype="multipart/form-data")[
         T.fieldset[
         T.legend(class_="freeform-form-label")["Download a file"],
         T.div["Tahoe-URI to download: ",
               T.input(type="text", name="uri")],
         T.div["Filename to download as: ",
               T.input(type="text", name="filename")],
         T.input(type="submit", value="Download!"),
         ]]
     return T.div[form]
Ejemplo n.º 47
0
 def render_upload_form(self, ctx, data):
     # this is a form where users can upload unlinked files
     form = T.form(action="uri", method="post",
                   enctype="multipart/form-data")[
         T.fieldset[
         T.legend(class_="freeform-form-label")["Upload a file"],
         T.div["Choose a file: ",
               T.input(type="file", name="file", class_="freeform-input-file")],
         T.input(type="hidden", name="t", value="upload"),
         T.div[T.input(type="checkbox", name="mutable"), T.label(for_="mutable")["Create mutable file"],
               " ", T.input(type="submit", value="Upload!")],
         ]]
     return T.div[form]
Ejemplo n.º 48
0
    def _renderTag(self, ctx, year, month, day, namer, readonly):
        yearTag = T.input(type="text", name=namer('year'), value=year, size=4)
        monthTag = T.input(type="text", name=namer('month'), value=month, size=2)
        dayTag = T.input(type="text", name=namer('day'), value=day, size=2)
        if readonly:
            tags = (yearTag, monthTag, dayTag)
            for tag in tags:
                tag(class_='readonly', readonly='readonly')

        if self.dayFirst:
            return dayTag, ' / ', monthTag, ' / ', yearTag, ' ', _('(day/month/year)')
        else:
            return monthTag, ' / ', dayTag, ' / ', yearTag, ' ', _('(month/day/year)')
Ejemplo n.º 49
0
        def line(queryName, label):
            ret = json.parse((yield getPage(
                "http://bigasterisk.com/magma/light/state?name=%s" % queryName,
                headers={'x-identity-forward': 'secret-8-' + self.identity})))

            currently = ret['value']
            returnValue(
                T.form(method="POST", action="light/state")
                [T.input(type="hidden", name="name", value=queryName),
                 T.div[label, " ", T.span[currently], ", turn ",
                       T.input(type="submit",
                               name="value",
                               value="off" if currently == 'on' else "on")]])
Ejemplo n.º 50
0
    def input(self, context, slot, data, name, value):
        ## The only difference here is the "checked" attribute; the value is still the same because
        ## we want true to be passed to the server when the checkbox is checked and the form
        ## is posted.
        node = tags.input(id=keyToXMLID(context.key), type="checkbox", name=name, value='True', _class="freeform-input-checkbox")
        if value:
            node(checked="checked")

        # HTML forms are so weak. If the checkbox is not checked, no value at all will be
        # in request.args with the name data.name. So let's force the value False to always
        # be in request.args[data.name]. If the checkbox is checked, the value True will
        # be first, and we will find that.
        return slot[node, tags.input(type="hidden", name=name, value="False")]
Ejemplo n.º 51
0
 def render_upload_form(self, ctx, data):
     # this is a form where users can upload unlinked files
     form = T.form(action="uri", method="post",
                   enctype="multipart/form-data")[
         T.fieldset[
         T.legend(class_="freeform-form-label")["Upload a file"],
         T.div["Choose a file: ",
               T.input(type="file", name="file", class_="freeform-input-file")],
         T.input(type="hidden", name="t", value="upload"),
         T.div[T.input(type="checkbox", name="mutable"), T.label(for_="mutable")["Create mutable file"],
               " ", T.input(type="submit", value="Upload!")],
         ]]
     return T.div[form]
Ejemplo n.º 52
0
class TreeRenderer(rend.Page):
    implements(ITreeEdit)
    addSlash = True
    docFactory = loaders.htmlstr("""
<html>
<head><title>Tree Editor</title></head>
<body><h1><span nevow:data="description"
                nevow:render="string">Tree Description</span></h1>
<span nevow:render="descriptionForm"/>
<ol nevow:data="children" nevow:render="sequence">
<li nevow:pattern="item"><span nevow:render="childLink"/>
<span nevow:render="childDel"/>
</li>
</ol>
<a href="..">Up</a>
</body>
</html>
    """)

    def setDescription(self, description):
        self.original.description = description

    def addChild(self, name, description):
        self.original.add(Tree(name, description))

    def deleteChild(self, name):
        del self.original[name]

    def data_description(self, context, data):
        return self.original.description

    def data_children(self, context, data):
        return self.original.items()

    def render_childLink(self, context, data):
        return T.a(href='subtree_%s/' % data[0])[data[1].description]

    def childFactory(self, ctx, name):
        if name.startswith('subtree_'):
            return self.original[name[len('subtree_'):]]

    def render_descriptionForm(self, context, data):
        return webform.renderForms()

    def render_childDel(self, context, (name, _)):
        ret = T.form(
            action="./freeform_post!!deleteChild",
            enctype="multipart/form-data",
            method="POST")[T.input(type="hidden", name="name", value=name),
                           T.input(type="submit", value="Delete")]
        return ret
Ejemplo n.º 53
0
 def render_genericCommand(self, ctx: WovenContext, data):
     IEventBus("Web").register(self, ITimeEntryChangedEvent)
     self.l = l = List([], ["Entry Type", "Work Location", "Sub Account", "Start Time", "End Time", "Shift Duration", "Daily Total", "Approved", "Denied"])
     l.closeable = False
     l.prepare(self)
     l.visible = True
     startTime = tags.input(id='startTime', placeholder='Start Time')
     #[
      #   tags.Tag('athena:handler')(event='onchange', handler='timeWindowChanged')]
     endTime = tags.input(id='endTime', placeholder='End Time')
     #[
      #   tags.Tag('athena:handler')(event='onchange', handler='timeWindowChanged')]
     self.preprocess([startTime, endTime])
     return [startTime, endTime, l]
Ejemplo n.º 54
0
 def render_genericCommand(self, ctx: WovenContext, data):
     self.l = l = List([], ['', "Employee ID", "Name"])
     l.closeable = False
     l.addRow(SaveList(3, start=1))
     l.prepare(self)
     l.visible = True
     showActive = tags.input(id='showActive', type='checkbox', checked=True)[
         tags.Tag('athena:handler')(handler='refresh', event='onchange')
     ]
     showInactive = tags.input(id='showInactive', type='checkbox')[
         tags.Tag('athena:handler')(handler='refresh', event='onchange')
     ]
     self.preprocess([showActive, showInactive])
     return "Show Active", showActive, tags.br(), "Show Inactive", showInactive, l
Ejemplo n.º 55
0
class MyPage(rend.Page):
    addSlash = True
    docFactory = loaders.stan(
    tags.html[
        tags.head[tags.title["Hi Boy"]],
        tags.body[
            tags.invisible(render=tags.directive("isLogged"))[
                tags.div(pattern="False")[
                    tags.form(action=guard.LOGIN_AVATAR, method='post')[
                        tags.table[
                            tags.tr[
                                tags.td[ "Username:"******"Password:"******"True")[
                    tags.h3["Hi bro"],
                    tags.invisible(render=tags.directive("sessionId")),
                    tags.br,
                    tags.a(href=guard.LOGOUT_AVATAR)["Logout"]
                ]
            ]
        ]
    ])
 
    def __init__(self, avatarId=None):
        rend.Page.__init__(self)
        self.avatarId=avatarId
 
    def render_isLogged(self, context, data):
        q = inevow.IQ(context)
        true_pattern = q.onePattern('True')
        false_pattern = q.onePattern('False')
        if self.avatarId: return true_pattern or context.tag().clear()
        else: return false_pattern or context.tag().clear()
 
    def render_sessionId(self, context, data):
        sess = inevow.ISession(context)
        return context.tag[sess.uid]
 
    def logout(self):
        print("Bye")
Ejemplo n.º 56
0
class LoginForm(MaayPage):
    """a basic login form. This page is rendered until the user
    is logged.
    """
    addSlash = True
    docFactory = loaders.stan(tags.html[
        tags.head[tags.title["Maay Login Page"]],
        tags.body[tags.form(action=guard.LOGIN_AVATAR, method='post')[
            tags.table(_class="loginTable")[tags.tr[
                tags.td["Username:"******"Password:"],
                    tags.td[tags.input(type='password', name='password')], ]],
            tags.input(type='submit'), tags.p, ]]])
Ejemplo n.º 57
0
 def render_overwrite_form(self, ctx, data):
     node = self.original
     root = self.get_root(ctx)
     action = "%s/uri/%s" % (root, urllib.quote(node.get_uri()))
     done_url = "%s/uri/%s?t=info" % (root, urllib.quote(node.get_uri()))
     overwrite = T.form(
         action=action, method="post",
         enctype="multipart/form-data")[T.fieldset[
             T.input(type="hidden", name="t", value="upload"),
             T.input(type='hidden', name='when_done', value=done_url),
             T.legend(class_="freeform-form-label")["Overwrite"],
             "Upload new contents: ",
             T.input(type="file", name="file"), " ",
             T.input(type="submit", value="Replace Contents")]]
     return ctx.tag[overwrite]
Ejemplo n.º 58
0
    def render_myLists(self, ctx, data):
        """Render the 'sender' field."""
        selected = {}
        for l in data['lst']:
            selected[l.id] = True
        # pylint: disable-msg=E1101
        srv = IService(ctx)
        user = must_user(ctx).user
        lsts = srv.getListsOwnedBy(user)
        lsts += srv.getFriendLists(user)

        checkbox = []

        for lst, _ in lsts:
            name = lst.name or T.i[u'Liste sans nom']

            args = {'type': "checkbox", 'name': "lst", 'value': lst.id}

            if lst.id in selected:
                args['checked'] = '1'

            checkbox.append(
                T.div(style="margin-left:2em")[T.input(**args)[u'\xa0' +
                                                               name]])

        return ctx.tag[checkbox]
Ejemplo n.º 59
0
class LiveExamplePage(livepage.LivePage):
    docFactory = loaders.stan(
        tags.html[tags.head[livepage.glue], tags.body[tags.input(
            type="text", onchange="server.handle('change', this.value)")]])

    def handle_change(self, ctx, value):
        return livepage.alert(value)