Tilføj oprettelse af tråde, grupper og opslag

This commit is contained in:
Mikkel
2022-05-31 16:21:09 +02:00
parent 0d93a37a5c
commit 4592591c4e
9 changed files with 149 additions and 13 deletions

14
aula/Post/routes.py Normal file
View File

@ -0,0 +1,14 @@
from flask import render_template, Blueprint, flash, redirect
from flask_login import current_user, login_required
from aula.models import insert_post
from aula.forms import CreatePostForm
Post = Blueprint('Post', __name__)
@Post.route("/posts/create", methods=['POST'])
@login_required
def create():
form = CreatePostForm()
insert_post(form.group_id.data, form.author_id.data, form.title.data, form.content.data)
flash('Opslag blev oprettet', 'success')
return redirect(f"/groups/{form.group_id.data}")