added events details with reviews
This commit is contained in:
@@ -7,7 +7,7 @@ from manage_events.forms import (
|
||||
VenueForm,
|
||||
)
|
||||
from django.core.paginator import Paginator
|
||||
from .models import EventMaster, Event, EventCategory, Venue
|
||||
from .models import EventMaster, Event, EventCategory, EventPrincipalInteraction, Venue
|
||||
from django.views import generic
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.urls import reverse_lazy
|
||||
@@ -322,13 +322,34 @@ class EventView(LoginRequiredMixin, generic.ListView):
|
||||
|
||||
|
||||
class EventDetailView(generic.DetailView):
|
||||
page_name = resource_action.RESOURCE_MANAGE_EVENTS
|
||||
resource = resource_action.RESOURCE_MANAGE_EVENTS
|
||||
action = resource_action.ACTION_READ
|
||||
model = Event
|
||||
template_name = "manage_events/event_details.html"
|
||||
context_object_name = "event"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
# Add additional context if necessary
|
||||
event_id = self.object.id # Get the current event's ID
|
||||
|
||||
# Separate count for interested and going
|
||||
interested_count = EventPrincipalInteraction.objects.filter(
|
||||
event_id=event_id, status="interested"
|
||||
).count()
|
||||
going_count = EventPrincipalInteraction.objects.filter(
|
||||
event_id=event_id, status="going"
|
||||
).count()
|
||||
|
||||
context["interested_count"] = interested_count
|
||||
context["going_count"] = going_count
|
||||
|
||||
# Reviews for the event
|
||||
context["reviews"] = self.object.reviews.all()
|
||||
|
||||
# Images of the event
|
||||
context["images"] = self.object.event_images.all()
|
||||
|
||||
return context
|
||||
|
||||
|
||||
|
||||
@@ -65,7 +65,45 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Optionally, add more sections/cards for additional event details such as organizer information, key guests, etc. -->
|
||||
<!-- Event Interaction Counts -->
|
||||
<div class="row mb-3">
|
||||
<div class="col">
|
||||
<div class="alert alert-info" role="alert">
|
||||
<strong>Interested:</strong> {{ interested_count }} | <strong>Going:</strong> {{ going_count }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Event Reviews -->
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Event Reviews</h5>
|
||||
{% for review in reviews %}
|
||||
<div class="border-bottom mb-2 pb-2">
|
||||
<p class="mb-1"><strong>{{ review.principal }}</strong> rated this event {{ review.rating }}/5</p>
|
||||
<p>{{ review.review_text }}</p>
|
||||
</div>
|
||||
{% empty %}
|
||||
<p>No reviews yet.</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Event Images -->
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Event Images</h5>
|
||||
<div class="row">
|
||||
{% for image in images %}
|
||||
<div class="col-md-4 mb-2">
|
||||
<img src="{{ image.image.url }}" class="img-fluid" alt="Event Image">
|
||||
</div>
|
||||
{% empty %}
|
||||
<p class="text-center w-100">No additional images for this event.</p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user