
from rest_framework.views import APIView

from .serializers import AuthorSerializer
from .dataUtils import getAuthor
from .httpUtils import JSONResponse

class AuthorView(APIView):
    """
    This view gets authors.
    """
    def get(self, request, aid):
        # Get author
        author = getAuthor(request, aid)
        authSer =  AuthorSerializer(author)
        return JSONResponse(authSer.data)


from rest_framework.views import APIView

from .serializers import AuthorSerializer
from .dataUtils import getAuthor
from .httpUtils import JSONResponse

class AuthorView(APIView):
    """
    This view gets authors.
    """
    def get(self, request, aid):
        # Get author
        author = getAuthor(request, aid)
        context = {'addFriends': True}
        authSer =  AuthorSerializer(author, context=context)
        return JSONResponse(authSer.data)

Add friends to author view.
Add friends to author view.

  
  from rest_framework.views import APIView
  
  from .serializers import AuthorSerializer
  from .dataUtils import getAuthor
  from .httpUtils import JSONResponse
  
  class AuthorView(APIView):
      """
      This view gets authors.
      """
      def get(self, request, aid):
          # Get author
          author = getAuthor(request, aid)
+         context = {'addFriends': True}
-         authSer =  AuthorSerializer(author)
+         authSer =  AuthorSerializer(author, context=context)
          return JSONResponse(authSer.data)
  
Add friends to author view.
## Code Before:

from rest_framework.views import APIView

from .serializers import AuthorSerializer
from .dataUtils import getAuthor
from .httpUtils import JSONResponse

class AuthorView(APIView):
    """
    This view gets authors.
    """
    def get(self, request, aid):
        # Get author
        author = getAuthor(request, aid)
        authSer =  AuthorSerializer(author)
        return JSONResponse(authSer.data)

## Instruction:
Add friends to author view.
## Code After:

from rest_framework.views import APIView

from .serializers import AuthorSerializer
from .dataUtils import getAuthor
from .httpUtils import JSONResponse

class AuthorView(APIView):
    """
    This view gets authors.
    """
    def get(self, request, aid):
        # Get author
        author = getAuthor(request, aid)
        context = {'addFriends': True}
        authSer =  AuthorSerializer(author, context=context)
        return JSONResponse(authSer.data)
