Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Upcoming events to tech group page. #134

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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