示例#1
0
def slide_a():
    ''' adding a slide '''
    form = forms.Slide_a(session.get('lang'))

    if form.validate_on_submit():
        background = form.background.data

        if background:
            image = data.Media.get(background)

            if not image:
                flash('Error: wrong entry, something went wrong', 'danger')
                return redirect(url_for('cust_app.slide_a'))

            background = image.name
        else:
            background = form.bgcolor.data

        ss = data.Slides()
        ss.title = form.title.data
        ss.hsize = form.hsize.data
        ss.hcolor = form.hcolor.data
        ss.hfont = form.hfont.data
        ss.hbg = form.hbg.data
        ss.subti = form.subti.data
        ss.tsize = form.tsize.data
        ss.tcolor = form.tcolor.data
        ss.tfont = form.tfont.data
        ss.tbg = form.tbg.data
        ss.bname = background
        ss.ikey = form.background.data

        db.session.add(ss)
        db.session.commit()
        flash('Notice: templates been updated.', 'info')
        return redirect(url_for('cust_app.slideshow'))

    return render_template('slide_add.html',
                           page_title='Add Slide ',
                           form=form,
                           navbar='#snb2',
                           hash=1,
                           dropdown='#dropdown-lvl3',
                           vtrue=data.Vid.get().enable,
                           strue=data.Slides_c.get().status)
示例#2
0
def slide_a():
    """ adding a slide """
    ex_functions.mse()
    if current_user.role_id != 1:
        flash('Error: only administrator can access the page', "danger")
        return redirect(url_for('core.root'))
    if data.Vid.query.first().enable == 1:
        flash('Error: must disable video before using slide-show', 'danger')
        return redirect(url_for('cust_app.video'))
    form = forms.Slide_a(session.get('lang'))
    if form.validate_on_submit():
        if form.background.data == 00:
            bb = form.bgcolor.data
        else:
            bb = data.Media.query.filter_by(id=form.background.data).first()
            if bb is None:
                flash('Error: wrong entry, something went wrong', "danger")
                return redirect(url_for("cust_app.slide_a"))
            bb = bb.name
        ss = data.Slides()
        ss.title = form.title.data
        ss.hsize = form.hsize.data
        ss.hcolor = form.hcolor.data
        ss.hfont = form.hfont.data
        ss.hbg = form.hbg.data
        ss.subti = form.subti.data
        ss.tsize = form.tsize.data
        ss.tcolor = form.tcolor.data
        ss.tfont = form.tfont.data
        ss.tbg = form.tbg.data
        ss.bname = bb
        ss.ikey = form.background.data
        db.session.add(ss)
        db.session.commit()
        flash("Notice: templates been updated.", "info")
        return redirect(url_for("cust_app.slideshow"))
    return render_template("slide_add.html",
                           ptitle="Add Slide ",
                           form=form,
                           navbar="#snb2",
                           hash=1,
                           dropdown='#dropdown-lvl3',
                           vtrue=data.Vid.query.first().enable,
                           strue=data.Slides_c.query.first().status)