Esempio n. 1
0
def create():
    if 'email' not in session:
        return redirect(url_for('index'))
    person = Person.query.filter_by(email=session['email']).first()
    if person:
        article = Article()
        print 'Article created'
        form = ArticleCreateForm()
        print 'Form created'
        name = person.firstname
        print 'name assigned'
        form.person_name.data = person.firstname
        if form.validate_on_submit():
            print 'inside article post'
            form.populate_obj(article)
            url = form.url.data
            print url
            if url:
                arch_local = image(url, person.firstname)
                article.arch_local = arch_local
            db.session.add(article)
            db.session.commit()
            return redirect(url_for('index', name=name))
        return render_template('create.html', form=form, person=person, name=name)
    return redirect(url_for('index'))
Esempio n. 2
0
def article_create():
    article = Article()
    form = ArticleCreateForm()
    form.post_order.data = db.session.query(db.func.max(Article.post_order)).scalar()+1

    if form.validate_on_submit():
        form.populate_obj(article)
        db.session.add(article)
        db.session.commit()

        return redirect(url_for('house.article_show', id=article.id))
    return render_template('article_create.html', form=form, article=article)
Esempio n. 3
0
def article_create():
    if 'email' not in session:
        return redirect(url_for('signin'))
    person = Person.query.filter_by(email=session['email']).first()
    name = person.firstname
    article = Article()
    form = ArticleCreateForm()
    form.person_name.data = person.firstname
    if form.validate_on_submit():
        form.populate_obj(article)
        db.session.add(article)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('article_create.html', form=form, person=person, name=name)
Esempio n. 4
0
def article_create():
    if 'email' not in session:
        return redirect(url_for('signin'))
    person = Person.query.filter_by(email=session['email']).first()
    name = person.firstname
    article = Article()
    form = ArticleCreateForm()
    form.person_name.data = person.firstname
    if form.validate_on_submit():
        form.populate_obj(article)
        db.session.add(article)
        db.session.commit()
        return redirect(url_for('index'))
    return render_template('create.html', form=form, person=person, name=name)
Esempio n. 5
0
def profile():
    if 'email' not in session:
        return redirect(url_for('signin'))
    person = Person.query.filter_by(email=session['email']).first()
    if person:
        article = Article()
        form = ArticleCreateForm()
        if request.method == 'POST' and form.validate_on_submit():
            form.populate_obj(article)
            db.session.add(article)
            db.session.commit()
            return redirect(url_for('index'))
        else:
            return render_template('create.html', form=form)
    return render_template('profile.html')
Esempio n. 6
0
def profile():
    if 'email' not in session:
        return redirect(url_for('signin'))
    person = Person.query.filter_by(email=session['email']).first()
    if person:
        article = Article()
        form = ArticleCreateForm()
        if request.method=='POST' and form.validate_on_submit():
            form.populate_obj(article)
            db.session.add(article)
            db.session.commit()
            return redirect(url_for('index'))
        else:
            return render_template('create.html',form=form)
    return render_template('profile.html')