Skip to content

Commit

Permalink
Merge pull request #134 from KGB33/48-show-upcoming-events
Browse files Browse the repository at this point in the history
Add Upcoming events to tech group page.
  • Loading branch information
KGB33 authored Sep 2, 2024
2 parents 9221152 + 09f3dc3 commit 55fc86c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/web/templates/web/partials/detail_tech_group.htm
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,13 @@ <h3>Tags</h3>
Edit <i class="fa-solid fa-pen-to-square"></i>
</a>
{% endif %}

{% with upcoming_events=object.event_set.all %}
{% if upcoming_events %}
<h2>Upcoming Events:</h2>
<div class="mw-100">
{% include "web/partials/event_list.htm" with queryset=upcoming_events %}
</div>
{% endif %}
{% endwith %}
</div>
7 changes: 7 additions & 0 deletions src/web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.contrib import messages
from django.contrib.auth.mixins import UserPassesTestMixin
from django.db.models import Prefetch
from django.http import HttpRequest, HttpResponse
from django.shortcuts import redirect
from django.template import loader
Expand Down Expand Up @@ -163,6 +164,12 @@ def get_success_url(self) -> str:
class DetailTechGroup(HtmxViewMixin, DetailView):
model = TechGroup

def __init__(self, **kwargs: Any) -> None:
self.queryset = TechGroup.objects.prefetch_related(
Prefetch("event_set", Event.objects.filter(date_time__gte=timezone.localtime()))
)
super().__init__(**kwargs)

def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
user = self.request.user
Expand Down

0 comments on commit 55fc86c

Please sign in to comment.