Skip to content

Commit

Permalink
Merge pull request #725 from Royal-Society-of-New-Zealand/ORCIDHUB-46…
Browse files Browse the repository at this point in the history
…0/469

Orcidhub 460/469
  • Loading branch information
rpaw053 committed Aug 14, 2019
2 parents 1ea58e6 + f3f10c9 commit 16a37f1
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 48 deletions.
2 changes: 1 addition & 1 deletion orcid_hub/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class WorkForm(FlaskForm):
short_description = TextAreaField(description="Short Description")
citation_type = SelectField(
choices=EMPTY_CHOICES + models.citation_type_choices, description="Citation Type")
citation = StringField("Citation Value")
citation = TextAreaField("Citation Value")
publication_date = PartialDateField("Publication date")
url = StringField("Url")
language_code = LanguageSelectField("Language used in this form")
Expand Down
126 changes: 104 additions & 22 deletions orcid_hub/models.py

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions orcid_hub/orcid_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,7 @@ def create_or_update_work(self, task_by_user, *args, **kwargs):
rec.type = wr.type.replace('_', '-').lower()

if wr.publication_date:
publication_date = wr.publication_date.as_orcid_dict()
# TODO:Fix media-type once ORCID starts supporting it again. If not then delete this commented code.
"""if wr.publication_media_type:
publication_date['media-type'] = wr.publication_media_type.upper()"""
rec.publication_date = publication_date
rec.publication_date = wr.publication_date.as_orcid_dict()

external_ids = []
contributors = []
Expand Down
25 changes: 11 additions & 14 deletions orcid_hub/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,6 @@ class RecordModelView(AppModelView):
]
column_export_exclude_list = (
"task",
"is_active",
)
can_edit = True
can_create = False
Expand Down Expand Up @@ -986,7 +985,6 @@ class CompositeRecordModelView(RecordModelView):

column_export_exclude_list = (
"task",
"is_active",
"status",
"processed_at",
"created_at",
Expand Down Expand Up @@ -1019,17 +1017,17 @@ def _export_tablib(self, export_type, return_url):
['invitees', 'review_group_id', 'review_url', 'reviewer_role', 'review_type',
'review_completion_date', 'subject_external_identifier', 'subject_container_name',
'subject_type', 'subject_name', 'subject_url', 'convening_organization',
'review_identifiers']]
'review_identifiers', 'is_active']]
elif self.model == FundingRecord:
self._export_columns = [(v, v.replace('_', '-')) for v in
['invitees', 'title', 'type', 'organization_defined_type', 'short_description',
'amount', 'url', 'start_date', 'end_date', 'organization', 'contributors',
'external_ids']]
'external_ids', 'is_active']]
elif self.model == WorkRecord:
self._export_columns = [(v, v.replace('_', '-')) for v in
['invitees', 'title', 'journal_title', 'short_description', 'citation', 'type',
'publication_date', 'url', 'language_code', 'country', 'contributors',
'external_ids']]
'external_ids', 'is_active']]
ds = tablib.Dataset(headers=[c[1] for c in self._export_columns])

count, data = self._export_data()
Expand Down Expand Up @@ -1141,8 +1139,9 @@ def expected_format(self, row):
vals.append(amount_dict)
elif c[0] == "citation":
citation_dict = dict()
citation_dict['citation-type'] = self.get_export_value(row, 'citation_type')
citation_dict['citation-value'] = csv_encode(self.get_export_value(row, 'citation_value'))
if self.get_export_value(row, 'citation_type'):
citation_dict['citation-type'] = self.get_export_value(row, 'citation_type')
citation_dict['citation-value'] = csv_encode(self.get_export_value(row, 'citation_value'))
vals.append(citation_dict)
elif c[0] == "contributors":
contributors_list = []
Expand Down Expand Up @@ -1273,7 +1272,8 @@ class FundingRecordAdmin(CompositeRecordModelView):
"external_id_type",
"external_id_url",
"external_id_relationship",
"status",)
"status",
"is_active")

def get_record_list(self, page, sort_column, sort_desc, search, filters, execute=True, page_size=None):
"""Return records and realated to the record data."""
Expand Down Expand Up @@ -1334,7 +1334,6 @@ class WorkRecordAdmin(CompositeRecordModelView):
"citation_value",
"type",
"publication_date",
"publication_media_type",
"url",
"language_code",
"country",
Expand All @@ -1348,6 +1347,7 @@ class WorkRecordAdmin(CompositeRecordModelView):
"external_id_url",
"external_id_relationship",
"status",
"is_active"
]

def get_record_list(self, page, sort_column, sort_desc, search, filters, execute=True, page_size=None):
Expand Down Expand Up @@ -1451,6 +1451,7 @@ class PeerReviewRecordAdmin(CompositeRecordModelView):
"peer_review_id",
"external_id_url",
"external_id_relationship",
"is_active"
]

def get_record_list(self,
Expand Down Expand Up @@ -1511,7 +1512,6 @@ class AffiliationRecordAdmin(RecordModelView):
)
column_export_exclude_list = (
"task",
"is_active",
)
form_widget_args = {"task": {"readonly": True}}

Expand Down Expand Up @@ -2147,10 +2147,7 @@ def edit_record(user_id, section_type, put_code=None):
citation=_data.get("citation", "citation-value"),
url=_data.get("url", "value"),
language_code=_data.get("language-code"),
# Removing key 'media-type' from the publication_date dict.
publication_date=PartialDate.create(
{date_key: _data.get("publication-date")[date_key] for date_key in
('day', 'month', 'year')}) if _data.get("publication-date") else None,
publication_date=PartialDate.create(_data.get("publication-date")),
country=_data.get("country", "value"),
visibility=(_data.get("visibility", default='') or '').upper())
else:
Expand Down
2 changes: 2 additions & 0 deletions schemas/funding_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ mapping:
type: str
currency-code:
type: str
is-active:
type: str
url:
type: map
mapping:
Expand Down
2 changes: 2 additions & 0 deletions schemas/peer_review_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ mapping:
mapping:
value:
type: timestamp
is-active:
type: str
source:
type: map
mapping:
Expand Down
4 changes: 2 additions & 2 deletions schemas/work_schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ mapping:
mapping:
value:
type: timestamp
is-active:
type: str
source:
type: map
mapping:
Expand Down Expand Up @@ -116,8 +118,6 @@ mapping:
mapping:
value:
type: str
media-type:
type: str
external-ids:
type: map
mapping:
Expand Down
3 changes: 1 addition & 2 deletions tests/data/example_works.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"publication-date": {
"year": {"value": "2001"},
"month": {"value": "1"},
"day": {"value": "12"},
"media-type": null
"day": {"value": "12"}
},
"external-ids": {
"external-id": [{
Expand Down
3 changes: 1 addition & 2 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3680,8 +3680,7 @@ def test_researcher_work(client, mocker):
"publication-date": {
"year": {"value": "2001"},
"month": {"value": "1"},
"day": {"value": "12"},
"media-type": null
"day": {"value": "12"}
},
"external-ids": {
"external-id": [{
Expand Down

0 comments on commit 16a37f1

Please sign in to comment.