Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kitsune/questions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def handle_metadata_tags(self, action):
# beta exists. A bare version is tagged only if it's a known
# major/stability release.
match = re.match(r"(\d+(?:\.\d+){0,2})([ab]\d*)?", raw_version)
sanitized_product_version = ""
if match:
version, suffix = match.group(1), match.group(2)
if "." not in version:
Expand All @@ -327,14 +328,17 @@ def handle_metadata_tags(self, action):

if suffix:
if any(key.startswith(f"{version}b") for key in development_releases):
sanitized_product_version = f"{version}b"
tags.append(f"{product_name} {version}")
if tenths and tenths != version:
tags.append(f"{product_name} {tenths}")
tags.append("beta")
elif version in major_releases or version in stability_releases:
sanitized_product_version = version
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.


# Add a tag for the OS but only if it already exists as a non-segmentation tag.
if os := self.metadata.get("os"):
Expand Down
13 changes: 13 additions & 0 deletions kitsune/sumo/jinja2/sumo/includes/question_entry.html
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ <h3 class="question-entry--title">
<div class="question-entry--meta">
<div class="question-entry--meta-primary">
{% if question.product and _product_url %}
<span class="question-entry--meta-item">
<a class="question-entry--meta-item"
href="{{ _product_url }}"
title="{{ _('{product} questions')|f(product=question.product.title) }}">
Expand All @@ -199,6 +200,18 @@ <h3 class="question-entry--title">
</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 %}

{% if question.metadata.sanitized_product_version is defined %}
{% if question.metadata.sanitized_product_version %}
{{ question.metadata.sanitized_product_version }}
{% endif %}
{% elif (question.product.slug == "firefox" or question.product.slug == "mobile" or question.product.slug == "ios") and question.metadata.ff_version | default(None, true) %}
{{ question.metadata.ff_version }}
{% elif (question.product.slug == "thunderbird" or question.product.slug == "thunderbird-android") and question.metadata.tb_version | default(None, true) %}
{{ question.metadata.tb_version }}
{% endif %}
{% endif %}
</span>
{% endif %}
{% if question.topic and _topic_url %}
<a class="question-entry--meta-item"
Expand Down
25 changes: 13 additions & 12 deletions kitsune/sumo/static/sumo/scss/layout/_question-entry.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,21 @@
flex-shrink: 0;
}

* {
position: relative;
z-index: 1;
}
}

a.question-entry--meta-item:hover {
color: var(--color-link);
text-decoration: underline;
}
a.question-entry--meta-item,
.question-entry--meta-item a {
text-decoration: none;

&:hover {
color: var(--color-link);
text-decoration: underline;
}
}

.question-entry--reply-count,
.question-entry--vote-count {
Expand All @@ -137,16 +146,8 @@ a.question-entry--meta-item:hover {
}

.question-entry--meta-asked-by {
position: relative;
z-index: 1;
color: var(--color-heading);
font-weight: 600;
text-decoration: none;

&:hover {
text-decoration: underline;
color: var(--color-link);
}
}

.question-entry--last-reply {
Expand Down