Exemple #1
0
    def maap_library(self, type="images", **kw):
        class Asset:
            def __init__(self, asset_type=None, record=None, thumb_url=None, view_url=None):
                self.asset_type = asset_type
                self.record = record
                self.name = record.name
                self.thumb_url = thumb_url
                self.view_url = view_url

            def __cmp__(self, other):
                return cmp(self.name, other.name)

        if type == "maps":
            maps = MapAsset.selectBy()
            assets = [
                Asset(asset_type="map", record=m, thumb_url=m.smallthumb_url, view_url="/place/then#map=%s" % m.name)
                for m in maps
            ]
        elif type == "videos":
            videos = VideoAsset.selectBy()
            assets = [
                Asset(asset_type="video", record=v, thumb_url=v.tiny_url, view_url="/video/view/%s" % v.id)
                for v in videos
            ]
        else:
            images = ImageAsset.selectBy()
            assets = [
                Asset(asset_type="image", record=i, thumb_url=i.thumb_url, view_url="/image/view/%s" % i.id)
                for i in images
            ]

        assets.sort()
        return dict(assets=assets, type=type)
Exemple #2
0
 def default(self, video_id, **kwargs):
     try:
         video = list(VideoAsset.selectBy(id=video_id))[0]
     except:
         log("video not found")
         video = None
     return dict(video=video)