Пример #1
0
        def wrapper(*args, **kwargs):
            objects = f(*args, **kwargs)
            if objects[1] != 200:
                return objects
            if not "journeys" in objects[0].keys():
                return objects
            ticket_by_section = defaultdict(list)
            if not 'tickets' in objects[0].keys():
                return objects

            for t in objects[0]['tickets']:
                if "links" in t.keys():
                    for s in t['links']:
                        ticket_by_section[s['id']].append(t['id'])

            for j in objects[0]['journeys']:
                if not "sections" in j.keys():
                    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
Пример #2
0
 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