Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Nov 21, 2024
1 parent 0a70301 commit 832b1e8
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lacommunaute/forum_conversation/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def unanswered(self):
.exclude(status=Topic.TOPIC_LOCKED)
.exclude(type=Topic.TOPIC_ANNOUNCE)
.filter(posts_count=1)
.select_related(
"forum",
"poster",
"poster__forum_profile",
"first_post",
"first_post__poster",)
.order_by("-last_post_on")
)

def optimized_for_topics_list(self, user_id):
Expand Down
4 changes: 4 additions & 0 deletions lacommunaute/pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from lacommunaute.event.models import Event
from lacommunaute.forum.models import Forum
from lacommunaute.forum_conversation.forms import PostForm
from lacommunaute.forum_conversation.models import Topic


logger = logging.getLogger(__name__)
Expand All @@ -28,6 +30,8 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context["forums_category"] = Forum.objects.filter(parent__type=1).order_by("-updated")[:4]
context["forum"] = Forum.objects.get_main_forum()
context["upcoming_events"] = Event.objects.filter(date__gte=timezone.now()).order_by("date")[:4]
context["unanswered_topics"] = Topic.objects.unanswered()[:4]
context["form"] = PostForm(user=self.request.user)
return context


Expand Down
62 changes: 62 additions & 0 deletions lacommunaute/templates/forum_conversation/topic_simple_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{% load i18n %}
<div id="topicsarea">
{% if topics or not hide_if_empty %}
<hr>
{% for topic in topics %}
<div class="row">
<div class="col-12">
<div id="{{ topic.pk }}" class="post mb-3">
<div class="mb-1 d-flex flex-column flex-md-row align-items-md-center">
<p class="h4 mb-0 flex-grow-1">
<a href="{% url 'forum_conversation:topic' topic.forum.slug topic.forum.pk topic.slug topic.pk %}"
class="matomo-event"
data-matomo-category="engagement"
data-matomo-action="view"
data-matomo-option="topic">{{ topic.subject }}</a>
</p>
</div>
<div class="pt-0">
<div class="row">
<div class="col-12 post-content-wrapper mb-1">
{% include "forum_conversation/partials/poster.html" with post=topic.first_post topic=topic is_topic_head=True forum=forum %}
</div>
<div class="col-12 post-content">
<div id="showmoretopicsarea{{ topic.pk }}">
{% include 'partials/rendered_md.html' with content=topic.first_post.content truncatechars=1 only %}
{% if topic.first_post.content.rendered|length > 200 %}
<a hx-get="{% url 'forum_conversation_extension:showmore_topic' topic.forum.slug topic.forum.pk topic.slug topic.pk %}"
id="showmoretopic-button{{ topic.pk }}"
hx-target="#showmoretopicsarea{{ topic.pk }}"
hx-swap="outerHTML"
class="btn btn-link p-0 mh-auto matomo-event"
data-matomo-category="engagement"
data-matomo-action="showmore"
data-matomo-option="topic">{% trans "+ show more" %}</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
<div id="showmorepostsarea{{ topic.pk }}">
<div id="postinfeedarea{{ topic.pk }}">
{% include "forum_conversation/partials/post_feed_form_collapsable.html" with post_form=form %}
</div>
</div>
</div>
</div>
<div class="row align-items-sm-center mb-3">
<div class="col-12 col-sm">
{% include "forum_conversation/partials/topic_detail_actions.html" with posts_count=topic.posts_count %}
</div>
</div>
<hr>
{% endfor %}
{% endif %}
</div>
<script nonce="{{ request.csp_nonce }}">
var showmorepostsButtons = document.querySelectorAll('.showmoreposts-button')
showmorepostsButtons.forEach((button) => button.addEventListener('click', function() {
button.classList.add('d-none');
}));
</script>
14 changes: 14 additions & 0 deletions lacommunaute/templates/pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,20 @@ <h1 class="h1-hero">L’espace d’entraide des professionnels de l’inclusion<
</div>
</div>
</section>
{% if unanswered_topics %}
<section class="s-section mt-0">
<div class="s-section__container container">
<div class="s-section__row row">
<div class="s-section__col col-12">
<p class="h1 text-tertiary">Des professionnels ont besoin de votre aide !</p>
{% with topics=unanswered_topics %}
{% include "forum_conversation/topic_simple_list.html" with active_tag=active_tag %}
{% endwith %}
</div>
</div>
</div>
</section>
{% endif %}
<section class="s-section my-5 my-md-10">
<div class="s-section__container container container-max-lg">
<div class="s-section__row row">
Expand Down

0 comments on commit 832b1e8

Please sign in to comment.