Пример #1
0
def create_gallery():
    if not login.current_user.is_active():
        flash('请登录后再搞相册哦~')
        return redirect(url_for('light-cms.user_login'))
    if request.method == 'GET':
        return render_template('create_gallery.html', title='创建相册')
    if request.method == 'POST':
        uuid = shortuuid.ShortUUID().random(length=6)
        while Gallery.objects(gid=uuid):
            uuid = shortuuid.ShortUUID().random(length=6)
        title = request.form['title']
        g = Gallery()
        g.user = login.current_user._get_current_object()
        g.gid = uuid
        g.title = title
        g.save()
        return redirect(url_for('light-cms.add_image_to_gallery', gid=g.gid))
Пример #2
0
def create_gallery():
    if not login.current_user.is_active():
        flash('앨범기능엔 로그인이 필요합니다')
        return redirect(url_for('light-cms.user_login'))
    if request.method == 'GET':
        return render_template('create_gallery.html', title='앨범 만들기')
    if request.method == 'POST':
        uuid = shortuuid.ShortUUID().random(length=6)
        while Gallery.objects(gid=uuid):
            uuid = shortuuid.ShortUUID().random(length=6)
        title = request.form['title']
        g = Gallery()
        g.user = login.current_user._get_current_object()
        g.gid = uuid
        g.title = title
        g.save()
        return redirect(url_for('light-cms.add_image_to_gallery', gid=g.gid))
Пример #3
0
def index():
    return render_template('index.html',
                           title='홈',
                           images=Image.objects(gallery__not__exists=True).order_by('-pub_date')[:30],
                           galleries=Gallery.objects().order_by('-pub_date'),
                           )
Пример #4
0
def index():
    return render_template('index.html',
                           title='首页',
                           images=Image.objects(gallery__not__exists=True).order_by('-pub_date')[:30],
                           galleries=Gallery.objects().order_by('-pub_date'),
                           )