diff --git a/lacommunaute/forum_conversation/models.py b/lacommunaute/forum_conversation/models.py index c0325e804..75838bba9 100644 --- a/lacommunaute/forum_conversation/models.py +++ b/lacommunaute/forum_conversation/models.py @@ -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): diff --git a/lacommunaute/pages/views.py b/lacommunaute/pages/views.py index 939eb5d0c..6ffb497b1 100644 --- a/lacommunaute/pages/views.py +++ b/lacommunaute/pages/views.py @@ -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__) @@ -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 diff --git a/lacommunaute/templates/forum_conversation/topic_simple_list.html b/lacommunaute/templates/forum_conversation/topic_simple_list.html new file mode 100644 index 000000000..03513d8b7 --- /dev/null +++ b/lacommunaute/templates/forum_conversation/topic_simple_list.html @@ -0,0 +1,62 @@ +{% load i18n %} +
Des professionnels ont besoin de votre aide !
+ {% with topics=unanswered_topics %} + {% include "forum_conversation/topic_simple_list.html" with active_tag=active_tag %} + {% endwith %} +