Example #1
0
def company_singular_greek(request, company):
	helper = RelayFunctions()

	cool = helper.company_greek_candles(company)

	response = json.dumps(cool)
	return HttpResponse(response, mimetype="application/json")
Example #2
0
def team_singular_general(request, team):
	helper = RelayFunctions()

	cool = helper.team_candles(team)

	response = json.dumps(cool)
	return HttpResponse(response, mimetype="application/json")
Example #3
0
def teams_all(request):
	helper = RelayFunctions()
	
	teams = []
	for team in Team.objects.all():
		teams.append(helper.teams_all(model_to_dict(team)['id']))
		
	response = json.dumps(teams)
	return HttpResponse(response, mimetype="application/json")
Example #4
0
def participant_unsigned(request):
	helper = RelayFunctions()
	
	participants = []
	for participant in Participant.objects.all():
		participants.append(helper.participants_unsigned(model_to_dict(participant)['id']))
		
	response = json.dumps(participants)
	return HttpResponse(response, mimetype="application/json")
Example #5
0
def all_company_corps_candles(request):
	helper = RelayFunctions()

	all_company_corps_candles = []

	for company in Company.objects.filter(company_type = 'CT'):
			all_company_corps_candles.append(helper.company_corps_candles(model_to_dict(company)['id']))

	response = json.dumps(all_company_corps_candles)
	return HttpResponse(response, mimetype="application/json")
Example #6
0
def all_candles(request):
	helper = RelayFunctions()

	all_candles_total = []

	for team in Team.objects.all():
			all_candles_total.append(helper.candles_total(model_to_dict(team)['id']))

	response = json.dumps(all_candles_total)
	return HttpResponse(response, mimetype="application/json")
Example #7
0
def counter_olympics_reg(request):
	helper = RelayFunctions()
	team_id = request.POST.get('id', '')
	counter = request.POST.get('signupCounter', '')
	signupCounter = counter.lower() in ("yes", "true", "t", "1")
	Olympics = request.POST.get('signupOlympics', '')
	signupOlympics = Olympics.lower() in ("yes", "true", "t", "1")
	tier = request.POST.get('tier', '')
	
	if tier == 'run':
		tier = 'RUN'
	else:
		tier = 'WALK'
		
	
	team_object = Team.objects.get(pk = team_id)
	team_id = team_object.pk
	company_object = Company.objects.get(team = team_object)
	captain_fname = model_to_dict(Team_Captain.objects.get(team = team_object))['fname']
	captain_lname = model_to_dict(Team_Captain.objects.get(team = team_object))['lname']
	captain_name = captain_fname + ' ' + captain_lname
	captain_email = model_to_dict(Team_Captain.objects.get(team = team_object))['email']

	try:
		new_Olympics_Lap_Counter_Signup = Olympics_Lap_Counter_Signup.objects.get(team = team_object)
	except Olympics_Lap_Counter_Signup.DoesNotExist:
		new_Olympics_Lap_Counter_Signup = Olympics_Lap_Counter_Signup(team = team_object, company = company_object, captain = captain_name, captain_email = captain_email, counter = signupCounter, olympics = signupOlympics, tier = tier, datetime = datetime.now())
		new_Olympics_Lap_Counter_Signup.save()

	for o in Olympics_Lap_Counter_Signup.objects.all():
		team_id = o.team.pk
		team_object = Team.objects.get(pk = team_id)
		try:
			new_counter = Counter.objects.get(team = team_object)
		except Counter.DoesNotExist:
			print('Creating new')
			b = 0
			for counter in Counter.objects.all():
				i = counter.strip_id
				if i > b:
					b = i
					number = b + 1
		
			counter_pledge_numbers = helper.counterTeam(team_id)
			pledge_amount = counter_pledge_numbers['pledge_amount']
			max_pledge_amount = counter_pledge_numbers['max_pledge_amount']
		
			new_counter = Counter(team = team_object, strip_id = number, tier = tier, pledge_amount = pledge_amount, max_pledge_amount = max_pledge_amount, laps_completed = int(0))
			new_counter.save()
		
	
	response = HttpResponse()
	response.content = serialized_obj = serializers.serialize('json', [ new_Olympics_Lap_Counter_Signup, ])
	response['Content-Type'] = 'application/json'
	return response
Example #8
0
def all_company_greek_candles(request):
	helper = RelayFunctions()

	all_company_greek_candles = []

	for company in Company.objects.filter(company_type = 'GT'):
			all_company_greek_candles.append(helper.company_greek_candles(model_to_dict(company)['id']))

	newlist = sorted(all_company_greek_candles, key=itemgetter('company_candles_total'), reverse = True)

	response = json.dumps(newlist)
	return HttpResponse(response, mimetype="application/json")
Example #9
0
def company_specific_greek_candles(request, company):
	helper = RelayFunctions()

	all_company_specific_greek_candles = []

	for team in Team.objects.filter(company = company):
			all_company_specific_greek_candles.append(helper.company_specific_greek_candles(model_to_dict(team)['id']))

	newlist = sorted(all_company_specific_greek_candles, key=itemgetter('team_event_milestone_candles'), reverse = True)

	response = json.dumps(newlist)
	return HttpResponse(response, mimetype="application/json")
Example #10
0
def team_specific_general_candles(request, team):
	helper = RelayFunctions()

	all_team_specific_general_candles = []

	for participant in Participant.objects.filter(team = team):
			all_team_specific_general_candles.append(helper.team_specific_general_candles(model_to_dict(participant)['id']))
			cool = helper.team_specific_general_candles(model_to_dict(participant)['id'])

	newlist = sorted(all_team_specific_general_candles, key=itemgetter('participant_candles_total'), reverse = True)

	response = json.dumps(newlist)
	return HttpResponse(response, mimetype="application/json")
def createFundraisingChallengeStartRecord():
	helper = RelayFunctions()
	
	for participant in Participant.objects.all():
		totals = helper.participant_specific_totals(model_to_dict(participant)['id'])
		total_donations = totals['donations_total']
		total_candles = totals['milestone_total'] + totals['emails_candles'] + totals['event_candles']
		try:
			for challenge in Fundraising_Challenge.objects.all():
				try:
					fundraising_challenge_start_record = Fundraising_Challenge_Start_Record(participant = participant, challenge = challenge)
				except Fundraising_Challenge_Start_Record.DoesNotExist:
					print('Record DNE.  Creating start record...')
					new_fundraising_challenge_start_record = Fundraising_Challenge_Start_Record(participant = participant, challenge = challenge, amount_raised = total_donations, candles_raised = total_candles, datetime_start = challenge.datetime_start)
					new_fundraising_challenge_start_record.save()
		except Exception:
			print('No challenges')

	createFundraisingChallengeRecord()
Example #12
0
def all_team_candles_general(request):
	helper = RelayFunctions()

	all_team_candles = []

	for company in Company.objects.filter(company_type = 'RT'):
		for team in Team.objects.filter(company = company):
			if team.signup == True:
				all_team_candles.append(helper.team_candles(model_to_dict(team)['id']))

	newlist = sorted(all_team_candles, key=itemgetter('team_candles_total'), reverse = True)

	#currPos = 1
	#for item in newlist:
		#['pos'] = currPos
		#currPos = currPos + 1

	response = json.dumps(newlist)
	return HttpResponse(response, mimetype="application/json")
Example #13
0
def counter(info, noCol):
    helper = RelayFunctions()

    try:
        counter = Counter.objects.get(strip_id=info[0])
        team_id = counter.team.pk
        counter_pledge_numbers = helper.counterTeam(team_id)
        pledge_amount = counter_pledge_numbers["pledge_amount"]
        max_pledge_amount = counter_pledge_numbers["max_pledge_amount"]
        laps_completed = int(noCol)

        counter.pledge_amount = pledge_amount
        counter.max_pledge_amount = max_pledge_amount
        counter.laps_completed = laps_completed
        total = laps_completed * pledge_amount
        counter.total = total
        counter.save()
    except Counter.DoesNotExist:
        print ("Uh oh")
Example #14
0
def counter():
	helper = RelayFunctions()

	for o in Olympics_Lap_Counter_Signup.objects.all():
		team_id = o.team.pk
		team_object = Team.objects.get(pk = team_id)
		try:
			new_counter = Counter.objects.get(team = team_id)
		except Counter.DoesNotExist:
			print('Creating new')
			number = 0
			for counter in Counter.objects.all():
				number = number + 1
			number = number + 1
		
			counter_pledge_numbers = helper.counter(team_id)
			tier = o.tier
			pledge_amount = counter_pledge_numbers['pledge_amount']
			max_pledge_amount = counter_pledge_numbers['max_pledge_amount']
		
			new_counter = Counter(team = team_object, strip_id = number, tier = 'WALK', pledge_amount = pledge_amount, max_pledge_amount = max_pledge_amount, laps_completed = int(0))
			new_counter.save()
Example #15
0
def renderCounterTeam(request, team):
	helper = RelayFunctions()
	
	team_object = Team.objects.get(pk = team)
	team_name = team_object.name
	#laps_completed = Counter.objects.get(team = team_name)
	
	team = []
	for participant in Participant.objects.filter(team = Team):
		participant_id = participant.pk
		team.append(helper.counterParticipant(participant_id))
	
	t = get_template('base_counterTeam.html')
	context = {'pagesButtonGeneral': 'generalDown', 
		'pagesButtonGreek': 'greeksDown', 
		'pagesButtonCorps': 'corpsDown', 
		'onLoad': 'setupCounterRegPage()',
		'team': team,
		'laps_completed': laps_completed
		}
	c = template.Context(context)
	r = t.render(c)
	return HttpResponse(r)
Example #16
0
def participant_specific(request, participant):
	helper = RelayFunctions()

	info = helper.participant_specific_info(participant)
	totals = helper.participant_specific_totals(participant)
	donations = helper.participant_specific_donations(participant)
	milestones = helper.participant_specific_milestones(participant)
	events = helper.participant_specific_events(participant)
	emails = helper.participant_specific_emails(participant)


	data = { 'info' : info , 'totals' : totals , 'donations' : donations , 'milestones' : milestones, 'events':events, 'emails':emails }

	response = json.dumps(data)
	return HttpResponse(response, mimetype="application/json")
Example #17
0
def participant_specific_greek(request, participant):
	helper = RelayFunctions()

	info = helper.participant_specific_info_greek(participant)
	totals = helper.participant_specific_totals_greek(participant)
	donations = helper.participant_specific_donations_greek(participant)
	events = helper.participant_specific_events_greek(participant)
	tshirts = helper.participant_specific_tshirt_greek(participant)
	
	data = { 'info' : info , 'totals' : totals , 'donations' : donations , 'events' : events, 'tshirts' : tshirts }

	response = json.dumps(data)
	return HttpResponse(response, mimetype="application/json")
def createFundraisingChallengeRecord():
	helper = RelayFunctions()
	timezone.now()
	utc=pytz.UTC
	
	
	
	for challenge in Fundraising_Challenge.objects.all():
		if challenge.datetime_start <= datetime.now(utc) <= challenge.datetime_end:
			if not challenge.amount_raised == 0 and challenge.candles_raised == 0:
				for participant in Participant.objects.all():
					save_participant = Participant.objects.get(pk = participant)
					currentRaised = Donation.objects.filter(participant = participant).aggregate(total_donations = Sum('amount'))
					startRecord = Fundraising_Challenge_Start_Record.objects.get(participant = participant, challenge = challenge)
					startRaised = startRecord.amount_raised
					diffRaised = currentRaised - startRaised
					print('Checking to see if record is deserved')
					if diffRaised > challenge.amount_raised:
						try:
							record = Fundraising_Challenge_Record.objects.get(participant = participant, challenge = challenge)
							print('Already created...editing')
							Fundraising_Challenge_Record.objects.get(participant = participant, challenge = challenge).delete()
							donations = Donation.objects.filter(participant = participant).order_by('datetime')
							tot = 0
							stop = 0
							for donation in donations:
								if stop == 0:
									if tot < challenge.amount_raised:
										amoun = donation.amount
										tot = tot + amoun
									else:
										donated_datetime = donation.datetime
										stop = 1
							#donated_datetime = Donation.objects.filter(participant = participant).annotate(most_recent_donation_datetime = Max('datetime'))
							new_fundraising_record = Fundraising_Challenge_Record(participant = save_participant, challenge = challenge, datetime = donated_datetime, candles_rewarded = challenge.candles_rewarded)
							new_fundraising_record.save()
						except Fundraising_Challenge_Record.DoesNotExist:
							print('Deserved...Fundraising_Challenge_Record does not exist...creating one...')
							donations = Donation.objects.filter(participant = participant).order_by('datetime')
							tot = 0
							stop = 0
							for donation in donations:
								if stop == 0:
									if tot < challenge.amount_raised:
										amoun = donation.amount
										tot = tot + amoun
									else:
										donated_datetime = donation.datetime
										stop = 1
							#donated_datetime = Donation.objects.filter(participant = participant).annotate(most_recent_donation_datetime = Max('datetime'))
							new_fundraising_record = Fundraising_Challenge_Record(participant = save_participant, challenge = challenge, datetime = donated_datetime, candles_rewarded = challenge.candles_rewarded)
							new_fundraising_record.save()
					else:
						print('It is not deserved')
			if not challenge.candles_raised == 0 and challenge.amount_raised == 0:
				for participant in Participant.objects.all():
					totals = helper.participant_specific_totals(model_to_dict(participant)['id'])
					currentCandles = totals['milestone_total'] + totals['emails_candles'] + totals['event_candles']
					startRecord = Fundraising_Challenge_Start_Record.objects.get(participant = participant, challenge = challenge)
					startCandles = startRecord.candles_raised
					diffCandles = currentCandles - startCandles
					print('Checking to see if record is deserved')
					if diffCandles > challenge.candles_raised:
						try:
							record = Fundraising_Challenge_Record.objects.filter(participant = participant, challenge = challenge)
							Fundraising_Challenge_Record.objects.get(participant = participant, challenge = challenge).delete()
							candles_record = Candles_Record.objects.filter(participant = participant).order_by('datetime')
							save_participant = Participant.objects.get(pk = participant)
							tot = 0
							stop = 0
							for candles in candles_record:
								if stop == 0:
									if tot < challenge.candles_raised:
										amoun = candles.candles_value
										tot = tot + amoun
									else:
										candles_datetime = candles.datetime
										stop = 1
							new_fundraising_record = Fundraising_Challenge_Record(participant = save_participant, challenge = challenge, datetime = candles_datetime, candles_rewarded = challenge.candles_rewarded)
							new_fundraising_record.save()
						except Fundraising_Challenge_Record.DoesNotExist:
							print('Deserved...Fundraising_Challenge_Record does not exist...creating one...')
							candles_record = Candles_Record.objects.filter(participant = participant).order_by('datetime')
							save_participant = Participant.objects.get(pk = participant)
							tot = 0
							stop = 0
							for candles in candles_record:
								if stop == 0:
									if tot < challenge.candles_raised:
										amoun = candles.candles_value
										tot = tot + amoun
									else:
										candles_datetime = candles.datetime
										stop = 1
							new_fundraising_record = Fundraising_Challenge_Record(participant = save_participant, challenge = challenge, datetime = candles_datetime, candles_rewarded = challenge.candles_rewarded)
							new_fundraising_record.save()
			else:
				print('No amount_raised or candles_raised specified.  Or both specified at the same time.')
		else:
			print('No challenge currently running')

	createFundraisingChallengeTrackerRecord()