Convert checkouts app to use organizations.
This commit is contained in:
@@ -66,7 +66,7 @@ class APICheckedoutDocumentListView(generics.ListCreateAPIView):
|
||||
|
||||
if serializer.is_valid():
|
||||
document = get_object_or_404(
|
||||
Document, pk=serializer.data['document']
|
||||
Document.on_organization, pk=serializer.data['document']
|
||||
)
|
||||
try:
|
||||
Permission.check_permissions(
|
||||
|
||||
@@ -25,14 +25,14 @@ class DocumentCheckoutManager(models.Manager):
|
||||
)
|
||||
|
||||
def checked_out_documents(self):
|
||||
return Document.objects.filter(
|
||||
return Document.on_organization.filter(
|
||||
pk__in=self.model.objects.all().values_list(
|
||||
'document__pk', flat=True
|
||||
)
|
||||
)
|
||||
|
||||
def expired_check_outs(self):
|
||||
expired_list = Document.objects.filter(
|
||||
expired_list = Document.on_organization.filter(
|
||||
pk__in=self.model.objects.filter(
|
||||
expiration_datetime__lte=now()
|
||||
).values_list('document__pk', flat=True)
|
||||
|
||||
@@ -12,6 +12,7 @@ from documents.models import DocumentType
|
||||
from documents.tests.literals import (
|
||||
TEST_DOCUMENT_TYPE, TEST_SMALL_DOCUMENT_PATH
|
||||
)
|
||||
from organizations.tests.base import OrganizationTestCase
|
||||
from user_management.tests.literals import (
|
||||
TEST_ADMIN_USERNAME, TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD
|
||||
)
|
||||
@@ -21,8 +22,9 @@ from ..models import DocumentCheckout
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class DocumentCheckoutTestCase(TestCase):
|
||||
class DocumentCheckoutTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
super(DocumentCheckoutTestCase, self).setUp()
|
||||
self.admin_user = get_user_model().objects.create_superuser(
|
||||
username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL,
|
||||
password=TEST_ADMIN_PASSWORD
|
||||
@@ -39,6 +41,7 @@ class DocumentCheckoutTestCase(TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.document_type.delete()
|
||||
super(DocumentCheckoutTestCase, self).tearDown()
|
||||
|
||||
def test_document_checkout(self):
|
||||
expiration_datetime = now() + datetime.timedelta(days=1)
|
||||
|
||||
@@ -30,7 +30,7 @@ class CheckoutDocumentView(SingleObjectCreateView):
|
||||
form_class = DocumentCheckoutForm
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.document = get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
self.document = get_object_or_404(Document.on_organization, pk=self.kwargs['pk'])
|
||||
|
||||
try:
|
||||
Permission.check_permissions(
|
||||
@@ -108,7 +108,6 @@ class CheckoutListView(DocumentListView):
|
||||
|
||||
class CheckoutDetailView(SingleObjectDetailView):
|
||||
form_class = DocumentCheckoutDefailForm
|
||||
model = Document
|
||||
object_permission = permission_document_checkout_detail_view
|
||||
|
||||
def get_extra_context(self):
|
||||
@@ -120,7 +119,7 @@ class CheckoutDetailView(SingleObjectDetailView):
|
||||
}
|
||||
|
||||
def get_object(self):
|
||||
return get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
return get_object_or_404(Document.on_organization, pk=self.kwargs['pk'])
|
||||
|
||||
|
||||
class DocumentCheckinView(ConfirmView):
|
||||
@@ -142,7 +141,7 @@ class DocumentCheckinView(ConfirmView):
|
||||
return context
|
||||
|
||||
def get_object(self):
|
||||
return get_object_or_404(Document, pk=self.kwargs['pk'])
|
||||
return get_object_or_404(Document.on_organization, pk=self.kwargs['pk'])
|
||||
|
||||
def get_post_action_redirect(self):
|
||||
return reverse('checkouts:checkout_info', args=(self.get_object().pk,))
|
||||
|
||||
Reference in New Issue
Block a user