programmeerles-ouderen

Teach programming to seniors
Log | Files | Refs

commit ba6b02b1c87a2a43bc99de634e696f456081c2a2
parent 5ac9fc5deff62f780085e7a55f3d8df07eaea697
Author: Friedel Schön <[email protected]>
Date:   Thu,  7 Apr 2022 13:45:14 +0200

post-merge

Diffstat:
Mpgmles/routes.py | 26+++++++++++++++-----------
Mpgmles/site.db | 0
2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/pgmles/routes.py b/pgmles/routes.py @@ -12,13 +12,12 @@ from .models import Classes, Language, User @app.route("/") def index(): - page = request.args.get('page', 1, type=int) languages = Language.query.all() - subs = Classes.query.filter_by(user_id=current_user.id) lijst = [] - for sub in subs: - lijst.append(sub.language_id) - return render_template('home.html', languages=languages, subs=lijst, subscribed="subscribed") + if current_user.is_authenticated: + subs = Classes.query.filter_by(user_id=current_user.id) + lijst = [sub.language_id for sub in subs] + return render_template('index.html', calendar=calendar, languages=languages, subs=lijst, subscribed="subscribed") @app.route("/about") @@ -118,7 +117,8 @@ def new_post(): @app.route("/admin") def admin(): languages = Language.query.all() - return render_template('admin.html', title = 'Administration Page', languages = languages) + return render_template('admin.html', calendar=calendar, title='Administration Page', languages=languages) + @app.route("/admin/update/<int:lang_id>", methods=['GET', 'POST']) def update_lang(lang_id): @@ -133,18 +133,21 @@ def update_lang(lang_id): elif request.method == 'GET': form.name.data = lang.name form.info.data = lang.info - return render_template('update_lang.html', form=form, legend='Update Language') + return render_template('update_lang.html', calendar=calendar, form=form, legend='Update Language') [email protected]("/course/<int:course_id>", methods=['GET', 'POST']) + [email protected]("/course/<int:course_id>", methods=['GET', 'POST']) def course(course_id): form = SubscribeForm() form2 = UnsubscribeForm() - subscription = Classes.query.filter_by(user_id=current_user.id, language_id=course_id).first() + subscription = Classes.query.filter_by( + user_id=current_user.id, language_id=course_id).first() show = True if subscription: show = False if form.validate_on_submit() and show == True: - course = Classes(user_id = current_user.id, language_id = course_id, teacher_id = 1, location = "hier") + course = Classes(user_id=current_user.id, + language_id=course_id, teacher_id=1, location="hier") db.session.add(course) db.session.commit() flash('You have subscribed to this course!', 'success') @@ -155,7 +158,8 @@ def course(course_id): flash('You been have Unsubscribed to this course!', 'success') return redirect(url_for('account')) course = Language.query.get_or_404(course_id) - return render_template('course.html', title=course.name, course=course, form=form, form2=form2, show=show) + return render_template('course.html', calendar=calendar, title=course.name, course=course, form=form, form2=form2, show=show) + @app.route("/course/<int:post_id>/update", methods=['GET', 'POST']) @login_required diff --git a/pgmles/site.db b/pgmles/site.db Binary files differ.