Exemplo n.º 1
0
 def get(self, letter):
     galleryManager = GalleryManager()
     galleries = galleryManager.getGalleriesStartingWith(letter)
     logger.info("Retrieving galleries starting with: " + letter)
     template_values = {'galleries' : galleries, 'page' : 'galleries', 'starts_with' : letter}
     template_file = get_template('galleries.html')
     self.response.out.write(template.render(template_file, template_values))
Exemplo n.º 2
0
    def get(self):
        galleryManager = GalleryManager()
        galleries = galleryManager.getRecentGalleries(20)
        other_galleries = sorted(
            galleries[6:], lambda x, y: cmp(x.search_term, y.search_term))
        #float(lt.strftime('%s'))
        min_date = min([
            time.mktime(gallery.ts_modified.timetuple())
            for gallery in other_galleries if gallery.ts_modified != None
        ])
        max_date = max([
            time.mktime(gallery.ts_modified.timetuple())
            for gallery in other_galleries if gallery.ts_modified != None
        ])
        for gallery in other_galleries:
            if max_date == min_date:
                gallery.weight = 0
            else:
                gallery.weight = 1 + int(
                    4 *
                    (time.mktime(gallery.ts_modified.timetuple()) - min_date) /
                    (max_date - min_date))
#        for gallery in galleries:
#            for photo in gallery.photos:
#                logger.info("photo: " + photo.getUrl('original'))

        template_values = {
            'galleries': galleries[0:6],
            'other_galleries': other_galleries,
            'page': 'main'
        }
        template_file = get_template('main.html')
        self.response.out.write(template.render(template_file,
                                                template_values))
Exemplo n.º 3
0
    def get(self, topic, ignore):
        topic = unquote(topic)
        galleryManager = GalleryManager()
        logger.info("gallery topic: " + topic);
        gallery = galleryManager.getGallery(topic)
        
        if gallery != None:
            logger.info("Found gallery for " + gallery.search_term + " objectclass = " + gallery.__class__.__name__)
#            for photo in gallery.photos:
#                logger.info("photo: " + photo.getUrl('original'))
            template_values = {'gallery' : gallery, 'page' : 'gallery'}
            template_file = get_template('gallery.html')
            self.response.out.write(template.render(template_file, template_values))
        else:
            logger.info("Did not find gallery for " + topic + " - using dynamic gallery view")
            template_values = {'topic' : topic, 'page' : 'gallery'}
            template_file = get_template('gallery_dynamic.html')
            self.response.out.write(template.render(template_file, template_values))
Exemplo n.º 4
0
    def get(self):
        galleryManager = GalleryManager()
        galleries = galleryManager.getRecentGalleries(20)
        other_galleries = sorted(galleries[6:], lambda x,y : cmp(x.search_term, y.search_term))
        #float(lt.strftime('%s'))
        min_date = min([time.mktime(gallery.ts_modified.timetuple()) for gallery in other_galleries if gallery.ts_modified != None])
        max_date = max([time.mktime(gallery.ts_modified.timetuple()) for gallery in other_galleries if gallery.ts_modified != None])
        for gallery in other_galleries:
            if max_date == min_date:
                gallery.weight = 0
            else:
                gallery.weight = 1 + int(4 * (time.mktime(gallery.ts_modified.timetuple()) - min_date) / (max_date - min_date) )
#        for gallery in galleries:
#            for photo in gallery.photos:
#                logger.info("photo: " + photo.getUrl('original'))
                
        template_values = {'galleries' : galleries[0:6], 
                           'other_galleries' : other_galleries,
                           'page' : 'main'}
        template_file = get_template('main.html')
        self.response.out.write(template.render(template_file, template_values))
Exemplo n.º 5
0
    def get(self, topic, ignore):
        topic = unquote(topic)
        galleryManager = GalleryManager()
        logger.info("gallery topic: " + topic)
        gallery = galleryManager.getGallery(topic)

        if gallery != None:
            logger.info("Found gallery for " + gallery.search_term +
                        " objectclass = " + gallery.__class__.__name__)
            #            for photo in gallery.photos:
            #                logger.info("photo: " + photo.getUrl('original'))
            template_values = {'gallery': gallery, 'page': 'gallery'}
            template_file = get_template('gallery.html')
            self.response.out.write(
                template.render(template_file, template_values))
        else:
            logger.info("Did not find gallery for " + topic +
                        " - using dynamic gallery view")
            template_values = {'topic': topic, 'page': 'gallery'}
            template_file = get_template('gallery_dynamic.html')
            self.response.out.write(
                template.render(template_file, template_values))
Exemplo n.º 6
0
class PurgePage(webapp.RequestHandler): 
    def __init__(self):
        self.galleryManager = GalleryManager()

    def get(self):
        when = subtract_one_month(datetime.datetime.now())
        galleries = self.galleryManager.getGalleriesOlderThan(when)
        photos = [photo.key()
                  for gallery in galleries
                  for photo in gallery.photos]
        logger.info("Purging " + str(len(galleries)) + " galleries with " + str(len(photos)) + " photos")
        db.delete(photos)
        db.delete(galleries)
        self.response.out.write("Purged " + str(len(galleries)) + " galleries with " + str(len(photos)) + " photos")
Exemplo n.º 7
0
class PurgePage(webapp.RequestHandler):
    def __init__(self):
        self.galleryManager = GalleryManager()

    def get(self):
        when = subtract_one_month(datetime.datetime.now())
        galleries = self.galleryManager.getGalleriesOlderThan(when)
        photos = [
            photo.key() for gallery in galleries for photo in gallery.photos
        ]
        logger.info("Purging " + str(len(galleries)) + " galleries with " +
                    str(len(photos)) + " photos")
        db.delete(photos)
        db.delete(galleries)
        self.response.out.write("Purged " + str(len(galleries)) +
                                " galleries with " + str(len(photos)) +
                                " photos")
Exemplo n.º 8
0
 def __init__(self):
     self.galleryManager = GalleryManager()
Exemplo n.º 9
0
 def __init__(self):
     self.galleryManager = GalleryManager()
Exemplo n.º 10
0
 def get(self, ignore):
     galleryManager = GalleryManager()
     logger.info("random gallery")
     gallery = galleryManager.getRandomGallery()
     self.redirect("/gallery/" + gallery.search_term)
Exemplo n.º 11
0
 def get(self,ignore):
     galleryManager = GalleryManager()
     logger.info("random gallery");
     gallery = galleryManager.getRandomGallery()
     self.redirect("/gallery/" + gallery.search_term)