Skip to content

Commit

Permalink
Fix url for sports events, add sasc events
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelmdLow committed Oct 10, 2024
1 parent 6fdaafd commit a880570
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
16 changes: 11 additions & 5 deletions events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ async def ical_create_event(self, ical_component, name, instructions):
event.category = instructions['category']
event.hidden=False

if 'hidden_title_terms' in instructions:
event.hidden = True in (term in ical_component.get('summary') for term in instructions['hidden_title_terms'])

if 'hidden_override' in instructions:
event.hidden = instructions['hidden_override'](ical_component)

Expand Down Expand Up @@ -437,14 +440,14 @@ def ubcevents_category(self, event):

async def gothunderbirds_create_event(self, ical_component):

if not await self.filter(event_url=ical_component.get('url')).aexists():
if not await self.filter(event_url=ical_component.get('url').replace("&", "&")).aexists():
event = await self.acreate(
title=ical_component.get('summary'),
event_url=ical_component.decoded('url'),
event_url=ical_component.decoded('url').replace("&", "&"),
hash=self.hashing(ical_component.get('summary') + str(ical_component.decoded('dtstart')))
)
else:
event = await self.filter(event_url=ical_component.get('url')).afirst()
event = await self.filter(event_url=ical_component.get('url').replace("&", "&")).afirst()
if event.update_mode != 2 and event.end_time.astimezone(timezone.get_current_timezone()) <= timezone.now() - timedelta(days=7): # Go Thunderbirds is unqiue because the events are updated after they pass to include the result
return None

Expand All @@ -466,7 +469,10 @@ 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] ", "").replace("[O] ", "").split("\n")[0].split(" ")
splitDesc = ical_component.get('description')
for t in ['[W]','[L]', '[T]', '[O]', 'CANCELLED']:
splitDesc = splitDesc.replace(t, '')
splitDesc = splitDesc.split("\n")[0].split(" ")
splitDesc = list(filter(lambda s: s!="", splitDesc))
if len(splitDesc) > 0:
i = 0
Expand All @@ -493,7 +499,7 @@ async def gothunderbirds_create_event(self, ical_component):

event.address=address
event.location=location
event.event_url=ical_component.decoded('url')
event.event_url=ical_component.decoded('url').replace("&amp;", "&")
event.category='sports'
event.hidden=self.gothunderbirds_judge_hidden(ical_component)

Expand Down
10 changes: 10 additions & 0 deletions events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,16 @@ async def update_events(request):
'instructions': {
'category': 'community',
'description_transform': lambda e : e.description.replace("UBC, UBC Vancouver, UBC students, UBC student life, UBC students, UBC events, events at UBC, UBC student events, UBC back to school, UBC back to school events, UBC campus, UBC campus events", ""),
'hidden_title_terms': ['SASC'],
}
},

{'name': 'AMS SASC',
'file': "https://www.amssasc.ca/events/?ical=1",
'create_function': Event.objects.ical_create_event,
'instructions': {
'category': 'community',
'hidden_title_terms': ['Roots and Resilience'],
}
},

Expand Down

0 comments on commit a880570

Please sign in to comment.