예제 #1
0
        Returns True if there is a publishable version newer than the one
        already published.

        """
        new_publishable = False
        if not self.chunk_set.exists():
            return False
        for chunk in self:
            change = chunk.publishable()
            if not change:
                return False
            if not new_publishable and not change.publish_log.exists():
                new_publishable = True
        return new_publishable
    new_publishable = cached_in_field('_new_publishable')(is_new_publishable)

    def is_published(self):
        return self.publish_log.exists()
    published = cached_in_field('_published')(is_published)

    def get_on_track(self):
        if self.published:
            return -1
        stages = [ch.stage.ordering if ch.stage is not None else 0
                    for ch in self]
        if not len(stages):
            return 0
        return min(stages)
    on_track = cached_in_field('_on_track')(get_on_track)
예제 #2
0
파일: image.py 프로젝트: jumasheff/redakcja
        try:
            return self.assert_publishable()
        except AssertionError, e:
            return e
        else:
            return None

    def accessible(self, request):
        return self.public or request.user.is_authenticated()

    def is_new_publishable(self):
        change = self.publishable()
        if not change:
            return False
        return not change.publish_log.exists()
    new_publishable = cached_in_field('_new_publishable')(is_new_publishable)

    def is_published(self):
        return self.publish_log.exists()
    published = cached_in_field('_published')(is_published)

    def is_changed(self):
        if self.head is None:
            return False
        return not self.head.publishable
    changed = cached_in_field('_changed')(is_changed)

    @cached_in_field('_short_html')
    def short_html(self):
        return render_to_string(
                    'catalogue/image_short.html', {'image': self})