Files
mayan-edms/mayan/apps/checkouts/handlers.py
Roberto Rosario 74c97314d7 Code style cleanups
Add keyword arguments. Sort arguments and models.
Move literals to their own module. Prepend handler_ to
signal handlers.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
2019-04-26 03:32:35 -04:00

18 lines
596 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