Exemplo n.º 1
0
def add_article(db):
    setting.check_login(db, request)
    data_classify = db.default.classify.select('*')
    data_tag = db.default.tag.select('*')
    return template('./admin/add_article.html',
                    data_classify=data_classify,
                    data_tag=data_tag,
                    act_article='active')
Exemplo n.º 2
0
def modify_article(id, db):
    setting.check_login(db, request)
    data = db.default.post.filter(id=id).first()
    print(data)
    data_classify = db.default.classify.select('*')
    return template('./admin/modify.html',
                    content=data,
                    data_classify=data_classify)
Exemplo n.º 3
0
def article(db, count=1):
    setting.check_login(db, request)
    data = db.default.post.select('*')
    page_all = data.count()
    page_data = data[(count - 1) * 10:count * 10]
    max_page = page_all / 10 if (page_all % 10 == 0) else page_all // 10 + 1
    print(max_page)
    return template('./admin/article.html',
                    article=page_data,
                    act_article='active',
                    page=max_page)
Exemplo n.º 4
0
def upload(db):
    setting.check_login(db, request)
    upload = request.files.get('files')
    name, ext = os.path.splitext(upload.filename)
    if ext not in ('.png', '.jpg', '.jpeg'):
        return abort(code=404)
    else:
        random_name = ''.join(
            random.sample(string.ascii_letters + string.digits, 16))

        upload.filename = ''.join((random_name, ext))
    save_path = './static/post/images/'
    upload.save(save_path)  # appends upload.filename automatically
    return upload.filename
Exemplo n.º 5
0
def modify_article(id, db):
    setting.check_login(db, request)
    post_dict = {}
    for pro in request.forms:
        post_dict[pro] = getattr(request.forms, pro)
        print(pro + ":" + getattr(request.forms, pro))
    if post_dict['post_time'] == '':
        del post_dict['post_time']

    if 'files' in request.forms.dict.keys():
        del post_dict['files']
    post_list = []
    post_list.append(post_dict)
    data_update = db.default.post.filter(id=id).bulk_update(post_list)
    if data_update:
        pass
    else:
        return abort(code=404)
Exemplo n.º 6
0
def add_article(db):
    setting.check_login(db, request)
    #验证数据(待补充)
    # data=request.forms.content
    # #data_create=dbs.default.post.bulk_create
    post_dict = {}
    for pro in request.forms:
        post_dict[pro] = getattr(request.forms, pro)
        print(pro + ":" + getattr(request.forms, pro))
    if post_dict['post_time'] == '':
        del post_dict['post_time']

    if 'files' in request.forms.dict.keys():
        del post_dict['files']
    post_list = []
    post_list.append(post_dict)
    data_create = db.default.post.bulk_create(post_list)
    if data_create:
        pass
    else:
        return abort(code=404)
Exemplo n.º 7
0
def index(db):
    setting.check_login(db, request)

    return template('./admin/index.html', act_index='active')
Exemplo n.º 8
0
def teclassify(db):
    setting.check_login(db, request)
    return template('./admin/classify.html', act_classify='active')