Example #1
0
def CoachRequestAccess(current_user, user_type, athlete_id):
    if not athlete_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if user_type != RequestConstants.USER_TYPE_COA:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    request_data = json.loads(request.data)
    access = CoachAthlete(
        athlete_id, current_user,
        request_data[CoachAthleteTable.CAN_ACCESS_TRAINING_LOG],
        request_data[CoachAthleteTable.CAN_ACCESS_TARGETS],
        request_data[CoachAthleteTable.IS_ACTIVE],
        request_data[CoachAthleteTable.START_DATE],
        request_data[CoachAthleteTable.INVITE_ID])

    access_dao = AccessDao()

    if access_dao.CreateCoachAccessWithInvite(access):
        return ResponseHelper.ReturnOkResponse("Ok")

    else:
        return ResponseHelper.ReturnConflictResponse(
            "Unable to request access!")
Example #2
0
def UpdateCoachAccess(current_user, user_type, coach_id):

    if not coach_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if user_type != RequestConstants.USER_TYPE_ATH:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    request_data = json.loads(request.data)
    access = CoachAthlete(
        None,
        None,
        request_data[CoachAthleteTable.CAN_ACCESS_TRAINING_LOG],
        request_data[CoachAthleteTable.CAN_ACCESS_TARGETS],
        None,
        None,
        None,
    )

    access_dao = AccessDao()

    if access_dao.UpdateCoachAccess(current_user, coach_id, access):
        return ResponseHelper.ReturnOkResponse("Access Updated!")

    else:
        return ResponseHelper.ReturnConflictResponse("Unable to Update Access")
Example #3
0
def GrantCoachPrivileges(current_user, user_type, coach_id):

    if not coach_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if user_type != RequestConstants.USER_TYPE_ATH:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    request_data = json.loads(request.data)
    access = CoachAthlete(
        current_user, coach_id,
        request_data[CoachAthleteTable.CAN_ACCESS_TRAINING_LOG],
        request_data[CoachAthleteTable.CAN_ACCESS_TARGETS],
        request_data[CoachAthleteTable.IS_ACTIVE],
        request_data[CoachAthleteTable.START_DATE],
        request_data[CoachAthleteTable.INVITE_ID])

    access_dao = AccessDao()

    if access_dao.CreateAccess(access):
        return ResponseHelper.ReturnOkResponse("Access Granted!")

    else:
        return ResponseHelper.ReturnConflictResponse("Unable to Grant Access")
Example #4
0
def UpdateCoachAccessFromInvite(current_user, user_type, invite_id):

    if not invite_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if user_type != RequestConstants.USER_TYPE_ATH:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    request_data = json.loads(request.data)

    update_data = UpdateData(
        request_data[RequestConstants.UPDATE_REQUEST_MEMBER_KEYS],
        request_data[RequestConstants.UPDATE_REQUEST_MEMBER_VALUES],
        [CoachAthleteTable.ATHLETE_ID, CoachAthleteTable.INVITE_ID],
        [current_user, invite_id],
    )

    if CoachAthleteTable.ATHLETE_ID in update_data.memberKeys or CoachAthleteTable.COACH_ID in update_data.memberKeys or CoachAthleteTable.INVITE_ID in update_data.memberKeys:
        return ResponseHelper.ReturnBadRequestResponse()

    access_dao = AccessDao()

    if access_dao.UpdateFromInvite(update_data):
        return ResponseHelper.ReturnOkResponse("Access Updated!")

    else:
        return ResponseHelper.ReturnConflictResponse("Unable to Update Access")
Example #5
0
def CreateMultipleInvites(current_user, user_type):
    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        request_data = json.loads(request.data)

        invite = Invite(
            None,  # For Id that is auto generated by a trigger
            request_data[str(InvitesTable.INVITE_TYPE)],
            current_user,  # Ensure log is created for the current user,
            None,
            request_data[str(InvitesTable.STATUS)],
            request_data[str(InvitesTable.SEND_DATE)],
            request_data[str(InvitesTable.EVENT_ID)])

        recipients = request_data["Recipients"]

        invite_dao = InviteDao()

        if invite_dao.CreateMultipleInvites(invite, recipients):

            return ResponseHelper.ReturnCreatedResponse("Invites Created")

        else:

            return ResponseHelper.ReturnConflictResponse(
                "Unable to Create Invites!")
Example #6
0
def CreateTarget(current_user, user_type, user_id):

    if current_user != user_id:

        access_dao = AccessDao()

        if not access_dao.CheckCoachTargetsAccess(current_user, user_id):
            return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        request_data = json.loads(request.data)

        target = Target(
            None,  # For Id that is auto generated by a trigger
            user_id,  # Ensure log is created for the current user,
            request_data[str(TargetsTable.CONTENT)],
            request_data[str(TargetsTable.STATUS)],
            request_data[str(TargetsTable.WEEK)],
            request_data[str(TargetsTable.YEAR)])

        target_dao = TargetDao()

        if target_dao.CreateTarget(target):

            return ResponseHelper.ReturnCreatedResponse("Target Created")

        else:

            return ResponseHelper.ReturnConflictResponse(
                "Unable to Create Target!")
Example #7
0
def CreateTemplate(current_user, user_type, user_id):

    if current_user != user_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if user_type != RequestConstants.USER_TYPE_COA:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        training_log_data = json.loads(request.data)

        template = TrainingLogTemplate(
            None,  # For Id that is auto generated by a trigger
            user_id,  # Ensure log is created for the current user,
            training_log_data[str(TrainingLogTemplateTable.NAME)],
            training_log_data[str(TrainingLogTemplateTable.DURATION_PLANNED)],
            training_log_data[str(TrainingLogTemplateTable.DURATION_ACTUAL)],
            training_log_data[str(TrainingLogTemplateTable.DISTANCE_PLANNED)],
            training_log_data[str(TrainingLogTemplateTable.DISTANCE_ACTUAL)],
            training_log_data[str(TrainingLogTemplateTable.DISTANCE_UNIT)],
            training_log_data[str(
                TrainingLogTemplateTable.HR_RESTING_PLANNED)],
            training_log_data[str(TrainingLogTemplateTable.HR_AVG_PLANNED)],
            training_log_data[str(TrainingLogTemplateTable.HR_MAX_PLANNED)],
            training_log_data[str(TrainingLogTemplateTable.HR_RESTING_ACTUAL)],
            training_log_data[str(TrainingLogTemplateTable.HR_AVG_ACTUAL)],
            training_log_data[str(TrainingLogTemplateTable.HR_MAX_ACTUAL)],
            training_log_data[str(TrainingLogTemplateTable.WATTS_AVG_PLANNED)],
            training_log_data[str(TrainingLogTemplateTable.WATTS_MAX_PLANNED)],
            training_log_data[str(TrainingLogTemplateTable.WATTS_AVG_ACTUAL)],
            training_log_data[str(TrainingLogTemplateTable.WATTS_MAX_ACTUAL)],
            training_log_data[str(TrainingLogTemplateTable.RPE_PLANNED)],
            training_log_data[str(TrainingLogTemplateTable.RPE_ACTUAL)],
            training_log_data[str(TrainingLogTemplateTable.HR_ZONE1_TIME)],
            training_log_data[str(TrainingLogTemplateTable.HR_ZONE2_TIME)],
            training_log_data[str(TrainingLogTemplateTable.HR_ZONE3_TIME)],
            training_log_data[str(TrainingLogTemplateTable.HR_ZONE4_TIME)],
            training_log_data[str(TrainingLogTemplateTable.HR_ZONE5_TIME)],
            training_log_data[str(TrainingLogTemplateTable.HR_ZONE6_TIME)])

        training_log_template_dao = TrainingLogTemplateDao()

        if training_log_template_dao.CreateTrainingLogTemplate(template):

            return ResponseHelper.ReturnCreatedResponse("Template Created")

        else:

            return ResponseHelper.ReturnConflictResponse(
                "Unable to Create Template!")
Example #8
0
def RevokeCoachPrivileges(current_user, user_type, coach_id):

    if not coach_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if user_type != RequestConstants.USER_TYPE_ATH:
        return ResponseHelper.ReturnBadRequestResponse()

    access_dao = AccessDao()

    if access_dao.RevokeCoachAccess(current_user, coach_id):
        return ResponseHelper.ReturnOkResponse("Access Deleted!")

    else:
        return ResponseHelper.ReturnConflictResponse("Unable to Delete Access")
Example #9
0
def DeleteTrainingLog(current_user, user_type, user_id, training_log_id):

    if current_user != user_id:

        access_dao = AccessDao()

        if not access_dao.CheckCoachTrainingLogAccess(current_user, user_id):
            return ResponseHelper.ReturnBadRequestResponse()

    training_log_dao = TrainingLogDao()

    if training_log_dao.DeleteWorkout(user_id, training_log_id):
        return ResponseHelper.ReturnOkResponse("Training Log Deleted")

    else:
        return ResponseHelper.ReturnConflictResponse("Unable to Delete Training Log!")
Example #10
0
def DeleteTarget(current_user, user_type, user_id, target_id):

    if current_user != user_id:

        access_dao = AccessDao()

        if not access_dao.CheckCoachTargetsAccess(current_user, user_id):
            return ResponseHelper.ReturnBadRequestResponse()

    target_dao = TargetDao()

    if target_dao.DeleteTarget(user_id, target_id):
        return ResponseHelper.ReturnOkResponse("Target Deleted")

    else:
        return ResponseHelper.ReturnConflictResponse(
            "Unable to Delete Target!")
Example #11
0
def DeleteTemplate(current_user, user_type, user_id, template_id):

    if current_user != user_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if user_type != RequestConstants.USER_TYPE_COA:
        return ResponseHelper.ReturnBadRequestResponse()

    training_log_template_dao = TrainingLogTemplateDao()

    if training_log_template_dao.DeleteTrainingLogTemplate(
            user_id, template_id):
        return ResponseHelper.ReturnOkResponse("Template Deleted")

    else:
        return ResponseHelper.ReturnConflictResponse(
            "Unable to Delete Template!")
Example #12
0
def DeleteInvite(current_user, user_type, invite_id):

    invite_check_dao = InviteDao()

    if invite_check_dao.CanEditOrDelete(current_user, invite_id):

        invite_dao = InviteDao()

        if invite_dao.DeclineInvite(invite_id):
            return ResponseHelper.ReturnOkResponse("Invite Declined")

        else:
            return ResponseHelper.ReturnConflictResponse(
                "Unable to Decline Invite!")

    else:

        return ResponseHelper.ReturnBadRequestResponse()
Example #13
0
def AcceptParticipants(current_user, user_type, event_id):

    if not event_id:
        return ResponseHelper.ReturnBadRequestResponse()

    event_access_dao = EventDao()

    if not event_access_dao.CanAccess(event_id, current_user):
        return ResponseHelper.ReturnBadRequestResponse()

    event_dao = EventDao()

    if event_dao.AcceptParticipant(event_id, current_user):
        return ResponseHelper.ReturnOkResponse("Participants Accepted!")

    else:
        return ResponseHelper.ReturnConflictResponse(
            "Unable to Accept Participants!")
Example #14
0
def UpdateMultipleInvite(current_user, user_type):

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        request_data = json.loads(request.data)

        update_data = UpdateInviteData(
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_KEYS],
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_VALUES],
            len(request_data[RequestConstants.UPDATE_REQUEST_MEMBER_VALUES]),
            request_data["Invite_Ids"], None, None)

        invite_check_dao = InviteDao()

        if invite_check_dao.CanEditOrDeleteMultiple(current_user,
                                                    update_data.inviteIds):

            if InvitesTable.ID in update_data.memberKeys:

                return ResponseHelper.ReturnBadRequestResponse()

            if InvitesTable.SENT_BY in update_data.memberKeys:

                return ResponseHelper.ReturnBadRequestResponse()

            if InvitesTable.SENT_TO in update_data.memberKeys:

                return ResponseHelper.ReturnBadRequestResponse()

            invite_dao = InviteDao()

            if invite_dao.UpdateMultipleInvites(update_data):
                return ResponseHelper.ReturnOkResponse("Invite Updated")

            else:
                return ResponseHelper.ReturnConflictResponse(
                    "Unable to Update Invite!")

        else:

            return ResponseHelper.ReturnBadRequestResponse()
Example #15
0
def DeleteEvent(current_user, user_type, event_id):

    if not event_id:
        return ResponseHelper.ReturnBadRequestResponse()

    host_check_dao = EventDao()

    if not host_check_dao.CheckHostAccess(current_user, event_id):
        return ResponseHelper.ReturnBadRequestResponse()

    invite_dao = InviteDao()
    invite_dao.DeleteInvitesFromEvent(event_id)

    event_dao = EventDao()

    if event_dao.DeleteEvent(event_id):
        return ResponseHelper.ReturnOkResponse("Event Deleted!")

    else:
        return ResponseHelper.ReturnConflictResponse("Unable to Delete Event!")
Example #16
0
def CreateEvent(current_user, user_type):

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    event_data = json.loads(request.data)

    event = Event(None, event_data[str(EventsTable.TYPE)],
                  event_data[str(EventsTable.NAME)],
                  event_data[str(EventsTable.HOST_USERNAME)],
                  event_data[str(EventsTable.CREATED_DATE)],
                  event_data[str(EventsTable.EVENT_DATE)], None)

    event_dao = EventDao()
    event_id = event_dao.CreateEvent(event)

    if event_id:
        return ResponseHelper.ReturnOkDataResponse("Event Created!", event_id)

    else:
        return ResponseHelper.ReturnConflictResponse("Unable to Create Event!")
Example #17
0
def RemoveParticipants(current_user, user_type, event_id):

    if not event_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    event_access_dao = EventDao()

    if not event_access_dao.CanAccess(event_id, current_user):
        return ResponseHelper.ReturnBadRequestResponse()

    request_data = json.loads(request.data)
    event_dao = EventDao()

    if event_dao.RemoveParticipants(event_id, request_data["Users"]):
        return ResponseHelper.ReturnOkResponse("Participants Deleted!")

    else:
        return ResponseHelper.ReturnConflictResponse(
            "Unable to Delete Participants!")
Example #18
0
def UpdateUser(current_user, user_type, user_id):

    if current_user != user_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        request_data = json.loads(request.data)

        update_data = UpdateData(
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_KEYS],
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_VALUES],
            [UsersTable.ID],
            [user_id],
        )

        if UsersTable.ID in update_data.memberKeys:

            return ResponseHelper.ReturnBadRequestResponse()

        if UsersTable.PASSWORD in update_data.memberKeys:

            update_data.memberValues[update_data.memberKeys.index(UsersTable.PASSWORD)] = \
                PasswordHashingHelper.GetEncryptedHash(update_data.memberValues[
                                                           update_data.memberKeys.index(UsersTable.PASSWORD)])

        user_dao = UserDao()

        if user_dao.UpdateUser(update_data):

            return ResponseHelper.ReturnOkResponse("User Updated")

        else:

            return ResponseHelper.ReturnConflictResponse(
                "Unable to Update User!")
Example #19
0
def UpdateEvent(current_user, user_type, event_id):

    if not event_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    host_check_dao = EventDao()

    if not host_check_dao.CheckHostAccess(current_user, event_id):
        return ResponseHelper.ReturnBadRequestResponse()

    request_data = json.loads(request.data)

    update_data = UpdateData(
        request_data[RequestConstants.UPDATE_REQUEST_MEMBER_KEYS],
        request_data[RequestConstants.UPDATE_REQUEST_MEMBER_VALUES],
        [EventsTable.ID],
        [event_id],
    )

    if EventsTable.ID in update_data.memberKeys:
        return ResponseHelper.ReturnBadRequestResponse()

    if EventsTable.HOST_USERNAME in update_data.memberKeys:
        return ResponseHelper.ReturnBadRequestResponse()

    if EventsTable.CREATED_DATE in update_data.memberKeys:
        return ResponseHelper.ReturnBadRequestResponse()

    event_dao = EventDao()

    if event_dao.UpdateEvent(update_data):
        return ResponseHelper.ReturnOkResponse("Event Updated!")

    else:
        return ResponseHelper.ReturnConflictResponse("Unable to Update Event!")
Example #20
0
def CreateParticipants(current_user, user_type, event_id):

    if not event_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    host_check_dao = EventDao()

    if not host_check_dao.CheckHostAccess(current_user, event_id):
        return ResponseHelper.ReturnBadRequestResponse()

    request_data = json.loads(request.data)

    event_dao = EventDao()

    if event_dao.CreateParticipants(event_id, request_data["Users"]):
        return ResponseHelper.ReturnOkResponse("Participants Added!")

    else:
        return ResponseHelper.ReturnConflictResponse(
            "Unable to Add Participants!")
Example #21
0
def UpdateTrainingLog(current_user, user_type, user_id, training_log_id):

    if current_user != user_id:

        access_dao = AccessDao()

        if not access_dao.CheckCoachTrainingLogAccess(current_user, user_id):
            return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        request_data = json.loads(request.data)

        update_data = UpdateData(
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_KEYS],
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_VALUES],
            [TrainingLogTable.ID, TrainingLogTable.ATHLETE_ID],
            [training_log_id, user_id]
        )

        if TrainingLogTable.ID in update_data.memberKeys:

            return ResponseHelper.ReturnBadRequestResponse()

        if TrainingLogTable.ATHLETE_ID in update_data.memberKeys:

            return ResponseHelper.ReturnBadRequestResponse()

        training_log_dao = TrainingLogDao()

        if training_log_dao.UpdateWorkout(update_data):
            return ResponseHelper.ReturnOkResponse("Training Log Updated")

        else:
            return ResponseHelper.ReturnConflictResponse("Unable to Update Training Log!")
Example #22
0
def CreateUser():

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        user_data = json.loads(request.data)

        password = PasswordHashingHelper.GetEncryptedHash(user_data[str(
            UsersTable.PASSWORD)])

        user = User(user_data[str(UsersTable.ID)], password, user_data[str(
            UsersTable.F_NAME)], user_data[str(UsersTable.L_NAME)],
                    user_data[str(UsersTable.E_MAIL)],
                    user_data[str(UsersTable.DOB)],
                    user_data[str(UsersTable.TYPE)],
                    user_data[str(UsersTable.LOCATION)],
                    user_data[str(UsersTable.BIO)])

        user_dao = UserDao()

        if user_dao.GetUserById(user.Id):

            return ResponseHelper.ReturnConflictResponse(
                "User Already Exists!")

        else:
            user_dao = UserDao()

            if user_dao.CreateUser(user):

                return ResponseHelper.ReturnCreatedResponse("User Created")

            else:

                return ResponseHelper.ReturnCreatedResponse(
                    "Unable to Create User!")
Example #23
0
def UpdateTarget(current_user, user_type, user_id, target_id):

    if current_user != user_id:

        access_dao = AccessDao()

        if not access_dao.CheckCoachTargetsAccess(current_user, user_id):
            return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        request_data = json.loads(request.data)

        update_data = UpdateData(
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_KEYS],
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_VALUES],
            [TargetsTable.ID, TargetsTable.ATHLETE_ID], [target_id, user_id])

        if TargetsTable.ID in update_data.memberKeys:

            return ResponseHelper.ReturnBadRequestResponse()

        if TargetsTable.ATHLETE_ID in update_data.memberKeys:

            return ResponseHelper.ReturnBadRequestResponse()

        target_dao = TargetDao()

        if target_dao.UpdateTarget(update_data):
            return ResponseHelper.ReturnOkResponse("Target Updated")

        else:
            return ResponseHelper.ReturnConflictResponse(
                "Unable to Update Target!")
Example #24
0
def UpdateTemplate(current_user, user_type, user_id, template_id):

    if current_user != user_id:
        return ResponseHelper.ReturnBadRequestResponse()

    if user_type != RequestConstants.USER_TYPE_COA:
        return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        request_data = json.loads(request.data)

        update_data = UpdateData(
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_KEYS],
            request_data[RequestConstants.UPDATE_REQUEST_MEMBER_VALUES],
            [TrainingLogTemplateTable.ID, TrainingLogTemplateTable.COACH_ID],
            [template_id, user_id])

        if TrainingLogTemplateTable.ID in update_data.memberKeys:

            return ResponseHelper.ReturnBadRequestResponse()

        if TrainingLogTemplateTable.COACH_ID in update_data.memberKeys:

            return ResponseHelper.ReturnBadRequestResponse()

        training_log_template_dao = TrainingLogTemplateDao()

        if training_log_template_dao.UpdateTrainingLogTemplate(update_data):
            return ResponseHelper.ReturnOkResponse("Template Updated")

        else:
            return ResponseHelper.ReturnConflictResponse(
                "Unable to Update Template!")
Example #25
0
def CreateTrainingLog(current_user, user_type, user_id):

    if current_user != user_id:

        access_dao = AccessDao()

        if not access_dao.CheckCoachTrainingLogAccess(current_user, user_id):
            return ResponseHelper.ReturnBadRequestResponse()

    if not request.data:
        return ResponseHelper.ReturnBadRequestResponse()

    else:
        training_log_data = json.loads(request.data)

        training_log = TrainingLog(
            None,  # For Id that is auto generated by a trigger
            user_id,  # Ensure log is created for the current user,
            training_log_data[str(TrainingLogTable.TYPE_ID)],
            training_log_data[str(TrainingLogTable.LOG_DATE)],
            training_log_data[str(TrainingLogTable.LOG_TIME)],
            training_log_data[str(TrainingLogTable.LOG_NAME)],
            training_log_data[str(TrainingLogTable.LOG_DESC)],
            training_log_data[str(TrainingLogTable.ATHLETES_COMMENTS)],
            training_log_data[str(TrainingLogTable.COACHES_COMMENTS)],
            training_log_data[str(TrainingLogTable.WORKOUT_COMMENTS)],
            training_log_data[str(TrainingLogTable.DURATION_PLANNED)],
            training_log_data[str(TrainingLogTable.DURATION_ACTUAL)],
            training_log_data[str(TrainingLogTable.DISTANCE_PLANNED)],
            training_log_data[str(TrainingLogTable.DISTANCE_ACTUAL)],
            training_log_data[str(TrainingLogTable.DISTANCE_UNIT)],
            training_log_data[str(TrainingLogTable.HR_RESTING_PLANNED)],
            training_log_data[str(TrainingLogTable.HR_AVG_PLANNED)],
            training_log_data[str(TrainingLogTable.HR_MAX_PLANNED)],
            training_log_data[str(TrainingLogTable.HR_RESTING_ACTUAL)],
            training_log_data[str(TrainingLogTable.HR_AVG_ACTUAL)],
            training_log_data[str(TrainingLogTable.HR_MAX_ACTUAL)],
            training_log_data[str(TrainingLogTable.WATTS_AVG_PLANNED)],
            training_log_data[str(TrainingLogTable.WATTS_MAX_PLANNED)],
            training_log_data[str(TrainingLogTable.WATTS_AVG_ACTUAL)],
            training_log_data[str(TrainingLogTable.WATTS_MAX_ACTUAL)],
            training_log_data[str(TrainingLogTable.RPE_PLANNED)],
            training_log_data[str(TrainingLogTable.RPE_ACTUAL)],
            training_log_data[str(TrainingLogTable.HR_ZONE1_TIME)],
            training_log_data[str(TrainingLogTable.HR_ZONE2_TIME)],
            training_log_data[str(TrainingLogTable.HR_ZONE3_TIME)],
            training_log_data[str(TrainingLogTable.HR_ZONE4_TIME)],
            training_log_data[str(TrainingLogTable.HR_ZONE5_TIME)],
            training_log_data[str(TrainingLogTable.HR_ZONE6_TIME)],
            training_log_data[str(TrainingLogTable.CALORIES_BURNED)],
            training_log_data[str(TrainingLogTable.SLEEP_QUALITY)]
        )

        training_log_dao = TrainingLogDao()

        if training_log_dao.CreateWorkout(training_log):

            return ResponseHelper.ReturnCreatedResponse("Training Log Created")

        else:

            return ResponseHelper.ReturnConflictResponse("Unable to Create Training Log!")