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)
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)
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)
def test_send_pre_moderation_signal(self): """check if custom_approve_handler function was called when """ """moderation_approve signal was send""" def custom_pre_moderation_handler(sender, instance, status, **kwargs): # do some stuff with approved instance instance.description = 'Change description' instance.save() pre_moderation.connect(custom_pre_moderation_handler, sender=UserProfile) pre_moderation.send(sender=UserProfile, instance=self.profile, status=MODERATION_STATUS_APPROVED) self.assertEqual(self.profile.description, 'Change description')
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