Revamp all model relationships to use backref attributes properly

- Fix new post form not including a CSRF token
- Removed some old leftover comment profanity validation, changed to validate_on_submit() for first time
- Include rest of pluralize macro work with this commit + used pluralizing logic where there once was none
This commit is contained in:
Xevion
2022-03-29 18:12:07 -05:00
parent db560b7c41
commit fd35443a9a
8 changed files with 47 additions and 52 deletions

View File

@@ -14,7 +14,7 @@ def edit_profile_post(username: str):
form = EditProfileForm(request.form)
user = User.query.filter_by(username=username).first_or_404()
if current_user.is_admin or user.id == current_user.id:
if current_user.is_admin or user == current_user:
if form.validate():
user.about_me = form.about_me.data
db.session.commit()
@@ -24,6 +24,9 @@ def edit_profile_post(username: str):
@blueprint.route('/login', methods=['GET', 'POST'])
def login():
if current_user.is_authenticated:
return redirect(url_for('main.index'))
form = LoginForm(request.form)
if request.method == 'POST' and form.validate():
@@ -44,7 +47,9 @@ def login():
@blueprint.route('/signup', methods=['GET', 'POST'])
def signup():
# validate and add user to db
if current_user.is_authenticated:
return redirect(url_for('main.index'))
form = RegistrationForm(request.form)
if request.method == 'POST' and form.validate():