hanze/muizenval

fixing some form/model imports and db and changed some 'pgmles' text (0231533b92e53ccbd28b2322c17aa82d23a48542)
Repositories

commit 0231533b92e53ccbd28b2322c17aa82d23a48542
parent 9e12d65abfa8868555b15a8b51c7c094ee433116
Author: Friedel Schön <[email protected]>
Date:   Mon, 25 Apr 2022 15:14:14 +0200

fixing some form/model imports and db and changed some 'pgmles' text

Diffstat:
Mserver/forms.py16++++++++--------
Mserver/routes.py8++++----
Mserver/site.db0
Mserver/templates/account.html12++++++------
Mserver/templates/index.html2+-
Mserver/templates/layout.html13++++++++-----
Mserver/templates/register.html10+++++-----
7 files changed, 32 insertions(+), 29 deletions(-)

diff --git a/server/forms.py b/server/forms.py @@ -8,15 +8,15 @@ from .models import User """ registration form for register.html """ class RegistrationForm(FlaskForm): - username = StringField('Naam', validators=[ DataRequired(), Length(min=2, max=20) ]) + name = StringField('Naam', validators=[ DataRequired(), Length(min=2, max=20) ]) email = StringField('E-Mail', validators=[ DataRequired(), Email() ]) password = PasswordField('Wachtwoord', validators=[ DataRequired() ]) confirm_password = PasswordField('Wachtwoord herhalen', validators=[ DataRequired(), EqualTo('password') ]) submit = SubmitField('Registeren') - """ validates whether username is already in use """ - def validate_username(self, username): - if User.query.filter_by(name=username.data).first(): + """ validates whether name is already in use """ + def validate_name(self, name): + if User.query.filter_by(name=name.data).first(): raise ValidationError('Deze gebruikersnaam bestaat al, kies een andere.') """ validates whether e-mail is already in use """ @@ -35,16 +35,16 @@ class LoginForm(FlaskForm): """ update account form for account.html """ class UpdateAccountForm(FlaskForm): - username = StringField('Naam', validators=[ DataRequired(), Length(min=2, max=20) ]) + name = StringField('Naam', validators=[ DataRequired(), Length(min=2, max=20) ]) email = StringField('E-Mail', validators=[ DataRequired(), Email() ]) password = PasswordField('Wachtwoord', validators=[]) confirm_password = PasswordField('Wachtwoord herhalen', validators=[ EqualTo('password') ]) picture = FileField('Profielfoto bewerken', validators=[ FileAllowed(['jpg', 'png']) ]) submit = SubmitField('Bewerken') - """ validates whether username is already in use """ - def validate_username(self, username): - if username.data != current_user.name and User.query.filter_by(username=username.data).first(): + """ validates whether name is already in use """ + def validate_name(self, name): + if name.data != current_user.name and User.query.filter_by(name=name.data).first(): raise ValidationError('Deze gebruikersnaam bestaat al, kies een andere.') """ validates whether e-mail is already in use """ diff --git a/server/routes.py b/server/routes.py @@ -8,7 +8,7 @@ from calendar import Calendar as Month from datetime import datetime from .app import app, bcrypt, db -from .forms import LoginForm, NewCourseForm, AdminForm, RegistrationForm, SearchForm, SubscribeForm, UnsubscribeForm, UpdateAccountForm +from .forms import LoginForm, RegistrationForm, UpdateAccountForm from .models import User @@ -31,7 +31,7 @@ def register(): form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') - user = User(name=form.username.data, email=form.email.data, password=hashed_password) + user = User(name=form.name.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash('Uw profiel werd toegevoegd! U kan nu inloggen.', 'success') @@ -83,7 +83,7 @@ def save_picture(form_picture): def account(): form = UpdateAccountForm() if form.validate_on_submit(): - current_user.name = form.username.data + current_user.name = form.name.data current_user.email = form.email.data if form.picture.data: picture_file = save_picture(form.picture.data) @@ -94,7 +94,7 @@ def account(): flash('Uw profiel is bewerkt!', 'success') return redirect(url_for('account')) elif request.method == 'GET': - form.username.data = current_user.name + form.name.data = current_user.name form.email.data = current_user.email image_file = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('account.html', title='Profiel', image_file=image_file, form=form) diff --git a/server/site.db b/server/site.db Binary files differ. diff --git a/server/templates/account.html b/server/templates/account.html @@ -4,7 +4,7 @@ <div class="media"> <img class="rounded-circle account-img" src="{{ image_file }}"> <div class="media-body"> - <h2 class="account-heading">{{ current_user.username }}</h2> + <h2 class="account-heading">{{ current_user.name }}</h2> <p class="text-secondary">{{ current_user.email }}</p> </div> </div> @@ -13,17 +13,17 @@ <fieldset class="form-group"> <legend class="border-bottom mb-4">Informatie</legend> <div class="form-group"> - {{ form.username.label(class="form-control-label") }} + {{ form.name.label(class="form-control-label") }} - {% if form.username.errors %} - {{ form.username(class="form-control form-control-lg is-invalid") }} + {% if form.name.errors %} + {{ form.name(class="form-control form-control-lg is-invalid") }} <div class="invalid-feedback"> - {% for error in form.username.errors %} + {% for error in form.name.errors %} <span>{{ error }}</span> {% endfor %} </div> {% else %} - {{ form.username(class="form-control form-control-lg") }} + {{ form.name(class="form-control form-control-lg") }} {% endif %} </div> <div class="form-group"> diff --git a/server/templates/index.html b/server/templates/index.html @@ -19,7 +19,7 @@ <p> wordt gegeven door {% for teacher in teachers if teacher.id == course.teacher_id %} - {{ teacher.username }}, + {{ teacher.name }}, {% endfor %} </p> <p> diff --git a/server/templates/layout.html b/server/templates/layout.html @@ -12,9 +12,9 @@ <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='openmoji/openmoji.css') }}"> {% if title %} - <title>Programmeerles voor ouderen - {{ title }}</title> + <title>muizenval.io - {{ title }}</title> {% else %} - <title>Programmeerles voor ouderen</title> + <title>muizenval.io</title> {% endif %} </head> @@ -22,7 +22,9 @@ <header class="site-header"> <nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top"> <div class="container"> - <a class="navbar-brand mr-4" href="/">Programmeerles voor ouderen</a> + <a class="navbar-brand mr-4" href="/"> + <code>muizenval.io</code> + </a> <div class="collapse navbar-collapse" id="navbarToggle"> <div class="navbar-nav mr-auto"> <a class="nav-item nav-link" href="{{ url_for('about') }}">Over ons</a> @@ -56,7 +58,7 @@ </div> <div class="col-md-4"> <div class="content-section"> - <h3>Welkom <b>{{ current_user.username if current_user.is_authenticated else 'gast' }}</b>!</h3> + <h3>Welkom <b>{{ current_user.name if current_user.is_authenticated else 'gast' }}</b>!</h3> {% if current_user.is_authenticated %} <p class='text-muted'> <ul class="list-group"> @@ -73,6 +75,7 @@ </ul> </p> {% endif %} + {# {% if current_user.is_authenticated %} <table class='calendar'> <tr> @@ -91,7 +94,7 @@ </tr> {% endfor %} </table> - {% endif %} + {% endif %}#} </div> </div> </div> diff --git a/server/templates/register.html b/server/templates/register.html @@ -6,17 +6,17 @@ <fieldset class="form-group"> <legend class="border-bottom mb-4">Nog vandaag meedoen!</legend> <div class="form-group"> - {{ form.username.label(class="form-control-label") }} + {{ form.name.label(class="form-control-label") }} - {% if form.username.errors %} - {{ form.username(class="form-control form-control-lg is-invalid") }} + {% if form.name.errors %} + {{ form.name(class="form-control form-control-lg is-invalid") }} <div class="invalid-feedback"> - {% for error in form.username.errors %} + {% for error in form.name.errors %} <span>{{ error }}</span> {% endfor %} </div> {% else %} - {{ form.username(class="form-control form-control-lg") }} + {{ form.name(class="form-control form-control-lg") }} {% endif %} </div> <div class="form-group">