示例#1
0
文件: models.py 项目: Duncodes/Paipai
    def update_all(data):
        if data:
            exist = []
            for item in data:
                if item.has_key('id') and item['id'] != '1':
                    exist.append(int(item['id']))
                    folder = Folder.query.get(item['id'])
                    folder.depth    = item['depth']
                    folder.left     = item['left']
                    folder.right    = item['right']
                    folder.parent   = item['parent_id']

                    folder.modified = 'NOW()'
                    Folder.query.update(folder)

            all_folders = []
            folders = Folder.query.get_all(array=True)
            for folder in folders:
                all_folders.append(int(folder.id))

            diff = [item for item in all_folders if item not in exist]
            for item in diff:
                if item != 1:
                    from fypress.post import Post 
                    posts = Post.query.filter(folder_id=item).all(array=True)
                    for post in posts:
                        post.folder_id = 1
                        Post.query.update(post)
                    Folder.query.delete(Folder.query.get(item))

            for folder in folders:
                folder.count_posts()

            Folder.build_guid()
            from fypress.post import Post
            
            Post.link_posts()        
示例#2
0
文件: models.py 项目: Duncodes/Paipai
    def update_all(data):
        if data:
            exist = []
            for item in data:
                if item.has_key('id') and item['id'] != '1':
                    exist.append(int(item['id']))
                    folder = Folder.query.get(item['id'])
                    folder.depth = item['depth']
                    folder.left = item['left']
                    folder.right = item['right']
                    folder.parent = item['parent_id']

                    folder.modified = 'NOW()'
                    Folder.query.update(folder)

            all_folders = []
            folders = Folder.query.get_all(array=True)
            for folder in folders:
                all_folders.append(int(folder.id))

            diff = [item for item in all_folders if item not in exist]
            for item in diff:
                if item != 1:
                    from fypress.post import Post
                    posts = Post.query.filter(folder_id=item).all(array=True)
                    for post in posts:
                        post.folder_id = 1
                        Post.query.update(post)
                    Folder.query.delete(Folder.query.get(item))

            for folder in folders:
                folder.count_posts()

            Folder.build_guid()
            from fypress.post import Post

            Post.link_posts()
示例#3
0
文件: models.py 项目: vv3g/FyPress
    def update_all(data):
        if data:
            exist = []
            for item in data:
                if item.has_key('id') and item['id'] != '1':
                    exist.append(int(item['id']))
                    folder = Folder.get(Folder.id == item['id'])
                    folder.depth = item['depth']
                    folder.left = item['left']
                    folder.right = item['right']
                    folder.parent = item['parent_id']

                    folder.modified = datetime.datetime.now()
                    folder.save()

            all_folders = []
            folders = Folder.all()
            for folder in folders:
                all_folders.append(int(folder.id))

            diff = [item for item in all_folders if item not in exist]
            for item in diff:
                if item != 1:
                    from fypress.post import Post
                    posts = Post.filter(Post.id_folder == item).all()
                    for post in posts:
                        post.id_folder = 1
                        post.save()
                    Folder.get(Folder.id == item).remove()

            for folder in folders:
                folder.count_posts()

            Folder.build_guid()
            from fypress.post import Post

            Post.link_posts()
示例#4
0
文件: models.py 项目: Fy-/FyPress
    def update_all(data):
        if data:
            exist = []
            for item in data:
                if item.has_key('id') and item['id'] != '1':
                    exist.append(int(item['id']))
                    folder = Folder.get(Folder.id == item['id'])
                    folder.depth = item['depth']
                    folder.left = item['left']
                    folder.right = item['right']
                    folder.parent = item['parent_id']

                    folder.modified = datetime.datetime.now()
                    folder.save()

            all_folders = []
            folders = Folder.all()
            for folder in folders:
                all_folders.append(int(folder.id))

            diff = [item for item in all_folders if item not in exist]
            for item in diff:
                if item != 1:
                    from fypress.post import Post
                    posts = Post.filter(Post.id_folder == item).all()
                    for post in posts:
                        post.id_folder = 1
                        post.save()
                    Folder.get(Folder.id == item).remove()

            for folder in folders:
                folder.count_posts()

            Folder.build_guid()
            from fypress.post import Post

            Post.link_posts()