Example #1
0
 def create(cls, name, fields, view_type="", builtin_type="", filter_cond="", sort="", index=-1):
     from pykintone.application_settings.form import FormAPI
     v = View()
     v.name = name
     v.fields = FormAPI.gather_codes(fields)
     v.view_type = view_type if view_type else v.view_type
     v.builtin_type = builtin_type if builtin_type else v.builtin_type
     v.filter_cond = filter_cond
     v.sort = sort
     v.index = index if index > -1 else v.index
     return v
Example #2
0
 def create(cls,
            name,
            fields,
            view_type="",
            builtin_type="",
            filter_cond="",
            sort="",
            index=-1):
     from pykintone.application_settings.form import FormAPI
     v = View()
     v.name = name
     v.fields = FormAPI.gather_codes(fields)
     v.view_type = view_type if view_type else v.view_type
     v.builtin_type = builtin_type if builtin_type else v.builtin_type
     v.filter_cond = filter_cond
     v.sort = sort
     v.index = index if index > -1 else v.index
     return v
Example #3
0
    def test_update_views(self):
        ks = pykintone.load(envs.FILE_PATH)
        view_api = ks.app(self.TEST_APP.app_id).administration().view()

        view_name = "test_view"
        codes = FormAPI.gather_codes(self._default_form())
        views = View.create(view_name, codes[1:])

        # add views
        add_result = view_api.update(views)
        self.assertTrue(add_result.ok)
        v_def = view_api.get(preview=True).views
        self.assertEqual(1, len(v_def))

        # update fields
        views = [View.create(view_name, codes), View.create("another_view", codes,  index=2)]
        update_result = view_api.update(views, revision=add_result.revision)
        self.assertTrue(update_result.ok)
        v_def = view_api.get(preview=True).views
        self.assertEqual(2, len(v_def))
        original = [v for v in v_def if v.name == view_name][0]
        self.assertEqual(len(codes), len(original.fields))