diff --git a/swh/deposit/api/deposit_status.py b/swh/deposit/api/deposit_status.py
--- a/swh/deposit/api/deposit_status.py
+++ b/swh/deposit/api/deposit_status.py
@@ -49,8 +49,8 @@
}
keys = (
"status",
- "swh_id",
- "swh_id_context",
+ "swhid",
+ "swhid_context",
"external_id",
)
for k in keys:
diff --git a/swh/deposit/api/deposit_update.py b/swh/deposit/api/deposit_update.py
--- a/swh/deposit/api/deposit_update.py
+++ b/swh/deposit/api/deposit_update.py
@@ -203,10 +203,10 @@
deposit = Deposit.objects.get(pk=deposit_id)
assert deposit.status == DEPOSIT_STATUS_LOAD_SUCCESS
- if swhid != deposit.swh_id:
+ if swhid != deposit.swhid:
return make_error_dict(
BAD_REQUEST,
- f"Mismatched provided SWHID {swhid} with deposit's {deposit.swh_id}.",
+ f"Mismatched provided SWHID {swhid} with deposit's {deposit.swhid}.",
"The provided SWHID does not match the deposit to update. "
"Please ensure you send the correct deposit SWHID.",
)
diff --git a/swh/deposit/api/private/deposit_read.py b/swh/deposit/api/private/deposit_read.py
--- a/swh/deposit/api/private/deposit_read.py
+++ b/swh/deposit/api/private/deposit_read.py
@@ -149,7 +149,7 @@
author_date, commit_date = self._normalize_dates(deposit, metadata)
if deposit.parent:
- swh_persistent_id = deposit.parent.swh_id
+ swh_persistent_id = deposit.parent.swhid
swhid = identifiers.parse_swhid(swh_persistent_id)
parent_revision = swhid.object_id
parents = [parent_revision]
diff --git a/swh/deposit/api/private/deposit_update_status.py b/swh/deposit/api/private/deposit_update_status.py
--- a/swh/deposit/api/private/deposit_update_status.py
+++ b/swh/deposit/api/private/deposit_update_status.py
@@ -87,9 +87,9 @@
snp_id = swhid(SNAPSHOT, data["snapshot_id"])
rev_id = swhid(REVISION, revision_id)
- deposit.swh_id = dir_id
+ deposit.swhid = dir_id
# new id with contextual information
- deposit.swh_id_context = swhid(
+ deposit.swhid_context = swhid(
DIRECTORY,
directory_id,
metadata={
diff --git a/swh/deposit/cli/admin.py b/swh/deposit/cli/admin.py
--- a/swh/deposit/cli/admin.py
+++ b/swh/deposit/cli/admin.py
@@ -263,8 +263,8 @@
ctx.exit(1)
# Reset the deposit's state
- deposit.swh_id = None
- deposit.swh_id_context = None
+ deposit.swhid = None
+ deposit.swhid_context = None
deposit.status = DEPOSIT_STATUS_VERIFIED
deposit.save()
diff --git a/swh/deposit/client.py b/swh/deposit/client.py
--- a/swh/deposit/client.py
+++ b/swh/deposit/client.py
@@ -361,7 +361,7 @@
empty_result={
"deposit_status": None,
"deposit_status_detail": None,
- "deposit_swh_id": None,
+ "deposit_swhid": None,
},
)
@@ -381,8 +381,8 @@
"deposit_id",
"deposit_status",
"deposit_status_detail",
- "deposit_swh_id",
- "deposit_swh_id_context",
+ "deposit_swhid",
+ "deposit_swhid_context",
"deposit_external_id",
],
)
diff --git a/swh/deposit/migrations/0020_auto_20200929_0855.py b/swh/deposit/migrations/0020_auto_20200929_0855.py
new file mode 100644
--- /dev/null
+++ b/swh/deposit/migrations/0020_auto_20200929_0855.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.23 on 2020-09-29 08:55
+from __future__ import unicode_literals
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("deposit", "0019_auto_20200519_1035"),
+ ]
+
+ operations = [
+ migrations.RenameField(
+ model_name="deposit", old_name="swh_id", new_name="swhid",
+ ),
+ migrations.RenameField(
+ model_name="deposit", old_name="swh_id_context", new_name="swhid_context",
+ ),
+ ]
diff --git a/swh/deposit/models.py b/swh/deposit/models.py
--- a/swh/deposit/models.py
+++ b/swh/deposit/models.py
@@ -126,8 +126,8 @@
# Deposit client
client = models.ForeignKey("DepositClient", models.DO_NOTHING)
# SWH's loading result identifier
- swh_id = models.TextField(blank=True, null=True)
- swh_id_context = models.TextField(blank=True, null=True)
+ swhid = models.TextField(blank=True, null=True)
+ swhid_context = models.TextField(blank=True, null=True)
# Deposit's status regarding loading
status = models.TextField(choices=DEPOSIT_STATUS, default=DEPOSIT_STATUS_PARTIAL)
status_detail = JSONField(null=True)
diff --git a/swh/deposit/templates/deposit/status.xml b/swh/deposit/templates/deposit/status.xml
--- a/swh/deposit/templates/deposit/status.xml
+++ b/swh/deposit/templates/deposit/status.xml
@@ -4,7 +4,7 @@
{{ deposit_id }}
{{ status }}
{{ status_detail }}
- {% if swh_id is not None %}{{ swh_id }}{% endif %}
- {% if swh_id_context is not None %}{{ swh_id_context }}{% endif %}
+ {% if swhid is not None %}{{ swhid }}{% endif %}
+ {% if swhid_context is not None %}{{ swhid_context }}{% endif %}
{% if external_id is not None %}{{ external_id }}{% endif %}
diff --git a/swh/deposit/tests/api/test_deposit_binary.py b/swh/deposit/tests/api/test_deposit_binary.py
--- a/swh/deposit/tests/api/test_deposit_binary.py
+++ b/swh/deposit/tests/api/test_deposit_binary.py
@@ -108,7 +108,7 @@
assert deposit.status == DEPOSIT_STATUS_DEPOSITED
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
- assert deposit.swh_id is None
+ assert deposit.swhid is None
deposit_request = DepositRequest.objects.get(deposit=deposit)
check_archive(sample_archive["name"], deposit_request.archive.name)
@@ -363,7 +363,7 @@
assert deposit.status == "partial"
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
- assert deposit.swh_id is None
+ assert deposit.swhid is None
deposit_request = DepositRequest.objects.get(deposit=deposit)
assert deposit_request.deposit == deposit
@@ -398,7 +398,7 @@
assert deposit.status == DEPOSIT_STATUS_DEPOSITED
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
- assert deposit.swh_id is None
+ assert deposit.swhid is None
deposit_requests = list(
DepositRequest.objects.filter(deposit=deposit).order_by("id")
@@ -454,7 +454,7 @@
assert deposit.status == DEPOSIT_STATUS_DEPOSITED
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
- assert deposit.swh_id is None
+ assert deposit.swhid is None
deposit_request = DepositRequest.objects.get(deposit=deposit)
assert deposit_request.deposit == deposit
diff --git a/swh/deposit/tests/api/test_deposit_multipart.py b/swh/deposit/tests/api/test_deposit_multipart.py
--- a/swh/deposit/tests/api/test_deposit_multipart.py
+++ b/swh/deposit/tests/api/test_deposit_multipart.py
@@ -104,7 +104,7 @@
assert deposit.status == DEPOSIT_STATUS_DEPOSITED
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
- assert deposit.swh_id is None
+ assert deposit.swhid is None
deposit_requests = DepositRequest.objects.filter(deposit=deposit)
assert len(deposit_requests) == 2
@@ -174,7 +174,7 @@
assert deposit.status == DEPOSIT_STATUS_DEPOSITED
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
- assert deposit.swh_id is None
+ assert deposit.swhid is None
deposit_requests = DepositRequest.objects.filter(deposit=deposit)
assert len(deposit_requests) == 2
@@ -244,7 +244,7 @@
assert deposit.status == "partial"
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
- assert deposit.swh_id is None
+ assert deposit.swhid is None
deposit_requests = DepositRequest.objects.filter(deposit=deposit)
@@ -275,7 +275,7 @@
assert deposit.status == DEPOSIT_STATUS_DEPOSITED
assert deposit.external_id == external_id
assert deposit.collection == deposit_collection
- assert deposit.swh_id is None
+ assert deposit.swhid is None
deposit_requests = DepositRequest.objects.filter(deposit=deposit)
assert len(deposit_requests) == 2
diff --git a/swh/deposit/tests/api/test_deposit_private_read_metadata.py b/swh/deposit/tests/api/test_deposit_private_read_metadata.py
--- a/swh/deposit/tests/api/test_deposit_private_read_metadata.py
+++ b/swh/deposit/tests/api/test_deposit_private_read_metadata.py
@@ -122,9 +122,9 @@
authenticated_client, deposit_collection, deposit, atom_dataset
)
rev_id = "da78a9d4cf1d5d29873693fd496142e3a18c20fa"
- swh_id = "swh:1:rev:%s" % rev_id
+ swhid = "swh:1:rev:%s" % rev_id
fake_parent = Deposit(
- swh_id=swh_id, client=deposit.client, collection=deposit.collection
+ swhid=swhid, client=deposit.client, collection=deposit.collection
)
fake_parent.save()
deposit.parent = fake_parent
diff --git a/swh/deposit/tests/api/test_deposit_private_update_status.py b/swh/deposit/tests/api/test_deposit_private_update_status.py
--- a/swh/deposit/tests/api/test_deposit_private_update_status.py
+++ b/swh/deposit/tests/api/test_deposit_private_update_status.py
@@ -54,8 +54,8 @@
rev_id = swhid(REVISION, revision_id)
snp_id = swhid(SNAPSHOT, snapshot_id)
- expected_swh_id = "swh:1:dir:%s" % directory_id
- expected_swh_id_context = (
+ expected_swhid = "swh:1:dir:%s" % directory_id
+ expected_swhid_context = (
f"{dir_id};origin={origin_url};" + f"visit={snp_id};anchor={rev_id};path=/"
)
@@ -67,8 +67,8 @@
deposit = Deposit.objects.get(pk=deposit.id)
assert deposit.status == expected_status
- assert deposit.swh_id == expected_swh_id
- assert deposit.swh_id_context == expected_swh_id_context
+ assert deposit.swhid == expected_swhid
+ assert deposit.swhid_context == expected_swhid_context
# Reset deposit
deposit = ready_deposit_verified
@@ -95,8 +95,8 @@
deposit = Deposit.objects.get(pk=deposit.id)
assert deposit.status == DEPOSIT_STATUS_LOAD_FAILURE
- assert deposit.swh_id is None
- assert deposit.swh_id_context is None
+ assert deposit.swhid is None
+ assert deposit.swhid_context is None
# Reset status
deposit = ready_deposit_verified
@@ -176,10 +176,10 @@
assert b"The status key is mandatory with possible values" in response.content
-def test_update_deposit_status_success_without_swh_id_fail(
+def test_update_deposit_status_success_without_swhid_fail(
authenticated_client, deposit_collection, ready_deposit_verified
):
- """Providing successful status without swh_id should return a 400
+ """Providing successful status without swhid should return a 400
"""
deposit = ready_deposit_verified
diff --git a/swh/deposit/tests/api/test_deposit_status.py b/swh/deposit/tests/api/test_deposit_status.py
--- a/swh/deposit/tests/api/test_deposit_status.py
+++ b/swh/deposit/tests/api/test_deposit_status.py
@@ -74,8 +74,8 @@
assert int(r["deposit_id"]) == deposit.id
assert r["deposit_status"] == DEPOSIT_STATUS_REJECTED
assert r["deposit_status_detail"] == "Deposit failed the checks"
- if deposit.swh_id:
- assert r["deposit_swh_id"] == deposit.swh_id
+ if deposit.swhid:
+ assert r["deposit_swhid"] == deposit.swhid
def test_status_with_http_accept_header_should_not_break(
@@ -115,7 +115,7 @@
assert (
r["deposit_status_detail"] == DEPOSIT_STATUS_DETAIL[DEPOSIT_STATUS_LOAD_SUCCESS]
)
- assert deposit.swh_id is not None
- assert r["deposit_swh_id"] == deposit.swh_id
- assert deposit.swh_id_context is not None
- assert r["deposit_swh_id_context"] == deposit.swh_id_context
+ assert deposit.swhid is not None
+ assert r["deposit_swh_id"] == deposit.swhid
+ assert deposit.swhid_context is not None
+ assert r["deposit_swh_id_context"] == deposit.swhid_context
diff --git a/swh/deposit/tests/api/test_deposit_update.py b/swh/deposit/tests/api/test_deposit_update.py
--- a/swh/deposit/tests/api/test_deposit_update.py
+++ b/swh/deposit/tests/api/test_deposit_update.py
@@ -586,7 +586,7 @@
Response: 204
"""
- deposit_swhid = parse_swhid(complete_deposit.swh_id)
+ deposit_swhid = parse_swhid(complete_deposit.swhid)
assert deposit_swhid.object_type == "directory"
directory_id = hash_to_bytes(deposit_swhid.object_id)
@@ -599,8 +599,8 @@
swh_storage.directory_add([existing_directory])
assert list(swh_storage.directory_missing([existing_directory.id])) == []
- # and patch one complete deposit swh_id so it targets said reference
- complete_deposit.swh_id = swhid("directory", existing_directory.id)
+ # and patch one complete deposit swhid so it targets said reference
+ complete_deposit.swhid = swhid("directory", existing_directory.id)
complete_deposit.save()
actual_existing_requests_archive = DepositRequest.objects.filter(
@@ -619,7 +619,7 @@
update_uri,
content_type="application/atom+xml;type=entry",
data=atom_dataset["entry-data1"],
- HTTP_X_CHECK_SWHID=complete_deposit.swh_id,
+ HTTP_X_CHECK_SWHID=complete_deposit.swhid,
)
assert response.status_code == status.HTTP_204_NO_CONTENT
@@ -663,7 +663,7 @@
)
assert actual_fetcher == metadata_fetcher
- directory_swhid = parse_swhid(complete_deposit.swh_id)
+ directory_swhid = parse_swhid(complete_deposit.swhid)
page_results = swh_storage.raw_extrinsic_metadata_get(
MetadataTargetType.DIRECTORY, directory_swhid, metadata_authority
)
@@ -698,7 +698,7 @@
"""
incorrect_swhid = "swh:1:dir:ef04a768181417fbc5eef4243e2507915f24deea"
- assert complete_deposit.swh_id != incorrect_swhid
+ assert complete_deposit.swhid != incorrect_swhid
update_uri = reverse(
EDIT_SE_IRI, args=[deposit_collection.name, complete_deposit.id]
@@ -734,7 +734,7 @@
update_uri,
content_type="application/atom+xml;type=entry",
data=atom_dataset["entry-data-ko"],
- HTTP_X_CHECK_SWHID=complete_deposit.swh_id,
+ HTTP_X_CHECK_SWHID=complete_deposit.swhid,
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -764,7 +764,7 @@
update_uri,
content_type="application/atom+xml;type=entry",
data=atom_content,
- HTTP_X_CHECK_SWHID=complete_deposit.swh_id,
+ HTTP_X_CHECK_SWHID=complete_deposit.swhid,
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
@@ -793,7 +793,7 @@
content_type="application/atom+xml;type=entry",
# no title, nor author, nor name fields
data=atom_dataset["entry-data-fail-metadata-functional-checks"],
- HTTP_X_CHECK_SWHID=complete_deposit.swh_id,
+ HTTP_X_CHECK_SWHID=complete_deposit.swhid,
)
assert response.status_code == status.HTTP_400_BAD_REQUEST
diff --git a/swh/deposit/tests/conftest.py b/swh/deposit/tests/conftest.py
--- a/swh/deposit/tests/conftest.py
+++ b/swh/deposit/tests/conftest.py
@@ -398,8 +398,8 @@
directory_id = "42a13fc721c8716ff695d0d62fc851d641f3a12b"
revision_id = "548b3c0a2bb43e1fca191e24b5803ff6b3bc7c10"
snapshot_id = "e5e82d064a9c3df7464223042e0c55d72ccff7f0"
- deposit.swh_id = swhid(DIRECTORY, directory_id)
- deposit.swh_id_context = swhid(
+ deposit.swhid = swhid(DIRECTORY, directory_id)
+ deposit.swhid_context = swhid(
DIRECTORY,
directory_id,
metadata={