def watch_approved(request): """Start watching approved revisions in a locale.""" if request.LANGUAGE_CODE not in settings.SUMO_LANGUAGES: raise Http404 ApproveRevisionInLocaleEvent.notify(request.user, locale=request.LANGUAGE_CODE) statsd.incr('wiki.watches.approved') return HttpResponse()
def setUp(self): """Have a user watch for revision approval. Log in.""" self.approved_watcher = user(email="*****@*****.**", save=True) ApproveRevisionInLocaleEvent.notify(self.approved_watcher, locale="en-US") approver = user(save=True) add_permission(approver, Revision, "review_revision") add_permission(approver, Revision, "mark_ready_for_l10n") self.client.login(username=approver.username, password="******")
def setUp(self): """Have a user watch for revision approval. Log in.""" self.approved_watcher = user(email='*****@*****.**', save=True) ApproveRevisionInLocaleEvent.notify(self.approved_watcher, locale='en-US') approver = user(save=True) add_permission(approver, Revision, 'review_revision') add_permission(approver, Revision, 'mark_ready_for_l10n') self.client.login(username=approver.username, password='******')
def setUp(self): """Have a user watch for revision approval. Log in.""" self.approved_watcher = UserFactory(email="*****@*****.**") ApproveRevisionInLocaleEvent.notify(self.approved_watcher, locale="en-US") approver = UserFactory() add_permission(approver, Revision, "review_revision") add_permission(approver, Revision, "mark_ready_for_l10n") self.client.login(username=approver.username, password="******")
def setUp(self): """Have a user watch for revision approval. Log in.""" self.approved_watcher = UserFactory(email='*****@*****.**') ApproveRevisionInLocaleEvent.notify(self.approved_watcher, locale='en-US') approver = UserFactory() add_permission(approver, Revision, 'review_revision') add_permission(approver, Revision, 'mark_ready_for_l10n') self.client.login(username=approver.username, password='******')
def watch_approved(request, product=None): """Start watching approved revisions in a locale for a given product.""" if request.LANGUAGE_CODE not in settings.SUMO_LANGUAGES: raise Http404 kwargs = {'locale': request.LANGUAGE_CODE} if product is not None: kwargs['product'] = product ApproveRevisionInLocaleEvent.notify(request.user, **kwargs) statsd.incr('wiki.watches.approved') return HttpResponse()
def test_product_specific_ready(self): """Verify product-specific ready for review notifications.""" # Add an all products in 'es' watcher and a Firefox OS in 'es' # watcher. ApproveRevisionInLocaleEvent.notify(UserFactory(), locale='es') ApproveRevisionInLocaleEvent.notify(UserFactory(), product='firefox-os', locale='es') # Create an 'es' document for Firefox parent = DocumentFactory() doc = DocumentFactory(parent=parent, locale='es') parent.products.add(ProductFactory(slug='firefox')) # Review a revision. There should be 3 new emails: # 1 to the creator, 1 to the reviewer and 1 to the 'es' watcher. self._review_revision(document=doc, is_ready=True, significance=MEDIUM_SIGNIFICANCE) eq_(3, len(mail.outbox)) _assert_approved_mail(mail.outbox[0]) _assert_creator_mail(mail.outbox[1]) # Add firefox-os to the document's products and review a new revision. # There should be 4 new emails now (the same 3 from before plus one # for the firefox-os watcher). parent.products.add(ProductFactory(slug='firefox-os')) self._review_revision(document=doc, is_ready=True, significance=MEDIUM_SIGNIFICANCE) eq_(7, len(mail.outbox)) _assert_approved_mail(mail.outbox[3]) _assert_approved_mail(mail.outbox[4]) _assert_creator_mail(mail.outbox[5]) # Add a Firefox watcher. This time there should be 5 new emails. ApproveRevisionInLocaleEvent.notify(UserFactory(), product='firefox', locale='es') self._review_revision(document=doc, is_ready=True, significance=MEDIUM_SIGNIFICANCE) eq_(12, len(mail.outbox))
def test_product_specific_ready(self): """Verify product-specific ready for review notifications.""" # Add an all products in 'es' watcher and a Firefox OS in 'es' # watcher. ApproveRevisionInLocaleEvent.notify(UserFactory(), locale='es') ApproveRevisionInLocaleEvent.notify( UserFactory(), product='firefox-os', locale='es') # Create an 'es' document for Firefox parent = DocumentFactory() doc = DocumentFactory(parent=parent, locale='es') parent.products.add(ProductFactory(slug='firefox')) # Review a revision. There should be 3 new emails: # 1 to the creator, 1 to the reviewer and 1 to the 'es' watcher. self._review_revision( document=doc, is_ready=True, significance=MEDIUM_SIGNIFICANCE) eq_(3, len(mail.outbox)) _assert_approved_mail(mail.outbox[0]) _assert_creator_mail(mail.outbox[1]) # Add firefox-os to the document's products and review a new revision. # There should be 4 new emails now (the same 3 from before plus one # for the firefox-os watcher). parent.products.add(ProductFactory(slug='firefox-os')) self._review_revision( document=doc, is_ready=True, significance=MEDIUM_SIGNIFICANCE) eq_(7, len(mail.outbox)) _assert_approved_mail(mail.outbox[3]) _assert_approved_mail(mail.outbox[4]) _assert_creator_mail(mail.outbox[5]) # Add a Firefox watcher. This time there should be 5 new emails. ApproveRevisionInLocaleEvent.notify( UserFactory(), product='firefox', locale='es') self._review_revision( document=doc, is_ready=True, significance=MEDIUM_SIGNIFICANCE) eq_(12, len(mail.outbox))