def match_display(request, match_number): """ This page will display any requested match. This page can be accessed through many places, such as the list of all matches, or when viewing any team's individual matches. @param match_number is the number of the match being displayed This page uses score results to show each team in the match, along with its statistics during just that match, not the overall average or sum as team in view_team """ context = {} this_match = Match.objects.get(matchNumber=match_number) score_result_list = [] for sr in this_match.scoreresult_set.all(): score_result_list.append(sr) context["score_result_list"] = score_result_list context["match_display"] = match_number official_match_search = OfficialMatch.objects.filter(matchNumber=match_number) if len(official_match_search) == 1 and official_match_search[0].hasOfficialData: context["has_official_data"] = True official_match = official_match_search[0] valid, invalid_fields, = validate_match(this_match, official_match) if not valid: context["official_mismatch"] = invalid_fields else: context["has_official_data"] = False return render(request, "Scouting2016/MatchPage.html", context)
def all_matches(request): """ will show a list of all matches, both scouted already and unscouted (upcoming) Will show all teams in each match, and display them into two tables of each variety """ matches = Match.objects.all() for match in matches: official_match_search = OfficialMatch.objects.filter(matchNumber=match.matchNumber) if len(official_match_search) == 1 and official_match_search[0].hasOfficialData: valid, _ = validate_match(match, official_match_search[0]) match.validity = "Yes" if valid else "No" else: match.validity = "Unknown" scouted_numbers = [match.matchNumber for match in matches] unscouted_matches = OfficialMatch.objects.all().exclude(matchNumber__in=scouted_numbers) context = {} context["scouted_matches"] = matches context["unscouted_matches"] = unscouted_matches return render(request, "Scouting2016/AllMatches.html", context)
def validate_matches(): matches = Match.objects.all() # matches = Match.objects.filter(id=1) for match in matches: official_match = OfficialMatch.objects.get(matchNumber=match.matchNumber) if not official_match.hasOfficialData: continue valid, invalid_results = validate_match(match, official_match) if not valid: print "Match %s has errors: %s" % (match.matchNumber, invalid_results)