From d4acb803f0f488d487db6cc088c4522618f94aab Mon Sep 17 00:00:00 2001 From: Alexander Watzinger Date: Thu, 10 Feb 2022 13:21:19 +0100 Subject: [PATCH] Fix for error adding administrative unit (#1616) --- config.py | 2 +- openatlas/models/entity.py | 3 ++- openatlas/util/changelog.py | 3 +++ tests/test_type.py | 18 ++++++++++-------- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/config.py b/config.py index cdcb6b672..9e062c9c4 100644 --- a/config.py +++ b/config.py @@ -3,7 +3,7 @@ from openatlas import app -VERSION = '7.0.3' +VERSION = '7.0.4' DATABASE_VERSION = '6.6.0' DEMO_MODE = False # If activated some options are disabled, login is pre filled IS_UNIT_TEST = False diff --git a/openatlas/models/entity.py b/openatlas/models/entity.py index 4874cff7b..42f670140 100644 --- a/openatlas/models/entity.py +++ b/openatlas/models/entity.py @@ -153,7 +153,8 @@ def update( self.update_attributes(data['attributes']) if 'aliases' in data: self.update_aliases(data['aliases']) - if 'administrative_units' in data: + if 'administrative_units' in data \ + and self.class_.name != 'administrative_unit': self.update_administrative_units(data['administrative_units'], new) if 'links' in data: redirect_link_id = self.update_links(data['links'], new) diff --git a/openatlas/util/changelog.py b/openatlas/util/changelog.py index 18c836218..1aab32c06 100644 --- a/openatlas/util/changelog.py +++ b/openatlas/util/changelog.py @@ -1,6 +1,9 @@ class Changelog: versions = { + '7.0.4': ['2022-02-10', { + 'fix': { + '1616': 'Error at inserting an administrative unit'}}], '7.0.3': ['2022-02-02', { 'fix': { '1634': 'Value Type with Subtype error'}}], diff --git a/tests/test_type.py b/tests/test_type.py index 41536cc58..947bb9676 100644 --- a/tests/test_type.py +++ b/tests/test_type.py @@ -20,10 +20,6 @@ def test_type(self) -> None: rv = self.app.get( url_for('insert', class_='type', origin_id=actor_type.id)) assert b'Actor actor relation' in rv.data - rv = self.app.post( - url_for('insert', class_='type', origin_id=actor_type.id), - data={'name_search': 'new'}) - assert b'Inverse' in rv.data data = { 'name': 'My secret type', 'name_inverse': 'Do I look inverse?', @@ -43,7 +39,7 @@ def test_type(self) -> None: follow_redirects=True) assert b'Changes have been saved.' in rv.data - # Insert an continue + # Insert and continue data['continue_'] = 'yes' rv = self.app.post( url_for('insert', class_='type', origin_id=actor_type.id), @@ -86,12 +82,18 @@ def test_type(self) -> None: assert b'Male' in rv.data # Administrative unit + admin_unit_id = Type.get_hierarchy('Administrative unit').id rv = self.app.get( + url_for('view', id_=admin_unit_id), follow_redirects=True) + assert b'Austria' in rv.data + rv = self.app.post( url_for( - 'view', - id_=Type.get_hierarchy('Administrative unit').id), + 'insert', + class_='administrative_unit', + origin_id=g.types[admin_unit_id].subs[0]), + data={'name': 'admin unit'}, follow_redirects=True) - assert b'Austria' in rv.data + assert b'An entry has been created' in rv.data # Value type rv = self.app.get(