[Bug 787360] Localization for TYPO_SIGNIFICANCE

This commit includes:

 - Backend ignore request to mark ready to localize if the revision is
   of TYPO_SIGNIFICANCE.
 - Reworked tests so that if they want an localization mail, it needs to
   be able to use MEDIUM_SIGNIFICANCE.
 - Hide the option for mark as ready for localization if reviewer
   selects typo significance in the front end.

Depends on:

 - PR #1395

Style fix

Fixed up the code. Added tests
This commit is contained in:
Shuhao Wu 2013-05-28 12:27:40 -07:00
Родитель 0588c6ba4c
Коммит 1de9134f33
4 изменённых файлов: 37 добавлений и 7 удалений

Просмотреть файл

@ -5,7 +5,7 @@ from nose.tools import eq_
from sumo.tests import post
from users.tests import add_permission, user
from wiki.config import SIGNIFICANCES, MEDIUM_SIGNIFICANCE
from wiki.config import SIGNIFICANCES, MEDIUM_SIGNIFICANCE, TYPO_SIGNIFICANCE
from wiki.events import ReadyRevisionEvent, ApproveRevisionInLocaleEvent
from wiki.models import Revision
from wiki.tests import revision, TestCaseBase
@ -43,18 +43,20 @@ class ReviewTests(TestCaseBase):
add_permission(approver, Revision, 'mark_ready_for_l10n')
self.client.login(username=approver.username, password='testpass')
def _review_revision(self, is_approved=True, is_ready=False, r=None):
def _review_revision(self, is_approved=True, is_ready=False,
significance=SIGNIFICANCES[0][0], r=None):
"""Make a revision, and approve or reject it through the view."""
if not r:
r = revision(is_approved=False,
is_ready_for_localization=False,
significance=significance,
save=True)
# Figure out POST data:
data = {'comment': 'đSome comment'}
if is_approved:
data['approve'] = 'Approve Revision'
data['significance'] = SIGNIFICANCES[0][0]
data['significance'] = significance
if is_ready:
data['is_ready_for_localization'] = 'on'
else:
@ -70,13 +72,20 @@ class ReviewTests(TestCaseBase):
"""Show that a ready(-and-approved) rev mails Ready watchers a Ready
notification and Approved watchers an Approved one."""
_set_up_ready_watcher()
self._review_revision(is_ready=True)
self._review_revision(is_ready=True, significance=MEDIUM_SIGNIFICANCE)
# 1 mail to each watcher, 1 to the creator, and one to the reviewer
eq_(4, len(mail.outbox))
_assert_ready_mail(mail.outbox[0])
_assert_approved_mail(mail.outbox[1])
_assert_creator_mail(mail.outbox[2])
def test_typo_significance_ignore(self):
_set_up_ready_watcher()
self._review_revision(is_ready=True, significance=TYPO_SIGNIFICANCE)
# This is the same as test_ready, except we miss 1 mail, that is the
# localization mail.
eq_(3, len(mail.outbox))
def test_approved(self):
"""Show that an approved rev mails Ready watchers nothing and Approved
watchers an Approved notification."""
@ -125,7 +134,7 @@ class ReviewTests(TestCaseBase):
# Have the Approved watcher watch Ready as well:
ReadyRevisionEvent.notify(self.approved_watcher)
self._review_revision(is_ready=True)
self._review_revision(is_ready=True, significance=MEDIUM_SIGNIFICANCE)
# 1 mail to watcher, 1 to creator, 1 to reviewer
eq_(3, len(mail.outbox))
_assert_ready_mail(mail.outbox[0])

Просмотреть файл

@ -1328,7 +1328,7 @@ class ReviewRevisionTests(TestCaseBase):
"""Verify revision approval with ready for l10n."""
add_permission(self.user, Revision, 'mark_ready_for_l10n')
# Approve something:
significance = SIGNIFICANCES[0][0]
significance = SIGNIFICANCES[1][0]
response = post(self.client, 'wiki.review_revision',
{'approve': 'Approve Revision',
'significance': significance,

Просмотреть файл

@ -473,7 +473,7 @@ def review_revision(request, document_slug, revision_id):
# If document is localizable and revision was approved and
# user has permission, set the is_ready_for_localization value.
if (doc.allows(request.user, 'mark_ready_for_l10n') and
rev.is_approved):
rev.is_approved and rev.can_be_readied_for_localization()):
rev.is_ready_for_localization = form.cleaned_data[
'is_ready_for_localization']

Просмотреть файл

@ -69,11 +69,32 @@
initReadyForL10n();
initArticleApproveModal();
initRevisionList();
$('img.lazy').lazyload();
}
function initArticleApproveModal() {
if ($('#approve-modal').length > 0) {
var onSignificanceClick = function(e) {
// Hiding if the significance is typo.
// .parent() is because #id_is_ready_for_localization is inside a
// <label>, as is the text
if (e.target.id === 'id_significance_0') {
$('#id_is_ready_for_localization').parent().hide();
} else {
$('#id_is_ready_for_localization').parent().show();
}
};
$('#id_significance_0').click(onSignificanceClick);
$('#id_significance_1').click(onSignificanceClick);
$('#id_significance_2').click(onSignificanceClick);
}
}
// Make <summary> and <details> tags work even if the browser doesn't support them.
// From http://mathiasbynens.be/notes/html5-details-jquery
function initDetailsTags() {