mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-19 15:25:51 +00:00
refactor home view to view_config dict
This commit is contained in:
parent
bb909d866c
commit
d4e266f9c0
@ -44,7 +44,7 @@ class HomeView(View):
|
|||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""return home search results"""
|
"""return home search results"""
|
||||||
colors, view_style, sort_order, hide_watched = self.read_config()
|
view_config = self.read_config()
|
||||||
# handle search
|
# handle search
|
||||||
search_get = request.GET.get("search", False)
|
search_get = request.GET.get("search", False)
|
||||||
if search_get:
|
if search_get:
|
||||||
@ -56,9 +56,11 @@ class HomeView(View):
|
|||||||
pagination_handler = Pagination(page_get, search_encoded)
|
pagination_handler = Pagination(page_get, search_encoded)
|
||||||
|
|
||||||
url = self.ES_URL + "/ta_video/_search"
|
url = self.ES_URL + "/ta_video/_search"
|
||||||
|
|
||||||
data = self.build_data(
|
data = self.build_data(
|
||||||
pagination_handler, sort_order, search_get, hide_watched
|
pagination_handler,
|
||||||
|
view_config["sort_order"],
|
||||||
|
search_get,
|
||||||
|
view_config["hide_watched"],
|
||||||
)
|
)
|
||||||
|
|
||||||
search = SearchHandler(url, data)
|
search = SearchHandler(url, data)
|
||||||
@ -68,10 +70,10 @@ class HomeView(View):
|
|||||||
context = {
|
context = {
|
||||||
"videos": videos_hits,
|
"videos": videos_hits,
|
||||||
"pagination": pagination_handler.pagination,
|
"pagination": pagination_handler.pagination,
|
||||||
"sortorder": sort_order,
|
"sortorder": view_config["sort_order"],
|
||||||
"hide_watched": hide_watched,
|
"hide_watched": view_config["hide_watched"],
|
||||||
"colors": colors,
|
"colors": view_config["colors"],
|
||||||
"view_style": view_style,
|
"view_style": view_config["view_style"],
|
||||||
}
|
}
|
||||||
return render(request, "home/home.html", context)
|
return render(request, "home/home.html", context)
|
||||||
|
|
||||||
@ -119,7 +121,13 @@ class HomeView(View):
|
|||||||
if not sort_order:
|
if not sort_order:
|
||||||
sort_order = "published"
|
sort_order = "published"
|
||||||
hide_watched = RedisArchivist().get_message("hide_watched")
|
hide_watched = RedisArchivist().get_message("hide_watched")
|
||||||
return colors, view_style, sort_order, hide_watched
|
view_config = {
|
||||||
|
"colors": colors,
|
||||||
|
"view_style": view_style,
|
||||||
|
"sort_order": sort_order,
|
||||||
|
"hide_watched": hide_watched,
|
||||||
|
}
|
||||||
|
return view_config
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post(request):
|
def post(request):
|
||||||
|
Loading…
Reference in New Issue
Block a user