Ejemplo n.º 1
0
def CreateAlbum(user, name='', password='', summary=''):
    '''创建相册'''
    album = model.Albums(AlbumName=name,
                         AlbumPassword=password,
                         AlbumAuthor=user,
                         Summary=summary)
    album.Save()
    memcache.delete('ALLALBUMS')
    return True
Ejemplo n.º 2
0
    def post(self):
        bf = self.request.get("Filedata")
        self.response.out.write(self.request)
        return
        if not bf:
            return self.redirect('/admin/upload/')


#        name=self.request.body_file.vars['file'].filename
        mime = self.request.body_file.vars['Filedata'].headers['content-type']
        if mime.find('image') == -1:
            return self.redirect('/admin/upload/')
        description = self.request.get("Description")
        name = self.request.get("Name")
        album = model.Albums().get_by_id(int(self.request.get("album")))
        image = methods.AddPhoto(name, description, mime, album,
                                 users.get_current_user(), bf)
        self.redirect('/admin/upload/')
Ejemplo n.º 3
0
    def post(self):

        bf = self.request.get("Filedata")

        if not bf:
            return self.redirect('/admin/upload/')
        path = '/album/' + datetime.datetime.now().strftime(
            '%m') + '/' + datetime.datetime.now().strftime(
                '%Y%m%d-%H%M%S') + '.jpg'

        a = yun.writeFile(path, bf, True)
        logging.info('upload result:' + str(a))
        if a == True:
            description = self.request.get("Description")
            name = self.request.get("Name")
            album = model.Albums().get_by_id(int(self.request.get("album")))
            imageurl = 'http://imgstore.b0.upaiyun.com' + path
            image = methods.AddPhoto(name, description, 'images/jpg', album,
                                     users.get_current_user(), bf, imageurl)
            self.response.out.write(imageurl + "!thumb")
        else:
            logging.info('upload image to upyun error:' + str(a))
            self.response.out.write(0)
        return
Ejemplo n.º 4
0
def GetAlbum(id):
    data = model.Albums().get_by_id(int(id))
    return data
Ejemplo n.º 5
0
def GetAllAlbums():

    albums = model.Albums().GetAll()
    return albums