Add keyword arguments

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2019-05-12 02:09:26 -04:00
parent 0d53e74238
commit c7e9a4dc99
28 changed files with 84 additions and 74 deletions
+12 -9
View File
@@ -23,8 +23,9 @@ class DashboardWidgetDocumentPagesTotal(DashboardWidgetNumeric):
icon_class = icon_dashboard_pages_per_month
label = _('Total pages')
link = reverse_lazy(
viewname='statistics:statistic_detail',
args=('total-document-pages-at-each-month',)
viewname='statistics:statistic_detail', kwargs={
'slug': 'total-document-pages-at-each-month'
}
)
def render(self, request):
@@ -44,7 +45,7 @@ class DashboardWidgetDocumentPagesTotal(DashboardWidgetNumeric):
class DashboardWidgetDocumentsTotal(DashboardWidgetNumeric):
icon_class = icon_dashboard_total_document
label = _('Total documents')
link = reverse_lazy('documents:document_list')
link = reverse_lazy(viewname='documents:document_list')
def render(self, request):
AccessControlList = apps.get_model(
@@ -63,7 +64,7 @@ class DashboardWidgetDocumentsTotal(DashboardWidgetNumeric):
class DashboardWidgetDocumentsInTrash(DashboardWidgetNumeric):
icon_class = icon_dashboard_documents_in_trash
label = _('Documents in trash')
link = reverse_lazy('documents:document_list_deleted')
link = reverse_lazy(viewname='documents:document_list_deleted')
def render(self, request):
AccessControlList = apps.get_model(
@@ -82,7 +83,7 @@ class DashboardWidgetDocumentsInTrash(DashboardWidgetNumeric):
class DashboardWidgetDocumentsTypesTotal(DashboardWidgetNumeric):
icon_class = icon_dashboard_document_types
label = _('Document types')
link = reverse_lazy('documents:document_type_list')
link = reverse_lazy(viewname='documents:document_type_list')
def render(self, request):
AccessControlList = apps.get_model(
@@ -102,8 +103,9 @@ class DashboardWidgetDocumentsNewThisMonth(DashboardWidgetNumeric):
icon_class = icon_dashboard_new_documents_this_month
label = _('New documents this month')
link = reverse_lazy(
'statistics:statistic_detail',
args=('new-documents-per-month',)
viewname='statistics:statistic_detail', kwargs={
'slug': 'new-documents-per-month'
}
)
def render(self, request):
@@ -115,8 +117,9 @@ class DashboardWidgetDocumentsPagesNewThisMonth(DashboardWidgetNumeric):
icon_class = icon_dashboard_pages_per_month
label = _('New pages this month')
link = reverse_lazy(
'statistics:statistic_detail',
args=('new-document-pages-per-month',)
viewname='statistics:statistic_detail', kwargs={
'slug': 'new-document-pages-per-month'
}
)
def render(self, request):
+5 -13
View File
@@ -1,6 +1,5 @@
from __future__ import absolute_import, unicode_literals
import hashlib
import logging
import uuid
@@ -8,7 +7,7 @@ from django.apps import apps
from django.core.files import File
from django.db import models
from django.urls import reverse
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.encoding import python_2_unicode_compatible
from django.utils.timezone import now
from django.utils.translation import ugettext, ugettext_lazy as _
@@ -22,19 +21,10 @@ from ..signals import post_document_type_change
from .document_type_models import DocumentType
__all__ = ('Document', 'UUID_FUNCTION')
__all__ = ('Document',)
logger = logging.getLogger(__name__)
# document image cache name hash function
def hash_function():
return hashlib.sha256()
def UUID_FUNCTION(*args, **kwargs):
return force_text(uuid.uuid4())
@python_2_unicode_compatible
class Document(models.Model):
"""
@@ -137,7 +127,9 @@ class Document(models.Model):
return False
def get_absolute_url(self):
return reverse('documents:document_preview', args=(self.pk,))
return reverse(
viewname='documents:document_preview', kwargs={'pk': self.pk}
)
def get_api_image_url(self, *args, **kwargs):
latest_version = self.latest_version
@@ -127,9 +127,10 @@ class DocumentPage(models.Model):
final_url = furl()
final_url.args = kwargs
final_url.path = reverse(
'rest_api:documentpage-image', args=(
self.document.pk, self.document_version.pk, self.pk
)
viewname='rest_api:documentpage-image', kwargs={
'pk': self.document.pk, 'version_pk': self.document_version.pk,
'page_pk': self.pk
}
)
final_url.args['_hash'] = transformations_hash
@@ -81,7 +81,9 @@ class DocumentType(models.Model):
def get_absolute_url(self):
return reverse(
'documents:document_type_document_list', args=(self.pk,)
viewname='documents:document_type_document_list', kwargs={
'pk': self.pk
}
)
def get_document_count(self, user):
@@ -151,7 +151,11 @@ class DocumentVersion(models.Model):
)
def get_absolute_url(self):
return reverse('documents:document_version_view', args=(self.pk,))
return reverse(
viewname='documents:document_version_view', kwargs={
'pk': self.pk
}
)
def get_api_image_url(self, *args, **kwargs):
first_page = self.pages.first()
+3 -3
View File
@@ -210,9 +210,9 @@ class DocumentAPITestCase(DocumentTestMixin, BaseAPITestCase):
with open(TEST_DOCUMENT_PATH, mode='rb') as file_descriptor:
return self.post(
viewname='rest_api:document-version-list', args=(
self.test_document.pk,
), data={
viewname='rest_api:document-version-list', kwargs={
'pk': self.test_document.pk,
}, data={
'comment': '', 'file': file_descriptor,
}
)
@@ -85,7 +85,7 @@ class DocumentTypeCreateView(SingleObjectCreateView):
'delete_time_unit'
)
model = DocumentType
post_action_redirect = reverse_lazy('documents:document_type_list')
post_action_redirect = reverse_lazy(viewname='documents:document_type_list')
view_permission = permission_document_type_create
def get_extra_context(self):
@@ -102,7 +102,7 @@ class DocumentTypeCreateView(SingleObjectCreateView):
class DocumentTypeDeleteView(SingleObjectDeleteView):
model = DocumentType
object_permission = permission_document_type_delete
post_action_redirect = reverse_lazy('documents:document_type_list')
post_action_redirect = reverse_lazy(viewname='documents:document_type_list')
def get_extra_context(self):
return {
@@ -119,7 +119,7 @@ class DocumentTypeEditView(SingleObjectEditView):
)
model = DocumentType
object_permission = permission_document_type_edit
post_action_redirect = reverse_lazy('documents:document_type_list')
post_action_redirect = reverse_lazy(viewname='documents:document_type_list')
def get_extra_context(self):
return {
+10 -4
View File
@@ -182,10 +182,14 @@ class DocumentDownloadFormView(FormView):
url = reverse(self.multiple_download_view)
else:
url = reverse(
self.single_download_view, args=(self.queryset.first().pk,)
viewname=self.single_download_view, kwargs={
'pk': self.queryset.first().pk
}
)
return HttpResponseRedirect('{}?{}'.format(url, querystring))
return HttpResponseRedirect(
redirect_to='{}?{}'.format(url, querystring)
)
def get_document_queryset(self):
id_list = self.request.GET.get(
@@ -382,7 +386,9 @@ class DocumentEditView(SingleObjectEditView):
def get_post_action_redirect(self):
return reverse(
'documents:document_properties', args=(self.get_object().pk,)
viewname='documents:document_properties', kwargs={
'pk': self.get_object().pk
}
)
@@ -641,7 +647,7 @@ class DocumentPrint(FormView):
context = {
'form_action': reverse(
'documents:document_print', args=(instance.pk,)
viewname='documents:document_print', kwargs={'pk': instance.pk}
),
'object': instance,
'submit_label': _('Submit'),