in kitsune/questions/models.py [0:0]
def auto_tag(self):
"""Apply tags to myself that are implied by my metadata.
You don't need to call save on the question after this.
"""
to_add = []
if product_config := self.product_config:
for tag in product_config.associated_tags.all():
to_add.append(tag)
version = self.metadata.get("ff_version", "")
# Remove the beta (b*), aurora (a2) or nightly (a1) suffix.
version = re.split("[a-b]", version)[0]
dev_releases = product_details.firefox_history_development_releases
if (
version in dev_releases
or version in product_details.firefox_history_stability_releases
or version in product_details.firefox_history_major_releases
):
to_add.append("Firefox %s" % version)
tenths = _tenths_version(version)
if tenths:
to_add.append("Firefox %s" % tenths)
elif _has_beta(version, dev_releases):
to_add.append("Firefox %s" % version)
to_add.append("beta")
# Add a tag for the OS if it already exists as a tag:
if os := self.metadata.get("os"):
try:
add_existing_tag(os, self.tags)
except SumoTag.DoesNotExist:
pass
product_md = self.metadata.get("product")
topic_md = self.metadata.get("category")
if self.product and not product_md:
to_add.append(self.product.slug)
if self.topic and not topic_md:
to_add.append(self.topic.slug)
self.tags.add(*to_add)