Skip to content

Commit

Permalink
Merge pull request #55 from andrewrgoss/master
Browse files Browse the repository at this point in the history
Create_labels_if_missing parameter for updating multiple column values
  • Loading branch information
chdastolfo authored May 5, 2022
2 parents 6b301dc + 68c8897 commit 2de9c46
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion monday/__version__.py
Original file line number Diff line number Diff line change
@@ -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'
11 changes: 6 additions & 5 deletions monday/query_joins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
7 changes: 4 additions & 3 deletions monday/resources/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 9 additions & 5 deletions monday/tests/test_item_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand All @@ -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)
Expand Down

0 comments on commit 2de9c46

Please sign in to comment.