search: Get publish date selector working
This commit is contained in:
parent
0c3fa843d8
commit
4a23aee7d9
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue