Example #1
0
 def test_TEXTAREA(self):
     self.assertEqual(TEXTAREA('<>', _a='1', _b='2').xml(),
                      b'<textarea a="1" b="2" cols="40" rows="10">&lt;&gt;' +
                      b'</textarea>')
     # override _rows and _cols
     self.assertEqual(TEXTAREA('<>', _a='1', _b='2', _rows=5, _cols=20).xml(),
                      b'<textarea a="1" b="2" cols="20" rows="5">&lt;&gt;' +
                      b'</textarea>')
     self.assertEqual(TEXTAREA('<>', value='bla bla bla...', _rows=10, _cols=40).xml(),
                      b'<textarea cols="40" rows="10">bla bla bla...</textarea>')
Example #2
0
                _width="25%"),
         LABEL("hola3", _width="25%"),
         INPUT(_type='text',
               _name='myvar',
               requires=IS_NOT_EMPTY(),
               _width="75%"),
         LABEL("Options:", _width="25%"),
         INPUT(_type='checkbox', _name='myvar', _width="10%"),
         LABEL("check1", _width="65%"),
         LABEL("", _width="25%"),
         INPUT(_type='checkbox', _name='myvar', _width="10%"),
         LABEL("check1", _width="65%"),
         LABEL("", _width="25%"),
         INPUT(_type='checkbox', _name='myvar', _width="10%"),
         LABEL("check1", _width="65%"),
         TEXTAREA("hola!", _name='mytextarea', _width="100%"),
         "hola3!",
         INPUT(_type='submit', _name='submit'),
     )
 elif '--sqlform' in sys.argv:
     form = SQLFORM.factory(
         Field("test",
               "string",
               requires=IS_NOT_EMPTY(),
               comment="some data"),
         Field("test1",
               "string",
               requires=IS_NOT_EMPTY(),
               comment="some data"),
         Field("test2",
               "string",
    def widget(cls, field, value, **attributes):

        default = dict(value=value)
        attr = cls._attributes(field, default, **attributes)
        return TEXTAREA(**attr)
Example #4
0
def report_template():
    response.subtitle = T("Edit report template")
    response.view = 'nas/template.html'
    #response.cmd_menu = None
    response.cmd_labels = ui.control.get_mobil_button(
        label=T("Labels"),
        href="#",
        cformat=None,
        style="text-align: left;",
        icon="edit",
        ajax="true",
        theme="d",
        onclick="document.getElementById('edit_label').style.display = 'block';"
        +
        "document.getElementById('edit_label_update').style.display = 'block';"
        +
        "document.getElementById('edit_template_update').style.display = 'none';"
        + "document.getElementById('view_template').style.display = 'none';" +
        "document.getElementById('edit_template').style.display = 'none';return true;"
    )
    response.cmd_view = ui.control.get_mobil_button(
        label=T("View XML"),
        href="#",
        cformat=None,
        style="text-align: left;",
        icon="page",
        ajax="true",
        theme="d",
        onclick="document.getElementById('edit_label').style.display = 'none';"
        +
        "document.getElementById('edit_label_update').style.display = 'none';"
        +
        "document.getElementById('edit_template_update').style.display = 'none';"
        + "document.getElementById('view_template').style.display = 'block';" +
        "document.getElementById('edit_template').style.display = 'none';return true;"
    )
    response.cmd_edit = ui.control.get_mobil_button(
        label=T("Edit XML"),
        href="#",
        cformat=None,
        style="text-align: left;",
        icon="edit",
        ajax="true",
        theme="d",
        onclick="document.getElementById('edit_label').style.display = 'none';"
        +
        "document.getElementById('edit_label_update').style.display = 'none';"
        +
        "document.getElementById('edit_template_update').style.display = 'block';"
        + "document.getElementById('view_template').style.display = 'none';" +
        "document.getElementById('edit_template').style.display = 'block';return true;"
    )
    response.cmd_labels_update = ui.control.get_mobil_button(
        label=T("Save"),
        href="#",
        cformat=None,
        style="text-align: left;",
        icon="check",
        ajax="false",
        theme="a",
        onclick="document.forms['frm_labels'].submit();")
    response.frm_report_update = ui.control.get_mobil_button(
        label=T("Save"),
        href="#",
        cformat=None,
        style="text-align: left;",
        icon="check",
        ajax="false",
        theme="a",
        onclick="document.forms['frm_report'].submit();")
    labels, tmp_view, tmp_edit = "", "", ""
    response.report_name = ""

    if ns.local.setEngine(
            database=db.databases(id=request.vars["database"]).alias,
            check_ndi=False,
            created=False,
            createdb=False):

        if request.post_vars.has_key("update_labels"):
            for label_id in request.post_vars.keys():
                if label_id not in ("update_labels"):
                    row_id = ns.connect.updateData(
                        "ui_message",
                        values={
                            "id": label_id,
                            "msg": request.post_vars[label_id]
                        },
                        validate=False,
                        insert_row=False)
                    if not row_id:
                        response.flash = str(ns.error_message)
            ns.db.commit()

        if request.post_vars.has_key("report_template"):
            row_id = ns.connect.updateData(
                "ui_report",
                values={
                    "id":
                    ns.db.ui_report(reportkey=request.vars["reportkey"])["id"],
                    "report":
                    request.post_vars["report_template"]
                },
                validate=False,
                insert_row=False)
            if not row_id:
                response.flash = str(ns.error_message)
            ns.db.commit()

        report = ns.db.ui_report(reportkey=request.vars["reportkey"])
        if report:
            response.report_name = report["repname"]
            tmp_view = CODE(report["report"])
            tmp_edit = TEXTAREA(
                _name="report_template",
                value=report["report"],
                _style="height: auto!important;overflow-y: scroll;",
                _rows=20)
            response.update_labels = INPUT(_name="update_labels",
                                           _type="hidden",
                                           _value="yes")

            ui_message = ns.db(
                (ns.db.ui_message.secname.like(report["reportkey"] + "%")
                 )).select(orderby=ns.db.ui_message.secname
                           | ns.db.ui_message.fieldname)
            labels = TABLE(_style="width: 100%;",
                           _cellpadding="0px;",
                           _cellspacing="0px;")
            ridlen = len(str(report["reportkey"]).split("_"))
            for message in ui_message:
                labels.append(
                    TR(
                        TD(DIV(str(message["secname"]).split("_")[ridlen],
                               _class="label"),
                           _style="padding-right:10px;"),
                        TD(DIV(message["fieldname"], _class="label"),
                           _style="padding-right:10px;"),
                        TD(INPUT(_name=message["id"],
                                 _type="text",
                                 _value=message["msg"],
                                 _style="width: 100%;"),
                           _style="width: 100%;")))

    else:
        response.flash = str(ns.error_message)

    return dict(labels=labels, tmp_view=tmp_view, tmp_edit=tmp_edit)