def eventInfo(request, eventID): try: event = Event.objects.get(id=eventID) similarEvents = Event.objects.exclude(id=event.id).filter(club=event.club, startTime__gte=datetime(datetime.now().year, datetime.now().month, datetime.now().day)).order_by('startTime') try: rageObject = Rage.objects.get(event__id = event.id) except: # create a rage object if there is none rageObject = Rage(count=0,event=event) rageObject.save() return render_to_response('eventInfo.html',{'event':event,'rageObject':rageObject,'similarEvents':similarEvents},context_instance=RequestContext(request)) except: raise Http404
def registerRage(request): results = {'success':False} if(request.method == 'POST'): print request.POST POST = request.POST if POST['id']: try: existingRage = Rage.objects.get(event__id=POST['id']) existingRage.count += 1 existingRage.save() results['numberOfRagers'] = existingRage.count except: newRage = Rage(count=1,event=Event.objects.get(id=POST['id'])) newRage.save() results['numberOfRagers'] = 1 results['success'] = True json_results = simplejson.dumps(results) return HttpResponse(json_results, mimetype='application/json')