golf/views/.~c9_invoke_H9Dn7P.py
def newTournament(request):
    """
    Create function for tournaments
    Need to ask several questions about course, tee, format, if multi-round - how many... how do you ask from a plugin?
    """
    from django.core import serializers
    courses = []
    courseTees = []
    courseIds = request.POST.getlist('courses')
    teeIds = request.POST.getlist('tees')
    t = Tournament(name=request.POST.get('name'))
    t.save()
    for i, teeId in enumerate(teeIds):
        ct = CourseTee.objects.get(id=teeId)
        t.course_tees.add(ct)
        courseTees.append(list(CourseTee.objects.filter(id=teeId).values('id', 'name', 'slope', 'course__name', 'color'))[0])
        courseTees[i]['color_text'] = CourseTee.COLOR_CHOICES[courseTees[i]['color']][1]
        courseTees[i]['tees'] = list(Tee.objects.filter(course_tee__id=teeId).values('id', 'yardage', 'par', 'hole__name', 'hole__number'))
        courseTees[i]['hole_count'] = len(courseTees[i]['tees'])
        yardageIn = 0
        yardageOut = 0
        parIn = 0
        parOut = 0
        if (int(courseTees[i]['hole_count']) == 9):
            for front in range(0, 9):
                yardageOut += int(courseTees[i]['tees'][front]['yardage'])
                parOut += int(courseTees[i]['tees'][front]['par'])
            courseTees[i]['yardageOut'] = yardageOut
            courseTees[i]['yardageTotal'] = yardageOut
            courseTees[i]['parOut'] = parOut
            courseTees[i]['parTotal'] = parOut
        if (int(courseTees[i]['hole_count']) == 18):
            for front in range(0, 9):
                yardageOut += int(courseTees[i]['tees'][front]['yardage'])
                parOut += int(courseTees[i]['tees'][front]['par'])
            courseTees[i]['yardageOut'] = yardageOut
            courseTees[i]['parOut'] = parOut
            for back in range(9, 18):
                yardageIn += int(courseTees[i]['tees'][back]['yardage'])
                parIn += int(courseTees[i]['tees'][back]['par'])
            courseTees[i]['yardageIn'] = yardageIn
            courseTees[i]['yardageTotal'] = yardageOut + yardageIn
            courseTees[i]['parIn'] = parIn
            courseTees[i]['parTotal'] = parOut + parIn
    if (len(teeIds) != 1):
        for courseId in courseIds:
            c = Course.objects.get(id=courseId)
            courses.append(model_to_dict(c))
            t.courses.add(c)
    from datetime import datetime
    d = datetime.strptime(request.POST.get('dateStart'), '%m/%d/%Y')
    td = TournamentDate(date=d, tournament=t)
    td.save()
    numRoundsRange = range(2, int(request.POST.get('numRounds'))+1)
    context = {
        "tournamentId": t.id,
        "name": request.POST.get('name'),
        "numRoundsRange": numRoundsRange,
        "numRounds": request.POST.get('numRounds'),
        "courses": courses,
        "courseTees": courseTees,
        "players": serializers.serialize('json', Player.objects.all())
    }
    return render(request, 'golf/newtournament.html', context=context)

    Create function for tournaments
    Need to ask several questions about course, tee, format, if multi-round - how many... how do you ask from a plugin?
    
Create function for tournaments
Need to ask several questions about course, tee, format, if multi-round - how many...
Create function for tournaments Need to ask several questions about course tee format if multi - round - how many ...
def newTournament(request):
    from django.core import serializers
    courses = []
    courseTees = []
    courseIds = request.POST.getlist('courses')
    teeIds = request.POST.getlist('tees')
    t = Tournament(name=request.POST.get('name'))
    t.save()
    for i, teeId in enumerate(teeIds):
        ct = CourseTee.objects.get(id=teeId)
        t.course_tees.add(ct)
        courseTees.append(list(CourseTee.objects.filter(id=teeId).values('id', 'name', 'slope', 'course__name', 'color'))[0])
        courseTees[i]['color_text'] = CourseTee.COLOR_CHOICES[courseTees[i]['color']][1]
        courseTees[i]['tees'] = list(Tee.objects.filter(course_tee__id=teeId).values('id', 'yardage', 'par', 'hole__name', 'hole__number'))
        courseTees[i]['hole_count'] = len(courseTees[i]['tees'])
        yardageIn = 0
        yardageOut = 0
        parIn = 0
        parOut = 0
        if (int(courseTees[i]['hole_count']) == 9):
            for front in range(0, 9):
                yardageOut += int(courseTees[i]['tees'][front]['yardage'])
                parOut += int(courseTees[i]['tees'][front]['par'])
            courseTees[i]['yardageOut'] = yardageOut
            courseTees[i]['yardageTotal'] = yardageOut
            courseTees[i]['parOut'] = parOut
            courseTees[i]['parTotal'] = parOut
        if (int(courseTees[i]['hole_count']) == 18):
            for front in range(0, 9):
                yardageOut += int(courseTees[i]['tees'][front]['yardage'])
                parOut += int(courseTees[i]['tees'][front]['par'])
            courseTees[i]['yardageOut'] = yardageOut
            courseTees[i]['parOut'] = parOut
            for back in range(9, 18):
                yardageIn += int(courseTees[i]['tees'][back]['yardage'])
                parIn += int(courseTees[i]['tees'][back]['par'])
            courseTees[i]['yardageIn'] = yardageIn
            courseTees[i]['yardageTotal'] = yardageOut + yardageIn
            courseTees[i]['parIn'] = parIn
            courseTees[i]['parTotal'] = parOut + parIn
    if (len(teeIds) != 1):
        for courseId in courseIds:
            c = Course.objects.get(id=courseId)
            courses.append(model_to_dict(c))
            t.courses.add(c)
    from datetime import datetime
    d = datetime.strptime(request.POST.get('dateStart'), '%m/%d/%Y')
    td = TournamentDate(date=d, tournament=t)
    td.save()
    numRoundsRange = range(2, int(request.POST.get('numRounds'))+1)
    context = {
        "tournamentId": t.id,
        "name": request.POST.get('name'),
        "numRoundsRange": numRoundsRange,
        "numRounds": request.POST.get('numRounds'),
        "courses": courses,
        "courseTees": courseTees,
        "players": serializers.serialize('json', Player.objects.all())
    }
    return render(request, 'golf/newtournament.html', context=context)
def newTournament ( request ) : from django . core import serializers courses = [ ] courseTees = [ ] courseIds = request . POST . getlist ( 'courses' ) teeIds = request . POST . getlist ( 'tees' ) t = Tournament ( name = request . POST . get ( 'name' ) ) t . save ( ) for i , teeId in enumerate ( teeIds ) : ct = CourseTee . objects . get ( id = teeId ) t . course_tees . add ( ct ) courseTees . append ( list ( CourseTee . objects . filter ( id = teeId ) . values ( 'id' , 'name' , 'slope' , 'course__name' , 'color' ) ) [ 0 ] ) courseTees [ i ] [ 'color_text' ] = CourseTee . COLOR_CHOICES [ courseTees [ i ] [ 'color' ] ] [ 1 ] courseTees [ i ] [ 'tees' ] = list ( Tee . objects . filter ( course_tee__id = teeId ) . values ( 'id' , 'yardage' , 'par' , 'hole__name' , 'hole__number' ) ) courseTees [ i ] [ 'hole_count' ] = len ( courseTees [ i ] [ 'tees' ] ) yardageIn = 0 yardageOut = 0 parIn = 0 parOut = 0 if ( int ( courseTees [ i ] [ 'hole_count' ] ) == 9 ) : for front in range ( 0 , 9 ) : yardageOut += int ( courseTees [ i ] [ 'tees' ] [ front ] [ 'yardage' ] ) parOut += int ( courseTees [ i ] [ 'tees' ] [ front ] [ 'par' ] ) courseTees [ i ] [ 'yardageOut' ] = yardageOut courseTees [ i ] [ 'yardageTotal' ] = yardageOut courseTees [ i ] [ 'parOut' ] = parOut courseTees [ i ] [ 'parTotal' ] = parOut if ( int ( courseTees [ i ] [ 'hole_count' ] ) == 18 ) : for front in range ( 0 , 9 ) : yardageOut += int ( courseTees [ i ] [ 'tees' ] [ front ] [ 'yardage' ] ) parOut += int ( courseTees [ i ] [ 'tees' ] [ front ] [ 'par' ] ) courseTees [ i ] [ 'yardageOut' ] = yardageOut courseTees [ i ] [ 'parOut' ] = parOut for back in range ( 9 , 18 ) : yardageIn += int ( courseTees [ i ] [ 'tees' ] [ back ] [ 'yardage' ] ) parIn += int ( courseTees [ i ] [ 'tees' ] [ back ] [ 'par' ] ) courseTees [ i ] [ 'yardageIn' ] = yardageIn courseTees [ i ] [ 'yardageTotal' ] = yardageOut + yardageIn courseTees [ i ] [ 'parIn' ] = parIn courseTees [ i ] [ 'parTotal' ] = parOut + parIn if ( len ( teeIds ) != 1 ) : for courseId in courseIds : c = Course . objects . get ( id = courseId ) courses . append ( model_to_dict ( c ) ) t . courses . add ( c ) from datetime import datetime d = datetime . strptime ( request . POST . get ( 'dateStart' ) , '%m/%d/%Y' ) td = TournamentDate ( date = d , tournament = t ) td . save ( ) numRoundsRange = range ( 2 , int ( request . POST . get ( 'numRounds' ) ) + 1 ) context = { "tournamentId" : t . id , "name" : request . POST . get ( 'name' ) , "numRoundsRange" : numRoundsRange , "numRounds" : request . POST . get ( 'numRounds' ) , "courses" : courses , "courseTees" : courseTees , "players" : serializers . serialize ( 'json' , Player . objects . all ( ) ) } return render ( request , 'golf/newtournament.html' , context = context )
Create function for tournaments
Need to ask several questions about course, tee, format, if multi-round - how many... how do you ask from a plugin?
Create function for tournaments Need to ask several questions about course tee format if multi - round - how many ... how do you ask from a plugin?
"""
    Create function for tournaments
    Need to ask several questions about course, tee, format, if multi-round - how many... how do you ask from a plugin?
    """
request