Update link component

This commit is contained in:
Andros Fenollosa 2021-11-21 09:34:54 +01:00
parent 528b623acd
commit 9845ba5c51
8 changed files with 29 additions and 22 deletions

1
TODO
View File

@ -1,2 +1 @@
- List profiles with talks
- Chat - Chat

View File

@ -50,10 +50,11 @@ class WebsiteConsumer(AsyncWebsocketConsumer):
# Single talk # Single talk
if data["value"] == "single-talk": if data["value"] == "single-talk":
await self.channel_layer.group_send( await self.channel_layer.group_send(
self.room_group_name, { self.room_group_name,
{
"type": "send_page_single_talk", "type": "send_page_single_talk",
"id": data["id"], "id": data["id"],
} },
) )
# Profiles # Profiles
if data["value"] == "profiles": if data["value"] == "profiles":
@ -70,10 +71,11 @@ class WebsiteConsumer(AsyncWebsocketConsumer):
# Search # Search
if data["value"] == "search-talks": if data["value"] == "search-talks":
await self.channel_layer.group_send( await self.channel_layer.group_send(
self.room_group_name, { self.room_group_name,
{
"type": "send_page_search", "type": "send_page_search",
"search": data["search"], "search": data["search"],
} },
) )
# Pages # Pages

View File

@ -6,6 +6,9 @@
{% if page %} {% if page %}
<input type="hidden" name="page" value="{{ page }}"> <input type="hidden" name="page" value="{{ page }}">
{% endif %} {% endif %}
{% if id %}
<input type="hidden" name="id" value="{{ id }}">
{% endif %}
{# Button #} {# Button #}
<button class="link__button" type="button" hx-ws="send" hx-trigger="click">{{ text }}</button> <a class="link__button" type="button" hx-ws="send" hx-trigger="click">{{ children }}</a>
</form> </form>

View File

@ -30,15 +30,15 @@
<ul> <ul>
<li> <li>
{# To page Talks #} {# To page Talks #}
{% #link text="Talks" action="page" value="talks" scroll-up="true" %}{% /link %} {% #link action="page" value="talks" scroll-up="true" %}Talks{% /link %}
</li> </li>
<li> <li>
{# To page Profiles #} {# To page Profiles #}
{% #link text="Profiles" action="page" value="profiles" scroll-up="true" %}{% /link %} {% #link action="page" value="profiles" scroll-up="true" %}Profiles{% /link %}
</li> </li>
<li> <li>
{# To page About #} {# To page About #}
{% #link text="About" action="page" value="about" scroll-up="true" %}{% /link %} {% #link action="page" value="about" scroll-up="true" %}About{% /link %}
</li> </li>
</ul> </ul>
</nav> </nav>

View File

@ -1,4 +1,5 @@
{% load static %} {% load static %}
{% load slippers %}
<main id="main" data-scroll-to-top="true"> <main id="main" data-scroll-to-top="true">
{# List Profiles #} {# List Profiles #}
<div style="display: flex; flex-wrap: wrap; justify-content: space-between; "> <div style="display: flex; flex-wrap: wrap; justify-content: space-between; ">
@ -9,14 +10,15 @@
{{ profile.full_name }} {{ profile.full_name }}
</h2> </h2>
<p> <p>
{# <img src="{{ profile.avatar.url }}" alt="{{ profile.full_name }}"> #} <img src="{{ profile.avatar.url }}" alt="{{ profile.full_name }}">
</p> </p>
</header> </header>
<h3>Talks</h3> <h3>Talks</h3>
<ul> <ul>
{% for talk in profile.talkspeaker.all %} {% for talk in profile.talkspeaker.all %}
<li> <li>
{{ talk.title }}
{% #link action="page" value="single-talk" id=talk.id scroll-up="true" %}{{ talk.title }}{% /link %}
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -13,6 +13,6 @@
<footer>Author {{ talk.author.full_name }} - {{ talk.category.name }}</footer> <footer>Author {{ talk.author.full_name }} - {{ talk.category.name }}</footer>
</article> </article>
<p> <p>
{% #link text="Back" action="page" value="talks" page=1 %}{% /link %} {% #link action="page" value="talks" page=1 %}More talks{% /link %}
</p> </p>
</main> </main>

View File

@ -23,10 +23,7 @@
{% if talks %} {% if talks %}
{% for talk in talks %} {% for talk in talks %}
<form> <form>
<input type="hidden" name="action" value="page"> {% #link action="page" value="single-talk" id=talk.id %}
<input type="hidden" name="value" value="single-talk">
<input type="hidden" name="id" value="{{ talk.id }}">
<a href="#" hx-ws="send" hx-trigger="click">
<article> <article>
<header> <header>
<div class="grid"> <div class="grid">
@ -41,7 +38,7 @@
</p> </p>
<footer>Author {{ talk.author.full_name }} - {{ talk.category.name }}</footer> <footer>Author {{ talk.author.full_name }} - {{ talk.category.name }}</footer>
</article> </article>
</a> {% /link %}
</form> </form>
{% endfor %} {% endfor %}
{% else %} {% else %}

View File

@ -40,11 +40,15 @@ def page_single_talk(id):
}, },
) )
def page_profiles(): def page_profiles():
return render_to_string( return render_to_string(
"pages/profiles.html", "pages/profiles.html",
{ {
"profiles": Profile.objects.filter(talkspeaker__isnull=False).order_by("full_name").distinct().all(), "profiles": Profile.objects.filter(talkspeaker__isnull=False)
.order_by("full_name")
.distinct()
.all(),
}, },
) )
@ -57,9 +61,9 @@ def page_results(search):
return render_to_string( return render_to_string(
"pages/talks.html", "pages/talks.html",
{ {
"talks": Talk.objects.filter( "talks": Talk.objects.filter(title__icontains=search.lower()).order_by(
title__icontains=search.lower() "title"
).order_by("title"), ),
"search": search, "search": search,
}, },
) )