Skip to content
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.

Commit

Permalink
Production update 22/05/01
Browse files Browse the repository at this point in the history
See merge request fairdata/fairdata-metax!184
  • Loading branch information
Sini Saarinen committed Apr 27, 2022
2 parents d719ec4 + bcded82 commit 0044867
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 5 deletions.
23 changes: 23 additions & 0 deletions src/metax_api/migrations/0049_auto_20220413_0952.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.10 on 2022-04-13 06:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('metax_api', '0048_organizationstatistics_projectstatistics'),
]

operations = [
migrations.AlterField(
model_name='organizationstatistics',
name='byte_size',
field=models.BigIntegerField(),
),
migrations.AlterField(
model_name='projectstatistics',
name='byte_size',
field=models.BigIntegerField(),
),
]
8 changes: 5 additions & 3 deletions src/metax_api/models/catalog_record_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
generate_uuid_identifier,
get_identifier_type,
get_tz_aware_now_without_micros,
is_metax_generated_doi_identifier,
)

from .catalog_record import (
Expand Down Expand Up @@ -303,9 +304,10 @@ def publish_dataset(self, pid_type=None):

self._validate_cr_against_datacite_schema()

self.add_post_request_callable(
DataciteDOIUpdate(self, self.research_dataset["preferred_identifier"], "create")
)
if is_metax_generated_doi_identifier(self.research_dataset.get("preferred_identifier")):
self.add_post_request_callable(
DataciteDOIUpdate(self, self.research_dataset["preferred_identifier"], "create")
)

if self._dataset_has_rems_managed_access() and settings.REMS["ENABLED"]:
self._pre_rems_creation()
Expand Down
2 changes: 1 addition & 1 deletion src/metax_api/models/organization_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
class OrganizationStatistics(models.Model):
organization = models.CharField(primary_key=True, max_length=200)
count = models.IntegerField()
byte_size = models.IntegerField()
byte_size = models.BigIntegerField()

2 changes: 1 addition & 1 deletion src/metax_api/models/project_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
class ProjectStatistics(models.Model):
project_identifier = models.CharField(primary_key=True, max_length=200)
count = models.IntegerField()
byte_size = models.IntegerField()
byte_size = models.BigIntegerField()
published_datasets = models.TextField()
15 changes: 15 additions & 0 deletions src/metax_api/tests/api/rest/v2/views/datasets/write.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,21 @@ def test_create_catalog_record_using_pid_type(self):
response.data["research_dataset"]["preferred_identifier"].startswith("urn:")
)

def test_create_catalog_record_with_existing_pid_to_harvested_catalog(self):
"""
Test creating a catalog record which already has a pid to a harvested catalog.
API should return 201 and the pid that is returned should be the same as the one that was sent.
"""
self.cr_test_data["research_dataset"]["preferred_identifier"] = "doi:10.1234/abcd"
self.cr_test_data["data_catalog"] = 3
response = self.client.post("/rest/v2/datasets", self.cr_test_data, format="json")
self.assertEqual(response.status_code, 201)
self.assertEqual(
self.cr_test_data["research_dataset"]["preferred_identifier"],
response.data["research_dataset"]["preferred_identifier"],
"in harvested catalogs, the service user is allowed to set preferred_identifier",
)


class CatalogRecordApiWriteIdentifierUniqueness(CatalogRecordApiWriteCommon):
"""
Expand Down

0 comments on commit 0044867

Please sign in to comment.