Exemplo n.º 1
0
def notify_change(change_id):
    from weblate.trans.models import Change
    from weblate.accounts.notifications import (
        notify_merge_failure,
        notify_parse_error,
        notify_new_string,
        notify_new_contributor,
        notify_new_suggestion,
        notify_new_comment,
        notify_new_translation,
        notify_new_language,
    )
    change = Change.objects.get(pk=change_id)
    if change.action in (Change.ACTION_FAILED_MERGE,
                         Change.ACTION_FAILED_REBASE):
        notify_merge_failure(change)
    elif change.action == Change.ACTION_PARSE_ERROR:
        notify_parse_error(change)
    elif change.action == Change.ACTION_NEW_STRING:
        notify_new_string(change)
    elif change.action == Change.ACTION_NEW_CONTRIBUTOR:
        notify_new_contributor(change)
    elif change.action == Change.ACTION_SUGGESTION:
        notify_new_suggestion(change)
    elif change.action == Change.ACTION_COMMENT:
        notify_new_comment(change)
    elif change.action in Change.ACTIONS_CONTENT:
        notify_new_translation(change)
    elif change.action in (Change.ACTION_ADDED_LANGUAGE,
                           Change.ACTION_REQUESTED_LANGUAGE):
        notify_new_language(change)
Exemplo n.º 2
0
    def test_notify_merge_failure(self):
        notify_merge_failure(self.subproject, 'Failed merge', 'Error\nstatus')

        # Check mail (second one is for admin)
        self.assertEqual(len(mail.outbox), 2)
        self.assertEqual(mail.outbox[0].subject,
                         '[Weblate] Merge failure in Test/Test')

        # Add project owner
        self.subproject.project.add_user(self.second_user(), '@Administration')
        notify_merge_failure(self.subproject, 'Failed merge', 'Error\nstatus')

        # Check mail (second one is for admin)
        self.assertEqual(len(mail.outbox), 5)
Exemplo n.º 3
0
    def test_notify_merge_failure(self):
        change = Change(
            component=self.component,
            details={
                'error': 'Failed merge',
                'status': 'Error\nstatus',
            },
        )
        notify_merge_failure(change)

        # Check mail
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject,
                         '[Weblate] Merge failure in Test/Test')

        # Add project owner
        self.component.project.add_user(self.second_user(), '@Administration')
        notify_merge_failure(change)

        # Check mail
        self.assertEqual(len(mail.outbox), 3)
Exemplo n.º 4
0
    def test_notify_merge_failure(self):
        notify_merge_failure(
            self.component,
            'Failed merge',
            'Error\nstatus'
        )

        # Check mail (second one is for admin)
        self.assertEqual(len(mail.outbox), 2)
        self.assertEqual(
            mail.outbox[0].subject,
            '[Weblate] Merge failure in Test/Test'
        )

        # Add project owner
        self.component.project.add_user(self.second_user(), '@Administration')
        notify_merge_failure(
            self.component,
            'Failed merge',
            'Error\nstatus'
        )

        # Check mail (second one is for admin)
        self.assertEqual(len(mail.outbox), 5)