Move new version creation blocking from the documents app to the checkouts app.
Closes GitLab #294.
This commit is contained in:
18
mayan/apps/checkouts/handlers.py
Normal file
18
mayan/apps/checkouts/handlers.py
Normal 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
|
||||
Reference in New Issue
Block a user