def test_canTranslate(self):
        # A user who has declined the licensing agreement can't
        # translate.  Someone who has agreed, or not made a decision
        # yet, can.
        user = self.factory.makePerson()
        translations_user = ITranslationsPerson(user)

        self.assertTrue(self.policy._canTranslate(user))

        translations_user.translations_relicensing_agreement = True
        self.assertTrue(self.policy._canTranslate(user))

        translations_user.translations_relicensing_agreement = False
        self.assertFalse(self.policy._canTranslate(user))
    def test_canTranslate(self):
        # A user who has declined the licensing agreement can't
        # translate.  Someone who has agreed, or not made a decision
        # yet, can.
        user = self.factory.makePerson()
        translations_user = ITranslationsPerson(user)

        self.assertTrue(self.policy._canTranslate(user))

        translations_user.translations_relicensing_agreement = True
        self.assertTrue(self.policy._canTranslate(user))

        translations_user.translations_relicensing_agreement = False
        self.assertFalse(self.policy._canTranslate(user))
Esempio n. 3
0
 def test_skips_translation_relicensing_agreements(self):
     person = self.factory.makePerson()
     translations_person = ITranslationsPerson(person)
     translations_person.translations_relicensing_agreement = True
     person_id = person.id
     account_id = person.account.id
     script = self.makeScript([six.ensure_str(person.name)])
     with dbuser('launchpad'):
         self.runScript(script)
     self.assertRemoved(account_id, person_id)
     self.assertTrue(translations_person.translations_relicensing_agreement)
Esempio n. 4
0
    def submit_action(self, action, data):
        """Store person's decision about translations relicensing.

        The user's decision is stored through
        `ITranslationsPerson.translations_relicensing_agreement`
        which is backed by the TranslationRelicensingAgreement table.
        """
        translations_person = ITranslationsPerson(self.context)
        allow_relicensing = data['allow_relicensing']
        if allow_relicensing == TranslationRelicensingAgreementOptions.BSD:
            translations_person.translations_relicensing_agreement = True
            self.request.response.addInfoNotification(
                _("Thank you for BSD-licensing your translations."))
        elif (allow_relicensing ==
              TranslationRelicensingAgreementOptions.REMOVE):
            translations_person.translations_relicensing_agreement = False
            self.request.response.addInfoNotification(
                _("We respect your choice. "
                  "Thanks for trying out Launchpad Translations."))
        else:
            raise AssertionError("Unknown allow_relicensing value: %r" %
                                 allow_relicensing)
        self.next_url = self.getSafeRedirectURL(data['back_to'])
Esempio n. 5
0
    def submit_action(self, action, data):
        """Store person's decision about translations relicensing.

        The user's decision is stored through
        `ITranslationsPerson.translations_relicensing_agreement`
        which is backed by the TranslationRelicensingAgreement table.
        """
        translations_person = ITranslationsPerson(self.context)
        allow_relicensing = data['allow_relicensing']
        if allow_relicensing == TranslationRelicensingAgreementOptions.BSD:
            translations_person.translations_relicensing_agreement = True
            self.request.response.addInfoNotification(_(
                "Thank you for BSD-licensing your translations."))
        elif (allow_relicensing ==
            TranslationRelicensingAgreementOptions.REMOVE):
            translations_person.translations_relicensing_agreement = False
            self.request.response.addInfoNotification(_(
                "We respect your choice. "
                "Thanks for trying out Launchpad Translations."))
        else:
            raise AssertionError(
                "Unknown allow_relicensing value: %r" % allow_relicensing)
        self.next_url = self.getSafeRedirectURL(data['back_to'])