Beispiel #1
0
def home():
    error = None
    form = MessageForm(request.form)
    if form.validate_on_submit():
        post = Post(
            title=form.title.data,
            body=form.content.data,
            author_id=current_user.id
        )
        hstags = hashTagFinder(form.content.data)
        if hstags is not None:
            for tag in hstags:
                oldTag = Tag.query.filter_by(name=tag).first()
                if oldTag is None:
                    newTag = Tag(tag)
                    post.tags.append(newTag)
                    db.session.add(newTag)
                else:
                    post.tags.append(oldTag)
        db.session.add(post)
        db.session.commit()
        flash("New Post has been added", category='message')
        return redirect(url_for('blogpost.home'))
    else:
        posts = db.session.query(Post).all()
        return render_template("index.html", posts=posts, form=form)
Beispiel #2
0
def message():
    form = MessageForm(request.form)
    if request.method == "POST" and form.validate():
        db.session.add(Message(form.name.data, form.email.data, form.content.data, request.remote_addr))
        db.session.commit()

    p, count = int(request.args.get("p", "1")), 10
    messags_page = Message.query.filter(Message.mark == 0).order_by(Message.id.desc()).paginate(p, count)
    return render_template("message.html", messages=messags_page.items, form=form)
Beispiel #3
0
def home():
    error = None
    form = MessageForm(request.form)
    if form.validate_on_submit():
        new_message = BlogPost(
            form.title.data,
            form.description.data,
            current_user.id
        )
        db.session.add(new_message)
        db.session.commit()
        flash('New entry was successfully posted. Thanks.')
        return redirect(url_for('home'))
    else:
        posts = db.session.query(BlogPost).all()
        return render_template('hello.html', posts=posts, form=form, error=error)
Beispiel #4
0
def home():
    error = None
    form = MessageForm(request.form)
    if form.validate_on_submit():
        blog = BlogPosts(
            title=form.title.data,
            description=form.content.data,
            author_id=current_user.id
        )
        db.session.add(blog)
        db.session.commit()
        flash("New Post has been added", category='message')
        return redirect(url_for('home.home'))
    else:
        posts = db.session.query(BlogPosts).all()
        return render_template("index.html", posts=posts, form=form)
Beispiel #5
0
def home():
    error = None
    form = MessageForm(request.form)
    if form.validate_on_submit():
        new_post = BlogPost(
            form.title.data,
            form.description.data,
            current_user.id
        )
        db.session.add(new_post)
        db.session.commit()
        flash('New post was added, thanks.')
        return redirect(url_for('home.home'))
    else:
        posts = db.session.query(BlogPost).filter_by(author_id=current_user.id).all()
        return render_template('index.html', posts=posts, form=form, error=error)
Beispiel #6
0
def home():
	error = None
	form = MessageForm(request.form)
	if form.validate_on_submit():
		new_message = BlogPost(
			form.title.data,
			form.description.data,
			current_user.id
		)
		db.session.add(new_message)
		db.session.commit()
		flash('New entry has succesfully posted. Thanks.')
		return redirect(url_for('home.home'))
	else:
		posts = db.session.query(BlogPost).all()
		return render_template(
			'index.html', form=form, posts=posts, error=error)
Beispiel #7
0
def index():
    data = Message.query.all()[::-1]
    form = MessageForm()
    if form.validate_on_submit():
        fname = form.fname.data
        lname = form.lname.data
        comment = form.comment.data
        now = datetime.now()
        date = now.strftime("%d/%m/%Y %H:%M:%S")
        entry = Message(fname=fname, lname=lname, comment=comment, date=date)
        db.session.add(entry)
        db.session.commit()
        data = Message.query.all()[::-1]
        stats = 20000 - len(data)
        return render_template('index.html',
                               form=False,
                               data=data,
                               stats=stats)
    return render_template('index.html', form=form, data=data)
Beispiel #8
0
def index():
    error = None
    form = MessageForm(request.form)
    if form.validate_on_submit():
        new_idea = Post(form.title.data, form.description.data,
                        current_user.id)
        db.session.add(new_idea)
        db.session.commit()
        flash('New Idea Shared!')
        return redirect(url_for('home.index'))
    else:
        posts = db.session.query(Post).order_by('posts.id desc')
    first_name = current_user.first_name
    last_name = current_user.last_name
    return render_template('index.html',
                           posts=posts,
                           form=form,
                           error=error,
                           last_name=last_name,
                           first_name=first_name,
                           title="Home")