From 84c8a638b85292e6fa0ff8acd20024fd42c112bc Mon Sep 17 00:00:00 2001 From: andrewrgoss Date: Fri, 1 Apr 2022 12:13:01 -0400 Subject: [PATCH 1/2] allow create_labels_if_missing parameter to be passed when updating multiple column values --- README.md | 2 +- monday/query_joins.py | 11 ++++++----- monday/resources/items.py | 7 ++++--- monday/tests/test_item_resource.py | 14 +++++++++----- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 67cc005..7720eb6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ monday.items.create_item(board_id='12345678', group_id='today', item_name='Do a - `change_item_value(board_id, item_id, column_id, value)` - Change column values for item on a board. Check Monday's API for which columns are supported. -- `change_multiple_column_values(board_id, item_id, column_values)` - Change multiple column values for item on a board. Column values should be passed in as JSON. Check Monday's API for which columns are supported. +- `change_multiple_column_values(board_id, item_id, column_values, create_labels_if_missing=False)` - Change multiple column values for item on a board. Column values should be passed in as JSON. Check Monday's API for which columns are supported. - `add_file_to_column(item_id, column_id, file)` - Upload a file to a file type column specified by column_id. Monday limits uploads to 500MB in size. diff --git a/monday/query_joins.py b/monday/query_joins.py index dd58a66..db34840 100644 --- a/monday/query_joins.py +++ b/monday/query_joins.py @@ -139,13 +139,14 @@ def delete_item_query(item_id): return query -def update_multiple_column_values_query(board_id, item_id, column_values): +def update_multiple_column_values_query(board_id, item_id, column_values, create_labels_if_missing): query = '''mutation { change_multiple_column_values ( board_id: %s, item_id: %s, - column_values: %s + column_values: %s, + create_labels_if_missing: %s ) { id name @@ -154,7 +155,7 @@ def update_multiple_column_values_query(board_id, item_id, column_values): text } } - }''' % (board_id, item_id, monday_json_stringify(column_values)) + }''' % (board_id, item_id, monday_json_stringify(column_values), str(create_labels_if_missing).lower()) return query @@ -495,7 +496,7 @@ def create_workspace_query(name, kind, description=""): } } ''' % (name, kind, description) - return query + return query def add_users_to_workspace_query(id, user_ids, kind): @@ -553,5 +554,5 @@ def create_notification_query(user_id, target_id, text, target_type): } } ''' % (user_id, target_id, text, target_type) - # Target type may be: Project/Post + # Target type may be: Project/Post return query diff --git a/monday/resources/items.py b/monday/resources/items.py index 9d708f2..7d8aa1d 100644 --- a/monday/resources/items.py +++ b/monday/resources/items.py @@ -31,14 +31,15 @@ def change_item_value(self, board_id, item_id, column_id, value): query = update_item_query(board_id, item_id, column_id, value) return self.client.execute(query) - def change_multiple_column_values(self, board_id, item_id, column_values): - query = update_multiple_column_values_query(board_id, item_id, column_values) + def change_multiple_column_values(self, board_id, item_id, column_values, create_labels_if_missing=False): + query = update_multiple_column_values_query( + board_id, item_id, column_values, create_labels_if_missing) return self.client.execute(query) def add_file_to_column(self, item_id, column_id, file): query = add_file_to_column_query(item_id, column_id) return self.file_upload_client.execute(query, variables={'file': file}) - + def delete_item_by_id(self, item_id): query = delete_item_query(item_id) return self.client.execute(query) diff --git a/monday/tests/test_item_resource.py b/monday/tests/test_item_resource.py index 27d199c..0141db9 100644 --- a/monday/tests/test_item_resource.py +++ b/monday/tests/test_item_resource.py @@ -18,13 +18,15 @@ def test_mutate_item_query(self): self.assertNotIn("create_labels_if_missing: true", query) def test_get_item_query(self): - query = get_item_query(board_id=self.board_id, column_id=self.column_id, value="foo") + query = get_item_query(board_id=self.board_id, + column_id=self.column_id, value="foo") self.assertIn(str(self.board_id), query) self.assertIn(self.column_id, query) self.assertIn("foo", query) def test_update_item_query(self): - query = update_item_query(board_id=self.board_id, item_id=self.item_id, column_id=self.column_id, value="foo") + query = update_item_query( + board_id=self.board_id, item_id=self.item_id, column_id=self.column_id, value="foo") self.assertIn(str(self.board_id), query) self.assertIn(str(self.item_id), query) self.assertIn(self.column_id, query) @@ -36,10 +38,11 @@ def get_item_by_id_query(self): def test_update_multiple_column_values(self): query = update_multiple_column_values_query(board_id=self.board_id, item_id=self.item_id, - column_values=self.column_values) + column_values=self.column_values, create_labels_if_missing=False) self.assertIn(str(self.board_id), query) self.assertIn(str(self.item_id), query) self.assertIn(monday_json_stringify(self.column_values), query) + self.assertNotIn("create_labels_if_missing: true", query) def test_mutate_subitem_query(self): query = mutate_subitem_query(parent_item_id=self.item_id, subitem_name=self.subitem_name, column_values=None, @@ -49,10 +52,11 @@ def test_mutate_subitem_query(self): self.assertNotIn("create_labels_if_missing: true", query) def test_add_file_to_column_query(self): - query = add_file_to_column_query(item_id=self.item_id, column_id=self.column_id) + query = add_file_to_column_query( + item_id=self.item_id, column_id=self.column_id) self.assertIn(str(self.item_id), query) self.assertIn(str(self.column_id), query) - + def test_delete_item_by_id(self): query = delete_item_query(item_id=self.item_id) self.assertIn(str(self.item_id), query) From 68c88977f48bae9fcd924e24d2460b45691da6c4 Mon Sep 17 00:00:00 2001 From: andrewrgoss Date: Mon, 25 Apr 2022 11:23:27 -0400 Subject: [PATCH 2/2] bump version --- monday/__version__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monday/__version__.py b/monday/__version__.py index efb50bf..8ef82a1 100644 --- a/monday/__version__.py +++ b/monday/__version__.py @@ -1,3 +1,3 @@ -__version__ = '1.2.9' +__version__ = '1.3.0' __author__ = 'Christina D\'Astolfo' __email__ = 'chdastolfo@gmail.com, pevner@prodperfect.com, lemi@prodperfect.com'