Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL touristiccontent_category can return types that are not properly associated with their respective category #4487

Open
justinefricou opened this issue Feb 6, 2025 · 0 comments
Labels

Comments

@justinefricou
Copy link
Contributor

The api/v2/touristiccontent_category endpoint returns TouristicContentCategory objects and for each of them, all TouristicContentType objects that are associated with it in a touristic content that is published and has not been deleted:

} for t in obj.types.has_content_published_not_deleted_in_list(i, obj.pk, portals, language)]

However, if a touristic content contains a category along with a type that is not associated with this category (even though this should not be possible, which is another topic), the endpoint will return the type as associated with the category.

Example (steps to reproduce):

  1. Create two categories C1 and C2, each containing a type1 (or type2) option:

Image

  1. Create two touristic contents, each associated with a category and its corresponding type option, and ensure they are both published:

Image

  1. Call api/v2/touristiccontent_category -> both categories and their type options are correct:

Image

  1. In the database, update the second touristic content's type to the one associated with the other category:
UPDATE tourism_touristiccontent_type1 SET touristiccontenttype1_id = 1 WHERE id = 2;
  1. Call api/v2/touristiccontent_category again -> the data for the second category should not appear in the response, as there is no valid pair (category, type) associated with a published touristic content for C2. Instead, the response still includes the second category which contains the type option from the first category:

Actual | Expected :

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant