Move new version creation blocking from the documents app to the checkouts app.

Closes GitLab #294.
This commit is contained in:
Roberto Rosario
2016-12-22 01:45:43 -04:00
parent 71af09c1fc
commit 1e194e04fa
16 changed files with 181 additions and 99 deletions

View File

@@ -0,0 +1,18 @@
from __future__ import unicode_literals
from django.apps import apps
from .exceptions import NewDocumentVersionNotAllowed
def check_new_version_creation(sender, instance, **kwargs):
"""
Make sure that new version creation is allowed for this document
"""
NewVersionBlock = apps.get_model(
app_label='checkouts', model_name='NewVersionBlock'
)
if NewVersionBlock.objects.is_blocked(instance.document):
raise NewDocumentVersionNotAllowed