Commit 052b5592 authored by Nicolas Gelot's avatar Nicolas Gelot

Fix first page render

This pathc fixes the render of the first page. This one have to display
general results plus a sample of 5 images and 2 videos.

Previously, torrent and videos results were included.

This change is related to the comment https://gitlab.e.foundation/e/cloud/my-spot/issues/30#note_10233
parent a35c0ff1
......@@ -510,16 +510,10 @@ def index():
results_copy = copy.deepcopy(search_data.results)
if is_general_first_page:
for res in results_copy:
if res.get('category') == 'images':
if len(images) < 5:
images.append(res)
results_copy.remove(res)
elif res.get('category') == 'videos':
if len(videos) < 2:
videos.append(res)
results_copy.remove(res)
elif res.get('category') is None:
images = [r for r in results_copy if r.get('category') == 'images'][:5]
videos = [r for r in results_copy if r.get('category') == 'videos'][:2]
for res in search_data.results:
if res.get('category') != 'general':
results_copy.remove(res)
# output
......
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