golf/abc_base.py
def updateTournament(self, playerResultList):
        """
            Sets the current tournament values in the database
            return True for success and False for fail
            TODO: Probably should say how many where updated.
            TODO: Return response time
        """
        a = datetime.now()
        try:
            tr = TournamentRound.objects.get(id=self.tournamentRoundId)
        except:
            print('Failed to get the tournament round')
            print(self.tournamentRoundId)
            return False
        for player in playerResultList:
            try:
                p = Player.objects.get(club_member_number=player['clubMemberNumber'])
            except (Player.DoesNotExist):
                print ('Get player failed');
                print (player['clubMemberNumber'])
                return False
            try:
                sc = Scorecard.objects.get(id=player['scorecardId'])
            except (Scorecard.DoesNotExist):
                print ('Get Scorecard failed')
                print (player['scorecardId'])
                return False
            try:
                ct = CourseTee.objects.get(id=player['round']['courseTeeId'])
            except (CourseTee.DoesNotExist):
                print ('Get CourseTee failed')
                print (player['round']['courseTeeId'])
                return False
            try:
                r = Round.objects.get(tournament_round=tr, player=p)
                r.scorecard = sc
                r.course_tee = ct
                r.handicap_index = player['handicapIndex']
                r.course_handicap = player['round']['courseHCP']
                r.total_out = player['round']['totalOut']
                r.total_out_style = player['round']['totalOutStyle']
                r.total_out_net = player['round']['totalOutNet']
                r.total_out_net_style = player['round']['totalOutNetStyle']
                r.total_in = player['round']['totalIn']
                r.total_in_style = player['round']['totalInStyle']
                r.total_in_net = player['round']['totalInNet']
                r.total_in_net_style = player['round']['totalInNetStyle']
                r.total = player['round']['total']
                r.total_style = player['round']['totalStyle']
                r.net = player['round']['totalNet']
                r.net_style = player['round']['totalNetStyle']
                r.save()
            except (Round.DoesNotExist):
                #Create the round because it doesn't exist
                r = Round(tournament_round=tr, player=p, scorecard=sc, course_tee=ct, handicap_index=player['handicapIndex'], course_handicap=player['round']['courseHCP'], total_out=player['round']['totalOut'], total_out_style=player['round']['totalOutStyle'], total_out_net=player['round']['totalOutNet'], total_out_net_style=player['round']['totalOutNetStyle'], total_in=player['round']['totalIn'], total_in_style=player['round']['totalInStyle'], total_in_net=player['round']['totalInNet'], total_in_net_style=player['round']['totalInNetStyle'], total=player['round']['total'], total_style=player['round']['totalStyle'], net=player['round']['totalNet'], net_style=player['round']['totalNetStyle'])
                r.save()
            #except:
            #    print ('Get Round failed')
            #    print (self.tournamentRoundId)
            #    return False
            for i in range (18):
                try:
                    te = Tee.objects.get(course_tee=player['round']['courseTeeId'], hole__number=int(i+1))
                except (Tee.DoesNotExist):
                    print ('Get Tee failed')
                    print (player['round']['courseTeeId'])
                    print (int(i+1))
                    return False
                try:
                    s = Score.objects.get(tee=te.id, round=r)
                    s.tee = te
                    s.score = player['round']['grossScores'][i]
                    s.score_style = player['round']['grossStyles'][i]
                    s.skin = player['round']['grossSkins'][i]
                    s.score_net = player['round']['netScores'][i]
                    s.score_net_style = player['round']['netStyles'][i]
                    s.skin_net = player['round']['netSkins'][i]
                    s.save()
                except Score.DoesNotExist:
                    s = Score(round=r, tee=te, score=player['round']['grossScores'][i], score_style=player['round']['grossStyles'][i], skin=player['round']['grossSkins'][i], score_net=player['round']['netScores'][i], score_net_style=player['round']['netStyles'][i], skin_net=player['round']['netSkins'][i])
                    s.save()
                except:
                    print ('Get Score failed')
                    print (te.id)
                    return False
        c = datetime.now() - a
        print('updateTournament time: '+str(c.seconds))
        return True

            Sets the current tournament values in the database
            return True for success and False for fail
            TODO: Probably should say how many where updated.
            TODO: Return response time
        
Sets the current tournament values in the database
return True for success and False for fail
TODO: Probably should say how many where updated.
TODO: Return response time
Sets the current tournament values in the database return True for success and False for fail TODO : Probably should say how many where updated . TODO : Return response time
def updateTournament(self, playerResultList):
        a = datetime.now()
        try:
            tr = TournamentRound.objects.get(id=self.tournamentRoundId)
        except:
            print('Failed to get the tournament round')
            print(self.tournamentRoundId)
            return False
        for player in playerResultList:
            try:
                p = Player.objects.get(club_member_number=player['clubMemberNumber'])
            except (Player.DoesNotExist):
                print ('Get player failed');
                print (player['clubMemberNumber'])
                return False
            try:
                sc = Scorecard.objects.get(id=player['scorecardId'])
            except (Scorecard.DoesNotExist):
                print ('Get Scorecard failed')
                print (player['scorecardId'])
                return False
            try:
                ct = CourseTee.objects.get(id=player['round']['courseTeeId'])
            except (CourseTee.DoesNotExist):
                print ('Get CourseTee failed')
                print (player['round']['courseTeeId'])
                return False
            try:
                r = Round.objects.get(tournament_round=tr, player=p)
                r.scorecard = sc
                r.course_tee = ct
                r.handicap_index = player['handicapIndex']
                r.course_handicap = player['round']['courseHCP']
                r.total_out = player['round']['totalOut']
                r.total_out_style = player['round']['totalOutStyle']
                r.total_out_net = player['round']['totalOutNet']
                r.total_out_net_style = player['round']['totalOutNetStyle']
                r.total_in = player['round']['totalIn']
                r.total_in_style = player['round']['totalInStyle']
                r.total_in_net = player['round']['totalInNet']
                r.total_in_net_style = player['round']['totalInNetStyle']
                r.total = player['round']['total']
                r.total_style = player['round']['totalStyle']
                r.net = player['round']['totalNet']
                r.net_style = player['round']['totalNetStyle']
                r.save()
            except (Round.DoesNotExist):
                r = Round(tournament_round=tr, player=p, scorecard=sc, course_tee=ct, handicap_index=player['handicapIndex'], course_handicap=player['round']['courseHCP'], total_out=player['round']['totalOut'], total_out_style=player['round']['totalOutStyle'], total_out_net=player['round']['totalOutNet'], total_out_net_style=player['round']['totalOutNetStyle'], total_in=player['round']['totalIn'], total_in_style=player['round']['totalInStyle'], total_in_net=player['round']['totalInNet'], total_in_net_style=player['round']['totalInNetStyle'], total=player['round']['total'], total_style=player['round']['totalStyle'], net=player['round']['totalNet'], net_style=player['round']['totalNetStyle'])
                r.save()
            for i in range (18):
                try:
                    te = Tee.objects.get(course_tee=player['round']['courseTeeId'], hole__number=int(i+1))
                except (Tee.DoesNotExist):
                    print ('Get Tee failed')
                    print (player['round']['courseTeeId'])
                    print (int(i+1))
                    return False
                try:
                    s = Score.objects.get(tee=te.id, round=r)
                    s.tee = te
                    s.score = player['round']['grossScores'][i]
                    s.score_style = player['round']['grossStyles'][i]
                    s.skin = player['round']['grossSkins'][i]
                    s.score_net = player['round']['netScores'][i]
                    s.score_net_style = player['round']['netStyles'][i]
                    s.skin_net = player['round']['netSkins'][i]
                    s.save()
                except Score.DoesNotExist:
                    s = Score(round=r, tee=te, score=player['round']['grossScores'][i], score_style=player['round']['grossStyles'][i], skin=player['round']['grossSkins'][i], score_net=player['round']['netScores'][i], score_net_style=player['round']['netStyles'][i], skin_net=player['round']['netSkins'][i])
                    s.save()
                except:
                    print ('Get Score failed')
                    print (te.id)
                    return False
        c = datetime.now() - a
        print('updateTournament time: '+str(c.seconds))
        return True
def updateTournament ( self , playerResultList ) : a = datetime . now ( ) try : tr = TournamentRound . objects . get ( id = self . tournamentRoundId ) except : print ( 'Failed to get the tournament round' ) print ( self . tournamentRoundId ) return False for player in playerResultList : try : p = Player . objects . get ( club_member_number = player [ 'clubMemberNumber' ] ) except ( Player . DoesNotExist ) : print ( 'Get player failed' ) ; print ( player [ 'clubMemberNumber' ] ) return False try : sc = Scorecard . objects . get ( id = player [ 'scorecardId' ] ) except ( Scorecard . DoesNotExist ) : print ( 'Get Scorecard failed' ) print ( player [ 'scorecardId' ] ) return False try : ct = CourseTee . objects . get ( id = player [ 'round' ] [ 'courseTeeId' ] ) except ( CourseTee . DoesNotExist ) : print ( 'Get CourseTee failed' ) print ( player [ 'round' ] [ 'courseTeeId' ] ) return False try : r = Round . objects . get ( tournament_round = tr , player = p ) r . scorecard = sc r . course_tee = ct r . handicap_index = player [ 'handicapIndex' ] r . course_handicap = player [ 'round' ] [ 'courseHCP' ] r . total_out = player [ 'round' ] [ 'totalOut' ] r . total_out_style = player [ 'round' ] [ 'totalOutStyle' ] r . total_out_net = player [ 'round' ] [ 'totalOutNet' ] r . total_out_net_style = player [ 'round' ] [ 'totalOutNetStyle' ] r . total_in = player [ 'round' ] [ 'totalIn' ] r . total_in_style = player [ 'round' ] [ 'totalInStyle' ] r . total_in_net = player [ 'round' ] [ 'totalInNet' ] r . total_in_net_style = player [ 'round' ] [ 'totalInNetStyle' ] r . total = player [ 'round' ] [ 'total' ] r . total_style = player [ 'round' ] [ 'totalStyle' ] r . net = player [ 'round' ] [ 'totalNet' ] r . net_style = player [ 'round' ] [ 'totalNetStyle' ] r . save ( ) except ( Round . DoesNotExist ) : r = Round ( tournament_round = tr , player = p , scorecard = sc , course_tee = ct , handicap_index = player [ 'handicapIndex' ] , course_handicap = player [ 'round' ] [ 'courseHCP' ] , total_out = player [ 'round' ] [ 'totalOut' ] , total_out_style = player [ 'round' ] [ 'totalOutStyle' ] , total_out_net = player [ 'round' ] [ 'totalOutNet' ] , total_out_net_style = player [ 'round' ] [ 'totalOutNetStyle' ] , total_in = player [ 'round' ] [ 'totalIn' ] , total_in_style = player [ 'round' ] [ 'totalInStyle' ] , total_in_net = player [ 'round' ] [ 'totalInNet' ] , total_in_net_style = player [ 'round' ] [ 'totalInNetStyle' ] , total = player [ 'round' ] [ 'total' ] , total_style = player [ 'round' ] [ 'totalStyle' ] , net = player [ 'round' ] [ 'totalNet' ] , net_style = player [ 'round' ] [ 'totalNetStyle' ] ) r . save ( ) for i in range ( 18 ) : try : te = Tee . objects . get ( course_tee = player [ 'round' ] [ 'courseTeeId' ] , hole__number = int ( i + 1 ) ) except ( Tee . DoesNotExist ) : print ( 'Get Tee failed' ) print ( player [ 'round' ] [ 'courseTeeId' ] ) print ( int ( i + 1 ) ) return False try : s = Score . objects . get ( tee = te . id , round = r ) s . tee = te s . score = player [ 'round' ] [ 'grossScores' ] [ i ] s . score_style = player [ 'round' ] [ 'grossStyles' ] [ i ] s . skin = player [ 'round' ] [ 'grossSkins' ] [ i ] s . score_net = player [ 'round' ] [ 'netScores' ] [ i ] s . score_net_style = player [ 'round' ] [ 'netStyles' ] [ i ] s . skin_net = player [ 'round' ] [ 'netSkins' ] [ i ] s . save ( ) except Score . DoesNotExist : s = Score ( round = r , tee = te , score = player [ 'round' ] [ 'grossScores' ] [ i ] , score_style = player [ 'round' ] [ 'grossStyles' ] [ i ] , skin = player [ 'round' ] [ 'grossSkins' ] [ i ] , score_net = player [ 'round' ] [ 'netScores' ] [ i ] , score_net_style = player [ 'round' ] [ 'netStyles' ] [ i ] , skin_net = player [ 'round' ] [ 'netSkins' ] [ i ] ) s . save ( ) except : print ( 'Get Score failed' ) print ( te . id ) return False c = datetime . now ( ) - a print ( 'updateTournament time: ' + str ( c . seconds ) ) return True
Sets the current tournament values in the database
return True for success and False for fail
TODO: Probably should say how many where updated.
Sets the current tournament values in the database return True for success and False for fail TODO : Probably should say how many where updated .
"""
            Sets the current tournament values in the database
            return True for success and False for fail
            TODO: Probably should say how many where updated.
            TODO: Return response time
        """ #Create the round because it doesn't exist #except: #    print ('Get Round failed') #    print (self.tournamentRoundId) #    return False
self
playerResultList