Skip to content

Commit

Permalink
Little styling fix on image credit, author string improvement, sports…
Browse files Browse the repository at this point in the history
… events fix
  • Loading branch information
SamuelmdLow committed Sep 24, 2024
1 parent 7984221 commit eeeb658
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
39 changes: 17 additions & 22 deletions article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class ArticleAuthorsOrderable(Orderable):
('illustrator','Illustrator'),
('photographer','Photographer'),
('videographer','Videographer'),
('designer','Designer'),
('org_role', 'Show organization role'),
],
),
Expand Down Expand Up @@ -1131,28 +1132,22 @@ def get_authors_with_roles(self) -> str:
"""Returns list of authors as a comma-separated string
sorted by author type (with 'and' before last author)."""

string_written = ''
string_photos = ''
string_illustrations = ''
string_videos = ''
string_org = ''

authors = dict((k, list(v)) for k, v in groupby(self.article_authors.all(), lambda a: a.author_role))
for author in authors:
if author == 'author':
string_written += 'Words by ' + self.get_authors_string(links=True, authors_list=authors['author'])
if author == 'photographer':
string_photos += 'Photos by ' + self.get_authors_string(links=True, authors_list=authors['photographer'])
if author == 'illustrator':
string_illustrations += 'Illustrations by ' + self.get_authors_string(links=True, authors_list=authors['illustrator'])
if author == 'videographer':
string_videos += 'Videos by ' + self.get_authors_string(links=True, authors_list=authors['videographer'])
if author == 'org_role':
string_org = ",".join( map(lambda a: ' ' + a.author.ubyssey_role + ": " + self.get_authors_string(links=True, authors_list=[a]) , authors['org_role']))


authors_with_roles = filter(lambda a: a != '', [string_written, string_photos, string_illustrations, string_videos, string_org])
return ', '.join(authors_with_roles)
role_types_words = {
'author': 'Words by ',
'photographer': 'Photos by ',
'illustrator': 'Illustrations by ',
'videographer': 'Videos by ',
'designer': 'Design by ',
}
role_types = ['author', 'photographer', 'illustrator', 'videographer', 'designer', 'org_role']
authors_with_roles = []
for k, v in groupby(self.article_authors.all(), lambda a: a.author_role):
if k=='org_role':
authors_with_roles.append([k, ",".join( map(lambda a: ' ' + a.author.ubyssey_role + ": " + self.get_authors_string(links=True, authors_list=[a]) , list(v)))])
else:
authors_with_roles.append([k, role_types_words[k] + self.get_authors_string(links=True, authors_list=list(v))])
authors_with_roles.sort(key=lambda s: role_types.index(s[0]))
return ', '.join(map(lambda a: a[1], authors_with_roles))
authors_with_roles = property(fget=get_authors_with_roles)

def get_category_articles(self, order='-first_published_at') -> QuerySet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
{{ featured_image_object.caption }}
{% endif %}
{% if featured_image_object.credit %}
<span class="credit">
{{ featured_image_object.credit }}
</span>
<span class="credit">{{ featured_image_object.credit }}</span>
{% endif %}
</div>
{% endif %}
Expand Down
16 changes: 10 additions & 6 deletions events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,16 @@ async def gothunderbirds_create_event(self, ical_component):
event.description=" ".join(ical_component.get('description').split(" ")[0:-1])

splitDesc = ical_component.get('description').replace("[W] ", "").replace("[L] ", "").replace("[T] ", "").split("\n")[0].split(" ")
i = 0
while splitDesc[i][0].isupper():
i = i + 1
sport = " ".join(splitDesc[0:i])
sport = sport.replace("Men's ", "").replace("Women's ", "").replace("UBC ", "")
event.host = sport
splitDesc = list(filter(lambda s: s!="", splitDesc))
if len(splitDesc) > 0:
i = 0
while splitDesc[i][0].isupper() and i+1<len(splitDesc):
i = i + 1
sport = " ".join(splitDesc[0:i])
sport = sport.replace("Men's ", "").replace("Women's ", "").replace("UBC ", "")
event.host = sport
else:
event.host = ""

if isinstance(ical_component.decoded('dtstart'), datetime):
event.start_time=ical_component.decoded('dtstart').astimezone(timezone.get_current_timezone())
Expand Down
1 change: 1 addition & 0 deletions ubyssey/static_src/src/styles/modules/_core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ div.image-inner {
}

span.credit {
margin-left: 0.5em;
font-style: italic;
color: #969696;
white-space: pre;
Expand Down

0 comments on commit eeeb658

Please sign in to comment.