def hide(self, annotation):
        """
        Hide an annotation from other users.

        This hides the given annotation from anybody except its author and the
        group moderators.

        In case the given annotation already has a moderation flag, this method
        is a no-op.

        :param annotation: The annotation to hide from others.
        :type annotation: h.models.Annotation
        """

        if self.hidden(annotation):
            return

        annotation.moderation = models.AnnotationModeration()
Example #2
0
    def hide(self, annotation):
        """
        Hide an annotation from other users.

        This hides the given annotation from anybody except its author and the
        group moderators.

        In case the given annotation already has a moderation flag, this method
        is a no-op.

        :param annotation: The annotation to hide from others.
        :type annotation: h.models.Annotation
        """

        query = self.session.query(models.AnnotationModeration) \
                            .filter_by(annotation=annotation)

        if query.count() > 0:
            return

        mod = models.AnnotationModeration(annotation=annotation)
        self.session.add(mod)