Fix issue when editing or removing metadata from multiple documents.

Bump version to 2.6.1.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-07-18 17:56:20 -04:00
parent 5dad91ca4e
commit 42a762481b
6 changed files with 160 additions and 12 deletions

View File

@@ -1,3 +1,7 @@
2.6.1 (2017-07-18)
==================
- Fix issue when editing or removing metadata from multiple documents.
2.6 (2017-07-18)
================
- Fix HTML mark up in window title. GitLab #397.

69
docs/releases/2.6.1.rst Normal file
View File

@@ -0,0 +1,69 @@
=============================
Mayan EDMS v2.6 release notes
=============================
Released: July 18, 2017
What's new
==========
Other Changes
-------------
- Fix issue when editing or removing metadata from multiple documents.
Removals
--------
* None
Upgrading from a previous version
---------------------------------
Using PIP
~~~~~~~~~
Type in the console::
$ pip install -U mayan-edms
the requirements will also be updated automatically.
Using Git
~~~~~~~~~
If you installed Mayan EDMS by cloning the Git repository issue the commands::
$ git reset --hard HEAD
$ git pull
otherwise download the compressed archived and uncompress it overriding the
existing installation.
Next upgrade/add the new requirements::
$ pip install --upgrade -r requirements.txt
Common steps
~~~~~~~~~~~~
Migrate existing database schema with::
$ mayan-edms.py performupgrade
Add new static media::
$ mayan-edms.py collectstatic --noinput
The upgrade procedure is now complete.
Backward incompatible changes
=============================
* None
Bugs fixed or issues closed
===========================
* None
.. _PyPI: https://pypi.python.org/pypi/mayan-edms/

View File

@@ -22,6 +22,7 @@ versions of the documentation contain the release notes for any later releases.
.. toctree::
:maxdepth: 1
2.6.1
2.6
2.5.2
2.5.1

View File

@@ -1,8 +1,8 @@
from __future__ import unicode_literals
__title__ = 'Mayan EDMS'
__version__ = '2.6'
__build__ = 0x020600
__version__ = '2.6.1'
__build__ = 0x020601
__author__ = 'Roberto Rosario'
__author_email__ = 'roberto.rosario@mayan-edms.com'
__description__ = 'Free Open Source Electronic Document Management System'

View File

@@ -19,7 +19,7 @@ from ..permissions import (
from .literals import (
TEST_DOCUMENT_METADATA_VALUE_2, TEST_METADATA_TYPE_LABEL,
TEST_METADATA_TYPE_LABEL_2, TEST_METADATA_TYPE_NAME,
TEST_METADATA_TYPE_NAME_2
TEST_METADATA_TYPE_NAME_2, TEST_METADATA_VALUE_EDITED
)
@@ -195,7 +195,9 @@ class DocumentMetadataTestCase(GenericDocumentViewTestCase):
file_object=File(file_object)
)
self.document.metadata.create(metadata_type=self.metadata_type)
document_metadata = self.document.metadata.create(
metadata_type=self.metadata_type
)
document_2.metadata.create(metadata_type=self.metadata_type)
response = self.get(
@@ -206,6 +208,69 @@ class DocumentMetadataTestCase(GenericDocumentViewTestCase):
self.assertContains(response, 'Edit', status_code=200)
# Test post to metadata removal view
response = self.post(
'metadata:metadata_multiple_edit', data={
'id_list': '{},{}'.format(self.document.pk, document_2.pk),
'form-0-id': document_metadata.pk,
'form-0-value': TEST_METADATA_VALUE_EDITED,
'form-0-update': True,
'form-TOTAL_FORMS': '1',
'form-INITIAL_FORMS': '0',
'form-MAX_NUM_FORMS': '',
}, follow=True
)
self.assertEqual(response.status_code, 200)
self.assertEqual(
self.document.metadata.first().value, TEST_METADATA_VALUE_EDITED
)
self.assertEqual(
document_2.metadata.first().value, TEST_METADATA_VALUE_EDITED
)
def test_multiple_document_metadata_remove(self):
self.login_user()
self.grant_permission(permission=permission_document_view)
self.grant_permission(permission=permission_metadata_document_remove)
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
document_2 = self.document_type.new_document(
file_object=File(file_object)
)
document_metadata = self.document.metadata.create(
metadata_type=self.metadata_type
)
document_2.metadata.create(metadata_type=self.metadata_type)
response = self.get(
'metadata:metadata_multiple_remove', data={
'id_list': '{},{}'.format(self.document.pk, document_2.pk)
}
)
self.assertEquals(response.status_code, 200)
# Test post to metadata removal view
response = self.post(
'metadata:metadata_multiple_remove', data={
'id_list': '{},{}'.format(self.document.pk, document_2.pk),
'form-0-id': document_metadata.pk,
'form-0-update': True,
'form-TOTAL_FORMS': '1',
'form-INITIAL_FORMS': '0',
'form-MAX_NUM_FORMS': '',
}, follow=True
)
self.assertEqual(response.status_code, 200)
self.assertEqual(self.document.metadata.count(), 0)
self.assertEqual(document_2.metadata.count(), 0)
def test_multiple_document_metadata_add(self):
self.login_user()

View File

@@ -234,7 +234,11 @@ class DocumentMetadataEditView(MultipleObjectFormActionView):
urlencode(
{
'id_list': ','.join(
queryset.value_list('pk', flat=True)
map(
force_text, queryset.values_list(
'pk', flat=True
)
)
)
}
)
@@ -404,7 +408,10 @@ class DocumentMetadataRemoveView(MultipleObjectFormActionView):
urlencode(
{
'id_list': ','.join(
queryset.value_list('pk', flat=True)
map(
force_text,
queryset.values_list('pk', flat=True)
)
)
}
)
@@ -446,13 +453,15 @@ class DocumentMetadataRemoveView(MultipleObjectFormActionView):
for document in queryset:
document.add_as_recent_document_for_user(self.request.user)
for item in document.metadata.all():
value = item.value
if item.metadata_type in metadata:
if value not in metadata[item.metadata_type]:
metadata[item.metadata_type].append(value)
for document_metadata in document.metadata.all():
# Metadata value cannot be None here, fallback to an empty
# string
value = document_metadata.value or ''
if document_metadata.metadata_type in metadata:
if value not in metadata[document_metadata.metadata_type]:
metadata[document_metadata.metadata_type].append(value)
else:
metadata[item.metadata_type] = [value] if value else ''
metadata[document_metadata.metadata_type] = [value] if value else ''
initial = []
for key, value in metadata.items():