Exemplo n.º 1
0
    def get(self):
        logging.debug(self.request.path)
        gal_id = -1
        gal_name = ""
        if (self.request.get("view")):
            gal_id = self.request.get("view")
        elif (self.request.path.startswith('/illustrations')):
            gal_name = 'illustrations'
            gal_id = GalleryModel.gql("WHERE name = :name", name='Illustrations').fetch(1)[0].key()
        elif (self.request.path.startswith('/vinyl')):
            gal_name = 'vinyl'
            gal_id = GalleryModel.gql("WHERE name = :name", name='Vinyl').fetch(1)[0].key()
        elif (self.request.path.startswith('/photographs')):
            gal_name = 'photographs'
            gal_id = GalleryModel.gql("WHERE name = :name", name='Photographs').fetch(1)[0].key()
        elif (self.request.path.startswith('/paintings')):
            gal_name = 'paintings'
            gal_id = GalleryModel.gql("WHERE name = :name", name='Paintings').fetch(1)[0].key()
        else:
            self.error(503)

        if ( self.request.path.endswith('list') ):
            self.view_xml(gal_id)
        elif ( self.request.path.endswith('flash') ):
            self.view_flash(gal_name)
        else:
            self.view(gal_id, gal_name)
Exemplo n.º 2
0
 def create(self):
     gal = GalleryModel(
                        name=self.request.get("name"),
                        desc=self.request.get("desc")
                        )
     gal.put()
     referrer = self.request.headers['referer']
     self.redirect(referrer)
Exemplo n.º 3
0
 def view_all(self):
     gals = GalleryModel.all().fetch(_MAX_FETCH)
     data = {
         "gals": 		gals,
         "template":	 	"admin/gallery_view_all.tpl"
     }
     self.generate(template_base, data)
Exemplo n.º 4
0
 def migrate_all(self, id):
     gal = GalleryModel.get(id)
     if (gal):
         imgs = ImageModel.gql("WHERE gallery = :gallery", gallery=gal.key()).fetch(_MAX_FETCH)
         for img in imgs:
             result = ImageModel2.gql("WHERE orig_image = :img", img=img.key()).fetch(1)
             if not result:
                 imgblob             = ImageBlobModel()
                 imgblob.image       = img.image
                 imgblob.thumbnail   = img.thumbnail
                 imgblob.put()
         
                 img2            = ImageModel2()
                 img2.name       = img.name
                 img2.desc       = img.desc
                 img2.orig_image = img.key()
                 img2.priority   = img.priority
                 img2.gallery    = img.gallery
                 img2.imageblob  = imgblob.key()
                 img2.put()   
             else:
                 logging.info("Image %s has already been migrated" % img.key())
                 
     else:
         logging.info("Gallery %s not found" % id)
         self.error(503)
Exemplo n.º 5
0
 def delete(self, id):
     gal = GalleryModel.get(id)
     if gal:
         gal.delete()
         referrer = self.request.headers['referer']
         self.redirect(referrer)
     else:
         self.error(503)
Exemplo n.º 6
0
 def update(self, id):
     gal = GalleryModel.get(id)
     if gal:
         gal.desc		= self.request.get("desc")
         gal.put()
         referrer = self.request.headers['referer']
         self.redirect(referrer)
     else:
         self.error(503)
Exemplo n.º 7
0
 def update(self, id):
     img = ImageModel.get(id)
     if img:
         img.name		= self.request.get("name")
         img.desc		= self.request.get("desc")
         img.priority	= int(self.request.get("priority"))
         img.gallery		= GalleryModel.get(self.request.get("gallery")).key()
         img.put()
         referrer = self.request.headers['referer']
         self.redirect(referrer)
     else:
         self.error(503)
Exemplo n.º 8
0
    def create(self):
        img = ImageModel()
        contenttype, width, height = getImageInfo(self.request.get("img"));
			
        img.name	= self.request.get("name")
        img.desc	= self.request.get("desc")
        img.priority	= int(self.request.get("priority"))
        img.image	= db.Blob(self.request.get("img"))
        img.gallery	= GalleryModel.get(self.request.get("gallery")).key()
        img.thumbnail	= db.Blob(images.resize(self.request.get("img"), 80, 60))
        img.put()
        referrer = self.request.headers['referer']
        self.redirect(referrer)
Exemplo n.º 9
0
 def view(self, id, gal_name):
     gal = GalleryModel.get(id)
     if (gal):
         imgs = ImageModel2.gql("WHERE gallery = :gallery", gallery=gal.key()).fetch(_MAX_FETCH)
         imgs = sorted(imgs, priority_sort)
             
         data = {
             "gal_name":     gal_name,
             "gal":		gal,
             "imgs":		imgs,
             "template":	"public/gallery_view.tpl"
         }
         self.generate(base_template, data)
     else:
         self.error(503)
Exemplo n.º 10
0
 def view_xml(self, id):
     gal = GalleryModel.get(id)
     if (gal):
         imgs = ImageModel2.gql("WHERE gallery = :gallery", gallery=gal.key()).fetch(_MAX_FETCH)
         imgs = sorted(imgs, priority_sort)
         xml = '<?xml version="1.0" encoding="utf-8"?>'
         xml += '<pics>'
         for img in imgs:
             src = '/image/?render=%s' % img.key()
             xml += '<pic src=%s title=%s/>' % (quoteattr(src), quoteattr(img.name))
         xml += '</pics>'
         self.response.headers['Content-Type'] = 'application/xml'
         self.response.out.write(xml)
     else:
         self.error(503)
Exemplo n.º 11
0
    def view_all(self):
        imgs = ImageModel.all()
        imgs = sorted(imgs, priority_sort)
        result_imgs = []
        for img in imgs:
            contenttype, width, height = getImageInfo(img.image)
            img.contenttype = contenttype
            result_imgs.append(img)
            
        gallerys = GalleryModel.all()

        data = {
            "imgs":	result_imgs,
            "gals":	gallerys,
            "template":	"admin/image_view_all.tpl"
        }
        self.generate(template_base, data)
Exemplo n.º 12
0
    def view(self, id):
        gal = GalleryModel.get(id)
        if (gal):
            result_imgs = []
            imgs = ImageModel.gql("WHERE gallery = :gallery", gallery=gal.key()).fetch(_MAX_FETCH)

            imgs = sorted(imgs, priority_sort)
        

            data = {
                "gal":			gal,
                "imgs_count":           len(imgs),
                "imgs":			imgs,
                "template":		"admin/gallery_view.tpl"
            }
            self.generate(template_base, data)
        else:
            self.error(503)