Changeset View
Changeset View
Standalone View
Standalone View
swh/deposit/api/private/deposit_read.py
# Copyright (C) 2017-2018 The Software Heritage developers | # Copyright (C) 2017-2019 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import json | import json | ||||
import os | import os | ||||
import shutil | import shutil | ||||
import tempfile | import tempfile | ||||
from contextlib import contextmanager | from contextlib import contextmanager | ||||
from dateutil import parser | |||||
from django.http import FileResponse | from django.http import FileResponse | ||||
from rest_framework import status | from rest_framework import status | ||||
from swh.core import tarball | from swh.core import tarball | ||||
from swh.model import identifiers | from swh.model import identifiers | ||||
from . import DepositReadMixin | from . import DepositReadMixin | ||||
from ...config import SWH_PERSON, ARCHIVE_TYPE | from ...config import SWH_PERSON, ARCHIVE_TYPE | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | def metadata_read(self, deposit): | ||||
'url': origin_url | 'url': origin_url | ||||
} | } | ||||
# revision | # revision | ||||
fullname = deposit.client.username | fullname = deposit.client.username | ||||
author_committer = SWH_PERSON | author_committer = SWH_PERSON | ||||
# metadata provider | # metadata provider | ||||
self.provider['provider_name'] = deposit.client.last_name | self.provider['provider_name'] = deposit.client.last_name | ||||
self.provider['provider_url'] = deposit.client.provider_url | self.provider['provider_url'] = deposit.client.provider_url | ||||
revision_type = 'tar' | revision_type = 'tar' | ||||
revision_msg = '%s: Deposit %s in collection %s' % ( | revision_msg = '%s: Deposit %s in collection %s' % ( | ||||
fullname, deposit.id, deposit.collection.name) | fullname, deposit.id, deposit.collection.name) | ||||
complete_date = identifiers.normalize_timestamp(deposit.complete_date) | complete_date = identifiers.normalize_timestamp(deposit.complete_date) | ||||
commit_date = metadata['codemeta:dateCreated'] | |||||
if isinstance(commit_date, str): | |||||
douardda: nitpicking a bit, but IMHO the `t` temp var is not needed here. The whole if/elif block can… | |||||
Done Inline Actionsoh, righty right. ardumont: oh, righty right.
initially, i just returned the tuple `t` and did not do anything on it
up… | |||||
commit_date = parser.parse(commit_date) | |||||
commit_date = identifiers.normalize_timestamp(commit_date) | |||||
data['revision'] = { | data['revision'] = { | ||||
'synthetic': True, | 'synthetic': True, | ||||
'date': complete_date, | 'date': complete_date, | ||||
'committer_date': complete_date, | 'committer_date': commit_date, | ||||
ardumontAuthorUnsubmitted Done Inline ActionsAccording to our discussion anyway, it's no longer the commit date, it's the author date. ardumont: According to our discussion anyway, it's no longer the commit date, it's the author date. | |||||
'author': author_committer, | 'author': author_committer, | ||||
'committer': author_committer, | 'committer': author_committer, | ||||
'type': revision_type, | 'type': revision_type, | ||||
'message': revision_msg, | 'message': revision_msg, | ||||
'metadata': metadata, | 'metadata': metadata, | ||||
} | } | ||||
if deposit.parent: | if deposit.parent: | ||||
Show All 24 Lines |
nitpicking a bit, but IMHO the t temp var is not needed here. The whole if/elif block can manipulate {author,commit}_date variables directly.