def semi_get_individual_donations(self, req): isAdmin, s = tools.checkAuthentication(self, False, from_endpoints=True) query = "individual_key:" + str(req.individual_key) results = s.search.donation(query, query_cursor=req.query_cursor) logging.info("Getting individual donations with query: " + query) donations = [] new_cursor = tools.getWebsafeCursor(results[1]) for d in results[0]: f = d.fields team_name = f[6].value if team_name == None: team_name = "" donation = Donation_Data(key=f[0].value, formatted_donation_date=f[9].value, name=f[2].value, email=tools.truncateEmail(f[3].value), payment_type=f[5].value, amount_donated=tools.moneyAmount(f[4].value), team_name=team_name) donations.append(donation) return Donations_Out(objects=donations, new_cursor=new_cursor)
def get_team_donation_total(self, req): isAdmin, s = tools.checkAuthentication(self, True, from_endpoints=True) t = tools.getKey(req.team_key).get() donation_total = tools.moneyAmount(t.data.donation_total) return GetTeamDonationTotal_Out(donation_total=donation_total)
def get_team_totals(self, req): s = tools.getSettingsKey(self, endpoints=True).get() i = tools.getKey(req.individual_key).get() team_totals = [] for tl in i.teamlist_entities: total = GetTeamTotals_Data(team_name=tl.team_name, donation_total=tools.moneyAmount(tl.data.donation_total)) team_totals.append(total) return GetTeamTotals_Out(team_totals=team_totals)
def get_team_members(self, req): isAdmin, s = tools.checkAuthentication(self, True, from_endpoints=True) query = "team_key:" + str(req.team_key) results = s.search.individual(query, query_cursor=req.query_cursor) logging.info("Getting team members with query: " + query) individuals = [] new_cursor = tools.getWebsafeCursor(results[1]) for i in results[0]: f = i.fields individual = Individual_Data(key=f[0].value, name=f[1].value, email=f[2].value, raised=tools.moneyAmount(f[4].value)) individuals.append(individual) return Individuals_Out(objects=individuals, new_cursor=new_cursor)
def get_teams(self, req): isAdmin, s = tools.checkAuthentication(self, True, from_endpoints=True) if req.query == None: req.query = "" results = s.search.team(req.query, query_cursor=req.query_cursor) logging.info("Getting teams with query: " + req.query) teams = [] new_cursor = tools.getWebsafeCursor(results[1]) for t in results[0]: f = t.fields team = Team_Data(key=f[0].value, name=f[1].value, donation_total=tools.moneyAmount(f[2].value)) teams.append(team) return Teams_Out(objects=teams, new_cursor=new_cursor)