Merge pull request #80 from WDI-Ideas/feature/module_8_socialmedia

fix(socialmedia):allowed only active event to publish on social media
This commit is contained in:
BOBBY VISHWAKARMA
2024-08-07 23:54:50 +05:30
committed by GitHub
2 changed files with 11 additions and 6 deletions

View File

@@ -17,6 +17,7 @@ from django.urls import reverse_lazy
from django.contrib import messages
from goodtimes import constants
from django.contrib.auth import get_user_model
from datetime import date
# Create your views here.
@@ -362,24 +363,26 @@ class EventDetailView(generic.DetailView):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["page_name"] = self.page_name
event_id = self.object.id # Get the current event's ID
event = self.object # Get the current event's ID
# Separate count for interested and going
interested_count = EventPrincipalInteraction.objects.filter(
event_id=event_id, status="interested"
event=event, status="interested"
).count()
going_count = EventPrincipalInteraction.objects.filter(
event_id=event_id, status="going"
event=event, status="going"
).count()
context["interested_count"] = interested_count
context["going_count"] = going_count
today = date.today()
context["publish"] = not event.draft and event.active and event.end_date >= today
# Reviews for the event
context["reviews"] = self.object.reviews.all()
context["reviews"] = event.reviews.all()
# Images of the event
context["images"] = self.object.event_images.all()
context["images"] = event.event_images.all()
return context

View File

@@ -62,7 +62,7 @@
</div>
<div class="row">
<div class="col-md-8">
<div class="col-md-{{ publish|yesno:'8,12' }}">
<div class="card mb-3" style="border-radius: 20px; box-shadow: 0 4px 8px rgba(0,0,0,.1);">
<div class="card-body">
<h2 class="card-title">{{ event.brand.title }}</h2>
@@ -72,6 +72,7 @@
</div>
</div>
</div>
{% if publish %}
<div class="col-md-4">
<div class="card mb-3" style="border-radius: 20px; box-shadow: 0 4px 8px rgba(0,0,0,.1);">
<div class="card-body">
@@ -92,6 +93,7 @@
</div>
</div>
</div>
{% endif %}
</div>