diff options
author | romangraef <roman.graef@gmail.com> | 2018-06-02 10:33:15 +0200 |
---|---|---|
committer | romangraef <roman.graef@gmail.com> | 2018-06-02 10:33:15 +0200 |
commit | 3dc96e8b31eeef876c89aadf26dbf1e5d3355e7f (patch) | |
tree | 57891d940b3121ca814ec37e04866ba42b6043ce | |
parent | 57a8d6c5abe24324fe21da405ecdb8632cdb8b33 (diff) | |
download | my-website-3dc96e8b31eeef876c89aadf26dbf1e5d3355e7f.tar.gz my-website-3dc96e8b31eeef876c89aadf26dbf1e5d3355e7f.tar.bz2 my-website-3dc96e8b31eeef876c89aadf26dbf1e5d3355e7f.zip |
Added featured projects
-rw-r--r-- | app.py | 18 | ||||
-rw-r--r-- | templates/gallery_all.html | 5 | ||||
-rw-r--r-- | templates/index.html | 1 |
3 files changed, 17 insertions, 7 deletions
@@ -36,7 +36,6 @@ def check_password(password) -> bool: @app.context_processor def inject(): return { - 'projects': from_json(db.all(), List[Project]), 'empty_project': Project(), 'admin': session.get('logged_in', False), 'no_login': False, @@ -83,6 +82,11 @@ def find_project(name) -> Document: return matches[0] +@app.route('/projects/') +def list_all_projects(): + return render_template("gallery_all.html", projects=from_json(db.all(), List[Project])) + + @app.route('/projects/new/') @require_admin() def new_project_form(): @@ -92,9 +96,8 @@ def new_project_form(): @app.route('/projects/new/', methods=['POST']) @require_admin() def new_project(): - id = request.form.get('id') - Q = Query() - matches = db.search(Q.id == id.lower()) + post_id = request.form.get('id') + matches = db.search(Query().id == post_id.lower()) if len(matches) != 0: abort(400) name = request.form.get('name') @@ -103,12 +106,13 @@ def new_project(): link = request.form.get('link') db.insert({ 'name': name, - 'id': id, + 'id': post_id, 'summary': summary, 'description': description, 'link': link, + 'featured': 0, }) - return redirect(url_for('projects', project_name=id)) + return redirect(url_for('projects', project_name=post_id)) @app.route('/projects/<project_name>/edit/', methods=['GET']) @@ -154,7 +158,7 @@ def delete_project_confirm(project_name): @app.route('/') def index(): - return render_template('index.html') + return render_template('index.html', projects=from_json(db.search(Query().featured == 1), List[Project])) app.secret_key = os.environ.get('app_secret', '') diff --git a/templates/gallery_all.html b/templates/gallery_all.html new file mode 100644 index 0000000..d6cc8f4 --- /dev/null +++ b/templates/gallery_all.html @@ -0,0 +1,5 @@ +{% extends "base.html" %} +{% block body %} + <h1>Projects</h1> + {% include "gallery.html" %} +{% endblock %}
\ No newline at end of file diff --git a/templates/index.html b/templates/index.html index 27b3232..1d0d753 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,6 +7,7 @@ <p>As long as it is not webdesign, I will program nearly anything for you</p> <div class="spacer"></div> <h1>Projects</h1> + <p><a href="{{ url_for('list_all_projects') }}">All projects</a> </p> {% include "gallery.html" %} {% endblock %} {% block title %} |