from django.db.utils import IntegrityError
from django.template.loader import render_to_string
from django.urls import reverse
-from django.utils.translation import ugettext_lazy as _
+from django.utils.translation import gettext_lazy as _
from documents.helpers import cached_in_field
from documents.managers import VisibleManager
from dvcs import models as dvcs_models
verbose_name_plural = _('chunks')
permissions = [('can_pubmark', 'Can mark for publishing')]
+ @classmethod
+ def get_visible_for(cls, user):
+ qs = cls.objects.all()
+ if not user.is_authenticated:
+ qs = qs.filter(book__public=True)
+ return qs
+
+ @classmethod
+ def get_revisions_visible_for(cls, user):
+ qs = cls.change_model.objects.all()
+ if not user.is_authenticated:
+ qs = qs.filter(tree__book__public=True)
+ return qs
+
# Representing
# ============