Skip to content

Commit

Permalink
Fixed linter errors in api_views
Browse files Browse the repository at this point in the history
- Also adjusted views to work with model change (removing election_year as Response attribute)
  • Loading branch information
JusticeV452 committed May 14, 2024
1 parent aeb484b commit d8c0615
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/app/api_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,13 +230,15 @@ def get_lokniti_responses_by_question_and_year(request, election_year, question_
election year
"""
responses = LoknitiResponses.objects.filter(
election_yearyear=election_year, question_var=question_var)
responder__election_year=election_year, question_var=question_var)
serializer = LoknitiResponsesSerializer(responses, many=True)
return Response(serializer.data)


@api_view(['GET'])
def get_lokniti_responses_by_constituency(request, election_year, state_name, PC_id, question_election_year, question_var_orig):
# pylint: disable=too-many-arguments
def get_lokniti_responses_by_constituency(
request, election_year, state_name, PC_id, question_election_year, question_var_orig):
"""
API endpoint to get all responses to a question in a specific
election year and constituency based on a question variable name
Expand All @@ -250,7 +252,9 @@ def get_lokniti_responses_by_constituency(request, election_year, state_name, PC
question_text=question_text, election_year=election_year).question_var

responses = LoknitiResponses.objects.filter(
election_year=election_year, question_var=question_var, responder__state_name=state_name, responder__PC_id=PC_id)
responder__election_year=election_year, question_var=question_var,
responder__state_name=state_name, responder__PC_id=PC_id
)
serializer = LoknitiResponsesSerializer(responses, many=True)

return Response(serializer.data)

0 comments on commit d8c0615

Please sign in to comment.