Skip to content

Commit 24ba061

Browse files
authored
Fix resource gallery submission workflow (#381)
* Move IssueInfo.data initialization from __post_init_post_parse__ to _get_input_() * Author affiliations parsing, use the term 'institution' * Use model_dump() instead of dict() as the latter is deprecated * Use model_dump_json() instead of dict() as the latter deprecated and json needs the former * 'institution' to 'affiliation ' changes in gallery_generator and resource_gallery * 'institution' to 'affiliation ' changes in collect-user-submission
1 parent b35bfec commit 24ba061

File tree

3 files changed

+115
-116
lines changed

3 files changed

+115
-116
lines changed

.github/workflows/collect-user-submission.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ class IssueInfo:
2828
gh_event_path: pydantic.FilePath
2929
submission: Submission = pydantic.Field(default=None)
3030

31-
def __post_init_post_parse__(self):
32-
with open(self.gh_event_path) as f:
33-
self.data = json.load(f)
34-
3531
def create_submission(self):
3632
self._get_inputs()
3733
self._create_submission_input()
3834
return self
3935

4036
def _get_inputs(self):
37+
with open(self.gh_event_path) as f:
38+
self.data = json.load(f)
39+
4140
self.author = self.data['issue']['user']['login']
4241
self.title = self.data['issue']['title']
4342
self.body = self.data['issue']['body']
@@ -78,6 +77,6 @@ def _create_submission_input(self):
7877

7978
if __name__ == '__main__':
8079
issue = IssueInfo(gh_event_path=os.environ['GITHUB_EVENT_PATH']).create_submission()
81-
inputs = issue.submission.dict()
80+
inputs = issue.submission.model_dump_json()
8281
with open('resource-gallery-submission-input.json', 'w') as f:
8382
json.dump(inputs, f)

portal/_extensions/gallery_generator.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
7878
tag_class_str = ' '.join(tag_list_f)
7979

8080
author_strs = set()
81-
institution_strs = set()
81+
affiliation_strs = set()
8282
for a in item['authors']:
8383
author_name = a.get('name', 'Anonymous')
8484
author_email = a.get('email', None)
@@ -88,20 +88,20 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
8888
_str = author_name
8989
author_strs.add(_str)
9090

91-
institution_name = a.get('institution', None)
92-
if institution_name:
93-
institution_url = a.get('institution_url', None)
94-
if institution_url:
95-
_str = f'<a href="{institution_url}">{institution_name}</a>'
91+
affiliation_name = a.get('affiliation', None)
92+
if affiliation_name:
93+
affiliation_url = a.get('affiliation_url', None)
94+
if affiliation_url:
95+
_str = f'<a href="{affiliation_url}">{affiliation_name}</a>'
9696
else:
97-
_str = institution_name
98-
institution_strs.add(_str)
97+
_str = affiliation_name
98+
affiliation_strs.add(_str)
9999

100100
authors_str = f"<strong>Author:</strong> {', '.join(author_strs)}"
101-
if institution_strs:
102-
institutions_str = f"<strong>Institution:</strong> {' '.join(institution_strs)}"
101+
if affiliation_strs:
102+
affiliations_str = f"<strong>Affiliation:</strong> {' '.join(affiliation_strs)}"
103103
else:
104-
institutions_str = ''
104+
affiliations_str = ''
105105

106106
ellipsis_str = '<a class="modal-btn"> ... more</a>'
107107
short_description = truncate(item['description'], max_descr_len, ellipsis=ellipsis_str)
@@ -114,7 +114,7 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
114114
<h3 class="display-3">{item["title"]}</h3>
115115
{authors_str}
116116
<br/>
117-
{institutions_str}
117+
{affiliations_str}
118118
<p class="my-2">{item['description']}</p>
119119
<p class="my-2">{tags}</p>
120120
<p class="mt-3 mb-0"><a href="{item["url"]}" class="btn btn-outline-primary btn-block">Visit Website</a></p>
@@ -133,7 +133,7 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, subtext=No
133133
<img src="{thumbnail}" class="gallery-thumbnail" />
134134
<div class="container">
135135
<a href="{item["url"]}" class="text-decoration-none"><h4 class="display-4 p-0">{item["title"]}</h4></a>
136-
<p class="card-subtitle">{authors_str}<br/>{institutions_str}</p>
136+
<p class="card-subtitle">{authors_str}<br/>{affiliations_str}</p>
137137
<p class="my-2">{short_description}</p>
138138
</div>
139139
</div>

0 commit comments

Comments
 (0)