Esempio n. 1
0
    def maps(self, callback=True, **kw):

        maps = dict(
            [
                (
                    m.name,
                    dict(
                        name=m.name,
                        id=m.id,
                        title=m.title,
                        publisher=m.publisher,
                        date=m.date.isoformat(),
                        year=m.year,
                        thumb_url=m.thumb_url,
                        images=dict(
                            preview=m.src_url,
                            thumb=m.thumb_url,
                            smallthumb=m.smallthumb_url,
                            bigthumb=m.bigthumb_url,
                            big=m.big_url,
                            gigantic=m.gigantic_url,
                        ),
                    ),
                )
                for m in MapAsset.select()
            ]
        )
        # we don't need patches at this moment.  maybe later?
        patches = []  # json.jsonify_sqlobject(mp) for mp in MapPatch.select()]
        rv = dict(maps=maps, patches=patches)
        if callback:
            return "loadMaps(%s)" % serializeJSON(rv)
        else:
            return rv
Esempio n. 2
0
 def json(self, callback=True, **kw):
     places = [
         dict(id=p.id, latitude=p.latitude, longitude=p.longitude, title=p.title, color=p.color)
         for p in Place.select()
     ]
     rv = dict(places=places)
     if callback:
         return "loadPlaces(%s)" % serializeJSON(rv)
     else:
         return rv
Esempio n. 3
0
    def welcome_places(self, callback=True, **kw):
        FEATURED_PLACE_NAMES = (
            "pierre_toussaint",
            "abyssinian_baptist_church",
            "african_grove_theater",
            "duke_ellington",
            "five_points",
            "fort_amsterdam",
            "harlem",
            "studio_museum",
            "the_african_burial_ground",
            "the_audubon_ballroom",
        )
        featured_places = [Place.selectBy(name=p)[0] for p in FEATURED_PLACE_NAMES]

        places = dict(
            [
                (
                    index,
                    dict(
                        name=p.name,
                        id=p.id,
                        title=p.title,
                        then_text=p.then_text,
                        then_image_id=p.then_image.id,
                        then_image_thumb_url=p.then_image.thennow_url,
                    ),
                )
                for index, p in enumerate(featured_places)
            ]
        )
        rv = dict(places=places)
        if callback:
            return "loadFeaturedPlaces(%s)" % serializeJSON(rv)
        else:
            return rv