Commit 022769a4 authored by shadMod's avatar shadMod 💬

refactor list() to render view and to get year, month and category from a request GET

parent 554472fd
......@@ -17,6 +17,8 @@
import os
import flask
from flask import request
from ... import cache
from .utils import GetNews
......@@ -35,12 +37,16 @@ class News:
nw_cl = GetNews(os.path.join(app.instance_path, "news"))
@bp.route("/")
@bp.route("/<year>")
@cache.enable
def index(year: int = None):
def list():
req = request.args
month = req.get("month")
year = req.get("year")
category = req.get("category")
return flask.render_template(
"news/index.html",
news=nw_cl.list_news(year),
"news/list.html",
news=nw_cl.list_news(year=year, category=category, month=month),
list_years=nw_cl.list_year_month
)
@bp.route("/<year>/<filename>")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment