def wrapper(*args, **kwargs): objects = f(*args, **kwargs) if has_invalid_reponse_code(objects) or journeys_absent(objects): return objects if 'tickets' not in objects[0]: return objects ticket_by_section = defaultdict(list) for t in objects[0]['tickets']: if "links" in t: for s in t['links']: ticket_by_section[s['id']].append(t['id']) for j in objects[0]['journeys']: if "sections" not in j: continue for s in j['sections']: # them we add the link to the different tickets needed for ticket_needed in ticket_by_section[s["id"]]: s['links'].append(create_internal_link(_type="ticket", rel="tickets", id=ticket_needed)) if "ridesharing_journeys" not in s: continue for rsj in s['ridesharing_journeys']: if "sections" not in rsj: continue for rss in rsj['sections']: # them we add the link to the different ridesharing-tickets needed for rs_ticket_needed in ticket_by_section[rss["id"]]: rss['links'].append( create_internal_link(_type="ticket", rel="tickets", id=rs_ticket_needed) ) return objects
def get_links(self, obj): disruption_links = [ create_internal_link(_type="disruption", rel="disruptions", id=uri) for uri in obj.impact_uris ] properties_links = pt.make_properties_links(obj.properties) return properties_links + disruption_links
def wrapper(*args, **kwargs): objects = f(*args, **kwargs) if objects[1] != 200: return objects if "journeys" not in objects[0]: return objects ticket_by_section = defaultdict(list) if 'tickets' not in objects[0]: return objects for t in objects[0]['tickets']: if "links" in t: for s in t['links']: ticket_by_section[s['id']].append(t['id']) for j in objects[0]['journeys']: if "sections" not in j: continue for s in j['sections']: #them we add the link to the different tickets needed for ticket_needed in ticket_by_section[s["id"]]: s['links'].append( create_internal_link(_type="ticket", rel="tickets", id=ticket_needed)) return objects
def get_links(self, obj): if not hasattr(obj, 'ticket_id'): return [] return [ create_internal_link(id=value, rel='tickets', _type='ticket') for value in obj.ticket_id ]
def get_links(self, obj): if not hasattr(obj, 'section_id'): return None return [ create_internal_link(id=value, rel='sections', _type='section') for value in obj.section_id ]
def output(self, key, obj): ticket_ids = [] try: for t_id in obj.ticket_id: ticket_ids.append(t_id) except ValueError: return None response = [] for value in ticket_ids: response.append( create_internal_link(_type="ticket", rel="tickets", id=value)) return response
def to_value(self, value): return [create_internal_link(_type="disruption", rel="disruptions", id=uri) for uri in value]
def output(self, key, obj): return [ create_internal_link(_type="disruption", rel="disruptions", id=uri) for uri in obj.impact_uris ]
def output(self, key, obj): return [ create_internal_link(_type="disruption", rel="disruptions", id=d.uri) for d in obj.disruptions ]