예제 #1
0
파일: views.py 프로젝트: hugesoft/flask-7_2
def index():
    form = UeditorForm()
    if form.validate_on_submit():
        content_data = Content(title='test1', content=form.editor1.data)
        db.session.add(content_data)
        db.session.commit()

    return render_template('edit/editor.html',form=form,
        editor1=form.editor1.data)
예제 #2
0
def index():
    form = UeditorForm()
    if form.validate_on_submit():
        content_data = Content(title='test1', content=form.editor1.data)
        db.session.add(content_data)
        db.session.commit()

    return render_template('edit/editor.html',
                           form=form,
                           editor1=form.editor1.data)
예제 #3
0
파일: views.py 프로젝트: hugesoft/flaskCMS
def add_content():
    form = UeditorForm()
#    tm = time.strftime("%Y-%m-%d %H:%M:%S")
#    print '%s ' % tm
    form.pub_time.data = time

    if form.validate_on_submit():
        content =Content(title=form.title.data,content=form.editor1.data,
            editor=form.edit.data)

        db.session.add(content)
        db.session.commit()
        return redirect(url_for('admin.update_content',id=content.id))

    return render_template('content/content.html',form=form)
예제 #4
0
파일: views.py 프로젝트: hugesoft/flask-7_2
def get_content(id):
    print(id)
    form = UeditorForm()
 #   content_data = Content.query.filter_by(id=id).first()
    content_data = Content.query.get(int(id))

    if form.validate_on_submit(): 
        content_data.content = form.editor1.data
        db.session.add(content_data)
        db.session.commit()    
    else:
        form.editor1.data = content_data.content
    
    return render_template('edit/editor.html',form=form,
        editor1=form.editor1.data)  
예제 #5
0
def add_content():
    form = UeditorForm()
    #    tm = time.strftime("%Y-%m-%d %H:%M:%S")
    #    print '%s ' % tm
    form.pub_time.data = time

    if form.validate_on_submit():
        content = Content(title=form.title.data,
                          content=form.editor1.data,
                          editor=form.edit.data)

        db.session.add(content)
        db.session.commit()
        return redirect(url_for('admin.update_content', id=content.id))

    return render_template('content/content.html', form=form)
예제 #6
0
def get_content(id):
    print(id)
    form = UeditorForm()
    #   content_data = Content.query.filter_by(id=id).first()
    content_data = Content.query.get(int(id))

    if form.validate_on_submit():
        content_data.content = form.editor1.data
        db.session.add(content_data)
        db.session.commit()
    else:
        form.editor1.data = content_data.content

    return render_template('edit/editor.html',
                           form=form,
                           editor1=form.editor1.data)
예제 #7
0
파일: views.py 프로젝트: hugesoft/flaskCMS
def update_content(id):
    form = UeditorForm()
    content = Content.query.get(int(id))
    
    if form.validate_on_submit(): 
        content.content = form.editor1.data
        content.title = form.title.data
        content.pub_time = form.pub_time.data
        content.editor = form.edit.data

        db.session.add(content)
        db.session.commit()            
    else:
        form.editor1.data = content.content
        form.title.data = content.title
        form.pub_time.data = content.pub_time
        form.edit.data = content.editor

    return render_template('content/content.html',form=form)
예제 #8
0
def update_content(id):
    form = UeditorForm()
    content = Content.query.get(int(id))

    if form.validate_on_submit():
        content.content = form.editor1.data
        content.title = form.title.data
        content.pub_time = form.pub_time.data
        content.editor = form.edit.data

        db.session.add(content)
        db.session.commit()
    else:
        form.editor1.data = content.content
        form.title.data = content.title
        form.pub_time.data = content.pub_time
        form.edit.data = content.editor

    return render_template('content/content.html', form=form)