Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Fix/online events #34

Merged
merged 3 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_eventbrite_events(group_list):
events = []

# Number of days to allow for past events
days_in_the_past = config.get('past_events', 'past_days')
days_in_the_past = config.get('past_events', 'days_in_the_past')

# the current date time in ISO8601 format
current_time = (datetime.datetime.utcnow())
Expand Down Expand Up @@ -212,31 +212,48 @@ def format_eventbrite_events(events_list, venues_list, group_list):
'lon': venue_address.get('longitude')
}
venues[venue_id] = venue_dict


for event in events_list:
if type(event.get('venue_id')) == str: # If venue id error
if type(event.get('venue_id')) == str or event.get('venue_id') is None: # If venue id error
group_item = [i for i in group_list if i['field_events_api_key'] == event.get('organizer_id')][0]
group_name = group_item.get('title')
tags = group_item.get('field_org_tags')
uuid = group_item.get('uuid')
nid = group_item.get('nid')
event_dict = {
'event_name': event.get('name').get('text'),
'group_name': group_name,
'venue': venues[event.get('venue_id')],
'url': event.get('url'),
'time': event.get('start').get("utc"),
'tags': tags,
'rsvp_count': None,
'created_at': event.get('created'),
'description': event.get('description').get('text'),
'uuid': uuid,
'nid': nid,
'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'),
'status': normalize_eventbrite_status_codes(event.get('status'))
}
if type(event.get('venue_id')) == str:
event_dict = {
'event_name': event.get('name').get('text'),
'group_name': group_name,
'venue': venues[event.get('venue_id')],
'url': event.get('url'),
'time': event.get('start').get("utc"),
'tags': tags,
'rsvp_count': None,
'created_at': event.get('created'),
'description': event.get('description').get('text'),
'uuid': uuid,
'nid': nid,
'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'),
'status': normalize_eventbrite_status_codes(event.get('status'))
}
elif event.get('venue_id') == None: # if event venue is None, it is online/virtual
event_dict = {
'event_name': event.get('name').get('text'),
'group_name': group_name,
'venue': event.get('venue_id'),
'url': event.get('url'),
'time': event.get('start').get("utc"),
'tags': tags,
'rsvp_count': None,
'created_at': event.get('created'),
'description': event.get('description').get('text'),
'uuid': uuid,
'nid': nid,
'data_as_of': datetime.datetime.utcnow().strftime('%Y-%m-%dT%H:%M:%SZ'),
'status': normalize_eventbrite_status_codes(event.get('status'))
}
events.append(event_dict)

return events


Expand All @@ -259,7 +276,7 @@ def parse_date(d):
def filter_events_by_date(events, start_date_str=datetime.datetime.now(datetime.timezone.utc), end_date_str=None):

# number of days specified in config
days_in_the_past = config.get('past_events', 'past_days')
days_in_the_past = config.get('past_events', 'days_in_the_past')

if start_date_str:
start_date = parse_date(start_date_str) - datetime.timedelta(days_in_the_past)
Expand Down Expand Up @@ -317,7 +334,6 @@ def get_dates():

# Sort events by time
events.sort(key=lambda s: s['time'])

return jsonify(events)


Expand Down
2 changes: 1 addition & 1 deletion config.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ username = user
update_cal_location = /home/user/upstate_tech_cal_service/update_cal_data.py

[past_events]
past_days = 5
days_in_the_past = 5
allella marked this conversation as resolved.
Show resolved Hide resolved
1 change: 0 additions & 1 deletion update_cal_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def refresh_all_meetings():
)
with open('all_meetings.json', 'w') as outfile:
json.dump(events, outfile)

return events


Expand Down