Skip to content

Commit 6332e4c

Browse files
Updated views as per frontend interaction
1 parent 359b876 commit 6332e4c

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

base/views.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ def register(request):
5656

5757

5858
#get note
59-
@api_view(['GET'])
59+
@api_view(['POST'])
6060
@login_required
6161
@csrf_exempt
6262
def get_notes(request):
63-
notes = Notes.objects.all()
63+
json_data = request.data
64+
user_id = json_data['user_id']
65+
user = User.objects.get(id = user_id)
66+
notes = Notes.objects.filter(user_id=user)
6467
serializer = NoteSerializer(notes,many=True)
65-
return JsonResponse(serializer.data,safe=False)
68+
# return JsonResponse(serializer.data,safe=False)
69+
return Response({'Message':"all notes", 'data': serializer.data},status=status.HTTP_200_OK)
6670

6771
#add note
6872
@api_view(['POST'])
@@ -91,6 +95,7 @@ def delete_notes(request):
9195
return Response({'Message':"Note has been deleted"},status=status.HTTP_200_OK)
9296

9397

98+
9499
#update note
95100
@api_view(['POST'])
96101
@login_required
@@ -114,7 +119,13 @@ def get_questions(request):
114119
json_data = request.data
115120
note_id = json_data['note_id']
116121
number_of_questions = json_data['number_of_questions']
122+
# [props.showQuizPage.fib, props.showQuizPage.mcq, props.showQuizPage.tf]
123+
types_of_questions = {"fib": json_data['types_of_questions'][0],
124+
"mcq" : json_data['types_of_questions'][1],
125+
"tf" : json_data['types_of_questions'][2]}
117126
note = Notes.objects.get(id = note_id)
127+
print(types_of_questions)
128+
print("aagaya atleast yaha! ")
118129
#url for ml server
119130
ml_server_url = "localhost/questions/11"
120131
data = requests.post(ml_server_url, data = {'note_text': note.content, 'number_of_questions': number_of_questions})
@@ -129,9 +140,11 @@ def get_questions(request):
129140
def get_image_content(request):
130141
if request.method == 'POST':
131142
json_data = request.data
132-
number_of_questions = json_data['number_of_questions']
143+
# number_of_questions = json_data['number_of_questions']
144+
number_of_questions = 7
133145
img_data = request.FILES['file'].read()
134-
img_string = base64.b64encode(img_data)
146+
print(img_data)
147+
img_string = base64.b64encode(img_data)
135148

136149
#url for ml server image to text
137150
ml_server_url = "localhost/questions/3"

0 commit comments

Comments
 (0)