diff --git a/app/routes/search.py b/app/routes/search.py index ec8cd83..48a47b9 100644 --- a/app/routes/search.py +++ b/app/routes/search.py @@ -6,7 +6,7 @@ from app.models.topic import Topic from app.models.forum import Forum from app.models.program import Program from app.utils.render import render -from sqlalchemy import text, func +from sqlalchemy import text, func, Date from flask import request from flask_sqlalchemy import Pagination @@ -59,6 +59,16 @@ def search(page=1): Comment.id, Post.id ) + if (form.date.data): + topic_query = topic_query.where( + Topic.date_created.cast(Date) == form.date.data + ) + program_query = program_query.where( + Program.date_created.cast(Date) == form.date.data + ) + comment_query = comment_query.where( + Comment.date_created.cast(Date) == form.date.data + ) if (form.sortBy.data == "Date croissante"): topic_query = topic_query.order_by( Topic.date_created.asc()