diff --git a/TODO b/TODO index 25ec61b..0e635c9 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,3 @@ -- Template base -- change about -- Single talk. \ No newline at end of file +- Single talk. +- List profiles +- Chat \ No newline at end of file diff --git a/app/website/consumers.py b/app/website/consumers.py index 4f53464..6b6f025 100644 --- a/app/website/consumers.py +++ b/app/website/consumers.py @@ -20,7 +20,8 @@ class WebsiteConsumer(AsyncWebsocketConsumer): await self.channel_layer.group_send( self.room_group_name, { - "type": "send_page_talks" + "type": "send_page_talks", + "page": 1, } ) @@ -36,10 +37,14 @@ class WebsiteConsumer(AsyncWebsocketConsumer): if data["action"] == "page": # Talks if data["value"] == "talks": + page = 1 + if "page" in data: + page = int(data["page"]) await self.channel_layer.group_send( self.room_group_name, { - "type": "send_page_talks" + "type": "send_page_talks", + "page": page, } ) # About @@ -53,12 +58,12 @@ class WebsiteConsumer(AsyncWebsocketConsumer): # Pages - def _get_talks(self): - return page_talks() + def _get_talks(self, page): + return page_talks(page=page) async def send_page_talks(self, event): ''' Send Home page ''' - html = await sync_to_async(self._get_talks)() + html = await sync_to_async(self._get_talks)(event["page"]) await self.send(text_data=html) def _get_about(self): diff --git a/app/website/templates/pages/talks.html b/app/website/templates/pages/talks.html index c7d22e2..5a8e27f 100644 --- a/app/website/templates/pages/talks.html +++ b/app/website/templates/pages/talks.html @@ -17,4 +17,13 @@ {% endfor %} + {# Pagination #} +
+
+ + + +

Show more

+
+
diff --git a/app/website/views.py b/app/website/views.py index b44a262..eb6d614 100644 --- a/app/website/views.py +++ b/app/website/views.py @@ -14,9 +14,13 @@ def index(request): }) -def page_talks(): - return render_to_string("pages/talks.html", { - "talks": Talk.objects.order_by("title")[:5] +def page_talks(page=1): + TALK_PER_PAGE = 5 + return render_to_string("pages/talks.html", + { + "talks": Talk.objects.order_by("title")[:TALK_PER_PAGE * page], + "page": page, + "next_page": page + 1, })