Skip to content

Add product version to question cards for contributors#7553

Open
denyshon wants to merge 1 commit into
mozilla:mainfrom
denyshon:product-version-question-cards
Open

Add product version to question cards for contributors#7553
denyshon wants to merge 1 commit into
mozilla:mainfrom
denyshon:product-version-question-cards

Conversation

@denyshon

@denyshon denyshon commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Resolves #2958.

To avoid fetching tags, we can use question metadata to get product versions (and display them). However, if we use raw data from the corresponding fields, this would expose us to all kinds of spam and UI breakages related to user input. In order to prevent that, this patch saves our validated version number (used to apply tags) into a separate question metadata field, and then displays it on question cards. For older questions, we fall back to the raw data from the version fields.

The SCSS changes do not represent any visual change, and are purely for clarity/future.

tags.append(f"{product_name} {version}")
if tenths and tenths != version:
tags.append(f"{product_name} {tenths}")
self.add_metadata(sanitized_product_version=sanitized_product_version)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be called on every update of the question. The add_metadata will call basically the QuestionMetaData.objects.create(...) but he model has a unique constraint applied. I suspect this is is going to lead to an IntegrityError from the DB.

</svg>
{{ question.product.title }}
</a>
{% if user_is_contributor %}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can push the logic with the nested if statements into python in a @property like display_version to simplify the template to something like

{% if user_is_contributor and question.display_version %}
  {{ question.display_version }}
{% endif %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Display product version on question cards

2 participants