Ejemplo n.º 1
0
def createTeam(request):
    tryoutID = request.query_params.get('tryoutID')
    teamName = request.query_params.get('teamName')
    thisTryout = tryout.objects.get(id=tryoutID)
    thisTeam = team(tryout=thisTryout, name=teamName)
    thisTeam.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 2
0
def addPlayerToTeam(request):
    teamID = request.query_params.get('teamID')
    playerID = request.query_params.get('playerID')
    thisPlayer = player.objects.get(id=playerID)
    thisPlayer.teamID = teamID
    thisPlayer.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 3
0
def addExecs(request):
    tryoutID = request.query_params.get('tryoutID')
    execEmail = request.query_params.get('execEmail')
    thisTryout = tryout.objects.get(id=tryoutID)
    thisExec = user.objects.get(email=execEmail)
    thisTryout.executives.add(thisExec)
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 4
0
def checkUser(request):
    username = request.query_params.get('username')
    password = request.query_params.get('password')
    thisUser = user.objects.get(username=username, password=password)
    if thisUser is not None:
        return Response(userIDSerializer(userID(thisUser.id)).data)
    else:
        return Response(isValidSerializer(False).data)
Ejemplo n.º 5
0
def deleteTeam(request):
    teamID = request.query_params.get('teamID')
    thisTeam = team.objects.get(id=teamID)
    thisTeam.delete()
    allPlayers = player.objects.filter(teamID=teamID)
    for thisPlayer in allPlayers:
        thisPlayer.teamID = 0
        thisPlayer.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 6
0
def getUserInfo(request):
    userID = request.query_params.get('userID')
    thisUser = user.objects.get(id=userID)
    if thisUser is not None:
        return Response(
            userInfoSerializer(
                userInfo(thisUser.firstName, thisUser.lastName,
                         thisUser.username, thisUser.email)).data)
    else:
        return Response(isValidSerializer(False).data)
Ejemplo n.º 7
0
def postComment(request):
    playerID = request.query_params.get('playerID')
    thisPlayer = player.objects.get(id=playerID)
    execID = request.query_params.get('userID')
    thisExec = user.objects.get(id=execID)
    commentText = request.query_params.get('commentText')
    thisComment = comment(player=thisPlayer, exec=thisExec)
    thisComment.text = commentText
    thisComment.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 8
0
def createTryout(request):
    userID = request.query_params.get('userID')
    thisUser = user.objects.get(id=userID)
    tryoutName = request.query_params.get('tryoutName')
    thisTryout = tryout(admin=thisUser, name=tryoutName)
    thisTryout.save()
    criteriaList = request.GET.getlist('criteria')
    for criterionName in criteriaList:
        thisCriterion = criterion(tryout=thisTryout, name=criterionName)
        thisCriterion.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 9
0
def createUser(request):
    username = request.query_params.get('username')
    password = request.query_params.get('password')
    email = request.query_params.get('email')
    firstName = request.query_params.get('firstName')
    lastName = request.query_params.get('lastName')
    try:
        if user.objects.get(username=username):
            return Response(isValidSerializer(isValid(False)).data)
    except:
        try:
            if user.objects.get(email=email):
                return Response(isValidSerializer(isValid(False)).data)
        except:
            thisUser = user(username=username,
                            password=password,
                            email=email,
                            firstName=firstName,
                            lastName=lastName)
            thisUser.save()
            return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 10
0
def addSession(request):
    tryoutID = request.query_params.get('tryoutID')
    thisTryout = tryout.objects.get(id=tryoutID)
    startTime = request.query_params.get('startTime')
    endTime = request.query_params.get('endTime')
    location = request.query_params.get('location')
    thisSession = session(tryout=thisTryout,
                          startTime=startTime,
                          endTime=endTime,
                          location=location)
    thisSession.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 11
0
def createPlayer(request):
    tryoutID = request.query_params.get('tryoutID')
    firstName = request.query_params.get('firstName')
    lastName = request.query_params.get('lastName')
    email = request.query_params.get('email')
    thisTryout = tryout.objects.get(id=tryoutID)
    thisPlayer = player(tryout=thisTryout,
                        firstName=firstName,
                        lastName=lastName,
                        email=email,
                        teamID=0)
    thisPlayer.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 12
0
def submitEval(request):
    playerID = request.query_params.get('playerID')
    thisPlayer = player.objects.get(id=playerID)
    execID = request.query_params.get('userID')
    thisExec = user.objects.get(id=execID)
    criterionID = request.query_params.get('criterionID')
    thisCriterion = criterion.objects.get(id=criterionID)
    grade = request.query_params.get('grade')
    thisEval, created = evaluation.objects.get_or_create(
        player=thisPlayer,
        exec=thisExec,
        criterion=thisCriterion,
        defaults={'grade': 3})
    thisEval.grade = grade
    thisEval.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 13
0
def deleteTryout(request):
    tryoutID = request.query_params.get('tryoutID')
    thisTryout = tryout.objects.get(id=tryoutID)
    thisTryout.delete()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 14
0
def removePlayerFromTeam(request):
    playerID = request.query_params.get('playerID')
    thisPlayer = player.objects.get(id=playerID)
    thisPlayer.teamID = 0
    thisPlayer.save()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 15
0
def deleteSession(request):
    sessionID = request.query_params.get('sessionID')
    thisSession = session.objects.get(id=sessionID)
    thisSession.delete()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 16
0
def deleteComment(request):
    commentID = request.query_params.get('commentID')
    thisComment = comment.objects.get(id=commentID)
    thisComment.delete()
    return Response(isValidSerializer(isValid(True)).data)
Ejemplo n.º 17
0
def deletePlayer(request):
    playerID = request.query_params.get('playerID')
    thisPlayer = player.objects.get(id=playerID)
    thisPlayer.delete()
    return Response(isValidSerializer(isValid(True)).data)