commit 539868c25ac41de9ef73d401bf5a7466943ce15b
parent cfb958f3740955b46b2c2b14bb2d2b90138df0d8
Author: Friedel Schön <[email protected]>
Date: Sat, 16 Apr 2022 04:13:23 +0200
bug-fixes, admin-page -> navbar/lesoverzicht, genederlandsd
Diffstat:
21 files changed, 171 insertions(+), 342 deletions(-)
diff --git a/pgmles/__init__.py b/pgmles/__init__.py
@@ -0,0 +1 @@
+# deze bestand moet er zijn, anders zou Python's leuke module-system niet werken );
+\ No newline at end of file
diff --git a/pgmles/coursecalendar.py b/pgmles/coursecalendar.py
@@ -1,32 +0,0 @@
-import random
-from calendar import Calendar as Month
-from datetime import datetime
-
-lesson_names = [ 'Python', 'C', 'C++', 'Java', 'JavaScript', None, None, None, None, None, None, None, None ]
-
-lessons = [ None ] * 31
-
-
-class Calendar:
- weekdays = enumerate(['Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo'])
- nextlesson = ''
- rows = []
-
- def __init__(self):
- today = datetime.today()
-
- m = Month()
-
- for day in m.itermonthdays(today.year, today.month):
- if day != 0:
- lessons[day] = random.choice(lesson_names)
-
- for day, lesson in enumerate(lessons[today.day:]):
- if lesson is not None:
- self.nextlesson = lesson
- break
-
- for days in m.monthdayscalendar(today.year, today.month):
- self.rows.append([(i, d, lessons[d]) for i, d in enumerate(days)])
-
-# print(self.rows)
diff --git a/pgmles/forms.py b/pgmles/forms.py
@@ -7,84 +7,66 @@ from wtforms.validators import DataRequired, Email, EqualTo, Length, ValidationE
from .models import User
class RegistrationForm(FlaskForm):
- username = StringField('Username', validators=[ DataRequired(), Length(min=2, max=20) ])
- email = StringField('Email', validators=[ DataRequired(), Email() ])
- password = PasswordField('Password', validators=[ DataRequired() ])
- confirm_password = PasswordField('Confirm Password', validators=[ DataRequired(), EqualTo('password') ])
- submit = SubmitField('Sign Up')
+ username = 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')
def validate_username(self, username):
if User.query.filter_by(username=username.data).first():
- raise ValidationError('That username is taken. Please choose a different one.')
+ raise ValidationError('Deze gebruikersnaam bestaat al, kies een andere.')
def validate_email(self, email):
if User.query.filter_by(email=email.data).first():
- raise ValidationError('That email is taken. Please choose a different one.')
+ raise ValidationError('Deze e-mail bestaat al, log in als dat uw e-mail is')
class LoginForm(FlaskForm):
- email = StringField('Email', validators=[ DataRequired(), Email() ])
- password = PasswordField('Password', validators=[ DataRequired() ])
- remember = BooleanField('Remember Me')
- submit = SubmitField('Login')
+ email = StringField('E-Mail', validators=[ DataRequired(), Email() ])
+ password = PasswordField('Wachtwoord', validators=[ DataRequired() ])
+ remember = BooleanField('Herinneren')
+ submit = SubmitField('Inloggen')
class UpdateAccountForm(FlaskForm):
- username = StringField('Username', validators=[ DataRequired(), Length(min=2, max=20) ])
- email = StringField('Email', validators=[ DataRequired(), Email() ])
- picture = FileField('Update Profile Picture', validators=[ FileAllowed(['jpg', 'png']) ])
- submit = SubmitField('Update')
+ username = StringField('Naam', validators=[ DataRequired(), Length(min=2, max=20) ])
+ email = StringField('E-Mail', validators=[ DataRequired(), Email() ])
+ picture = FileField('Profielfoto bewerken', validators=[ FileAllowed(['jpg', 'png']) ])
+ submit = SubmitField('Bewerken')
def validate_username(self, username):
- if username.data != current_user.username:
- user = User.query.filter_by(username=username.data).first()
- if user:
- raise ValidationError('That username is taken. Please choose a different one.')
+ if username.data != current_user.username and User.query.filter_by(username=username.data).first():
+ raise ValidationError('Deze gebruikersnaam bestaat al, kies een andere.')
def validate_email(self, email):
- if email.data != current_user.email:
- user = User.query.filter_by(email=email.data).first()
- if user:
- raise ValidationError('That email is taken. Please choose a different one.')
-
-
-class LanguageForm(FlaskForm):
- name = StringField('Name', validators=[ DataRequired() ])
- info = TextAreaField('Info', validators=[ DataRequired() ])
- submit = SubmitField('Update')
-
+ if email.data != current_user.email and User.query.filter_by(email=email.data).first():
+ raise ValidationError('Deze e-mail bestaat al, log in als dat uw e-mail is')
class NewCourseForm(FlaskForm):
- name = StringField('Title', validators=[ DataRequired(), Length(min=1, max=100) ])
- description = TextAreaField('Description', validators=[ DataRequired() ])
- teacher_id = SelectField('Teacher', validators=[ DataRequired() ], coerce=int)
- weekday = StringField('Weekday', validators=[ DataRequired() ])
- start = StringField('Start', validators=[ DataRequired() ])
- end = StringField('End', validators=[ DataRequired() ])
- location = StringField('Location', validators=[ DataRequired(), Length(min=1, max=100) ])
- submit = SubmitField('Add')
+ name = StringField('Naam', validators=[ DataRequired(), Length(min=1, max=100) ])
+ description = TextAreaField('Beschrijving', validators=[ DataRequired() ])
+ teacher_id = SelectField('Docent', validators=[ DataRequired() ], coerce=int)
+ weekday = SelectField('Weekdag', choices=list(enumerate([ 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag', 'Zondag' ])))
+ start = StringField('Begim', validators=[ DataRequired() ])
+ end = StringField('Einde', validators=[ DataRequired() ])
+ location = StringField('Locatie', validators=[ DataRequired(), Length(min=1, max=100) ])
+ submit = SubmitField('Bewerken')
class SubscribeForm(FlaskForm):
lang_id = HiddenField()
- submit = SubmitField('Subscribe')
+ submit = SubmitField('Inschrijven')
class UnsubscribeForm(FlaskForm):
lang_id = HiddenField()
- submit = SubmitField('Unsubscribe')
-
-
-class PostForm(FlaskForm): # redundant
- title = StringField('Title', validators=[ DataRequired() ])
- content = TextAreaField('Content', validators=[ DataRequired() ])
- submit = SubmitField('Post')
+ submit = SubmitField('Uitschrijven')
class SearchForm(FlaskForm):
- username = StringField('Username', validators=[
- DataRequired(), Length(min=2, max=20)])
- submit = SubmitField('Search')
+ username = StringField('Naam', validators=[ DataRequired(), Length(min=2, max=20)])
+ submit = SubmitField('Zoeken')
class PermissionForm(FlaskForm):
- type = SelectField('Type', choices=[('client', 'Klant'), ('teacher', 'Leraar'), ('admin', 'Administrator')])
- submit = SubmitField('Update')
+ type = SelectField('Type', choices=[('client', 'Klant'), ('teacher', 'Docent'), ('admin', 'Administrator')])
+ submit = SubmitField('Bewerken')
diff --git a/pgmles/routes.py b/pgmles/routes.py
@@ -4,12 +4,32 @@ import secrets
from flask import flash, redirect, render_template, request, url_for, abort
from flask_login import current_user, login_required, login_user, logout_user
from PIL import Image
+from calendar import Calendar as Month
+from datetime import datetime
-from .server import app, bcrypt, calendar, db
+from .server import app, bcrypt, db
from .forms import LoginForm, NewCourseForm, PermissionForm, RegistrationForm, SearchForm, SubscribeForm, UnsubscribeForm, UpdateAccountForm
from .models import Course, CourseMember, User
+def make_calendar():
+ weekdays = list(enumerate(['Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo']))
+
+ courses = [ None, None, None, None, None, None, None ]
+ if current_user.is_authenticated:
+ subscriptions = [ cm.course_id for cm in CourseMember.query.filter_by(user_id=current_user.id) ]
+ courses = [ ' +\n'.join([ c.name for c in Course.query.filter_by(weekday=i) if c.id in subscriptions ]) for i in range(7) ]
+
+ today = datetime.today()
+ m = Month()
+
+ rows = []
+ for days in m.monthdayscalendar(today.year, today.month):
+ rows.append([ (i, d, courses[i]) for i, d in enumerate(days) ])
+
+ return { 'weekdays': weekdays, 'rows': rows }
+
+
@app.route("/")
def index():
courses = Course.query.all()
@@ -17,11 +37,11 @@ def index():
teachers = User.query.filter_by(type='teacher')
if current_user.is_authenticated:
subscriptions = [ cm.course_id for cm in CourseMember.query.filter_by(user_id=current_user.id) ]
- return render_template('index.html', calendar=calendar, courses=courses, subs=subscriptions, teachers=teachers)
+ return render_template('index.html', calendar=make_calendar(), courses=courses, subs=subscriptions, teachers=teachers)
@app.route("/about")
def about():
- return render_template('about.html', calendar=calendar, title='About')
+ return render_template('about.html', calendar=make_calendar(), title='Over ons')
@app.route("/register", methods=['GET', 'POST'])
def register():
@@ -33,9 +53,9 @@ def register():
user = User(username=form.username.data, email=form.email.data, password=hashed_password)
db.session.add(user)
db.session.commit()
- flash('Your account has been created! You are now able to log in', 'success')
+ flash('Uw profiel werd toegevoegd! U kan nu inloggen.', 'success')
return redirect(url_for('login'))
- return render_template('register.html', calendar=calendar, title='Register', form=form)
+ return render_template('register.html', calendar=make_calendar(), title='Registeren', form=form)
@app.route("/login", methods=['GET', 'POST'])
@@ -50,8 +70,8 @@ def login():
next_page = request.args.get('next')
return redirect(next_page if next_page else '/')
else:
- flash('Login Unsuccessful. Please check email and password', 'danger')
- return render_template('login.html', calendar=calendar, title='Login', form=form)
+ flash('Kon niet inloggen, is uw e-mail en wachtwoord juist?', 'danger')
+ return render_template('login.html', calendar=make_calendar(), title='Inloggen', form=form)
@app.route("/logout")
def logout():
@@ -82,29 +102,28 @@ def account():
current_user.username = form.username.data
current_user.email = form.email.data
db.session.commit()
- flash('Your account has been updated!', 'success')
+ flash('Uw profiel werd bewerkt!', 'success')
return redirect(url_for('account'))
elif request.method == 'GET':
form.username.data = current_user.username
form.email.data = current_user.email
image_file = url_for('static', filename='profile_pics/' + current_user.image_file)
- return render_template('account.html', calendar=calendar, title='Account', image_file=image_file, form=form)
+ return render_template('account.html', calendar=make_calendar(), title='Profiel', image_file=image_file, form=form)
@app.route("/course_overview")
@login_required
def course_overview():
- if current_user.type != "admin" and current_user.type != "teacher":
+ if current_user.type not in [ "admin", "teacher" ]:
abort(403)
- courses = Course.query.all()
- type = current_user.type
- return render_template('course_overview.html', calendar=calendar, title='Administration Page', courses=courses, type=type)
+ courses = [ (c, User.query.filter_by(id=c.id).first() ) for c in Course.query.all() ]
+ return render_template('course_overview.html', calendar=make_calendar(), title='Lesoverzicht', courses=courses)
@app.route("/course_overview/new_course", methods=['GET', 'POST'])
@login_required
def new_course():
- if current_user.type != "admin" and current_user.type != "teacher":
+ if current_user.type not in [ "admin", "teacher" ]:
abort(403)
form = NewCourseForm()
form.teacher_id.choices = [ (g.id, g.username) for g in User.query.filter_by(type='teacher') ]
@@ -112,15 +131,15 @@ def new_course():
course = Course(name=form.name.data, description=form.description.data, teacher_id=form.teacher_id.data, weekday=form.weekday.data, start=form.start.data, end=form.end.data, location=form.location.data)
db.session.add(course)
db.session.commit()
- flash('The course has been created!', 'success')
- return redirect(url_for('admin'))
- return render_template('new_course.html', calendar=calendar, title='New Course', form=form)
+ flash('De les werd toegevoegd!', 'success')
+ return redirect(url_for('course_overview'))
+ return render_template('new_course.html', calendar=make_calendar(), title='Nieuwe les', form=form)
@app.route("/course_overview/course_update/<int:course_id>", methods=['GET', 'POST'])
@login_required
def update_course(course_id):
- if current_user.type != "admin" and current_user.type != "teacher":
+ if current_user.type not in [ "admin", "teacher" ]:
abort(403)
form = NewCourseForm()
form.teacher_id.choices = [ (g.id, g.username) for g in User.query.filter_by(type='teacher') ]
@@ -134,7 +153,7 @@ def update_course(course_id):
course.end = form.end.data
course.location = form.location.data
db.session.commit()
- flash('The course has been updated!', 'success')
+ flash('De les werd bewerkt!', 'success')
return redirect(url_for('course_overview'))
elif request.method == 'GET':
form.name.data = course.name
@@ -144,7 +163,7 @@ def update_course(course_id):
form.start.data = course.start
form.end.data = course.end
form.location.data = course.location
- return render_template('update_course.html', calendar=calendar, form=form, legend='Update Language')
+ return render_template('new_course.html', calendar=make_calendar(), form=form, legend='Update Language')
@app.route("/course/<int:course_id>", methods=[ 'GET', 'POST' ])
def course(course_id):
@@ -159,35 +178,27 @@ def course(course_id):
course = CourseMember(user_id=current_user.id, course_id=course_id)
db.session.add(course)
db.session.commit()
- flash('You have subscribed to this course!', 'success')
- return redirect(url_for('account'))
+ flash('U bent nu ingeschreven!', 'success')
+ return redirect('/')
if form2.validate_on_submit() and subscribed:
db.session.delete(subscribed)
db.session.commit()
- flash('You been have Unsubscribed to this course!', 'success')
- return redirect(url_for('account'))
+ flash('U bent nu uitgeschreven!', 'success')
+ return redirect('/')
course = Course.query.get_or_404(course_id)
- return render_template('course.html', calendar=calendar, title=course.name, course=course, form=form, form2=form2, show=not subscribed, teachers=teachers)
+ return render_template('course.html', calendar=make_calendar(), title=course.name, course=course, form=form, form2=form2, show=not subscribed, teachers=teachers)
@app.route("/delete_course/<int:course_id>", methods=['GET','POST'])
@login_required
def delete_course(course_id):
- if current_user.type != "admin":
+ if current_user.type not in [ "admin", "teacher" ]:
abort(403)
course = Course.query.get_or_404(course_id)
db.session.delete(course)
db.session.commit()
- return redirect(url_for('index'))
-
[email protected]("/admin")
-@login_required
-def admin():
- if current_user.type != "admin":
- abort(403)
- courses = Course.query.all()
- return render_template('admin.html', calendar=calendar, courses=courses)
+ return redirect('/')
@app.route("/permissions", methods=['GET','POST'])
@login_required
@@ -198,11 +209,11 @@ def permissions():
if form.validate_on_submit():
user = User.query.filter_by(username=form.username.data).first()
if user == None:
- flash(f'No user found in the database with username: {form.username.data}', 'danger')
+ flash(f'Geen gebruker gevonden: {form.username.data}', 'danger')
else:
- flash(f'Username found in the database with username: {form.username.data}', 'success')
+ flash(f'Gebruiker gevonden: {form.username.data}', 'success')
return redirect(url_for('updatePermissions', user_id= user.id))
- return render_template('permissions.html', calendar=calendar, form=form)
+ return render_template('permissions.html', calendar=make_calendar(), form=form)
@app.route("/permissions/update/<int:user_id>", methods=['GET','POST'])
@login_required
@@ -211,13 +222,12 @@ def updatePermissions(user_id):
abort(403)
form = PermissionForm()
user = User.query.filter_by(id=user_id).first()
- image_file = url_for(
- 'static', filename='profile_pics/' + user.image_file)
+ image_file = url_for('static', filename='profile_pics/' + user.image_file)
if form.validate_on_submit():
user.type = form.type.data
db.session.commit()
- flash(f'The permissions for user: {user.username} have been set to {user.type}', 'success')
+ flash(f'De gebruiker {user.username} is nu een {user.type}', 'success')
return redirect(url_for('permissions'))
elif request.method == 'GET':
form.type.data = user.type
- return render_template('updatepermissions.html', calendar=calendar, form=form, user=user, image_file=image_file)
+ return render_template('updatepermissions.html', calendar=make_calendar(), form=form, user=user, image_file=image_file)
diff --git a/pgmles/routes.txt b/pgmles/routes.txt
@@ -0,0 +1,13 @@
+/ -> index.html
+/about -> about.html
+/register -> register.html
+/login -> login.html
+/logout -> /
+/account -> account.html
+/course_overview -> course_overview.html @ teacher/admin
+/course_overview/new_course -> new_course.html / course_overview.html @ teacher/admin
+/course_overview/course_update/:id -> new_course.html / course_overview.html @ teacher/admin
+/course/:id -> / / course.html
+/delete_course/:id -> / @ teacher/admin
+/permissions -> permissions.html @ admin
+/permissions/update/:id -> updatepermissions.html / permissions.html @ admin
diff --git a/pgmles/server.py b/pgmles/server.py
@@ -12,7 +12,4 @@ login_manager = LoginManager(app)
login_manager.login_view = 'login'
login_manager.login_message_category = 'info'
-from .coursecalendar import Calendar
-calendar = Calendar()
-
from .routes import *
diff --git a/pgmles/site.db b/pgmles/site.db
Binary files differ.
diff --git a/pgmles/static/main.css b/pgmles/static/main.css
@@ -101,7 +101,7 @@ a.article-title:hover {
position: relative;
}
-.calendar .lesson {
+.calendar .course {
background: rgb(84, 230, 84);
border: #444 solid 1px;
color: #444
diff --git a/pgmles/templates/about.html b/pgmles/templates/about.html
@@ -1,4 +1,4 @@
{% extends "layout.html" %}
{% block content %}
- <h1>About Page</h1>
+ <h1>Over ons</h1>
{% endblock content %}
diff --git a/pgmles/templates/account.html b/pgmles/templates/account.html
@@ -11,7 +11,7 @@
<form method="POST" action="" enctype="multipart/form-data">
{{ form.hidden_tag() }}
<fieldset class="form-group">
- <legend class="border-bottom mb-4">Account Info</legend>
+ <legend class="border-bottom mb-4">Informatie</legend>
<div class="form-group">
{{ form.username.label(class="form-control-label") }}
diff --git a/pgmles/templates/admin.html b/pgmles/templates/admin.html
@@ -1,36 +0,0 @@
-{% extends "layout.html" %}
-{% block content %}
-<a class="btn btn-secondary btn-sm mt-1 mb-1" href="{{ url_for('new_course') }}">New Course</a>
-<a class="btn btn-secondary btn-sm mt-1 mb-1" href="{{ url_for('permissions') }}">Permissions</a>
-{% for course in courses %}
- <article class="media content-section">
- <div class="media-body">
- <h2><a class="article-title" href="{{url_for('course', course_id=course.id)}}">{{course.name}}</a></h2>
- <div>
- <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{{ url_for('update_course', course_id = course.id) }}">Update</a>
- <button type="button" class="btn btn-danger btn-sm m-1" data-toggle="modal" data-target="#deleteModal">Delete</button>
- </div>
- </div>
- </div>
- </article>
- <!-- Modal -->
- <div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="deleteModalLabel">Delete Post?</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
- <form action="{{ url_for('delete_course', course_id=course.id) }}" method="POST">
- <input class="btn btn-danger" type="submit" value="Delete">
- </form>
- </div>
- </div>
- </div>
- </div>
- {% endfor %}
-{% endblock content %}
diff --git a/pgmles/templates/course.html b/pgmles/templates/course.html
@@ -6,14 +6,10 @@
{{ course.name }}
{{ '(subscribed)' if course.id in subs }}
</a></h2>
- <p>{{course.description}}</p>
- <p>De cursus <b>{{course.name}}</b> wordt gegeven door
- {% for teacher in teachers %}
- {{ teacher.username if teacher.id == course.teacher_id }}
- {% endfor %}
- </p>
- <p>Elke {{ ['maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag'][course.weekday] }}, {{ course.start }} uur t/m {{ course.end }} uur op locatie: {{ course.location }}</p>
- </div>
+ <p><i>{{ course.description }}</i></p>
+ <p>wordt gegeven door {% for teacher in teachers if teacher.id == course.teacher_id %}{{ teacher.username }},{% endfor %}</p>
+ <p>elke {{ ['maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag'][course.weekday] }} {{ course.start }} uur t/m {{ course.end }} uur op locatie: <b>{{ course.location }}</b></p>
+ </div>
<div class="article-metadata">
{% if current_user.is_authenticated %}
{% if show %}
@@ -32,7 +28,7 @@
</form>
{%endif%}
{% else %}
- <p> Please Log in to subscribe to course</p>
+ <p><a href="{{ url_for('login') }}">Inloggen om in te schrijven</a></p>
{% endif %}
</div>
</article>
diff --git a/pgmles/templates/course_overview.html b/pgmles/templates/course_overview.html
@@ -1,15 +1,36 @@
{% extends "layout.html" %}
{% block content %}
-{% for course in courses %}
- {% if current_user.id == course.teacher_id%}
- <article class="media content-section">
- <div class="media-body">
- <h2><a class="article-title" href="{{url_for('course', course_id=course.id)}}">{{course.name}}</a></h2>
- <div>
- <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{{ url_for('update_course', course_id = course.id) }}">Update</a>
- </div>
+<h1>Course Overview
+ <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{{ url_for('new_course') }}">Nieuwe les</a>
+</h1>
+{% for course, teacher in courses %}
+<article class="media content-section">
+ <div class="media-body">
+ <h2><a class="article-title" href="{{url_for('course', course_id=course.id)}}">{{course.name}} <small>by {{ teacher.username }}</small></a></h2>
+ <div>
+ <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{{ url_for('update_course', course_id = course.id) }}">Bewerkem</a>
+ <button type="button" class="btn btn-danger btn-sm m-1" data-toggle="modal" data-target="#deleteModal">Verwijderen</button>
+ </div>
+ </div>
+</article>
+ <!-- Modal -->
+<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalLabel" aria-hidden="true">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title" id="deleteModalLabel">Les verwijderen?</h5>
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+ <span aria-hidden="true">×</span>
+ </button>
</div>
- </article>
- {% endif %}
+ <div class="modal-footer">
+ <button type="button" class="btn btn-secondary" data-dismiss="modal">Sluiten</button>
+ <form action="{{ url_for('delete_course', course_id=course.id) }}" method="POST">
+ <input class="btn btn-danger" type="submit" value="Delete">
+ </form>
+ </div>
+ </div>
+ </div>
+</div>
{% endfor %}
{% endblock content %}
diff --git a/pgmles/templates/index.html b/pgmles/templates/index.html
@@ -7,13 +7,9 @@
{{ course.name }}
{{ '(subscribed)' if course.id in subs }}
</a></h2>
- <p>{{course.description}}</p>
- <p>De cursus <b>{{course.name}}</b> wordt gegeven door
- {% for teacher in teachers %}
- {{ teacher.username if teacher.id == course.teacher_id }}
- {% endfor %}
- </p>
- <p>Elke {{ ['maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag'][course.weekday] }}, {{ course.start }} uur t/m {{ course.end }} uur op locatie: {{ course.location }}</p>
+ <p><i>{{ course.description }}</i></p>
+ <p>wordt gegeven door {% for teacher in teachers if teacher.id == course.teacher_id %}{{ teacher.username }},{% endfor %}</p>
+ <p>elke {{ ['maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag', 'zondag'][course.weekday] }} {{ course.start }} uur t/m {{ course.end }} uur op locatie: <b>{{ course.location }}</b></p>
</div>
</article>
{% endfor %}
diff --git a/pgmles/templates/layout.html b/pgmles/templates/layout.html
@@ -11,38 +11,28 @@
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='main.css') }}">
{% if title %}
- <title>Flask Blog - {{ title }}</title>
+ <title>Programmeerles voor ouderen - {{ title }}</title>
{% else %}
- <title>Flask Blog</title>
+ <title>Programmeerles voor ouderen</title>
{% endif %}
</head>
<body>
<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="/">Flask Blog</a>
- <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
- <span class="navbar-toggler-icon"></span>
- </button>
+ <a class="navbar-brand mr-4" href="/">Programmeerles voor ouderen</a>
<div class="collapse navbar-collapse" id="navbarToggle">
<div class="navbar-nav mr-auto">
- <a class="nav-item nav-link" href="{{ '/' }}">Home</a>
- <a class="nav-item nav-link" href="{{ '/' }}">About</a>
- {% if current_user.type == "teacher" %}
- <a class="nav-item nav-link" href="{{ url_for('course_overview') }}">Course overview</a>
- {% endif %}
- {% if current_user.type == "admin" %}
- <a class="nav-item nav-link" href="{{ url_for('admin') }}">Admin</a>
- {% endif %}
+ <a class="nav-item nav-link" href="/about">Over ons</a>
</div>
<!-- Navbar Right Side -->
<div class="navbar-nav">
{% if current_user.is_authenticated %}
- <a class="nav-item nav-link" href="{{ url_for('account') }}">Account</a>
- <a class="nav-item nav-link" href="{{ url_for('logout') }}">Logout</a>
+ <a class="nav-item nav-link" href="{{ url_for('account') }}">Profiel</a>
+ <a class="nav-item nav-link" href="{{ url_for('logout') }}">Uitloggen</a>
{% else %}
- <a class="nav-item nav-link" href="{{ url_for('login') }}">Login</a>
- <a class="nav-item nav-link" href="{{ url_for('register') }}">Register</a>
+ <a class="nav-item nav-link" href="{{ url_for('login') }}">Inloggen</a>
+ <a class="nav-item nav-link" href="{{ url_for('register') }}">Registeren</a>
{% endif %}
</div>
</div>
@@ -65,41 +55,40 @@
</div>
<div class="col-md-4">
<div class="content-section">
- <h3>Our Sidebar</h3>
- <p class='text-muted'>You can put any information here you'd like.
+ <h3>Welkom <b>{{ current_user.username if current_user.is_authenticated else 'gast' }}</b>!</h3>
+ {% if current_user.type == 'teacher' or current_user.type == 'admin' %}
+ <p class='text-muted'>
<ul class="list-group">
- <li class="list-group-item list-group-item-light">Latest Posts</li>
- <li class="list-group-item list-group-item-light">Announcements</li>
- <li class="list-group-item list-group-item-light">Calendars</li>
- <li class="list-group-item list-group-item-light">etc</li>
+ <li class="list-group-item list-group-item-light"><a href="{{ url_for('course_overview') }}">Lesoverzicht</a></li>
+ {% if current_user.type == 'admin' %}
+ <li class="list-group-item list-group-item-light"><a href="{{ url_for('permissions') }}">Rechten bewerken</a></li>
+ {% endif %}
</ul>
</p>
+ {% endif %}
<table class='calendar'>
<tr>
- {% for d, day in calendar.weekdays %}
+ {% for d, day in calendar['weekdays'] %}
<th class="{{ 'weekend' if d >= 5 }}">{{ day }}</th>
{% endfor %}
</tr>
- {% for row in calendar.rows %}
+ {% for row in calendar['rows'] %}
<tr>
- {% for d, day, lesson in row %}
- <td class="{{ 'weekend' if d >= 5 }} {{ 'lesson' if lesson }}">
+ {% for d, day, course in row %}
+ <td class="{{ 'weekend' if d >= 5 }} {{ 'course' if course and day }}">
{{ day if day }}
- {% if lesson %}<span class='hover-day'>{{ lesson }}</span>{% endif %}
+ {% if course %}<span class='hover-day'>{{ course }}</span>{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</table>
- {{ calendar.nextlesson }}
</div>
</div>
</div>
</main>
- <!-- Optional JavaScript -->
- <!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
diff --git a/pgmles/templates/login.html b/pgmles/templates/login.html
@@ -4,7 +4,7 @@
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
- <legend class="border-bottom mb-4">Log In</legend>
+ <legend class="border-bottom mb-4">Inloggen</legend>
<div class="form-group">
{{ form.email.label(class="form-control-label") }}
{% if form.email.errors %}
@@ -40,13 +40,13 @@
{{ form.submit(class="btn btn-outline-info") }}
</div>
<small class="text-muted ml-2">
- <a href="#">Forgot Password?</a>
+ <a href="#">Wachtwoord vergeten?</a>
</small>
</form>
</div>
<div class="border-top pt-3">
<small class="text-muted">
- Need An Account? <a class="ml-2" href="{{ url_for('register') }}">Sign Up Now</a>
+ Een profiel nodig? <a class="ml-2" href="{{ url_for('register') }}">Nu inschrijven!</a>
</small>
</div>
{% endblock content %}
diff --git a/pgmles/templates/new_course.html b/pgmles/templates/new_course.html
@@ -96,7 +96,6 @@
{{ form.location(class="form-control form-control-lg") }}
{% endif %}
</div>
- </div>
</fieldset>
<div class="form-group">
{{ form.submit(class="btn btn-outline-info") }}
diff --git a/pgmles/templates/permissions.html b/pgmles/templates/permissions.html
@@ -1,11 +1,11 @@
{% extends "layout.html" %}
{% block content %}
- <h1>Update permissions</h1>
+ <h1>Rechten bewerken!</h1>
<div class="content-section">
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
- <legend class="border-bottom mb-4">Search</legend>
+ <legend class="border-bottom mb-4">Zoeken</legend>
<div class="form-group">
{{ form.username.label(class="form-control-label") }}
{% if form.username.errors %}
diff --git a/pgmles/templates/register.html b/pgmles/templates/register.html
@@ -4,7 +4,7 @@
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
- <legend class="border-bottom mb-4">Join Today</legend>
+ <legend class="border-bottom mb-4">Nog vandaag meedoen!</legend>
<div class="form-group">
{{ form.username.label(class="form-control-label") }}
@@ -65,8 +65,6 @@
</form>
</div>
<div class="border-top pt-3">
- <small class="text-muted">
- Already Have An Account? <a class="ml-2" href="{{ url_for('login') }}">Sign In</a>
- </small>
+ <small class="text-muted">Heb jij al een account? <a class="ml-2" href="{{ url_for('login') }}">Inloggen!</a></small>
</div>
{% endblock content %}
diff --git a/pgmles/templates/update_course.html b/pgmles/templates/update_course.html
@@ -1,106 +0,0 @@
-{% extends "layout.html" %}
-{% block content %}
-<div class="content-section">
- <form method="POST" action="">
- {{ form.hidden_tag() }}
- <fieldset class="form-group">
- <legend class="border-bottom mb-4">{{ legend }}</legend>
- <div class="form-group">
- {{ form.name.label(class="form-control-label") }}
- {% if form.name.errors %}
- {{ form.name(class="form-control form-control-lg is-invalid") }}
- <div class="invalid-feedback">
- {% for error in form.name.errors %}
- <span>{{ error }}</span>
- {% endfor %}
- </div>
- {% else %}
- {{ form.name(class="form-control form-control-lg") }}
- {% endif %}
- </div>
- <div class="form-group">
- {{ form.description.label(class="form-control-label") }}
- {% if form.description.errors %}
- {{ form.description(class="form-control form-control-lg is-invalid") }}
- <div class="invalid-feedback">
- {% for error in form.description.errors %}
- <span>{{ error }}</span>
- {% endfor %}
- </div>
- {% else %}
- {{ form.description(class="form-control form-control-lg") }}
- {% endif %}
- </div>
- <div class="form-group">
- {{ form.teacher_id.label(class="form-control-label") }}
- {% if form.teacher_id.errors %}
- {{ form.teacher_id(class="form-control form-control-lg is-invalid") }}
- <div class="invalid-feedback">
- {% for error in form.teacher_id.errors %}
- <span>{{ error }}</span>
- {% endfor %}
- </div>
- {% else %}
- {{ form.teacher_id(class="form-control form-control-lg") }}
- {% endif %}
- </div>
- <div class="form-group">
- {{ form.weekday.label(class="form-control-label") }}
- {% if form.weekday.errors %}
- {{ form.weekday(class="form-control form-control-lg is-invalid") }}
- <div class="invalid-feedback">
- {% for error in form.weekday.errors %}
- <span>{{ error }}</span>
- {% endfor %}
- </div>
- {% else %}
- {{ form.weekday(class="form-control form-control-lg") }}
- {% endif %}
- </div>
- <div class="form-group">
- {{ form.start.label(class="form-control-label") }}
- {% if form.start.errors %}
- {{ form.start(class="form-control form-control-lg is-invalid") }}
- <div class="invalid-feedback">
- {% for error in form.start.errors %}
- <span>{{ error }}</span>
- {% endfor %}
- </div>
- {% else %}
- {{ form.start(class="form-control form-control-lg") }}
- {% endif %}
- </div>
- <div class="form-group">
- {{ form.end.label(class="form-control-label") }}
- {% if form.end.errors %}
- {{ form.end(class="form-control form-control-lg is-invalid") }}
- <div class="invalid-feedback">
- {% for error in form.end.errors %}
- <span>{{ error }}</span>
- {% endfor %}
- </div>
- {% else %}
- {{ form.end(class="form-control form-control-lg") }}
- {% endif %}
- </div>
- <div class="form-group">
- {{ form.location.label(class="form-control-label") }}
- {% if form.location.errors %}
- {{ form.location(class="form-control form-control-lg is-invalid") }}
- <div class="invalid-feedback">
- {% for error in form.location.errors %}
- <span>{{ error }}</span>
- {% endfor %}
- </div>
- {% else %}
- {{ form.location(class="form-control form-control-lg") }}
- {% endif %}
- </div>
- </div>
- </fieldset>
- <div class="form-group">
- {{ form.submit(class="btn btn-outline-info") }}
- </div>
- </form>
-</div>
-{% endblock content %}
diff --git a/pgmles/templates/updatepermissions.html b/pgmles/templates/updatepermissions.html
@@ -10,7 +10,7 @@
<form method="POST" action="">
{{ form.hidden_tag() }}
<fieldset class="form-group">
- <legend class="border-bottom mb-4">Permission Update</legend>
+ <legend class="border-bottom mb-4">Rechten bewerken!</legend>
<div class="form-group">
{{ form.type.label(class="form-control-label") }}
{% if form.type.errors %}