<commit_before>from __future__ import absolute_import

from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required

from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response

from .models import Routine, Exercise

from .serializers import RoutineSerializer, ExerciseSerializer


@login_required
def routineListView(request):
    return render(request, 'routines/routine_list.html')


@login_required
def routineAddEditView(request):
    return render(request, 'routines/routine_add_edit.html')


@login_required
def routineUseView(request):
    return render(request, 'routines/routine_use.html')


# API #########################################################################

@api_view(['POST'])
def routineCreate(request):

    serializer = RoutineSerializer(data=request.data, partial=True)

    if serializer.is_valid():
        serializer.save(user=request.user)
        return Response(serializer.data, status=status.HTTP_201_CREATED)

    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


@api_view(['POST'])
def exerciseCreate(request):

    serializer = ExerciseSerializer(data=request.data)
    serializer.initial_data['routine'] = Routine.objects.filter(name=serializer.initial_data['routine'])[:1]

    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data, status=status.HTTP_201_CREATED)

    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


@api_view(['GET'])
def routineGet(request):
    pass
<commit_msg>Added get apis for routines and exercises<commit_after>from __future__ import absolute_import

from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required

from rest_framework import status
from rest_framework.decorators import api_view
from rest_framework.response import Response

from .models import Routine, Exercise

from .serializers import RoutineSerializer, ExerciseSerializer


@login_required
def routineListView(request):
    return render(request, 'routines/routine_list.html')


@login_required
def routineAddEditView(request):
    return render(request, 'routines/routine_add_edit.html')


@login_required
def routineUseView(request):
    return render(request, 'routines/routine_use.html')


# API #########################################################################

@api_view(['POST'])
def routineCreate(request):

    serializer = RoutineSerializer(data=request.data, partial=True)

    if serializer.is_valid():
        serializer.save(user=request.user)
        return Response(serializer.data, status=status.HTTP_201_CREATED)

    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


@api_view(['POST'])
def exerciseCreate(request):

    serializer = ExerciseSerializer(data=request.data)
    serializer.initial_data['routine'] = Routine.objects.filter(name=serializer.initial_data['routine'])[:1]

    if serializer.is_valid():
        serializer.save()
        return Response(serializer.data, status=status.HTTP_201_CREATED)

    else:
        return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


@api_view(['GET'])
def routineGet(request):

    exercises = Exercise.objects.get(routine=request.data['routine'], routine__user=request.user)
    serializer = ExerciseSerializer(exercises, many=True)

    return Response(serializer.data)


@api_view(['GET'])
def routinesGet(request):

    routines = Routine.objects.get(user=request.user)
    serializer = RoutineSerializer(routines, many=True)

    return Response(serializer.data)

{'fraction_non_alphanumeric': 0.13349514563106796, 'fraction_numerical': 0.007011866235167206, 'mean_word_length': 5.731397459165154, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3917085', 'n_tokens_mistral': 1097, 'n_tokens_neox': 1028, 'n_words': 205}