def get_context_data(self, **kwargs): context = {} context.update(kwargs) future_meetings = Meeting.objects.filter( when__gt=datetime.datetime.now() - datetime.timedelta(hours=24)) if future_meetings.count() == 0: context['next_meeting'] = False else: next_meeting = future_meetings.order_by('when')[0] next_meeting.topics_list = list() for topic in next_meeting.topics.filter( approved=True).order_by('start_time'): topic.minutes = topic.length.seconds / 60 next_meeting.topics_list.append(topic) context['next_meeting'] = next_meeting # Check if user and get rsvp if self.request.user.is_authenticated(): # Is there already an RSVP if RSVP.objects.filter(meeting=next_meeting, user=self.request.user).exists(): context['rsvp'] = RSVP.objects.get(meeting=next_meeting, user=self.request.user) else: context['rsvp'] = None context["general_sponsors"] = GeneralSponsor.objects.all( ).order_by('sponsor__name') context['rsvp_form'] = RSVPForm(self.request) return context
def get_context_data(self, **kwargs): context = super(MeetingDetail, self).get_context_data(**kwargs) context.update(kwargs) if self.request.user.is_authenticated(): context['rsvp_form'] = RSVPForm(self.request) else: context['rsvp_form'] = AnonymousRSVPForm(self.request) return context
def get_context_data(self, **kwargs): context = {} context.update(kwargs) # get upcoming main meeting future_meetings = Meeting.objects.filter( meeting_type__isnull=True).filter( when__gt=datetime.datetime.now() - datetime.timedelta(hours=24)) # get next 3 non-main meetings other_meetings = Meeting.objects.filter( meeting_type__isnull=False).filter( when__gt=datetime.datetime.now() - datetime.timedelta(hours=24) ).order_by('when')[:3] context['other_meetings'] = other_meetings context["general_sponsors"] = GeneralSponsor.objects.all( ).order_by('?') if future_meetings.count() == 0: context['next_meeting'] = False else: next_meeting = future_meetings.order_by('when')[0] context['next_meeting'] = next_meeting # Check if user and get rsvp if self.request.user.is_authenticated(): # Is there already an RSVP if RSVP.objects.filter( meeting=next_meeting, user=self.request.user).exists(): context['rsvp'] = RSVP.objects.get( meeting=next_meeting, user=self.request.user) else: context['rsvp'] = None context['rsvp_form'] = RSVPForm(self.request) else: context['rsvp_form'] = AnonymousRSVPForm(self.request) try: context['announcement'] = Announcement.objects.all().order_by('-created')[0] except IndexError: context['announcement'] = None return context