def get_events_sorted(): try: return Event.get_events_sorted() except Exception as ex: import traceback traceback.print_exc() return Tools.Result(False, ex.args)
def add_event(): try: data = request.get_json() return Event.add_event(data['Title'], data['ImageUrl'], data['Description'], data['Date'], data['Price'], data['Capacity'], ) except Exception as ex: return Tools.Result(False, ex.args)
def loadCalendarEvents(self, df, time_min, time_max, calendar_id='primary', single_events=True, order_by='startTime'): events = self.service.events().list(timeMin=time_min, timeMax=time_max, calendarId=calendar_id, singleEvents=single_events, orderBy=order_by).execute().get( 'items', []) owner = "EuanTemp" if not events: print('No upcoming events found.') return df for event in events: start = parser.parse(event['start'].get( 'dateTime', event['start'].get('date'))) end = parser.parse(event['end'].get('dateTime', event['start'].get('date'))) try: event['description'] except KeyError: priority = 1 else: priority = int(event['description'][10]) duration_in_hours = int( round(divmod((end - start).total_seconds(), 3600)[0])) # Check if appointment is longer then 1 full hour. if (duration_in_hours < 1): print('time of appointment is < 0.') continue first_hour = int(str(start.time())[0:2]) for hour in range(0, duration_in_hours): # TODO: Checken of dit werkt if df[start.date()][first_hour + hour] == 0: event_to_set = Event(owner, priority) df.loc[(first_hour + hour), start.date()] = event_to_set else: df.loc[first_hour + hour, start.date()].add_owner(owner, priority) return df
def __init__(self, jason): self.spy = jason["spy"] self.sniper = jason["sniper"] self.spy_username = jason["spy_username"] self.sniper_username = jason["sniper_username"] self.uuid = jason["uuid"] self.date = jason["start_time"] # this date is when the terrace update patch notes were published on steam if jason["venue"] == "Terrace" and jason[ "start_time"] < "2018-06-05T08:05:00": self.venue = Venues["Terrace_old"] else: self.venue = Venues[jason["venue"]] self.mode = jason["game_type"] self.guests = jason["guest_count"] self.clock = jason["start_clock_seconds"] if self.clock is None: # some values are none, so this fills those gaps self.clock = jason["timeline"][0]["time"] // 1 self.missions_selected = jason["selected_missions"] self.event = jason["event"] self.division = jason["division"] self.week = jason["week"] self.specific_win_condition, self.general_win_condition = jason[ "win_type"] self.cast = Cast() self.timeline = [] self.sniper_lights = [] self.missions_complete = [] self.missions_progress = set() self.time_added = 0 self.reaches_ot = False in_convo = None during_countdown = False during_overtime = False for json_event in jason["timeline"]: # counterintuitive, but the initial value must be the opposite of the event itself if json_event["event"] in { "spy enters conversation.", }: in_convo = False break elif json_event["event"] in { "spy leaves conversation.", "double agent joined conversation with spy.", "double agent left conversation with spy.", "stopped talking." }: in_convo = True break for json_event in jason["timeline"]: if json_event["event"] == "spy enters conversation.": in_convo = True elif json_event["event"] == "spy leaves conversation.": in_convo = False elif json_event[ "event"] == "missions completed. 10 second countdown.": during_countdown = True elif json_event["event"] == "overtime!": during_overtime = True elif json_event["event"] == "45 seconds added to match.": self.time_added += 45 if json_event["time"] < 0: self.reaches_ot = True if ("MissionSelected" in json_event["category"] or "MissionEnabled" in json_event["category"] or json_event["event"] == "begin flirtation with seduction target."): continue if "Cast" in json_event["category"]: chara = Character(name=json_event["cast_name"][0], role=json_event["role"][0]) self.cast.invite(chara) else: event = Event( json_event, in_convo=in_convo, during_mwc=during_countdown, during_ot=during_overtime, ) self.timeline.append(event) # if "MissionComplete" in json_event["category"]: # self.missions_complete.append(event.mission) # elif "SniperLights" in json_event["category"]: # self.sniper_lights.append(event) # elif event == "guest list purloined." and event.character.role != "Spy": # self.cast.invite(event.character, "Delegate") # elif event == "statue swapped." and event.character.role != "Spy": # self.cast.invite(event.character, "Swapper") if "SniperShot" in json_event["category"]: self.cast.invite(event.character, "Shot") self.reaches_mwc = len(self.missions_complete) >= int(self.mode[1])
def get_event_image(image_id): try: return Event.get_event_image(image_id) except Exception as ex: return Tools.Result(False, ex.args)
def get_events(): try: return Event.get_events() except Exception as ex: return Tools.Result(False, ex.args)
def delete_event(): try: data = request.get_json() return Event.delete_event(data['EventId']) except Exception as ex: return Tools.Result(False, ex.args)