mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-25 13:10:15 +00:00
consolidate request attributes into parent class
This commit is contained in:
parent
4c46f0bdbd
commit
386220ee94
@ -162,13 +162,15 @@ class ArchivistResultsView(ArchivistViewConfig):
|
|||||||
result = search.get_data()[0]["source"]
|
result = search.get_data()[0]["source"]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def initiate_vars(self, page_get, user_id, search_get=False):
|
def initiate_vars(self, request):
|
||||||
"""search in es for vidoe hits"""
|
"""search in es for vidoe hits"""
|
||||||
self.user_id = user_id
|
page_get = int(request.GET.get("page", 0))
|
||||||
|
self.user_id = request.user.id
|
||||||
self.config_builder(self.user_id)
|
self.config_builder(self.user_id)
|
||||||
self.search_get = search_get
|
self.search_get = request.GET.get("search", False)
|
||||||
|
search_encoded = self._url_encode(self.search_get)
|
||||||
self.pagination_handler = Pagination(
|
self.pagination_handler = Pagination(
|
||||||
page_get, self.user_id, search_get=self._url_encode(search_get)
|
page_get=page_get, user_id=self.user_id, search_get=search_encoded
|
||||||
)
|
)
|
||||||
self.sort_by = self._sort_by_overwrite()
|
self.sort_by = self._sort_by_overwrite()
|
||||||
self._initial_data()
|
self._initial_data()
|
||||||
@ -193,14 +195,9 @@ class HomeView(ArchivistResultsView):
|
|||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""handle get requests"""
|
"""handle get requests"""
|
||||||
user_id = request.user.id
|
self.initiate_vars(request)
|
||||||
page_get = int(request.GET.get("page", 0))
|
|
||||||
search_get = request.GET.get("search", False)
|
|
||||||
|
|
||||||
self.initiate_vars(page_get, user_id, search_get)
|
|
||||||
self._update_view_data()
|
self._update_view_data()
|
||||||
self.find_results()
|
self.find_results()
|
||||||
|
|
||||||
self.context.update({"search_form": VideoSearchForm()})
|
self.context.update({"search_form": VideoSearchForm()})
|
||||||
|
|
||||||
return render(request, "home/home.html", self.context)
|
return render(request, "home/home.html", self.context)
|
||||||
@ -292,13 +289,9 @@ class DownloadView(ArchivistResultsView):
|
|||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""handle get request"""
|
"""handle get request"""
|
||||||
user_id = request.user.id
|
self.initiate_vars(request)
|
||||||
page_get = int(request.GET.get("page", 0))
|
|
||||||
|
|
||||||
self.initiate_vars(page_get, user_id)
|
|
||||||
self._update_view_data()
|
self._update_view_data()
|
||||||
self.find_results()
|
self.find_results()
|
||||||
|
|
||||||
self.context.update(
|
self.context.update(
|
||||||
{
|
{
|
||||||
"title": "Downloads",
|
"title": "Downloads",
|
||||||
@ -358,9 +351,7 @@ class ChannelIdView(ArchivistResultsView):
|
|||||||
|
|
||||||
def get(self, request, channel_id):
|
def get(self, request, channel_id):
|
||||||
"""get request"""
|
"""get request"""
|
||||||
user_id = request.user.id
|
self.initiate_vars(request)
|
||||||
page_get = int(request.GET.get("page", 0))
|
|
||||||
self.initiate_vars(page_get, user_id)
|
|
||||||
self._update_view_data(channel_id)
|
self._update_view_data(channel_id)
|
||||||
self.find_results()
|
self.find_results()
|
||||||
|
|
||||||
@ -410,10 +401,7 @@ class ChannelView(ArchivistResultsView):
|
|||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""handle get request"""
|
"""handle get request"""
|
||||||
user_id = request.user.id
|
self.initiate_vars(request)
|
||||||
page_get = int(request.GET.get("page", 0))
|
|
||||||
|
|
||||||
self.initiate_vars(page_get, user_id)
|
|
||||||
self._update_view_data()
|
self._update_view_data()
|
||||||
self.find_results()
|
self.find_results()
|
||||||
self.context.update(
|
self.context.update(
|
||||||
@ -464,13 +452,9 @@ class PlaylistIdView(ArchivistResultsView):
|
|||||||
|
|
||||||
def get(self, request, playlist_id):
|
def get(self, request, playlist_id):
|
||||||
"""handle get request"""
|
"""handle get request"""
|
||||||
user_id = request.user.id
|
self.initiate_vars(request)
|
||||||
page_get = int(request.GET.get("page", 0))
|
|
||||||
self.initiate_vars(page_get, user_id)
|
|
||||||
|
|
||||||
playlist_info, channel_info = self._get_info(playlist_id)
|
playlist_info, channel_info = self._get_info(playlist_id)
|
||||||
playlist_name = playlist_info["playlist_name"]
|
playlist_name = playlist_info["playlist_name"]
|
||||||
|
|
||||||
self._update_view_data(playlist_id, playlist_info)
|
self._update_view_data(playlist_id, playlist_info)
|
||||||
self.find_results()
|
self.find_results()
|
||||||
self.context.update(
|
self.context.update(
|
||||||
@ -544,11 +528,7 @@ class PlaylistView(ArchivistResultsView):
|
|||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
"""handle get request"""
|
"""handle get request"""
|
||||||
user_id = request.user.id
|
self.initiate_vars(request)
|
||||||
page_get = int(request.GET.get("page", 0))
|
|
||||||
search_get = request.GET.get("search", False)
|
|
||||||
|
|
||||||
self.initiate_vars(page_get, user_id, search_get)
|
|
||||||
self._update_view_data()
|
self._update_view_data()
|
||||||
self.find_results()
|
self.find_results()
|
||||||
self.context.update(
|
self.context.update(
|
||||||
|
Loading…
Reference in New Issue
Block a user