Skip to content

Commit

Permalink
indicate articles that are targets of in-product links
Browse files Browse the repository at this point in the history
  • Loading branch information
escattone committed Apr 8, 2024
1 parent cf8b3a9 commit f85947b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions kitsune/sumo/static/sumo/img/fa-bullseye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions kitsune/wiki/jinja2/wiki/document.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@
{{ search_box(settings, id='support-search-sidebar', params=search_params) }}
</div>

{% if document.is_inproduct_target %}
<div class="sidebar-subheading">
<img height=32 width=32 src="{{ webpack_static('sumo/img/fa-bullseye.svg') }}" alt="{{ _('Target') }}" />
{{ _("In-Product Link") }}
</div>
{% endif %}

{{ aaq_widget(request, "document") }}

{% if fallback_reason == 'no_translation' %}
Expand Down
12 changes: 12 additions & 0 deletions kitsune/wiki/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from pyquery import PyQuery

from kitsune.gallery.models import Image
from kitsune.inproduct.models import Redirect
from kitsune.products.models import Product, Topic
from kitsune.sumo.apps import ProgrammingError
from kitsune.sumo.i18n import split_into_language_and_path
Expand Down Expand Up @@ -779,6 +780,17 @@ def is_unrestricted_for(self, user, use_cache=True):

return user.id in self.unrestricted_for_user_ids

@cached_property
def is_inproduct_target(self):
if self.parent:
return Redirect.objects.filter(
(Q(locale__in=("", self.locale)) & Q(target__contains=f"kb/{self.parent.slug}"))
| (Q(locale=self.locale) & Q(target__contains=f"kb/{self.slug}"))
).exists()
return Redirect.objects.filter(
locale__in=("", self.locale), target__contains=f"kb/{self.slug}"
).exists()


class AbstractRevision(models.Model):
# **%(class)s** is being used because it will allow a unique reverse name for the field
Expand Down

0 comments on commit f85947b

Please sign in to comment.