New document version improvements from clients/bc
- Comment field help text. - Remove create_document_form_form. - Use static NewVersionForm. - Update sources document upload and new version upload view names. Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -33,7 +33,7 @@ class CabinetDocumentUploadTestCase(CabinetTestMixin, GenericDocumentViewTestCas
|
||||
def _request_upload_interactive_document_create_view(self):
|
||||
with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object:
|
||||
return self.post(
|
||||
viewname='sources:upload_interactive', kwargs={
|
||||
viewname='sources:document_upload_interactive', kwargs={
|
||||
'source_id': self.test_source.pk
|
||||
}, data={
|
||||
'document_type_id': self.test_document_type.pk,
|
||||
|
||||
@@ -376,7 +376,7 @@ class NewVersionBlockViewTestCase(
|
||||
self.login_superuser()
|
||||
|
||||
response = self.post(
|
||||
viewname='sources:upload_version', kwargs={
|
||||
viewname='sources:document_version_upload', kwargs={
|
||||
'document_pk': self.test_document.pk
|
||||
}, follow=True
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ class DocumentUploadMetadataTestCase(MetadataTypeTestMixin, GenericDocumentViewT
|
||||
|
||||
def test_upload_interactive_with_unicode_metadata(self):
|
||||
url = URL(
|
||||
path=reverse(viewname='sources:upload_interactive')
|
||||
path=reverse(viewname='sources:document_upload_interactive')
|
||||
)
|
||||
url.args['metadata0_id'] = self.test_metadata_type.pk
|
||||
url.args['metadata0_value'] = TEST_METADATA_VALUE_UNICODE
|
||||
@@ -61,7 +61,7 @@ class DocumentUploadMetadataTestCase(MetadataTypeTestMixin, GenericDocumentViewT
|
||||
|
||||
def test_upload_interactive_with_ampersand_metadata(self):
|
||||
url = URL(
|
||||
path=reverse(viewname='sources:upload_interactive')
|
||||
path=reverse(viewname='sources:document_upload_interactive')
|
||||
)
|
||||
url.args['metadata0_id'] = self.test_metadata_type.pk
|
||||
url.args['metadata0_value'] = TEST_METADATA_VALUE_WITH_AMPERSAND
|
||||
|
||||
@@ -145,8 +145,9 @@ class SourcesApp(MayanAppConfig):
|
||||
menu_secondary.bind_links(
|
||||
links=(link_document_version_upload,),
|
||||
sources=(
|
||||
'documents:document_version_list', 'documents:upload_version',
|
||||
'documents:document_version_revert'
|
||||
'documents:document_version_list',
|
||||
'documents:document_version_revert',
|
||||
'sources:document_version_upload'
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -23,14 +23,11 @@ class NewDocumentForm(DocumentForm):
|
||||
|
||||
|
||||
class NewVersionForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NewVersionForm, self).__init__(*args, **kwargs)
|
||||
|
||||
self.fields['comment'] = forms.CharField(
|
||||
label=_('Comment'),
|
||||
required=False,
|
||||
widget=forms.widgets.Textarea(attrs={'rows': 4}),
|
||||
)
|
||||
comment = forms.CharField(
|
||||
help_text=_('An optional comment to explain the upload.'),
|
||||
label=_('Comment'), required=False,
|
||||
widget=forms.widgets.Textarea(attrs={'rows': 4}),
|
||||
)
|
||||
|
||||
|
||||
class UploadBaseForm(forms.Form):
|
||||
|
||||
@@ -117,7 +117,7 @@ link_document_version_upload = Link(
|
||||
args='resolved_object.pk', condition=document_new_version_not_blocked,
|
||||
icon_class_path='mayan.apps.sources.icons.icon_document_version_upload',
|
||||
permissions=(permission_document_new_version,),
|
||||
text=_('Upload new version'), view='sources:upload_version',
|
||||
text=_('Upload new version'), view='sources:document_version_upload',
|
||||
)
|
||||
link_setup_source_logs = Link(
|
||||
args=('resolved_object.pk',),
|
||||
|
||||
@@ -32,7 +32,7 @@ class DocumentUploadWizardViewTestMixin(object):
|
||||
def _request_upload_wizard_view(self, document_path=TEST_SMALL_DOCUMENT_PATH):
|
||||
with open(document_path, mode='rb') as file_object:
|
||||
return self.post(
|
||||
viewname='sources:upload_interactive', kwargs={
|
||||
viewname='sources:document_upload_interactive', kwargs={
|
||||
'source_id': self.test_source.pk
|
||||
}, data={
|
||||
'source-file': file_object,
|
||||
@@ -42,7 +42,7 @@ class DocumentUploadWizardViewTestMixin(object):
|
||||
|
||||
def _request_upload_interactive_view(self):
|
||||
return self.get(
|
||||
viewname='sources:upload_interactive', data={
|
||||
viewname='sources:document_upload_interactive', data={
|
||||
'document_type_id': self.test_document_type.pk,
|
||||
}
|
||||
)
|
||||
@@ -113,7 +113,7 @@ class DocumentUploadWizardViewTestCase(
|
||||
|
||||
with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object:
|
||||
response = self.post(
|
||||
viewname='sources:upload_interactive', kwargs={
|
||||
viewname='sources:document_upload_interactive', kwargs={
|
||||
'source_id': self.test_source.pk
|
||||
}, data={
|
||||
'source-file': file_object,
|
||||
@@ -157,7 +157,7 @@ class DocumentUploadIssueTestCase(GenericDocumentViewTestCase):
|
||||
# Upload the test document
|
||||
with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object:
|
||||
self.post(
|
||||
viewname='sources:upload_interactive', data={
|
||||
viewname='sources:document_upload_interactive', data={
|
||||
'document-language': 'eng',
|
||||
'source-file': file_object,
|
||||
'document_type_id': self.test_document_type.pk
|
||||
@@ -207,7 +207,7 @@ class NewDocumentVersionViewTestCase(GenericDocumentViewTestCase):
|
||||
NewVersionBlock.objects.block(self.test_document)
|
||||
|
||||
response = self.post(
|
||||
viewname='sources:upload_version', kwargs={
|
||||
viewname='sources:document_version_upload', kwargs={
|
||||
'document_pk': self.test_document.pk
|
||||
}, follow=True
|
||||
)
|
||||
|
||||
@@ -9,7 +9,7 @@ from .api_views import (
|
||||
from .views import (
|
||||
SetupSourceCheckView, SetupSourceCreateView, SetupSourceDeleteView,
|
||||
SetupSourceEditView, SetupSourceListView, SourceLogListView,
|
||||
StagingFileDeleteView, UploadInteractiveVersionView, UploadInteractiveView
|
||||
StagingFileDeleteView, DocumentVersionUploadInteractiveView, UploadInteractiveView
|
||||
)
|
||||
from .wizards import DocumentCreateWizard
|
||||
|
||||
@@ -27,19 +27,23 @@ urlpatterns = [
|
||||
),
|
||||
url(
|
||||
regex=r'^documents/upload/new/interactive/(?P<source_id>\d+)/$',
|
||||
view=UploadInteractiveView.as_view(), name='upload_interactive'
|
||||
view=UploadInteractiveView.as_view(),
|
||||
name='document_upload_interactive'
|
||||
),
|
||||
url(
|
||||
regex=r'^documents/upload/new/interactive/$',
|
||||
view=UploadInteractiveView.as_view(), name='upload_interactive'
|
||||
view=UploadInteractiveView.as_view(),
|
||||
name='document_upload_interactive'
|
||||
),
|
||||
url(
|
||||
regex=r'^documents/(?P<document_pk>\d+)/versions/upload/interactive/(?P<source_id>\d+)/$',
|
||||
view=UploadInteractiveVersionView.as_view(), name='upload_version'
|
||||
view=DocumentVersionUploadInteractiveView.as_view(),
|
||||
name='document_version_upload'
|
||||
),
|
||||
url(
|
||||
regex=r'^documents/(?P<document_pk>\d+)/versions/upload/interactive/$',
|
||||
view=UploadInteractiveVersionView.as_view(), name='upload_version'
|
||||
view=DocumentVersionUploadInteractiveView.as_view(),
|
||||
name='document_version_upload'
|
||||
),
|
||||
|
||||
# Setup views
|
||||
|
||||
@@ -84,10 +84,10 @@ class UploadBaseView(MultiFormView):
|
||||
@staticmethod
|
||||
def get_tab_link_for_source(source, document=None):
|
||||
if document:
|
||||
view = 'sources:upload_version'
|
||||
view = 'sources:document_version_upload'
|
||||
args = ('"{}"'.format(document.pk), '"{}"'.format(source.pk),)
|
||||
else:
|
||||
view = 'sources:upload_interactive'
|
||||
view = 'sources:document_upload_interactive'
|
||||
args = ('"{}"'.format(source.pk),)
|
||||
|
||||
return Link(
|
||||
@@ -180,8 +180,8 @@ class UploadBaseView(MultiFormView):
|
||||
},
|
||||
})
|
||||
|
||||
menu_facet.bound_links['sources:upload_interactive'] = self.tab_links
|
||||
menu_facet.bound_links['sources:upload_version'] = self.tab_links
|
||||
menu_facet.bound_links['sources:document_upload_interactive'] = self.tab_links
|
||||
menu_facet.bound_links['sources:document_version_upload'] = self.tab_links
|
||||
|
||||
context.update(
|
||||
{
|
||||
@@ -360,7 +360,7 @@ class UploadInteractiveView(UploadBaseView):
|
||||
return context
|
||||
|
||||
|
||||
class UploadInteractiveVersionView(UploadBaseView):
|
||||
class DocumentVersionUploadInteractiveView(UploadBaseView):
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
|
||||
self.subtemplates_list = []
|
||||
@@ -392,7 +392,7 @@ class UploadInteractiveVersionView(UploadBaseView):
|
||||
self.tab_links = UploadBaseView.get_active_tab_links(self.document)
|
||||
|
||||
return super(
|
||||
UploadInteractiveVersionView, self
|
||||
DocumentVersionUploadInteractiveView, self
|
||||
).dispatch(request, *args, **kwargs)
|
||||
|
||||
def forms_valid(self, forms):
|
||||
@@ -448,13 +448,6 @@ class UploadInteractiveVersionView(UploadBaseView):
|
||||
files=kwargs.get('files', None),
|
||||
)
|
||||
|
||||
def create_document_form_form(self, **kwargs):
|
||||
return self.get_form_classes()['document_form'](
|
||||
prefix=kwargs['prefix'],
|
||||
data=kwargs.get('data', None),
|
||||
files=kwargs.get('files', None),
|
||||
)
|
||||
|
||||
def get_form_classes(self):
|
||||
return {
|
||||
'document_form': NewVersionForm,
|
||||
@@ -463,12 +456,14 @@ class UploadInteractiveVersionView(UploadBaseView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(
|
||||
UploadInteractiveVersionView, self
|
||||
DocumentVersionUploadInteractiveView, self
|
||||
).get_context_data(**kwargs)
|
||||
context['object'] = self.document
|
||||
context['title'] = _(
|
||||
'Upload a new version from source: %s'
|
||||
) % self.source.label
|
||||
'Upload a new version for document "%(document)s" '
|
||||
'from source: %(source)s'
|
||||
) % {'document': self.document, 'source': self.source.label}
|
||||
context['submit_label'] = _('Submit')
|
||||
|
||||
return context
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ class DocumentCreateWizard(SessionWizardView):
|
||||
for step in WizardStep.get_all():
|
||||
query_dict.update(step.done(wizard=self) or {})
|
||||
|
||||
url = furl(reverse(viewname='sources:upload_interactive'))
|
||||
url = furl(reverse(viewname='sources:document_upload_interactive'))
|
||||
# Use equal and not .update() to get the same result as using
|
||||
# urlencode(doseq=True)
|
||||
url.args = query_dict
|
||||
|
||||
@@ -27,7 +27,7 @@ class TaggedDocumentUploadTestCase(TagTestMixin, GenericDocumentViewTestCase):
|
||||
def _request_upload_interactive_document_create_view(self):
|
||||
with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object:
|
||||
return self.post(
|
||||
viewname='sources:upload_interactive', kwargs={
|
||||
viewname='sources:document_upload_interactive', kwargs={
|
||||
'source_id': self.test_source.pk
|
||||
}, data={
|
||||
'document_type_id': self.test_document_type.pk,
|
||||
|
||||
Reference in New Issue
Block a user