Rename checkout views and URLs for clarity

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-08-21 04:25:16 -04:00
parent 605e6356a7
commit 8bcd2c247f
2 changed files with 26 additions and 25 deletions

View File

@@ -4,24 +4,25 @@ from django.conf.urls import url
from .api_views import APICheckedoutDocumentListView, APICheckedoutDocumentView
from .views import (
CheckoutDocumentView, CheckoutDetailView, CheckoutListView,
DocumentCheckinView
DocumentCheckOutView, DocumentCheckOutDetailView, DocumentCheckOutListView,
DocumentCheckInView
)
urlpatterns = [
url(
regex=r'^list/$', view=CheckoutListView.as_view(), name='check_out_list'
regex=r'^documents/$', view=DocumentCheckOutListView.as_view(),
name='check_out_list'
),
url(
regex=r'^(?P<pk>\d+)/check/out/$', view=CheckoutDocumentView.as_view(),
regex=r'^documents/(?P<pk>\d+)/check/out/$', view=DocumentCheckOutView.as_view(),
name='check_out_document'
),
url(
regex=r'^(?P<pk>\d+)/check/in/$', view=DocumentCheckinView.as_view(),
regex=r'^documents/(?P<pk>\d+)/check/in/$', view=DocumentCheckInView.as_view(),
name='check_in_document'
),
url(
regex=r'^(?P<pk>\d+)/check/info/$', view=CheckoutDetailView.as_view(),
regex=r'^documents/(?P<pk>\d+)/check/info/$', view=DocumentCheckOutDetailView.as_view(),
name='check_out_info'
),
]

View File

@@ -24,7 +24,7 @@ from .permissions import (
)
class DocumentCheckinView(ConfirmView):
class DocumentCheckInView(ConfirmView):
def get_extra_context(self):
document = self.get_object()
@@ -82,7 +82,21 @@ class DocumentCheckinView(ConfirmView):
)
class CheckoutDocumentView(SingleObjectCreateView):
class DocumentCheckOutDetailView(SingleObjectDetailView):
form_class = DocumentCheckoutDefailForm
model = Document
object_permission = permission_document_check_out_detail_view
def get_extra_context(self):
return {
'object': self.object,
'title': _(
'Check out details for document: %s'
) % self.object
}
class DocumentCheckOutView(SingleObjectCreateView):
form_class = DocumentCheckoutForm
def dispatch(self, request, *args, **kwargs):
@@ -94,7 +108,7 @@ class CheckoutDocumentView(SingleObjectCreateView):
)
return super(
CheckoutDocumentView, self
DocumentCheckOutView, self
).dispatch(request, *args, **kwargs)
def form_valid(self, form):
@@ -131,7 +145,7 @@ class CheckoutDocumentView(SingleObjectCreateView):
)
class CheckoutListView(DocumentListView):
class DocumentCheckOutListView(DocumentListView):
def get_document_queryset(self):
return AccessControlList.objects.restrict_queryset(
permission=permission_document_check_out_detail_view,
@@ -140,7 +154,7 @@ class CheckoutListView(DocumentListView):
)
def get_extra_context(self):
context = super(CheckoutListView, self).get_extra_context()
context = super(DocumentCheckOutListView, self).get_extra_context()
context.update(
{
'extra_columns': (
@@ -174,17 +188,3 @@ class CheckoutListView(DocumentListView):
}
)
return context
class CheckoutDetailView(SingleObjectDetailView):
form_class = DocumentCheckoutDefailForm
model = Document
object_permission = permission_document_check_out_detail_view
def get_extra_context(self):
return {
'object': self.object,
'title': _(
'Check out details for document: %s'
) % self.object
}