Merge branch 'versions/minor' into features/multi_version_document

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-10-10 14:56:47 -04:00
17 changed files with 68 additions and 50 deletions

View File

@@ -19,7 +19,7 @@ job_docker_build:
- docker build --pull -t "$CI_REGISTRY_IMAGE" -f docker/Dockerfile .
- VERSION=`cat docker/rootfs/version`
- docker tag "$CI_REGISTRY_IMAGE" "$CI_REGISTRY_IMAGE:$VERSION"
- docker run --rm "$CI_REGISTRY_IMAGE:$VERSION" run-tests
- docker run --rm "$CI_REGISTRY_IMAGE:$VERSION" run_tests
- docker push "$CI_REGISTRY_IMAGE:$VERSION"
- docker push "$CI_REGISTRY_IMAGE:latest"
- docker tag "$CI_REGISTRY_IMAGE:$VERSION" registry-1.docker.io/mayanedms/mayanedms:"$VERSION"
@@ -58,7 +58,7 @@ job_docker_nightly:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -f docker/Dockerfile .
- docker run --rm "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" run-tests
- docker run --rm "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" run_tests
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
only:
- nightly
@@ -152,7 +152,9 @@ job_push_python:
- locale-gen en_US.UTF-8
- update-locale LANG=en_US.UTF-8
- export LC_ALL=en_US.UTF-8
- apt-get install -qq curl exiftool gcc ghostscript gnupg1 graphviz libfuse2 libjpeg-dev libmagic1 libpng-dev libtiff-dev poppler-utils libreoffice poppler-utils python-dev python-pip tesseract-ocr tesseract-ocr-deu
- apt-get install -qq curl exiftool gcc ghostscript gnupg1 graphviz libfuse2 libjpeg-dev libmagic1 libpng-dev libtiff-dev poppler-utils libreoffice poppler-utils python-dev python-virtualenv python3-dev tesseract-ocr tesseract-ocr-deu
- virtualenv venv -p /usr/bin/python3
- . venv/bin/activate
- pip install -r requirements.txt -r requirements/testing-base.txt
only:
- releases/all
@@ -170,6 +172,7 @@ test-mysql:
- mysql:8.0.3
script:
- apt-get install -qq libmysqlclient-dev mysql-client
- . venv/bin/activate
- pip install mysqlclient
- mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD" -e "set global character_set_server=utf8mb4;"
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_mysql --nomigrations
@@ -185,6 +188,7 @@ test-postgres:
- postgres
script:
- apt-get install -qq libpq-dev
- . venv/bin/activate
- pip install psycopg2
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci.db_postgres --nomigrations
tags:
@@ -193,6 +197,7 @@ test-postgres:
test-sqlite:
<<: *test_base
script:
- . venv/bin/activate
- python manage.py test --mayan-apps --settings=mayan.settings.testing.gitlab-ci --nomigrations
deploy_demo:

View File

@@ -3,7 +3,7 @@ from __future__ import unicode_literals
__title__ = 'Mayan EDMS'
__version__ = '3.3beta1'
__build__ = 0x030300
__build_string__ = 'v3.3beta1_Sat Oct 5 15:08:53 2019 -0400'
__build_string__ = 'v3.3beta1-9-g1b327b99f0_Tue Oct 8 15:15:08 2019 -0400'
__django_version__ = '1.11'
__author__ = 'Roberto Rosario'
__author_email__ = 'roberto.rosario@mayan-edms.com'

View File

@@ -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,

View File

@@ -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
)

View File

@@ -66,7 +66,7 @@ class MultiFormView(DjangoFormView):
def dispatch(self, request, *args, **kwargs):
form_classes = self.get_form_classes()
self.forms = self.get_forms(form_classes)
self.forms = self.get_forms(form_classes=form_classes)
return super(MultiFormView, self).dispatch(request, *args, **kwargs)
def forms_valid(self, forms):
@@ -74,9 +74,9 @@ class MultiFormView(DjangoFormView):
form_valid_method = '{}_form_valid'.format(form_name)
if hasattr(self, form_valid_method):
return getattr(self, form_valid_method)(form)
return getattr(self, form_valid_method)(form=form)
self.all_forms_valid(forms)
self.all_forms_valid(forms=forms)
return HttpResponseRedirect(redirect_to=self.get_success_url())
@@ -102,10 +102,12 @@ class MultiFormView(DjangoFormView):
kwargs.update({'prefix': self.get_prefix(form_name=form_name)})
if self.request.method in ('POST', 'PUT'):
kwargs.update({
kwargs.update(
{
'data': self.request.POST,
'files': self.request.FILES,
})
}
)
kwargs.update(self.get_form_extra_kwargs(form_name=form_name) or {})
@@ -118,7 +120,7 @@ class MultiFormView(DjangoFormView):
return dict(
[
(
key, self._create_form(key, klass)
key, self._create_form(form_name=key, klass=klass)
) for key, klass in form_classes.items()
]
)
@@ -206,9 +208,9 @@ class AddRemoveView(
getattr(self.main_object, self.related_field).add(*queryset)
else:
raise ImproperlyConfigured(
'View %s must be called with a main_object_method_add, a '
'View {} must be called with a main_object_method_add, a '
'related_field, or an action_add '
'method.' % self.__class__.__name__
'method.'.format(self.__class__.__name__)
)
def _action_remove(self, queryset):
@@ -225,9 +227,9 @@ class AddRemoveView(
getattr(self.main_object, self.related_field).remove(*queryset)
else:
raise ImproperlyConfigured(
'View %s must be called with a main_object_method_remove, a '
'View {} must be called with a main_object_method_remove, a '
'related_field, or an action_remove '
'method.' % self.__class__.__name__
'method.'.format(self.__class__.__name__)
)
def dispatch(self, request, *args, **kwargs):
@@ -348,8 +350,10 @@ class AddRemoveView(
def get_list_added_queryset(self):
if not self.related_field:
raise ImproperlyConfigured(
'View %s must be called with either a related_field or '
'override .get_list_added_queryset().' % self.__class__.__name__
'View {} must be called with either a related_field or '
'override .get_list_added_queryset().'.format(
self.__class__.__name__
)
)
return self.get_secondary_object_list().filter(

View File

@@ -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

View File

@@ -146,8 +146,9 @@ class SourcesApp(MayanAppConfig):
menu_secondary.bind_links(
links=(link_document_version_upload,),
sources=(
'documents:document_version_list', 'sources:upload_version',
'documents:document_version_revert'
'documents:document_version_list',
'documents:document_version_revert',
'sources:document_version_upload'
)
)
menu_secondary.bind_links(

View File

@@ -28,7 +28,6 @@ class NewVersionForm(forms.Form):
label=_('Comment'), required=False,
widget=forms.widgets.Textarea(attrs={'rows': 4}),
)
append_pages = forms.BooleanField(
help_text=_(
'If selected, the pages of the file uploaded will be appended '

View File

@@ -124,7 +124,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',),

View File

@@ -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
)

View File

@@ -7,10 +7,10 @@ from .api_views import (
APIStagingSourceListView, APIStagingSourceView
)
from .views import (
DocumentPagesAppendView, SetupSourceCheckView, SetupSourceCreateView,
SetupSourceDeleteView, SetupSourceEditView, SetupSourceListView,
SourceLogListView, StagingFileDeleteView, UploadInteractiveVersionView,
UploadInteractiveView
DocumentPagesAppendView, DocumentVersionUploadInteractiveView,
SetupSourceCheckView, SetupSourceCreateView, SetupSourceDeleteView,
SetupSourceEditView, SetupSourceListView, SourceLogListView,
StagingFileDeleteView, UploadInteractiveView
)
from .wizards import DocumentCreateWizard
@@ -28,19 +28,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'
),
url(
regex=r'^documents/(?P<document_pk>\d+)/pages/append/interactive/(?P<source_id>\d+)/$',

View File

@@ -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 = []
@@ -391,7 +391,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):
@@ -460,13 +460,13 @@ 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 for document "%(document)s" from source: %(source)s'
'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

View File

@@ -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

View File

@@ -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,

View File

@@ -8,6 +8,7 @@ from mayan.apps.common.menus import menu_tools
from mayan.apps.navigation.classes import SourceColumn
from .classes import CeleryQueue, Task
from .dependencies import * # NOQA
from .links import link_task_manager
from .settings import * # NOQA

View File

@@ -1,7 +1,9 @@
Pillow==6.0.0
PyPDF2==1.26.0
PyYAML==5.1.1
celery==4.3.0
django-activity-stream==0.7.0
django-celery-beat==1.5.0
django-colorful==1.3
django-cors-headers==2.5.2
django-downloadview==1.9

View File

@@ -60,7 +60,9 @@ django==1.11.24
Pillow==6.0.0
PyPDF2==1.26.0
PyYAML==5.1.1
celery==4.3.0
django-activity-stream==0.7.0
django-celery-beat==1.5.0
django-colorful==1.3
django-cors-headers==2.5.2
django-downloadview==1.9