diff --git a/mayan/apps/cabinets/tests/test_wizard_steps.py b/mayan/apps/cabinets/tests/test_wizard_steps.py index 84f7fabd82..3f93b768fa 100644 --- a/mayan/apps/cabinets/tests/test_wizard_steps.py +++ b/mayan/apps/cabinets/tests/test_wizard_steps.py @@ -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, diff --git a/mayan/apps/checkouts/tests/test_views.py b/mayan/apps/checkouts/tests/test_views.py index 128e1643e0..c701618511 100644 --- a/mayan/apps/checkouts/tests/test_views.py +++ b/mayan/apps/checkouts/tests/test_views.py @@ -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 ) diff --git a/mayan/apps/metadata/tests/test_wizard_steps.py b/mayan/apps/metadata/tests/test_wizard_steps.py index a2384fdd83..853d735085 100644 --- a/mayan/apps/metadata/tests/test_wizard_steps.py +++ b/mayan/apps/metadata/tests/test_wizard_steps.py @@ -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 diff --git a/mayan/apps/sources/apps.py b/mayan/apps/sources/apps.py index 7139e5a846..bd86e07bd6 100644 --- a/mayan/apps/sources/apps.py +++ b/mayan/apps/sources/apps.py @@ -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' ) ) diff --git a/mayan/apps/sources/forms.py b/mayan/apps/sources/forms.py index a6431f71e5..e555967cd9 100644 --- a/mayan/apps/sources/forms.py +++ b/mayan/apps/sources/forms.py @@ -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): diff --git a/mayan/apps/sources/links.py b/mayan/apps/sources/links.py index b1793547f5..35146f38a1 100644 --- a/mayan/apps/sources/links.py +++ b/mayan/apps/sources/links.py @@ -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',), diff --git a/mayan/apps/sources/tests/test_views.py b/mayan/apps/sources/tests/test_views.py index ee64dfdffd..a5484201f1 100644 --- a/mayan/apps/sources/tests/test_views.py +++ b/mayan/apps/sources/tests/test_views.py @@ -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 ) diff --git a/mayan/apps/sources/urls.py b/mayan/apps/sources/urls.py index fdc7adc330..cffeb4bf29 100644 --- a/mayan/apps/sources/urls.py +++ b/mayan/apps/sources/urls.py @@ -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\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\d+)/versions/upload/interactive/(?P\d+)/$', - view=UploadInteractiveVersionView.as_view(), name='upload_version' + view=DocumentVersionUploadInteractiveView.as_view(), + name='document_version_upload' ), url( regex=r'^documents/(?P\d+)/versions/upload/interactive/$', - view=UploadInteractiveVersionView.as_view(), name='upload_version' + view=DocumentVersionUploadInteractiveView.as_view(), + name='document_version_upload' ), # Setup views diff --git a/mayan/apps/sources/views.py b/mayan/apps/sources/views.py index be55047b7d..4e24c01be3 100644 --- a/mayan/apps/sources/views.py +++ b/mayan/apps/sources/views.py @@ -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 diff --git a/mayan/apps/sources/wizards.py b/mayan/apps/sources/wizards.py index c88c7c0822..0523442b15 100644 --- a/mayan/apps/sources/wizards.py +++ b/mayan/apps/sources/wizards.py @@ -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 diff --git a/mayan/apps/tags/tests/test_wizard_steps.py b/mayan/apps/tags/tests/test_wizard_steps.py index 46824a83b1..b93a8edf10 100644 --- a/mayan/apps/tags/tests/test_wizard_steps.py +++ b/mayan/apps/tags/tests/test_wizard_steps.py @@ -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,