api will 302 instead of 404 when item model changed
This commit is contained in:
parent
86289bdaab
commit
1fa6a09cbb
2 changed files with 6 additions and 1 deletions
|
@ -66,7 +66,7 @@ def fetch_item(request, url: str):
|
|||
|
||||
|
||||
def _get_item(cls, uuid, response):
|
||||
item = cls.get_by_url(uuid)
|
||||
item = Item.get_by_url(uuid)
|
||||
if not item:
|
||||
return 404, {"message": "Item not found"}
|
||||
if item.merged_to_item:
|
||||
|
@ -74,6 +74,9 @@ def _get_item(cls, uuid, response):
|
|||
return 302, {"message": "Item merged", "url": item.merged_to_item.api_url}
|
||||
if item.is_deleted:
|
||||
return 404, {"message": "Item not found"}
|
||||
if item.__class__ != cls:
|
||||
response["Location"] = item.api_url
|
||||
return 302, {"message": "Item recasted", "url": item.api_url}
|
||||
return item
|
||||
|
||||
|
||||
|
|
|
@ -243,6 +243,8 @@ def fetch_tvepisodes(request, item_path, item_uuid):
|
|||
def fetch_episodes_for_season_task(item_uuid, user):
|
||||
with set_actor(user):
|
||||
season = Item.get_by_url(item_uuid)
|
||||
if not season:
|
||||
return
|
||||
episodes = season.episode_uuids
|
||||
IMDB.fetch_episodes_for_season(season)
|
||||
season.log_action({"!fetch_tvepisodes": [episodes, season.episode_uuids]})
|
||||
|
|
Loading…
Add table
Reference in a new issue