Add form field clean method to detect if documents are already checked out

This commit is contained in:
Roberto Rosario
2012-06-16 02:03:14 -04:00
parent 4a1acbbaac
commit c39f1aa8a0

View File

@@ -7,6 +7,7 @@ from django.utils.translation import ugettext_lazy as _
from django.core import validators
from .models import DocumentCheckout
from .exceptions import DocumentAlreadyCheckedOut
class SplitDeltaWidget(forms.widgets.MultiWidget):
@@ -101,3 +102,9 @@ class DocumentCheckoutForm(forms.ModelForm):
widgets = {
'document': forms.widgets.HiddenInput(),
}
def clean_document(self):
document = self.cleaned_data['document']
if document.is_checked_out():
raise DocumentAlreadyCheckedOut
return document