Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
fix bug 899665 - add change update subscription link for parents of t…
Browse files Browse the repository at this point in the history
…ranslated pages
  • Loading branch information
jezdez committed Oct 22, 2014
1 parent 4360ac1 commit 6218566
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
26 changes: 18 additions & 8 deletions kuma/wiki/templates/wiki/includes/document_macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<li><bdi><a rel="internal" href="{{ url('wiki.document', translation.full_path, locale=translation.locale) }}" title="{{ translation.title }}">{{ translation.language }}</a></bdi></li>
{% endfor %}
{% else %}
<li class="smaller">{{ _('No translations exist for this document.') }}</li>
<li class="smaller">{{ _('No translations exist for this article.') }}</li>
{% endif %}

{% if document.is_localizable %}
Expand All @@ -50,13 +50,23 @@
<li><a href="{{ url('wiki.document_revisions', document.full_path) }}">{{_('History')}}</a></li>
{% if user.is_authenticated() and document %}
<li class="page-watch">

<form action="{{ url('wiki.subscribe_document', document.slug) }}" method="post">
{{ csrf() }}
<a href="#" data-subscribe-text="{{ _('Subscribe') }}" data-unsubscribe-text="{{ _('Unsubscribe') }}">
{% if document.is_watched_by(user) %}{{ _('Unsubscribe') }}{% else %}{{ _('Subscribe') }}{% endif %}
</a>
</form>
{% set subscribe_status = _('Updating subscription status') %}
<form action="{{ url('wiki.subscribe_document', document.slug, locale=document.locale) }}" method="post">
{{ csrf() }}
<a href="#" data-subscribe-status="{{ subscribe_status }}" data-subscribe-text="{{ _('Subscribe to this article') }}" data-unsubscribe-text="{{ _('Unsubscribe from this article') }}" data-subscribe-message="{{ _('You are now subscribed to this article.') }}" data-unsubscribe-message="{{ _('You have been unsubscribed from this article.') }}">
{% if document.is_watched_by(user) %}{{ _('Unsubscribe from this article') }}{% else %}{{ _('Subscribe to this article') }}{% endif %}
</a>
</form>

{% if document.parent %}
{% set parent_language = document.parent.language %}
<form action="{{ url('wiki.subscribe_document', document.parent.slug, locale=document.parent.locale) }}" method="post">
{{ csrf() }}
<a href="#" data-subscribe-status="{{ subscribe_status }}" data-subscribe-text="{{ _('Subscribe to {language} version')|f(language=parent_language) }}" data-unsubscribe-text="{{ _('Unsubscribe from {language} version')|f(language=parent_language) }}" data-subscribe-message="{{ _('You are now subscribed to the {language} version of this article.')|f(language=parent_language) }}" data-unsubscribe-message="{{ _('You have been unsubscribed from the {language} version of this article.')|f(language=parent_language) }}">
{% if document.parent.is_watched_by(user) %}{{ _('Unsubscribe from {language} version')|f(language=parent_language) }}{% else %}{{ _('Subscribe to {language} version')|f(language=parent_language) }}{% endif %}
</a>
</form>
{% endif %}

</li>{% endif %}
{% if user.is_authenticated() and not document.is_template %}
Expand Down
8 changes: 4 additions & 4 deletions media/redesign/js/wiki.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@

var $form = $link.closest('form');

var notification = mdn.Notifier.growl(gettext('Updating subscription status'), { duration: 0 });
var notification = mdn.Notifier.growl($link.data('subscribe-status'), { duration: 0 });

$link.addClass('disabled');
$.ajax($form.attr('action'), {
Expand All @@ -142,14 +142,14 @@
data = JSON.parse(data);
if(Number(data.status) === 1) {
$link.text($link.data('unsubscribe-text'));
message = 'You are now subscribed to this document.';
message = $link.data('subscribe-message');
}
else {
$link.text($link.data('subscribe-text'));
message = 'You have been unsubscribed from this document.';
message = $link.data('unsubscribe-message');
}

notification.success(gettext(message), 2000);
notification.success(message, 2000);

$link.removeClass('disabled');
});
Expand Down

0 comments on commit 6218566

Please sign in to comment.