def test_remove_unlicensed_when_licensed(self):
        # Removing translations whose submitters rejected our
        # translations licence does not affect translations by those who
        # agreed to license.
        answer = TranslationRelicensingAgreement(
            person=self.nl_message.submitter, allow_relicensing=True)

        try:
            self._removeMessages(reject_license=True)
            self._checkInvariant()
        finally:
            # Clean up.
            answer.destroySelf()
    def test_remove_unlicensed_when_licensed(self):
        # Removing translations whose submitters rejected our
        # translations licence does not affect translations by those who
        # agreed to license.
        answer = TranslationRelicensingAgreement(
            person=self.nl_message.submitter, allow_relicensing=True)

        try:
            self._removeMessages(reject_license=True)
            self._checkInvariant()
        finally:
            # Clean up.
            answer.destroySelf()
    def set_translations_relicensing_agreement(self, value):
        """Set a translations relicensing decision by translator.

        If she has already made a decision, overrides it with the new one.
        """
        relicensing_agreement = TranslationRelicensingAgreement.selectOneBy(
            person=self.person)
        if relicensing_agreement is None:
            relicensing_agreement = TranslationRelicensingAgreement(
                person=self.person,
                allow_relicensing=value)
        else:
            relicensing_agreement.allow_relicensing = value
        del get_property_cache(self)._translations_relicensing_agreement
    def test_remove_unlicensed_restriction(self):
        # When removing unlicensed translations, other restrictions
        # still apply.
        self.nl_message.is_current_upstream = True
        self.de_message.is_current_upstream = True
        answer = TranslationRelicensingAgreement(
            person=self.nl_message.submitter, allow_relicensing=False)

        try:
            self._removeMessages(reject_license=True,
                                 is_current_upstream=False)
            self._checkInvariant()
        finally:
            # Clean up.
            answer.destroySelf()
    def test_remove_unlicensed_restriction(self):
        # When removing unlicensed translations, other restrictions
        # still apply.
        self.nl_message.is_current_upstream = True
        self.de_message.is_current_upstream = True
        answer = TranslationRelicensingAgreement(
            person=self.nl_message.submitter, allow_relicensing=False)

        try:
            self._removeMessages(
                reject_license=True, is_current_upstream=False)
            self._checkInvariant()
        finally:
            # Clean up.
            answer.destroySelf()
    def _translations_relicensing_agreement(self):
        """Return whether translator agrees to relicense their translations.

        If she has made no explicit decision yet, return None.
        """
        relicensing_agreement = TranslationRelicensingAgreement.selectOneBy(
            person=self.person)
        if relicensing_agreement is None:
            return None
        else:
            return relicensing_agreement.allow_relicensing
    def test_remove_by_license_rejection(self):
        # Remove translations submitted by users who rejected the
        # licensing agreement.
        refusenik = self.factory.makePerson()

        self._makeMessages("Don't download this song",
                           "Niet delen",
                           "Nicht teilen",
                           submitter=refusenik)

        TranslationRelicensingAgreement(person=refusenik,
                                        allow_relicensing=False)

        self._removeMessages(reject_license=True)

        self._checkInvariant()