Skip to content

Commit

Permalink
Add host name to previews for seminar events, syndicated green colleg…
Browse files Browse the repository at this point in the history
…e events calendar, removed annoying whitespace and newlines in event description when reading ical
  • Loading branch information
SamuelmdLow committed Oct 2, 2024
1 parent 6e69e85 commit 76f3533
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ async def ical_create_event(self, ical_component, name, instructions):
event.title=str(ical_component.decoded('summary'), 'UTF-8')
if ical_component.get('description', False):
event.description=str(ical_component.decoded('description'), 'UTF-8')
while '\t' in event.description:
event.description = event.description.replace("\t", "")
while '\n ' in event.description:
event.description = event.description.replace("\n ", "\n")
while '\n\n\n' in event.description:
event.description = event.description.replace("\n\n\n", "\n\n")
else:
event.description=""

Expand Down
10 changes: 9 additions & 1 deletion events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,6 @@ async def update_events(request):
await asyncio.gather(*tasks)
tasks = []


ical_files = [

{'name': 'Go Thunderbirds',
Expand Down Expand Up @@ -530,6 +529,15 @@ async def update_events(request):
'hidden_override': lambda e : len(e.get('categories').cats) > 0, # The scheduled events are all cringe but well categorized. Events added manually can be cool but categories typically aren't added. At some point we should be more sophistiacted in filtering this lmao
}
},

{'name': 'Green College',
'file': 'https://greencollege.ubc.ca/civicrm/event/ical',
'create_function': Event.objects.ical_create_event,
'instructions': {
'category': 'seminar',
'description_transform': lambda e : e.description.split('in the series\n\n')[-1][e.description.split('in the series\n\n')[-1].index("\n")+4:],
}
},
]

for f in ical_files:
Expand Down
2 changes: 1 addition & 1 deletion ubyssey/static_src/src/js/components/Events/calendar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ function EventsCalendar({events}) {
setSearchParams(searchParams);
}}
dangerouslySetInnerHTML={
{__html: "<b>" + event.displayTime + "</b> " + event.title}
{__html: "<b>" + event.displayTime + "</b> " + ((event.host && event.category=="seminar") ? event.host.replace("UBC ", "").split("for ").slice(-1)[0].split("of ").slice(-1)[0] + ":<br>" : "" ) + event.title}
}>
{/*
{event.start_time|date:"F j" != event.end_time|date:"F j" and day.day|stringformat:"i" != event.start_time|date:"j" %}<b>Ongoing</b>{% elif event.start_time|time == 'midnight' %}{% else %}<b>{{event.start_time|time:"fA"}}</b>{% endif %} {event.title|safe}
Expand Down

0 comments on commit 76f3533

Please sign in to comment.