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
def __init__(self, response): super(GetFormResult, self).__init__(response) self.raw = {} self.revision = -1 self.fields = [] if self.ok: serialized = response.json() if "properties" in serialized: self.revision = int(serialized["revision"]) self.raw = serialized["properties"] from pykintone.application_settings.form import FormAPI self.fields = FormAPI.load_properties(self.raw)
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))
def form(self): from pykintone.application_settings.form import FormAPI return FormAPI(self.account, self.api_token, self.requests_options, self.app_id)