Files
mayan-edms/mayan/apps/checkouts/handlers.py
Roberto Rosario 92e615ce4c Add keyword arguments to checkouts app
Add keyword arguments to calls and view parameters. Add missing icons.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
2019-01-02 14:19:32 -04:00

19 lines
597 B
Python

from __future__ import unicode_literals
from django.apps import apps
from .exceptions import NewDocumentVersionNotAllowed
def handler_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(document=instance.document) and not instance.pk:
# Block only new versions (no pk), not existing version being updated.
raise NewDocumentVersionNotAllowed