Skip to content

Commit b977614

Browse files
joemullajrbyers
authored andcommitted
Fix #4952 Display authors in metadata sidebar
1 parent f70bdd5 commit b977614

File tree

22 files changed

+226
-306
lines changed

22 files changed

+226
-306
lines changed

src/core/tests/test_views.py

Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ def setUpTestData(cls):
871871
cls.ror_svg = ror_svg_template.render({})
872872

873873
def test_all_custom(self):
874-
template = get_template("common/elements/affiliation_display.html")
874+
template = get_template("common/elements/affiliation_inner_li_details.html")
875875
org = core_models.Organization.objects.create()
876876
core_models.OrganizationName(
877877
value="Birkbeck",
@@ -898,52 +898,45 @@ def test_all_custom(self):
898898
"affiliation": affil,
899899
}
900900
expected = """
901-
<span class="comma-separated">
902-
<span>Reader</span>
903-
<span>English</span>
904-
<span itemprop="worksFor" itemscope itemtype="http://schema.org/CollegeOrUniversity">
905-
<span itemprop="name">
906-
<span>Birkbeck</span>
907-
</span>
908-
</span>
909-
<span>London, United Kingdom</span>
910-
<span>May 2010&ndash;Oct 2016</span>
911-
</span>
901+
<li>Reader</li>
902+
<li>English</li>
903+
<li itemprop="worksFor" itemscope itemtype="http://schema.org/CollegeOrUniversity">
904+
<span itemprop="name">
905+
<span>Birkbeck</span>
906+
</span>
907+
</li>
908+
<li>London, United Kingdom</li>
912909
"""
913910
self.assertHTMLEqual(expected, template.render(context))
914911

915912
def test_title(self):
916-
template = get_template("common/elements/affiliation_display.html")
913+
template = get_template("common/elements/affiliation_inner_li_details.html")
917914
context = {
918915
"affiliation": core_models.ControlledAffiliation.objects.create(
919916
account=self.user,
920917
title="Reader",
921918
),
922919
}
923920
expected = """
924-
<span class="comma-separated">
925-
<span>Reader</span>
926-
</span>
921+
<li>Reader</li>
927922
"""
928923
self.assertHTMLEqual(expected, template.render(context))
929924

930925
def test_department(self):
931-
template = get_template("common/elements/affiliation_display.html")
926+
template = get_template("common/elements/affiliation_inner_li_details.html")
932927
context = {
933928
"affiliation": core_models.ControlledAffiliation.objects.create(
934929
account=self.user,
935930
department="English",
936931
),
937932
}
938933
expected = """
939-
<span class="comma-separated">
940-
<span>English</span>
941-
</span>
934+
<li>English</li>
942935
"""
943936
self.assertHTMLEqual(expected, template.render(context))
944937

945938
def test_controlled_org(self):
946-
template = get_template("common/elements/affiliation_display.html")
939+
template = get_template("common/elements/affiliation_inner_li_details.html")
947940
org, _ = core_models.Organization.objects.get_or_create(
948941
ror_id="02mb95055",
949942
)
@@ -955,22 +948,23 @@ def test_controlled_org(self):
955948
"affiliation": affil,
956949
}
957950
expected = f"""
958-
<span class="comma-separated">
959-
<span itemprop="worksFor" itemscope itemtype="http://schema.org/CollegeOrUniversity">
960-
<a href="https://ror.org/02mb95055" itemprop="url" target="_blank">
961-
<span itemprop="name">
962-
<span>Birkbeck, University of London</span>
963-
</span>
964-
<span class="show-for-sr sr-only">(opens in new tab)</span>
965-
{self.ror_svg}
966-
</a>
967-
</span>
951+
<li itemprop="worksFor" itemscope itemtype="http://schema.org/CollegeOrUniversity">
952+
<span itemprop="name">
953+
<span>Birkbeck, University of London</span>
968954
</span>
955+
<a href="https://ror.org/02mb95055" itemprop="url" target="_blank">
956+
<span class="sr-only show-for-sr">
957+
View ROR record for Birkbeck, University of London.
958+
</span>
959+
<span class="show-for-sr sr-only">(opens in new tab)</span>
960+
{self.ror_svg}
961+
</a>
962+
</li>
969963
"""
970964
self.assertHTMLEqual(expected, template.render(context))
971965

972966
def test_custom_org(self):
973-
template = get_template("common/elements/affiliation_display.html")
967+
template = get_template("common/elements/affiliation_inner_li_details.html")
974968
org = core_models.Organization.objects.create()
975969
core_models.OrganizationName(
976970
value="Birkbeck",
@@ -984,18 +978,16 @@ def test_custom_org(self):
984978
"affiliation": affil,
985979
}
986980
expected = """
987-
<span class="comma-separated">
988-
<span itemprop="worksFor" itemscope itemtype="http://schema.org/CollegeOrUniversity">
989-
<span itemprop="name">
990-
<span>Birkbeck</span>
991-
</span>
992-
</span>
981+
<li itemprop="worksFor" itemscope itemtype="http://schema.org/CollegeOrUniversity">
982+
<span itemprop="name">
983+
<span>Birkbeck</span>
993984
</span>
985+
</li>
994986
"""
995987
self.assertHTMLEqual(expected, template.render(context))
996988

997989
def test_location_city(self):
998-
template = get_template("common/elements/affiliation_display.html")
990+
template = get_template("common/elements/affiliation_inner_li_details.html")
999991
org = core_models.Organization.objects.create()
1000992
location, _ = core_models.Location.objects.get_or_create(
1001993
name="London",
@@ -1009,14 +1001,12 @@ def test_location_city(self):
10091001
"affiliation": affil,
10101002
}
10111003
expected = """
1012-
<span class="comma-separated">
1013-
<span>London</span>
1014-
</span>
1004+
<li>London</li>
10151005
"""
10161006
self.assertHTMLEqual(expected, template.render(context))
10171007

10181008
def test_location_country(self):
1019-
template = get_template("common/elements/affiliation_display.html")
1009+
template = get_template("common/elements/affiliation_inner_li_details.html")
10201010
org = core_models.Organization.objects.create()
10211011
country, _ = core_models.Country.objects.get_or_create(
10221012
code="GB",
@@ -1034,44 +1024,40 @@ def test_location_country(self):
10341024
"affiliation": affil,
10351025
}
10361026
expected = """
1037-
<span class="comma-separated">
1038-
<span>United Kingdom</span>
1039-
</span>
1027+
<li>United Kingdom</li>
10401028
"""
10411029
self.assertHTMLEqual(expected, template.render(context))
10421030

10431031
def test_start(self):
1044-
template = get_template("common/elements/affiliation_display.html")
1032+
template = get_template("common/elements/affiliation_inner_li_details.html")
10451033
affil = core_models.ControlledAffiliation.objects.create(
10461034
account=self.user,
10471035
title="Independent scholar",
10481036
start=timezone.datetime(2010, 5, 5, tzinfo=timezone.utc),
10491037
)
10501038
context = {
10511039
"affiliation": affil,
1040+
"include_dates": True,
10521041
}
10531042
expected = """
1054-
<span class="comma-separated">
1055-
<span>Independent scholar</span>
1056-
<span>May 2010&ndash;</span>
1057-
</span>
1043+
<li>Independent scholar</li>
1044+
<li>May 2010&ndash;</li>
10581045
"""
10591046
self.assertHTMLEqual(expected, template.render(context))
10601047

10611048
def test_end(self):
1062-
template = get_template("common/elements/affiliation_display.html")
1049+
template = get_template("common/elements/affiliation_inner_li_details.html")
10631050
affil = core_models.ControlledAffiliation.objects.create(
10641051
account=self.user,
10651052
title="Independent scholar",
10661053
end=timezone.datetime(2016, 10, 15, tzinfo=timezone.utc),
10671054
)
10681055
context = {
10691056
"affiliation": affil,
1057+
"include_dates": True,
10701058
}
10711059
expected = """
1072-
<span class="comma-separated">
1073-
<span>Independent scholar</span>
1074-
<span>&ndash;Oct 2016</span>
1075-
</span>
1060+
<li>Independent scholar</li>
1061+
<li>&ndash;Oct 2016</li>
10761062
"""
10771063
self.assertHTMLEqual(expected, template.render(context))
13.4 KB
Loading

src/submission/models.py

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,25 +1465,7 @@ def journal_sections(self):
14651465

14661466
@property
14671467
def carousel_subtitle(self):
1468-
carousel_text = ""
1469-
1470-
idx = 0
1471-
1472-
for author in self.frozenauthor_set.all():
1473-
if idx > 0:
1474-
idx = 1
1475-
carousel_text += ", "
1476-
1477-
if author.institution:
1478-
carousel_text += author.full_name() + " ({0})".format(
1479-
author.institution
1480-
)
1481-
else:
1482-
carousel_text += author.full_name()
1483-
1484-
idx = 1
1485-
1486-
return carousel_text
1468+
return self.author_list
14871469

14881470
@property
14891471
def carousel_title(self):

src/templates/common/elements/affiliation_display.html

Lines changed: 0 additions & 48 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{% load static %}
2+
{% load i18n %}
3+
4+
{% if affiliation.title %}
5+
<li>{{ affiliation.title }}</li>
6+
{% endif %}
7+
{% if affiliation.department %}
8+
<li>{{ affiliation.department }}</li>
9+
{% endif %}
10+
{% if affiliation.organization %}
11+
{% if affiliation.organization.name %}
12+
<li
13+
itemprop="worksFor"
14+
itemscope
15+
itemtype="http://schema.org/CollegeOrUniversity">
16+
<span itemprop="name">
17+
<span>{{ affiliation.organization.name }}</span>
18+
</span>
19+
{% if affiliation.organization.ror_id %}
20+
<a
21+
itemprop="url"
22+
href="{{ affiliation.organization.uri }}"
23+
target="_blank">
24+
<span class="sr-only show-for-sr">
25+
{% trans "View ROR record for" %} {{ affiliation.organization.name }}.
26+
</span>
27+
<span class="sr-only show-for-sr">
28+
{% trans "(opens in new tab)" %}
29+
</span>
30+
{% include "common/svg/ror-mono.svg" %}
31+
</a>
32+
{% endif %}
33+
</li>
34+
{% endif %}
35+
{% if not affiliation.organization or not affiliation.organization.ror_id %}
36+
{% if affiliation.organization.locations.exists %}
37+
<li>{{ affiliation.organization.locations.first }}</li>
38+
{% endif %}
39+
{% endif %}
40+
{% endif %}
41+
{% if include_dates %}
42+
{% if affiliation.start or affiliation.end %}
43+
<li>{{ affiliation.start|date:"M Y" }}&ndash;{{ affiliation.end|date:"M Y" }}</li>
44+
{% endif %}
45+
{% endif %}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<ul class="flex direction-column gap-0-75">
2+
{% for affiliation in affiliations %}
3+
<li>
4+
<ul class="list-no-bullet">
5+
{% include "common/elements/affiliation_inner_li_details.html" with include_dates=True %}
6+
</ul>
7+
</li>
8+
{% endfor %}
9+
</ul>

src/templates/common/elements/affiliations_br.html

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/templates/common/elements/affiliations_ul.html

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)