commit d852d0b63359c232dd8b569778216a31b47bc8fd
parent fa18f72f5a8091409f5c7ae5c28b9af5d685b015
Author: xd <[email protected]>
Date: Mon, 4 Apr 2022 15:14:30 +0200
begin met sign up for course
Diffstat:
4 files changed, 23 insertions(+), 46 deletions(-)
diff --git a/flaskblog/routes.py b/flaskblog/routes.py
@@ -102,10 +102,10 @@ def new_post():
return render_template('create_post.html', title='New Post',
form=form, legend='New Post')
[email protected]("/post/<int:post_id>")
-def post(post_id):
- #post = Post.query.get_or_404(post_id)
- return render_template('post.html', title=post.title, post=post)
[email protected]("/course/<int:course_id>")
+def course(course_id):
+ course = Language.query.get_or_404(course_id)
+ return render_template('course.html', title=course.name, course=course)
@app.route("/post/<int:post_id>/update", methods=['GET', 'POST'])
@login_required
diff --git a/flaskblog/templates/course.html b/flaskblog/templates/course.html
@@ -0,0 +1,18 @@
+{% extends "layout.html" %}
+{% block content %}
+ <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>
+ <p class="article-content">{{ course.info }}</p>
+ </div>
+ <div class="article-metadata">
+ {% if current_user.is_authenticated %}
+ <div>
+ <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{{url_for('course', course_id=course.id)}}">Sign Up</a>
+ </div>
+ {% else %}
+ <p> Please Log in to subscribe to course</p>
+ {% endif %}
+ </div>
+ </article>
+{% endblock content %}
diff --git a/flaskblog/templates/home.html b/flaskblog/templates/home.html
@@ -3,7 +3,7 @@
{% for language in languages %}
<article class="media content-section">
<div class="media-body">
- <h1>{{language.name}}</h1>
+ <h2><a class="article-title" href="{{url_for('course', course_id=language.id)}}">{{language.name}}</a></h2>
<p> {{language.info}}</p>
</div>
</article>
diff --git a/flaskblog/templates/post.html b/flaskblog/templates/post.html
@@ -1,41 +0,0 @@
-{% extends "layout.html" %}
-{% block content %}
- <article class="media content-section">
- <img class="rounded-circle article-img" src="{{ url_for('static', filename='profile_pics/' + post.author.image_file) }}">
- <div class="media-body">
- <div class="article-metadata">
- <a class="mr-2" href="{{ url_for('user_posts', username=post.author.username)}}">{{ post.author.username }}</a>
- <small class="text-muted">{{ post.date_posted.strftime('%Y-%m-%d') }}</small>
- {% if post.author == current_user %}
- <div>
- <a class="btn btn-secondary btn-sm mt-1 mb-1" href="{{ url_for('update_post', post_id=post.id)}}">Update</a>
- <button type="button" class="btn btn-danger btn-sm m-1" data-toggle="modal" data-target="#deletemodal">Delete</button>
- </div>
- {% endif %}
- </div>
- <h2 class="article-title">{{ post.title }}</h2>
- <p class="article-content">{{ post.content }}</p>
- </div>
- </article>
- <!-- Modal -->
- <div class="modal fade" id="deletemodal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title" id="deletemodal">Delete Post?</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="modal-body">
- Are you sure you want to delete this post?
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
- <form action="{{ url_for('delete_post', post_id=post.id) }}" method="POST">
- <input class="btn btn-danger" type="submit" value="Delete">
- </div>
- </div>
- </div>
- </div>
-{% endblock content %}