diff --git a/tubearchivist/home/templates/home/downloads.html b/tubearchivist/home/templates/home/downloads.html index 740e5a8..10daac9 100644 --- a/tubearchivist/home/templates/home/downloads.html +++ b/tubearchivist/home/templates/home/downloads.html @@ -56,8 +56,8 @@

Total videos: {{ max_hits }}

- {% if all_video_hits %} - {% for video in all_video_hits %} + {% if results %} + {% for video in results %}
video_thumb diff --git a/tubearchivist/home/templates/home/home.html b/tubearchivist/home/templates/home/home.html index 28818ab..6291c03 100644 --- a/tubearchivist/home/templates/home/home.html +++ b/tubearchivist/home/templates/home/home.html @@ -59,8 +59,8 @@
- {% if videos %} - {% for video in videos %} + {% if results %} + {% for video in results %}
diff --git a/tubearchivist/home/views.py b/tubearchivist/home/views.py index 27300de..2e4250c 100644 --- a/tubearchivist/home/views.py +++ b/tubearchivist/home/views.py @@ -149,8 +149,9 @@ class ArchivistResultsView(ArchivistViewConfig): } self.data = data - def initiate_vars(self, page_get, search_get=False): + def initiate_vars(self, page_get, user_id, search_get=False): """search in es for vidoe hits""" + self.user_id = user_id self.config_builder(self.user_id) self.search_get = search_get self.pagination_handler = Pagination( @@ -159,15 +160,14 @@ class ArchivistResultsView(ArchivistViewConfig): self.sort_by = self._sort_by_overwrite() self._initial_data() - def find_video_hits(self): - """return videos list""" + def find_results(self): + """add results and pagination to context""" url = self.default_conf["application"]["es_url"] + self.es_search search = SearchHandler(url, self.data) - videos_hits = search.get_data() + self.context["results"] = search.get_data() self.pagination_handler.validate(search.max_hits) self.context["max_hits"] = search.max_hits - - return videos_hits + self.context["pagination"] = self.pagination_handler.pagination class HomeView(ArchivistResultsView): @@ -184,17 +184,11 @@ class HomeView(ArchivistResultsView): page_get = int(request.GET.get("page", 0)) search_get = request.GET.get("search", False) - self.config_builder(user_id) - self.initiate_vars(page_get, search_get) + self.initiate_vars(page_get, user_id, search_get) self._update_view_data() + self.find_results() - self.context.update( - { - "search_form": VideoSearchForm(), - "videos": self.find_video_hits(), - "pagination": self.pagination_handler.pagination, - } - ) + self.context.update({"search_form": VideoSearchForm()}) return render(request, "home/home.html", self.context) @@ -288,16 +282,14 @@ class DownloadView(ArchivistResultsView): user_id = request.user.id page_get = int(request.GET.get("page", 0)) - self.config_builder(user_id) - self.initiate_vars(page_get) + self.initiate_vars(page_get, user_id) self._update_view_data() + self.find_results() self.context.update( { "title": "Downloads", "add_form": AddToQueueForm(), - "all_video_hits": self.find_video_hits(), - "pagination": self.pagination_handler.pagination, } ) return render(request, "home/downloads.html", self.context)