Esempio n. 1
0
 def reject(self, moderated_by=None, reason=None):
     pre_moderation.send(sender=self.content_object.__class__,
                         instance=self.changed_object,
                         status=MODERATION_STATUS_REJECTED)
     self._moderate(MODERATION_STATUS_REJECTED, moderated_by, reason)
     post_moderation.send(sender=self.content_object.__class__,
                          instance=self.content_object,
                          status=MODERATION_STATUS_REJECTED)
Esempio n. 2
0
 def reject(self, moderated_by=None, reason=None):
     pre_moderation.send(sender=self.changed_object.__class__,
                         instance=self.changed_object,
                         status=MODERATION_STATUS_REJECTED)
     self._moderate(MODERATION_STATUS_REJECTED, moderated_by, reason)
     post_moderation.send(sender=self.content_object.__class__,
                          instance=self.content_object,
                          status=MODERATION_STATUS_REJECTED)
Esempio n. 3
0
    def set_as_pending(self, moderated_by=None, reason=None):
        pre_moderation.send(sender=self.content_object.__class__,
                            instance=self.changed_object,
                            status=MODERATION_STATUS_PENDING)

        self._moderate(MODERATION_STATUS_PENDING, moderated_by, reason)

        post_moderation.send(sender=self.content_object.__class__,
                            instance=self.content_object,
                            status=MODERATION_STATUS_PENDING)
Esempio n. 4
0
    def test_send_post_moderation_signal(self):
        """check if custom_approve_handler function was called when """ 
        """moderation_approve signal was send"""

        def custom_post_moderation_handler(sender, instance, status, **kwargs):
            # do some stuff with approved instance
            instance.description = 'Change description'
            instance.save()
        
        post_moderation.connect(custom_post_moderation_handler,
                                sender=UserProfile)
        
        post_moderation.send(sender=UserProfile, instance=self.profile,
                             status=MODERATION_STATUS_APPROVED)
        
        self.assertEqual(self.profile.description, 'Change description')
Esempio n. 5
0
    def test_send_post_moderation_signal(self):
        """check if custom_approve_handler function was called when """
        """moderation_approve signal was send"""

        def custom_post_moderation_handler(sender, instance, status, **kwargs):
            # do some stuff with approved instance
            instance.description = 'Change description'
            instance.save()

        post_moderation.connect(custom_post_moderation_handler,
                                sender=UserProfile)

        post_moderation.send(sender=UserProfile, instance=self.profile,
                             status=MODERATION_STATUS_APPROVED)

        self.assertEqual(self.profile.description, 'Change description')
Esempio n. 6
0
    def approve(self, moderated_by=None, reason=None):
        crx = CrxFile(self.changed_object.crx)
        try:
            launch_url = crx.manifest["app"]["launch"]["web_url"]
        except KeyError:
            launch_url = None
        if is_redundant_item(self.changed_object.__class__, self.changed_object, appid=crx.get_appid()):
            return self.reject(reason=_u("Private key already exists."))
        if launch_url and is_redundant_item(self.changed_object.__class__, self.changed_object, launch_url=launch_url):
            return self.reject(reason=_u("Hosted application with the same URL already exists."))

        pre_moderation.send(sender=self.content_object.__class__,
                            instance=self.changed_object,
                            status=MODERATION_STATUS_APPROVED)

        self._moderate(MODERATION_STATUS_APPROVED, moderated_by, reason)

        post_moderation.send(sender=self.content_object.__class__,
                             instance=self.content_object,
                             status=MODERATION_STATUS_APPROVED)

        return _("Item approved: %s") % reason