Пример #1
0
 def test_html3(self, **kw):
     form = HTMLForm(loadFromType="type1", app=self.app, view=self.view, request=Request())
     form.formUrl = "form/url"
     form.cssID = u"upload"
     form.css_class = u"niveform"
     form.subsets = {u"test": {"fields": [u"ftext", FieldConf(**{"id": "section1", "name": "Section 1", "datatype": "number"})]}}
     form.Setup(subset=u"test")
     v,d,e = form.Validate(data1_2)
     self.assert_(v, e)
     form.Render(d, msgs=None, errors=None)
Пример #2
0
 def test_html2(self, **kw):
     form = HTMLForm(loadFromType="type1", app=self.app, view=self.view, request=Request())
     form.formUrl = "form/url"
     form.cssID = u"upload"
     form.css_class = u"niveform"
     form.subsets = {u"test": {"fields": [u"ftext",u"funit"]}}
     form.Setup(subset=u"test")
     v,d,e = form.Validate(data1_2)
     self.assert_(v, e)
     form.Render(d, msgs=None, errors=None)
Пример #3
0
    def test_fields(self, **kw):
        form = HTMLForm(loadFromType="type1", app=self.app, view=self.view, request=Request())
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"
        # create
        form.Setup()

        f = form.GetFields(removeReadonly=True)
        self.assert_(len(f)==len(db_app.type1.data)+len(db_app.appconf.meta)-len(ReadonlySystemFlds)-len(UserFlds))
        f = form.GetFields(removeReadonly=False)
        self.assert_(len(f)==len(db_app.type1.data)+len(db_app.appconf.meta)-len(ReadonlySystemFlds))
Пример #4
0
    def test_fields(self, **kw):
        form = HTMLForm(loadFromType="type1", app=self.app, view=self.view, request=Request())
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"
        # create
        form.Setup()

        f = form.GetFields(removeReadonly=True)
        self.assert_(len(f) == 9)
        f = form.GetFields(removeReadonly=False)
        self.assert_(len(f) == 14)
Пример #5
0
    def editroot(self):
        self.ResetFlashMessages()
        defaultroot = self.context.app.root()
        form = HTMLForm(view=self,
                        context=defaultroot,
                        loadFromType=self.context.configuration)
        form.use_ajax = True
        form.Setup(subset="edit")

        def updateRoot(data):
            # map pool_filename to deault root
            defaultroot.Update(data, user=self.User())
            if "pool_filename" in data:
                del data["pool_filename"]
            self.context.Update(data, user=self.User())

        form.ListenEvent("success", updateRoot)

        default = form.LoadObjData(defaultroot)
        result, data, action = form.Process(redirectSuccess="page_url",
                                            defaultData=default)
        return {
            u"content": data,
            u"result": result,
            u"cmsview": self,
            u"head": form.HTMLHead()
        }
Пример #6
0
    def test_actions(self, **kw):
        form = HTMLForm(loadFromType="type1", app=self.app, view=self.view, request=Request())
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"

        # create
        form.actions = [
            Conf(
                **{
                    "id": "default",
                    "method": "StartForm",
                    "name": "Initialize",
                    "hidden": True,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": "",
                }
            ),
            Conf(
                **{
                    "id": "create",
                    "method": "CreateObj",
                    "name": "Create",
                    "hidden": False,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": "",
                }
            ),
            Conf(
                **{
                    "id": "cancel",
                    "method": "Cancel",
                    "name": "Cancel",
                    "hidden": False,
                    "description": "",
                    "css_class": "",
                    "html": "",
                    "tag": "",
                }
            ),
        ]
        form.Setup()
        a = form.GetActions(removeHidden=False)
        self.assert_(len(a) == 3)
        a = form.GetActions(removeHidden=True)
        self.assert_(len(a) == 2)
Пример #7
0
    def editroot(self):
        self.ResetFlashMessages()
        defaultroot = self.context.app.root()
        form = HTMLForm(view=self, context=defaultroot, loadFromType=defaultroot.configuration)
        form.use_ajax = True
        form.Setup(subset="edit")

        def updateRoot(data):
            # map pool_filename to deault root
            defaultroot.Update(data, user=self.User())
            #self.context.app.CloseRoot(ref)
        form.ListenEvent("success", updateRoot)
        
        default = form.LoadObjData(defaultroot)
        result, data, action = form.Process(redirectSuccess="page_url", defaultData=default)
        return {u"content": data, u"result": result, u"cmsview":self, u"head": form.HTMLHead()}
Пример #8
0
 def test_form(self, **kw):
     form = HTMLForm(loadFromType="type1", context=None, request=Request(), app=self.app, view=self.view)
     form.Setup()
     self.assert_(form.GetFields())
     form._SetUpSchema()
     self.assertFalse(form.GetField("test000"))
     request = Request()
     form.LoadDefaultData()
     form.GetActions(True)
     form.GetActions(False)
     form.GetFormValue("test", request=request, method=None)
     form.GetFormValues(request)
     form.StartForm("action", defaultData={"a":1})
     form.StartForm("action")
     form.StartRequestGET("action")
     form.StartRequestPOST("action")
     form.Cancel("action")
Пример #9
0
    def test_html(self, **kw):
        form = HTMLForm(loadFromType="type1", app=self.app, view=self.view, request=Request())
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"
        form.Setup()

        v,d,e = form.Validate(data1_1)
        self.assert_(v, str(e))
        
        v,d,e = form.Validate(data1_2)
        self.assertFalse(v, e)
        form.Render(d, msgs=None, errors=None)
        
        result, data = form.Extract(data1_1)
        self.assert_(data)
        result, data = form.Extract(data1_2)
        self.assert_(data)
Пример #10
0
    def test_html(self, **kw):
        form = HTMLForm(loadFromType="type1",
                        app=self.app,
                        view=self.view,
                        request=Request())
        form.formUrl = "form/url"
        form.cssID = u"upload"
        form.css_class = u"niveform"
        form.Setup()

        v, d, e = form.Validate(data1_1)
        self.assert_(v, str(e))

        v, d, e = form.Validate(data1_2)
        self.assertFalse(v, e)
        form.Render(d, msgs=None, errors=None)

        result, data = form.Extract(data1_1)
        self.assert_(data)
        result, data = form.Extract(data1_2)
        self.assert_(data)