def _build_dict(self): data = {} data['notification_type'] = NotificationType.type_names[self._type] data['message_data'] = {} data['message_data']['event_key'] = self.event.key_name data['message_data']['event_name'] = self.event.name data['message_data']['match_key'] = self.match.key_name data['message_data']['team_keys'] = self.match.team_key_names if self.match.time: data['message_data']['scheduled_time'] = calendar.timegm( self.match.time.utctimetuple()) else: data['message_data']['scheduled_time'] = None if self.match.predicted_time: data['message_data']['predicted_time'] = calendar.timegm( self.match.predicted_time.utctimetuple()) else: data['message_data']['predicted_time'] = None current_webcasts = self.event.current_webcasts WebcastOnlineHelper.add_online_status(current_webcasts) online_webcasts = filter(lambda x: x.get('status', '') != 'offline', current_webcasts if current_webcasts else []) if online_webcasts: data['message_data']['webcast'] = online_webcasts[0] else: data['message_data']['webcast'] = None return data
def _build_dict(self): data = {} data['message_type'] = NotificationType.type_names[self._type] data['message_data'] = {} data['message_data']['event_key'] = self.event.key_name data['message_data']['event_name'] = self.event.name data['message_data']['match_key'] = self.match.key_name data['message_data']['team_keys'] = self.match.team_key_names if self.match.time: data['message_data']['scheduled_time'] = calendar.timegm(self.match.time.utctimetuple()) else: data['message_data']['scheduled_time'] = None if self.match.predicted_time: data['message_data']['predicted_time'] = calendar.timegm(self.match.predicted_time.utctimetuple()) else: data['message_data']['predicted_time'] = None current_webcasts = self.event.current_webcasts WebcastOnlineHelper.add_online_status(current_webcasts) online_webcasts = filter(lambda x: x.get('status', '') != 'offline', current_webcasts if current_webcasts else []) if online_webcasts: data['message_data']['webcast'] = online_webcasts[0] else: data['message_data']['webcast'] = None return data
def online_webcasts(self): current_webcasts = self.current_webcasts from helpers.webcast_online_helper import WebcastOnlineHelper WebcastOnlineHelper.add_online_status(current_webcasts) return filter(lambda x: x.get('status', '') != 'offline', current_webcasts if current_webcasts else [])
def update_event(cls, event): WebcastOnlineHelper.add_online_status(event.webcast) converted_event = EventConverter.convert(event, 3) deferred.defer( cls._patch_data, 'live_events/{}'.format(event.key_name), json.dumps({key: converted_event[key] for key in ['key', 'name', 'short_name', 'webcasts']}), _queue="firebase")
def webcast_status(self): WebcastOnlineHelper.add_online_status(self.current_webcasts) overall_status = 'offline' for webcast in self.current_webcasts: status = webcast.get('status') if status == 'online': overall_status = 'online' break elif status == 'unknown': overall_status = 'unknown' return overall_status