Skip to content

Commit 3b51b65

Browse files
authored
Merge pull request #10 from Guidebook/add-relations
Update alphabetize to use custom list item relations
2 parents e32aa14 + 1f4d704 commit 3b51b65

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ def _alphabetize_all_items(builder_client, guide_id, customlist_id):
7171

7272
rank = 0
7373
for item in sorted_list:
74-
item_patch_url = "https://builder.guidebook.com/open-api/v1/custom-list-items/{}/".format(item['id'])
75-
builder_client.patch(item_patch_url, data={'rank': rank})
74+
relation_url = f"https://builder.guidebook.com/open-api/v1/custom-list-item-relations/?custom_list_item={item['id']}&custom_list={customlist_id}"
75+
cutom_list_item_relation = builder_client.get(relation_url).json()['results'][0]
76+
relation_patch_url = f"https://builder.guidebook.com/open-api/v1/custom-list-item-relations/{cutom_list_item_relation['id']}/"
77+
builder_client.patch(relation_patch_url, data={'rank': rank})
7678
rank += 1

0 commit comments

Comments
 (0)