def events_admin(request): past = request.GET.get("past", False) inactive = request.GET.get("inactive", False) if past: events = Event.objects.all().order_by("-start_date") params = "past=1&" else: events = Event.objects.filter(end_date__gte = days_in_past(3)).order_by("-start_date") params = "past=&" if inactive: events = events.filter(active = False) params += "inactive=1&" else: events = events.all() params += "inactive=&" try: page = int(request.GET.get("page", 1)) except: page = 1 events = page_this(events, page, 8) return render(request, "trwibc_app/events_admin.html", {"events": events, "past": past, "inactive": inactive, "params": params})
def home(request): events = Event.objects.filter(active = True, end_date__gte = days_in_past(7)).order_by("start_date")[:5] if not events: try: events = Event.objects.filter(active = True).order_by("-start_date")[:1] except ObjectDoesNotExist: pass announcements = Announcement.objects.filter(active=True).order_by("-date")[:5] charities = Affiliate.objects.filter(type="charity", homepage=True) businesses = Affiliate.objects.filter(type="business", homepage=True) try: spotlight = Spotlight.objects.get(id=1) except ObjectDoesNotExist: spotlight = None return render(request, "trwibc_app/home.html", {"events": events, "announcements": announcements, "charities": charities, "businesses": businesses, "spotlight": spotlight,})
def events(request, event_id = False): if event_id: events = Event.objects.filter(active = True) event = get_object_or_404(events, id = event_id) return render(request, "trwibc_app/event_detail.html", {"event": event,}) past = request.GET.get("past", False) if past: events = Event.objects.filter(active = True).order_by("-start_date") params = "past=1" else: events = Event.objects.filter(active = True, end_date__gte = days_in_past(3)).order_by("-start_date") params = "past=" try: page = int(request.GET.get("page", 1)) except: page = 1 events = page_this(events, page, 8) return render(request, "trwibc_app/events.html", {"events": events, "past": past, "params": params})