コード例 #1
0
ファイル: unitdata.py プロジェクト: Acidburn0zzz/weblate
    def add(self, unit, user, lang, text):
        '''
        Adds comment to this unit.
        '''
        new_comment = self.create(
            user=user,
            contentsum=unit.contentsum,
            project=unit.translation.subproject.project,
            comment=text,
            language=lang
        )
        Change.objects.create(
            unit=unit,
            action=Change.ACTION_COMMENT,
            translation=unit.translation,
            user=user,
            author=user
        )

        # Notify subscribed users
        notify_new_comment(
            unit,
            new_comment,
            user,
            unit.translation.subproject.report_source_bugs
        )
コード例 #2
0
    def add(self, unit, user, lang, text):
        '''
        Adds comment to this unit.
        '''
        new_comment = self.create(
            user=user,
            content_hash=unit.content_hash,
            project=unit.translation.subproject.project,
            comment=text,
            language=lang
        )
        Change.objects.create(
            unit=unit,
            action=Change.ACTION_COMMENT,
            translation=unit.translation,
            user=user,
            author=user
        )

        # Notify subscribed users
        notify_new_comment(
            unit,
            new_comment,
            user,
            unit.translation.subproject.report_source_bugs
        )
コード例 #3
0
ファイル: unitdata.py プロジェクト: paour/weblate
    def add(self, unit, user, lang, text):
        '''
        Adds comment to this unit.
        '''
        from weblate.accounts.models import notify_new_comment

        new_comment = self.create(user=user,
                                  contentsum=unit.contentsum,
                                  project=unit.translation.subproject.project,
                                  comment=text,
                                  language=lang)
        Change.objects.create(unit=unit,
                              action=Change.ACTION_COMMENT,
                              translation=unit.translation,
                              user=user,
                              author=user)

        # Invalidate counts cache
        if lang is None:
            unit.translation.invalidate_cache('sourcecomments')
        else:
            unit.translation.invalidate_cache('targetcomments')

        # Update unit stats
        for relunit in new_comment.get_related_units():
            relunit.update_has_comment()

        # Notify subscribed users
        notify_new_comment(unit, new_comment, user,
                           unit.translation.subproject.report_source_bugs)
コード例 #4
0
ファイル: unitdata.py プロジェクト: paour/weblate
    def add(self, unit, user, lang, text):
        """
        Adds comment to this unit.
        """
        from weblate.accounts.models import notify_new_comment

        new_comment = self.create(
            user=user,
            contentsum=unit.contentsum,
            project=unit.translation.subproject.project,
            comment=text,
            language=lang,
        )
        Change.objects.create(
            unit=unit, action=Change.ACTION_COMMENT, translation=unit.translation, user=user, author=user
        )

        # Invalidate counts cache
        if lang is None:
            unit.translation.invalidate_cache("sourcecomments")
        else:
            unit.translation.invalidate_cache("targetcomments")

        # Update unit stats
        for relunit in new_comment.get_related_units():
            relunit.update_has_comment()

        # Notify subscribed users
        notify_new_comment(unit, new_comment, user, unit.translation.subproject.report_source_bugs)
コード例 #5
0
ファイル: tests.py プロジェクト: phewcentral/weblate
    def test_notify_new_comment(self):
        unit = self.get_unit()
        notify_new_comment(
            unit,
            Comment.objects.create(contentsum=unit.contentsum,
                                   project=unit.translation.subproject.project,
                                   language=unit.translation.language,
                                   comment='Foo'), self.second_user(), '')

        # Check mail
        self.assertEqual(len(mail.outbox), 1)
        self.assertEqual(mail.outbox[0].subject,
                         '[Weblate] New comment in Test/Test')
コード例 #6
0
    def test_notify_new_comment_report(self):
        unit = self.get_unit()
        notify_new_comment(
            unit,
            Comment.objects.create(
                contentsum=unit.contentsum, project=unit.translation.subproject.project, language=None, comment="Foo"
            ),
            self.second_user(),
            "*****@*****.**",
        )

        # Check mail
        self.assertEqual(len(mail.outbox), 2)
        self.assertEqual(mail.outbox[0].subject, "[Weblate] New comment in Test/Test")
        self.assertEqual(mail.outbox[1].subject, "[Weblate] New comment in Test/Test")
コード例 #7
0
    def test_notify_new_comment_report(self):
        unit = self.get_unit()
        notify_new_comment(
            unit,
            Comment.objects.create(content_hash=unit.content_hash,
                                   project=unit.translation.subproject.project,
                                   language=None,
                                   comment='Foo'), self.second_user(),
            '*****@*****.**')

        # Check mail
        self.assertEqual(len(mail.outbox), 2)
        self.assertEqual(mail.outbox[0].subject,
                         '[Weblate] New comment in Test/Test')
        self.assertEqual(mail.outbox[1].subject,
                         '[Weblate] New comment in Test/Test')
コード例 #8
0
    def test_notify_new_comment(self):
        unit = self.get_unit()
        notify_new_comment(
            unit,
            Comment.objects.create(
                contentsum=unit.contentsum,
                project=unit.translation.subproject.project,
                language=unit.translation.language,
                comment='Foo'
            ),
            self.second_user(),
            ''
        )

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