Open TheDepe opened 7 months ago
GET: curl --location 'http://127.0.0.1:8000/api/5/modules/available' \ --header 'Cookie: csrftoken=3ppvmQIb4d5H73dqJcXNQ4Vf654PerSw'
it returns not enhanced module details like, if we need I can change relations with detailed fields. [ { "id": 2, "name": "Test Module", "code": null, "start_date": "2024-03-11", "end_date": "2024-06-01", "created_at": "2024-03-11T06:38:46Z", "survey_days": "1", "faculty": null, "owners": 2 } ]
Output is good I think
I assume this is the function?
`@api_view(["GET"]) def get_available_modules(request, student_id):
try:
student_user = StudentUser.objects.get(user=student_id)
except StudentUser.DoesNotExist:
return Response({"error": "Student user not found"}, status=404)
current_date = timezone.now().date()
student_modules = StudentModule.objects.filter(
student=student_user, module__start_date__lte=current_date
).select_related("module")
serializer = ModuleSerializer([sm.module for sm in student_modules], many=True)
return Response(serializer.data)
`
Can we remove the student filter from the function? We only need essentialy:
modules_available = Modules.objects.filter(university = student.university)
but that means it will return all modules even the not related one is that okay, I though we are expecting to return only the registered course which is started, when you confirm I will make the change
nah, this is for the page that you see TO register to a course.
We have https://mz-bdev.de/api/student/${user.id}/modules
which gives us the modules for which the student is registered, we now need the ones that they COULD sign up to.
I just changed and send the code It will be up in 2 min, when I checked my local It looks working but not sure
GET Endpoint for a list of all modules available to a given student.
We can do this for now by returning all modules at the student's University.
Data required: