コード例 #1
0
ファイル: app.py プロジェクト: chosak/restful-gallery
    def get(self, hash, extension=None):
        q = Album.all().filter('hash =', hash)
        album = q.get()
        if album:
            if extension:
                return self.error(404)
            
            q = Image.all().filter('album =', album)
            return self.response.out.write(render_template('album.html', {
                'name': album.name,
                'images': q,
            }))

        q = Image.all().filter('hash =', hash)
        image = q.get()
        if image:
            if not extension:
                return self.response.out.write(render_template('image.html',
                    { 'image': image }))
            elif image.extension == extension:
                return write_image(self, image.image_data, extension)
            else:
                return self.error(404)
        
        return self.error(404)
コード例 #2
0
ファイル: app.py プロジェクト: chosak/restful-gallery
    def get(self, album_id, image_id, extension=None):
        """GET handler for GGB image metadata and files.

        URL pattern: /albums/${album_id}/images/${image_id}(${extension})

        If called without a file extension:
            If image exists, returns 200 OK with JSON image data structure.
            Returns Content-type: application/json.
            If image doesn't exist, returns 404 NOT FOUND.
        
        If called with a file extension:
            If image exists and has the matching extension, returns the image.
            Returned Content-type matches the image format.
            Otherwise returns 404 NOT FOUND.
       
        Returns 401 UNAUTHORIZED to all calls if authorization fails.
        """
        q = Album.all().filter('album_id =', album_id)
        album = q.get()
        if not album:
            return self.error(404)

        q = Image.all().filter('album =', album).filter('image_id =', image_id)
        image = q.get()
        if not image:
            return self.error(404)

        if not extension:
            data = image.to_dict()
            return write_json(self, image.to_dict())
        
        if extension != image.extension:
            return self.error(404)
   
        write_image(self, image.image_data, image.extension)
コード例 #3
0
ファイル: handlers.py プロジェクト: andreyvit/mockko
    def get(self, group_id, image_name):
        filename, effect = parse_image_name(image_name)

        group = get_image_group_or_404(self, group_id)

        img = Image.all().filter('file_name', filename).filter('group',
                                                               group).get()
        if not img or not img.data:
            #            raise NotFound()
            self.abort(404)

        if not effect:
            response_data = img.data.data
            response_type = img.mime_type
        else:
            square_file = os.path.join(os.path.dirname(__file__),
                                       'server-images', effect + '.png')

            f = overlay_png(png.Reader(file=open(square_file, 'rb')),
                            png.Reader(bytes=img.data.data))

            response_data = f.getvalue()
            response_type = 'image/png'  # We know overlay_png returns PNG


#        return Response(response=response_data,
#                        content_type=response_type,
#                        headers={'Cache-Control' : 'private, max-age=31536000'})
        self.response.headers['Content-Type'] = response_type.encode('utf')
        self.response.headers['Cache-Control'] = 'private, max-age=31536000'
        self.response.write(response_data)
コード例 #4
0
ファイル: app.py プロジェクト: chosak/restful-gallery
    def delete(self, album_id, image_id, extension=None):
        """DELETE handler for gallery images.

        URL pattern: /albums/${album_id}/images/${image_id}
        
        If image exists, returns 200 OK. 
        If image doesn't exist, returns 404 NOT FOUND.

        Returns 401 UNAUTHORIZED to all calls if authorization fails.
        """
        q = Album.all().filter('album_id =', album_id)
        album = q.get()
        if not album:
            return self.error(404)

        q = Image.all().filter('album =', album).filter('image_id =', image_id)
        image = q.get()
        if not image:
            return self.error(404)
        
        if extension and extension != image.extension:
            return self.error(404)

        if not config.DEMO_MODE:
            image.delete()
コード例 #5
0
ファイル: handlers.py プロジェクト: andreyvit/mockko
    def get(self, group_id, image_name):
        filename, effect = parse_image_name(image_name)

        group = get_image_group_or_404(self, group_id)

        img = Image.all().filter("file_name", filename).filter("group", group).get()
        if not img or not img.data:
            #            raise NotFound()
            self.abort(404)

        if not effect:
            response_data = img.data.data
            response_type = img.mime_type
        else:
            square_file = os.path.join(os.path.dirname(__file__), "server-images", effect + ".png")

            f = overlay_png(png.Reader(file=open(square_file, "rb")), png.Reader(bytes=img.data.data))

            response_data = f.getvalue()
            response_type = "image/png"  # We know overlay_png returns PNG

        #        return Response(response=response_data,
        #                        content_type=response_type,
        #                        headers={'Cache-Control' : 'private, max-age=31536000'})
        self.response.headers["Content-Type"] = response_type.encode("utf")
        self.response.headers["Cache-Control"] = "private, max-age=31536000"
        self.response.write(response_data)
コード例 #6
0
ファイル: main.py プロジェクト: v998/sa3album
 def get(self,key_name):
     album = get_or_404(Album.get_by_key_name,key_name)
     imgs = Image.all().filter('album =',album).order('-created').fetch(10)
     self.template_value['imgs']=imgs
     self.template_value['lastupdated'] = imgs[0].created if len(imgs) >0 else datetime.datetime.now()
     self.response.headers['Content-Type'] = "application/atom+xml"
     self.response.out.write(self.get_render("rss.xml"))
コード例 #7
0
 def get(self):
     key = self.request.get('key')
     album = get_or_404(Album.get, key)
     imgs = Image.all().filter('album =', album)
     for img in imgs:
         img.delete()
     album.delete()
     self.redirect("/a/album/")
コード例 #8
0
ファイル: wrappy.py プロジェクト: dforsyth/gif-wrappy
 def get_images_by_tags(self, tags):
     """Returns the url of an image in the index that has tags"""
     DEBUG('get_images_by_tags: %s' % tags)
     ltags = [tag.lower() for tag in tags]
     q = Image.all()
     for tag in ltags:
         q.filter('tags =', tag)
     return q.fetch(100)
コード例 #9
0
 def get(self):
     if self.request.headers.get('X-AppEngine-Cron', 'false') == 'true':
         now = datetime.datetime.now()
         half_hour_ago = now - datetime.timedelta(minutes=30)
         for image in Image.all().filter('date <', half_hour_ago):
             image_blob = blobstore.BlobInfo.get(image.blob_key)
             if image_blob:
                     image_blob.delete()
             image.delete()
コード例 #10
0
ファイル: wrappy.py プロジェクト: dforsyth/gif-wrappy
 def _rmtag(self, blip, startend, arguments):
     url = arguments[0]
     tags = arguments[1:]
     q = Image.all()
     q.filter('url =', url)
     images = q.fetch(1)
     for image in images:
         image.tags = [tag for tag in image.tags if tag not in tags]
         image.put()
コード例 #11
0
ファイル: wrappy.py プロジェクト: dforsyth/gif-wrappy
 def _list_tags(self, blip, startend, arguments):
     q = Image.all()
     images = q.fetch(2000)
     tag_list = []
     for image in images:
         tag_list.extend(image.tags)
     tag_set = set(tag_list)
     range = blip.range(startend[0], startend[1])
     range.replace(', '.join(tag_set))
コード例 #12
0
    def get(self):
        td = {
            "statuses_selected": True,
            "action": "create",
            "url": "/admin/api/v1/statuses",
            "images": Image.all().fetch(200),
        }

        td.update(site.default_template_data())
        self.render(td, 'admin/status_create.html')
コード例 #13
0
ファイル: admin.py プロジェクト: Homefinder/stashboard
    def get(self):
        td = {
            "statuses_selected": True,
            "action": "create",
            "url": "/admin/api/v1/statuses",
            "images": Image.all().fetch(200),
            }

        td.update(site.default_template_data())
        self.render(td, 'admin/status_create.html')
コード例 #14
0
ファイル: api.py プロジェクト: v998/sa3album
 def get(self, slug):
     album = Album.get_by_key_name(slug)
     if album is None:
         return self.error(404)
     self.template_value['album'] = (album.name, album.slug, album.count,
                                     album.url)
     self.template_value['imgs'] = [
         (img.name, img.size, img.f, img.s)
         for img in Image.all().filter('album =', album)
     ]
     return self.render()
コード例 #15
0
ファイル: image.py プロジェクト: ranginui/kohacon
    def get(self):
        images = Image.all().order('-inserted').fetch(image_count+1)

        more = True if len(images) > image_count else False

        vals = {
            'images'      : images,
            'image_count' : image_count if more else len(images),
            'more'        : more,
        }
        self.template( 'image-list.html', vals, 'admin' );
コード例 #16
0
ファイル: main.py プロジェクト: v998/sa3album
 def get(self,key_name):
     p = int(self.request.get('p','1'))
     album = get_or_404(Album.get_by_key_name,key_name)
     self.template_value['album']=album
     PAGESIZE = 500 if self.settings.theme <> 'default' else 24
     imgs = PagedQuery(Image.all().filter('album = ',album),PAGESIZE)
     temp = imgs.fetch_page(p)
     self.template_value['prev']=p-1 if p>1 else None
     self.template_value['next'] = p +1 if len(temp) == PAGESIZE else None
     self.template_value['imgs']  = temp
     self.template_value['ps'] = range(1,imgs.page_count()+1)
     self.template_value['current_p'] = p
     self.render('album.html')
コード例 #17
0
 def get(self, key_name):
     album = get_or_404(Album.get_by_key_name, key_name)
     p = int(self.request.get("p", "1"))
     imgs = PagedQuery(
         Image.all().filter("album =", album).order('-created'), PAGESIZE)
     temp = imgs.fetch_page(p)
     self.template_value['album'] = album
     self.template_value['prev'] = p - 1 if p > 1 else None
     self.template_value['next'] = p + 1 if len(temp) == PAGESIZE else None
     self.template_value['imgs'] = temp
     self.template_value['ps'] = range(1, imgs.page_count() + 1)
     self.template_value['current_p'] = p
     self.render('album_manage.html')
コード例 #18
0
ファイル: index.py プロジェクト: jamslevy/portfolio
 def get(self):
     "Responds to GET requests with the admin interface"
     # query the datastore for images 
     images = Image.all().order("date").fetch(1000)
     context = {
         "images": images,
         "total_width": len(images) * IMAGE_WIDTH
         }
     # calculate the template path
     path = os.path.join(os.path.dirname(__file__), 'templates',
         'index.html')
     # render the template with the provided context
     self.response.out.write(template.render(path, context))
コード例 #19
0
    def get(self):
        "Responds to GET requets with the admin interface"
        images = Image.all()
        images.order("-date")

        # we need the logout url for the frontend
        logout = users.create_logout_url("/")

        # prepare the context for the template
        context = {
            "images": images,
            "logout": logout,
        }
        template = jinja_environment.get_template('index.html')
        # render the template with the provided context
        self.response.out.write(template.render(context))
コード例 #20
0
ファイル: handlers.py プロジェクト: Man-UP/website
    def get(self):
        if 'tabselect' in self.request.GET:
           tabselect = self.request.get('tabselect')
        else:
           tabselect='general'

        self.render_template('admin',
            {'news_list' : NewsArticleNew.all().order('-date'),
             'talk_list' : TalkNew.all().order('-date'),
             'hack_list' : Hack.all().order('-date'),
             'image_list' : Image.all(),
             'image_height' : self.image_height,
             'image_width' : self.image_width,
             'members': Member.all(),
             'message' : self.admin_message,
             'tabselect':tabselect})
コード例 #21
0
ファイル: api.py プロジェクト: Tradeshift/stashboard
    def get(self, version):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        host = self.request.headers.get('host', 'nohost')
        images = []

        for img in Image.all().fetch(1000):
            image = {
                "url": "http://" + host + "/images/" + img.path,
                "icon_set": img.icon_set,
                "name": img.slug,
                }
            images.append(image)

        self.json({"images": images})
コード例 #22
0
    def get(self, version):
        if not self.valid_version(version):
            self.error(404, "API Version %s not supported" % version)
            return

        host = self.request.headers.get('host', 'nohost')
        images = []

        for img in Image.all().fetch(1000):
            image = {
                "url": "http://" + host + "/images/" + img.path,
                "icon_set": img.icon_set,
                "name": img.slug,
            }
            images.append(image)

        self.json({"images": images})
コード例 #23
0
def posts(postkey):
    p = Post.all()
    if postkey != 'all':
        key = Key(postkey)
        p.filter("__key__ =",key)
    postList = ['defualtfirst']
    for post in p.run():
        tmpPost = MultiDict()
        tmpPost['title'] = post.title
        tmpPost['msg'] = post.msg
        q = Image.all()
        q.filter("post_id",post.key())
        for i,image in enumerate(q.run()):
            tmpPost['image'+str(i)] = image.encoded_string
        postList.append(tmpPost)
    tmpOutput = MultiDict()
    tmpOutput['res'] = postList
    return jsonify(tmpOutput)
コード例 #24
0
ファイル: app.py プロジェクト: chosak/restful-gallery
    def get(self, album_id):
        """GET handler for images in a particular gallery album.

        URL pattern: /albums/${album_id}/images
        
        If album exists, returns 200 OK with JSON image data structure.
        Returns Content-type: application/json.
        If album doesn't exist, returns 404 NOT FOUND.

        Returns 401 UNAUTHORIZED to all calls if authorization fails.
        """
        q = Album.all().filter('album_id =', album_id)
        album = q.get()
        if not album:
            return self.error(404)

        images = Image.all().filter("album =", album)
        write_json(self, [image.to_dict() for image in images])
コード例 #25
0
ファイル: wrappy.py プロジェクト: dforsyth/gif-wrappy
    def _metrics(self, blip, startend, arguments):
        q = Image.all()
        images = q.fetch(2000) # fetch needs a 'limit'
        user_dict = {}
        tag_list = []
        image_total = len(images)
        for image in images:
            tag_list.extend(image.tags)
            if image.submitter not in user_dict:
                user_dict[image.submitter] = 1
            else:
                user_dict[image.submitter] = user_dict[image.submitter] + 1
        
        metrics_message = '\n%d images in the database (%d unique tags):\n' % (image_total, len(set(tag_list)))
        for user, count in user_dict.iteritems():
            metrics_message = '%s\n%s: %d (%f%%)' % (metrics_message, user, count, (float(count * 100) / image_total))

        range = blip.range(startend[0], startend[1])
        range.replace(metrics_message)
コード例 #26
0
    def get(self):
        "Responds to GET requets with the admin interface"
        # query the datastore for images owned by
        # the current user. You can't see anyone elses images
        # in the admin

        test = geturl("http://org-images.appspot.com/remote/upload/image/[valid key]")  # add valid realmkey
        url = test.get_url()

        user = users.get_current_user()

        realms = RealmKeys.all()
        images = Image.all().filter("user ="******"-date")

        cssfilesq = File.all()
        jscriptfilesq = File.all()

        cssfiles = cssfilesq.filter("content_type =", "text/css").order("-date")
        jscriptfiles = jscriptfilesq.filter("content_type =", "text/x-c").order("-date")

        blobs = BlobFile.all()
        blobs.filter("user ="******"-date")

        # we are enforcing loggins so we know we have a user
        # we need the logout url for the frontend
        logout = users.create_logout_url("/")

        # prepare the context for the template
        context = {
            "testurl": url,
            "blobuploadurl": blobstore.create_upload_url("/upload/blob"),
            "blobs": blobs,
            "cssfiles": cssfiles,
            "jscriptfiles": jscriptfiles,
            "images": images,
            "logout": logout,
            "realms": realms,
        }
        # calculate the template path
        path = os.path.join(os.path.dirname(__file__), "templates", "index.html")
        # render the template with the provided context
        self.response.out.write(template.render(path, context))
コード例 #27
0
    def get(self):
        "Responds to GET requets with the admin interface"
        # query the datastore for images.
        images = Image.all()
        images.order("-date")

        # we need the logout url for the frontend
        logout = users.create_logout_url("/")

        # prepare the context for the template
        context = {
            "images": images,
            "logout": logout,
        }
        # calculate the template path
        path = os.path.join(os.path.dirname(__file__), 'templates',
            'index.html')
        # render the template with the provided context
        self.response.out.write(template.render(path, context))
コード例 #28
0
    def get(self):
        # query the datastore for images.
        images_query = Image.all().order("-date")
        offset = self.request.get("start")
        if offset:
            offset = int(offset)
        else:
	        offset = 0

        # prepare the context for the template
        results = []
        for image in images_query.run(offset=offset, limit=10):
            image_json = {
               'id': str(image.key())
            }
            results.append(image_json)

        # render the template with the provided context
        self.response.headers['Content-Type'] = "application/json"
        self.response.out.write(json.dumps(results))
コード例 #29
0
    def get(self, slug):
        status = Status.get_by_slug(slug)
        if not status:
            self.not_found()
            return

        td = {
            "statuses_selected": True,
            "status": status,
            "action": "edit",
            "url": "/admin/api/v1/statuses/" + slug,
            "description": status.description,
            "name": status.name,
            "image_url": status.image,
            "images": Image.all().fetch(200),
            "default": status.default,
        }

        td.update(site.default_template_data())
        self.render(td, 'admin/status_edit.html')
コード例 #30
0
ファイル: admin.py プロジェクト: Homefinder/stashboard
    def get(self, slug):
        status = Status.get_by_slug(slug)
        if not status:
            self.not_found()
            return

        td = {
            "statuses_selected": True,
            "status": status,
            "action": "edit",
            "url": "/admin/api/v1/statuses/" + slug,
            "description": status.description,
            "name": status.name,
            "image_url": status.image,
            "images": Image.all().fetch(200),
            "default": status.default,
            }

        td.update(site.default_template_data())
        self.render(td, 'admin/status_edit.html')
コード例 #31
0
ファイル: app.py プロジェクト: chosak/restful-gallery
    def delete(self, album_id):
        """DELETE handler for gallery album.

        URL pattern: /albums/${album_id}
        
        If album exists, returns 200 OK. 
        If album doesn't exist, returns 404 NOT FOUND.

        Also deletes all images associated with this album.

        Returns 401 UNAUTHORIZED to all calls if authorization fails.
        """
        q = Album.all().filter('album_id =', album_id)
        album = q.get()
        if not album:
            return self.error(404)

        if not config.DEMO_MODE:
            q = Image.all().filter('album =', album)
            for image in q:
                image.delete()

            album.delete()
コード例 #32
0
    def get(self):
        "Responds to GET requets with the admin interface"
        # query the datastore for images owned by
        # the current user. You can't see anyone elses images
        # in the admin
        images = Image.all()
        images.filter("user ="******"-date")

        # we are enforcing loggins so we know we have a user
        user = users.get_current_user()
        # we need the logout url for the frontend
        logout = users.create_logout_url("/")

        # prepare the context for the template
        context = {
            "images": images,
            "logout": logout,
        }
        # calculate the template path
        path = os.path.join(os.path.dirname(__file__), 'templates',
                            'index.html')
        # render the template with the provided context
        self.response.out.write(template.render(path, context))
コード例 #33
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
    def get(self):
        "Responds to GET requets with the admin interface"
        # query the datastore for images owned by
        # the current user. You can't see anyone elses images
        # in the admin
        images = Image.all()
        images.filter("user ="******"-date")

        # we are enforcing loggins so we know we have a user
        user = users.get_current_user()
        # we need the logout url for the frontend
        logout = users.create_logout_url("/")

        # prepare the context for the template
        context = {
            "images": images,
            "logout": logout,
        }
        # calculate the template path
        path = os.path.join(os.path.dirname(__file__), 'templates',
            'index.html')
        # render the template with the provided context
        self.response.out.write(template.render(path, context))
コード例 #34
0
ファイル: handlers.py プロジェクト: Man-UP/website
    def post(self, key):
        post = self.request.POST
        edit = self.request.get('kind')
        form_data = dict((k, post.get(k, ''))
                          for k in ('title', 'author', 'date', 'body', 'picture','video'))
        template_dict = {'form_data': form_data, 'key': key, 'show_form' : True,'members': Member.all(),
                         'edit':edit,'thing' : self.thing_descriptors.get(edit),'images':Image.all().filter('name != ', "no-name")}

        try:
                this_date = utils.parse_date(form_data['date'])
        except ValueError:
                template_dict['message'] = \
                    'Date is not in the correct format (YYYY-MM-DD).'
        else:
                if key == 'new':
                    try:
                        if(edit=="news"):
                             thing = NewsArticleNew(
                                  title=post['title'],
                                  author=Member.get_by_id(int(post['author'])),
                                  date=this_date,
                                  body=post['body']
                             )
                        elif(edit=="talk"):
                             thing = TalkNew(
                                  title=post['title'],
                                  author=Member.get_by_id(int(post['author'])),
                                  date=this_date,
                                  body=post['body']
                             )
                             if('video' in post):
                                 talk.video = post['video']
                        elif(edit=="hack"):
                             thing = Hack(
                                  title=post['title'],
                                  date=this_date,
                                  body=post['body']
                             )
                        if(edit=="news" or edit=="hack"):
                             if(self.request.get("picture")):
                                  pictureImage = Image(
                                               picture=images.resize(self.request.get("picture"), self.image_height, self.image_width),
                                               name="no-name",title=" ",alt=" ")
                                  if post['picture_title'] :
                                     pictureImage.title=post['picture_title']
                                  if post['picture_alt'] :
                                     pictureImage.alt=post['picture_alt']
                                  pictureImage.put()
                                  thing.picture=pictureImage
                             elif(post['picture_alias']!="none"):
                                  thing.picture=Image.get_by_id(int(post['picture_alias']))

                        thing.put()
                        template_dict['key']=thing.key

                    except datastore_errors.Error:
                        template_dict['message'] = \
                            'Could not create new %s.' % self.thing_descriptors.get(edit)
                    else:
                        template_dict['message'] = '%s created.' % self.thing_descriptors.get(edit)
                        template_dict['show_form'] = False
                else:
                    try:
                        if(edit=="news"):
                             thing = NewsArticleNew.get(Key(key))
                             thing.title = form_data['title']
                             thing.author = Member.get_by_id(int(post['author']))
                             thing.date = this_date
                             thing.body = form_data['body']

                        elif(edit=="talk"):

                             thing = TalkNew.get(Key(key))
                             thing.title = form_data['title']
                             thing.date = this_date
                             thing.body = form_data['body']

                        elif(edit=="hack"):

                             thing = Hack.get(Key(key))
                             thing.title = form_data['title']
                             thing.date = this_date
                             thing.body = form_data['body']

                        if(self.request.get("picture")):
                             pictureImage = Image(picture=images.resize(self.request.get("picture"), self.image_height, self.image_width),
                                                   name="no-name",title=" ",alt=" ")
                             if post['picture_title'] :
                                 pictureImage.title=post['picture_title']
                             if post['picture_alt'] :
                                 pictureImage.alt=post['picture_alt']
                             pictureImage.put()
                             thing.picture = pictureImage
                        elif(post['picture_alias']!="none"):
                                  thing.picture=Image.get_by_id(int(post['picture_alias']))

                        if 'delete_picture' in post:
                             thing.picture=None

                    except BadKeyError:
                        template_dict['message'] = \
                            'Could not find %s with key %r.' % (self.thing_descriptors.get(edit),key)
                    else:
                        try:
                            thing.put()
                        except datastore_errors.Error:
                            template_dict['message'] = \
                                'Could not save changes to %s.' % self.thing_descriptors.get(edit)
                        else:
                            template_dict['form_data'] = thing
                            template_dict['message'] = 'Changes saved.'
        self.render_template('edit', template_dict)
コード例 #35
0
ファイル: handlers.py プロジェクト: Man-UP/website
 def get(self, key):
     edit = self.request.get('edit')
     template_dict = {'key': key, 'show_form' : True,'members': Member.all(),
                      'edit':edit,'thing' : self.thing_descriptors.get(edit),'images':Image.all().filter('name != ', "no-name") }
     if key == 'new':
         template_dict['form_data'] = {
             'author': Member.get_current_member().handle,
             'date': unicode(datetime.date.today())}
     else:
         try:
             if(edit=='news'):
                thing = NewsArticleNew.get(Key(key))
                form_data={'title':thing.title,'author':thing.author,'date':unicode(thing.date),'body':thing.body,'picture':thing.picture}
             elif(edit=='talk'):
                thing = TalkNew.get(Key(key))
                form_data={'title':thing.title,'author':thing.author,'date':unicode(thing.date),'body':thing.body,'video':thing.video}
             elif(edit=='hack'):
                thing = Hack.get(Key(key))
                form_data={'title':thing.title,'date':unicode(thing.date),'body':thing.body,'picture':thing.picture}
             template_dict['form_data']=form_data
         except BadKeyError:
             template_dict['message'] = \
                 'Could not find %s with key %r.' %  (self.thing_descriptors.get(edit), key)
             template_dict['show_form'] = False
     self.render_template('edit', template_dict)
コード例 #36
0
ファイル: handlers.py プロジェクト: Man-UP/website
    def post(self):
        post = self.request.POST
        kind=post['kind']
        if  kind== 'taglineform':
            properties = GeneralSiteProperties.all().get()
            if properties == None:
                properties = GeneralSiteProperties(tag_line=post['tagline'])
                properties.put()
            else:
                properties.tag_line = post['tagline']
                properties.put()
        elif kind=="image_upload":
             if(self.request.get("picture")):
                 try:
                      if('resize' in post):
                          pictureImage = Image(picture=images.resize(self.request.get("picture"),int(post['height']), int(post['width'])),
                                               name="no-name",title=" ",alt=" ")
                      else:
                          pictureImage = Image(picture=self.request.get("picture"),name="no-name",title=" ",alt=" ")
                      if(post['alias']!=""):
                         replace=True
                         name=post['alias']
                         for other_image in Image.all():
                             if other_image.name == name :
                                replace=False
                                self.admin_message="You cannot use %s as an alias as it is used for another image" % name
                         if replace :
                             pictureImage.name=name
                      if(post['title']!=""):
                         pictureImage.name=post['title']
                      if(post['alt']!=""):
                         pictureImage.name=post['alt']
                      pictureImage.put()
                      self.admin_message = 'Image uploaded'
                 except RequestTooLargeError:
                      self.admin_message = 'Image not uploaded - too large'
                 except TypeError:
                      self.admin_message = 'Width and Height have to be integers'
             else:
                 self.admin_message = 'You need to actually select a picture!'
             kind='image'
        else :
             things_deleted = 0
             for entry_key in self.request.POST.getall('delete_entry'):
                try:
                    entry_key = Key(entry_key)
                except BadKeyError:
                    # Wrong syntax for a key, move on to next key.
                    continue
                if(kind=='news'):
                    thing = NewsArticleNew.get(entry_key)
                elif(kind=='talk'):
                    thing = TalkNew.get(entry_key)
                elif(kind=='hack'):
                    thing = Hack.get(entry_key)
                if thing:
                    thing.delete()
                    things_deleted += 1
                # Else, not article has this key.
             self.admin_message = '%d %s(s) deleted.' % (things_deleted,self.thing_descriptors.get(kind))

        self.render_template('admin',
            {'news_list' : NewsArticleNew.all().order('-date'),
             'talk_list' : TalkNew.all().order('-date'),
             'hack_list' : Hack.all().order('-date'),
             'image_list' : Image.all(),
             'image_height' : self.image_height,
             'image_width' : self.image_width,
             'members': Member.all(),
             'message' : self.admin_message,
             'tabselect':kind})
コード例 #37
0
ファイル: test_images.py プロジェクト: shanma01/stashboard-1
    def test_load_default_images(self):
        Image.load_defaults()
        images = Image.all().fetch(1000)
        self.assertEquals(len(images), 112)

        fugue = Image.all().fetch(1000)
コード例 #38
0
ファイル: image.py プロジェクト: ranginui/kohacon
 def get(self, filename):
     image = Image.all().filter('filename =', filename).get()
     if image:
         self.send_blob(image.blob)
     else:
         self.error(404)
コード例 #39
0
 def get_images():
     return jsonify(Image.all().serialize())
コード例 #40
0
def show_Gallery():
    """Return a list of files contained in the directory pointed by settings.GALLERY_ROOT_DIR.
    """
    images = Image.all()
    return render_template('index.html', images=images)
コード例 #41
0
ファイル: admin.py プロジェクト: jamslevy/portfolio
def imageQuery():
  return Image.all().order("date")
コード例 #42
0
ファイル: photoapp.py プロジェクト: asjad99/sandbox
def show_Gallery():
    """Return a list of files contained in the directory pointed by settings.GALLERY_ROOT_DIR.
    """
    images = Image.all()
    return render_template('index.html', images=images)
コード例 #43
0
ファイル: main.py プロジェクト: v998/sa3album
 def get(self):
     imgs = Image.all().order('-created').fetch(10)
     self.template_value['imgs']=imgs
     self.template_value['lastupdated'] = imgs[0].created if len(imgs) >0 else datetime.datetime.now()
     self.response.headers['Content-Type'] = "application/atom+xml"
     self.response.out.write(self.get_render("rss.xml"))