Exemple #1
0
    def get(self):
        user = users.get_current_user()
        if user is None:
            return self.redirect('/admin/index')
        if self.request.get('pictureid'):
            pictureid = self.request.get('pictureid')
            img = memcache.get(pictureid)
            if img is None:
                img = Picture.get_by_id(long(pictureid))
                memcache.add(pictureid, img, 20)

            #if img.user.email != user.email():
            #  img=''
            if img:
                newimg = images.Image(img.binary)
                newimg.resize(width=80, height=80)
                newimg.im_feeling_lucky()
                if img.mime == 'image/png':
                    smallimg = newimg.execute_transforms(
                        output_encoding=images.PNG)
                else:
                    img.mime == 'image/jpeg'
                    smallimg = newimg.execute_transforms(
                        output_encoding=images.JPEG)
                self.response.headers['Content-Type'] = img.mime
                self.response.out.write(smallimg)
            else:
                self.error(404)
        else:
            self.error(404)
    def post(self):
        try:
            user = users.get_current_user()
            if user is None:
                return self.redirect('/index')
            else:
                logout_link = users.create_logout_url(PROTOCOLHTTP + DOMAIN +
                                                      "/index")
            cookie = SimpleCookie(os.environ.get('HTTP_COOKIE', ''))
            picturHandlerePage = self.request.get('picturHandlerePage')

            cookie['picturHandlerePage'] = picturHandlerePage.encode('utf-8')
            cookie['picturHandlerePage']['expires'] = 3600
            print cookie.output()

            pictureIdList = self.request.POST.getall("pictureid")

            for pil in pictureIdList:
                label = self.request.get("label" + pil)
                if len(label) > 10:
                    raise RuntimeError("labelMax error")
                data = Picture.get_by_id(long(pil))
                data.label = label
                data.put()

            return self.redirect('/user/picture/list')
        except:
            self.errorFunc()
 def post(self):
     user = users.get_current_user()
     if not user:
         return self.redirect('/admin/index')
     pictureid = self.request.get('pictureid')
     datas = Picture.get_by_id(long(pictureid))
     params = {'datas': datas}
     fpath = os.path.join(os.path.dirname(__file__),
                          'template/admin/picture', 'update.html')
     html = template.render(fpath, params)
     self.response.out.write(html)
    def post(self):
        user = users.get_current_user()
        if not user:
            return self.redirect('/admin/index')
        pictureIdList = self.request.POST.getall("pictureid")
        for pil in pictureIdList:
            data = Picture.get_by_id(long(pil))
            data.delete()

        fpath = os.path.join(os.path.dirname(__file__),
                             'template/admin/picture', 'deleteend.html')
        html = template.render(fpath, '')
        self.response.out.write(html)

        return
    def post(self):
        try:
            user = users.get_current_user()
            if user is None:
                return self.redirect('/index')
            else:
                logout_link = users.create_logout_url(PROTOCOLHTTP + DOMAIN +
                                                      "/index")

            cookie = SimpleCookie(os.environ.get('HTTP_COOKIE', ''))
            picturHandlerePage = self.request.get('picturHandlerePage')

            cookie['picturHandlerePage'] = picturHandlerePage.encode('utf-8')
            cookie['picturHandlerePage']['expires'] = 3600
            print cookie.output()

            email = user.email()
            userData = db.GqlQuery("SELECT * FROM User WHERE email='" + email +
                                   "'")
            for user in userData:
                id = user.key().id()

            user = User.get_by_id(long(id))
            pictureIdList = self.request.POST.getall("pictureid")
            sumBinary = 0
            for pil in pictureIdList:
                picture = Picture.get_by_id(long(pil))
                sumBinary = sumBinary + len(picture.binary) / 1000
                PcaDatas = PictureConnectAlbum.gql(
                    "WHERE picture = :1 ORDER BY picture", picture)

                for PcaData in PcaDatas:
                    albumid = PcaData.album.key().id()
                    albumData = Album.get_by_id(long(albumid))
                    cnt = albumData.picture_counter - 1
                    albumData.picture_counter = cnt
                    albumData.put()

                picture.delete()

            contentPicture = user.contentPicture
            contentPicture = contentPicture - sumBinary
            user.contentPicture = contentPicture
            user.put()

            return self.redirect('/user/picture/list')
        except:
            self.errorFunc()
    def post(self):
        try:
            user = users.get_current_user()
            if not user:
                return self.redirect('/admin/index')

            pictureIdList = self.request.POST.getall("pictureid")

            for pil in pictureIdList:
                label = self.request.get("label" + pil)
                if len(label) > 10:
                    raise RuntimeError("labelMax error")
                data = Picture.get_by_id(long(pil))
                data.label = label
                data.put()
        except:
            self.errorFunc()