This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* CSCFAIRMETA-647: [FIX] bug with almost simultaneous requests - LightFileserializer made modifications to class variable so when two requests came almost at the same time the latter was using modified version of the variable. Fixed with deepcopy - Changed app to use local Elasticsearch with tests since it is now working * CSCFAIRMETA-710: [FIX] _mapping endpoint and ES in testcases - Correctly call elasticsearch when request comes to _mapping endpoint - Tests can be run against local elasticsearch which reduces the population time - Follow naming convention in refdata loader with non-internal functions * CSCFAIRMETA-710: [FIX] remove unnecessary variable * CSCFAIRADM-337: [ADD] Update domain references (#631) - These mostly concern test data, but should be updated still * CSCFAIRMETA-704 [FIX] merge-draft-does-not-save-changes - In merge_draft take preservation_state from draft cr * CSCFAIRMETA-704-merge-draft-does-not-save-changes - Change metax-demo to metax.demo * CSCFAIRMETA-716: [FIX] create-draft-internal-error-when-draft-already-exists - Add a check for next_draft * CSCFAIRMETA-712-Issues-with-emails -Add migration to change email and organization name * CSCFAIRMETA-712-Issues-with-emails - Add check whether metadata_owner_org or metadata_provider_org exists * CSCFAIRMETA-636-return-if-files-are-part-of-some-dataset - Add ?keys=datasets|files and ?keysonly=bool - Remove parameter ?detailed as it is the same as ?keys=files * CSCFAIRMETA-636-return-if-files-are-part-of-some-dataset - Add test for parameter ?keysonly * CSCFAIRMETA-636-return-if-files-are-part-of-some-dataset - Add support for leaving argument ?detailed * CSCFAIRMETA-636-return-if-files-are-part-of-some-dataset Add ?keysonly return input list except standalone files or datasets without files * CSCFAIRMETA-636-return-if-files-are-part-of-some-dataset - Refactor sql's - Fix parameters 'request' and 'preferred_identifier' Co-authored-by: Tommi Pulli <[email protected]> Co-authored-by: Tommi Pulli <[email protected]> Co-authored-by: Mattias Levlin <[email protected]> Co-authored-by: Tommi Pulli <[email protected]> Co-authored-by: Tommi Pulli <[email protected]> Co-authored-by: Mattias Levlin <[email protected]>
- Loading branch information
1 parent
104da4f
commit 6e046be
Showing
21 changed files
with
387 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,10 @@ | |
# :author: CSC - IT Center for Science Ltd., Espoo Finland <[email protected]> | ||
# :license: MIT | ||
|
||
import logging | ||
from copy import deepcopy | ||
from collections import OrderedDict | ||
from datetime import datetime | ||
import logging | ||
|
||
from django.db import transaction | ||
from django.db.models.query import QuerySet | ||
|
@@ -315,7 +316,8 @@ def ls_field_list(cls, received_field_list=[]): | |
|
||
else: | ||
# get all fields | ||
field_list = cls.allowed_fields | ||
# deepcopy prevents inheriting classes from modifying the allowed_fields -set which should be static | ||
field_list = deepcopy(cls.allowed_fields) | ||
|
||
return field_list | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
# Generated by Django 3.0.7 on 2020-09-17 12:04 | ||
|
||
from django.db import migrations | ||
import logging | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
def change_emails(apps, schema_editor): | ||
import json | ||
CatalogRecord = apps.get_model('metax_api', 'CatalogRecord') | ||
|
||
for cr in CatalogRecord.objects.all(): | ||
owner = json.loads(json.dumps(cr.metadata_owner_org)) | ||
provider = json.loads(json.dumps(cr.metadata_provider_org)) | ||
|
||
cr_changed = False | ||
|
||
owner_data = '' | ||
prov_data = '' | ||
if owner: | ||
if 'tut.fi' in owner: | ||
owner_data = owner.replace("tut.fi", "tuni.fi") | ||
cr_changed = True | ||
elif 'uta.fi' in owner: | ||
owner_data = owner.replace("uta.fi", "tuni.fi") | ||
cr_changed = True | ||
if provider: | ||
if 'tut.fi' in provider: | ||
prov_data = provider.replace("tut.fi", "tuni.fi") | ||
cr_changed = True | ||
elif 'uta.fi' in provider: | ||
prov_data = provider.replace("uta.fi", "tuni.fi") | ||
cr_changed = True | ||
|
||
if cr_changed: | ||
cr.metadata_owner_org = owner_data | ||
cr.metadata_provider_org = prov_data | ||
cr.save() | ||
|
||
# Change actor emails in research dataset | ||
research_dataset_changed = False | ||
|
||
dataset = json.loads(json.dumps(cr.research_dataset)) | ||
|
||
roles = ['curator', 'creator', 'contributor', 'publisher', 'rights_holder'] | ||
|
||
for role in roles: | ||
if role in dataset: | ||
for actor in dataset[role]: | ||
email = '' | ||
if isinstance(actor, str): | ||
if 'email' in dataset[role].keys(): | ||
email = dataset[role]['email'] | ||
if isinstance(actor, dict): | ||
if 'email' in actor.keys(): | ||
email = actor['email'] | ||
|
||
changed = False | ||
if 'tut.fi' in email: | ||
email = email.replace("tut.fi", "tuni.fi") | ||
changed = True | ||
elif 'uta.fi' in email: | ||
email = email.replace("uta.fi", "tuni.fi") | ||
changed = True | ||
|
||
if changed: | ||
research_dataset_changed = True | ||
if isinstance(actor, str): | ||
dataset[role]['email'] = email | ||
else: | ||
actor['email'] = email | ||
if research_dataset_changed: | ||
cr.research_dataset = dataset | ||
cr.save() | ||
|
||
|
||
def revert(apps, schema_editor): | ||
pass | ||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('metax_api', '0025_auto_20200811_1050'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(change_emails, revert), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.