From c3bf63dfa22015db3ec5d8d907ac1dbea94bc7c4 Mon Sep 17 00:00:00 2001 From: ticoucke Date: Mon, 4 Mar 2024 11:35:42 +0100 Subject: [PATCH] Temp commit --- api/__pycache__/admin.cpython-311.pyc | Bin 868 -> 868 bytes api/__pycache__/middleware.cpython-311.pyc | Bin 1318 -> 1318 bytes api/__pycache__/models.cpython-311.pyc | Bin 5448 -> 5522 bytes api/__pycache__/serializers.cpython-311.pyc | Bin 840 -> 6806 bytes api/__pycache__/settings.cpython-311.pyc | Bin 3787 -> 3739 bytes api/__pycache__/urls.cpython-311.pyc | Bin 1540 -> 1633 bytes api/__pycache__/utils.cpython-311.pyc | Bin 1524 -> 1089 bytes .../__pycache__/0001_initial.cpython-311.pyc | Bin 4631 -> 4631 bytes ...move_student_name_and_more.cpython-311.pyc | Bin 1472 -> 1472 bytes ...003_alter_student_subjects.cpython-311.pyc | Bin 919 -> 919 bytes ...004_alter_student_subjects.cpython-311.pyc | Bin 881 -> 881 bytes .../0005_alter_vak_teachers.cpython-311.pyc | Bin 891 -> 891 bytes ...alter_lesgever_lesgever_id.cpython-311.pyc | Bin 971 -> 971 bytes ...ubjects_alter_vak_teachers.cpython-311.pyc | Bin 1121 -> 1121 bytes .../__pycache__/__init__.cpython-311.pyc | Bin 192 -> 192 bytes api/models.py | 2 +- api/serializers.py | 3 -- api/settings.py | 2 +- api/urls.py | 5 +-- api/utils.py | 12 +------ api/views/__pycache__/student.cpython-311.pyc | Bin 1598 -> 2684 bytes api/views/__pycache__/views.cpython-311.pyc | Bin 962 -> 962 bytes api/views/student.py | 32 +++++++++++------- 23 files changed, 26 insertions(+), 30 deletions(-) diff --git a/api/__pycache__/admin.cpython-311.pyc b/api/__pycache__/admin.cpython-311.pyc index de8c4a228d3219a57d1e43fc36290ee78dc51e95..b4323d432a3023cf217ce8bffcbd53a1cc8c8ddf 100644 GIT binary patch delta 19 ZcmaFD_JoaVIWI340}z-cZsdw$1^_c01X%z8 delta 19 ZcmaFD_JoaVIWI340}yCLZ{&(%1^_au1VsP< diff --git a/api/__pycache__/middleware.cpython-311.pyc b/api/__pycache__/middleware.cpython-311.pyc index a95134ebdca902b614438002c6cd824993db95d8..53923d4948d5f35e5baa49f1cf91cba548ce14cb 100644 GIT binary patch delta 19 ZcmZ3+wTz2vIWI340}z-cZsd|-1pq2?1E~N2 delta 19 ZcmZ3+wTz2vIWI340}yCLZ{(6;1pq1l1C;;( diff --git a/api/__pycache__/models.cpython-311.pyc b/api/__pycache__/models.cpython-311.pyc index 41ecef06b78f4d910732d53c32e1f3b29561efc8..663de4ff9f17959837a77e34645828be4753f63a 100644 GIT binary patch delta 567 zcmX@1HA$OyIWI340}yPS_cXO@Bd;h6>waAc_pic@GUOa+{DZrx6IU>lv}K+Aok>otgeicCX2IKi15gE zxLx6qU66W#N9Q7s&J`Y=2G`AgY(E$oWhc9H)G&%|J^~~e%_ci?l`^VM-p*yi?F6*3 zNCre$P5#Ga#AOF!f(V7lR@_yLc9T!@Nlre;{T`@kACDHJ!{nDdnT&>$gLz#Uy(iD) zwP19fe2LeA%M7FqL}*Nw;adk(e46j3G}tT$pkNh8X+chYVoI@oksFZfR^%~xKYtpd z)nqjRCsAjhNRc#eUXQbv`@jNCTd4nXZiG9bcYvIn;jmko#s zBIGBxa91(fZ2r&90n%}iU3juIuQ;RKWMke;MuW+7d0iPjCqL%3V04@;!{@+d0@4Q} z)F-F$tpjTK&n-DwkNRO0j;C3y|wpefd<2PqK}ZTs Mt`(7(d{E>f0B?nTsQ>@~ diff --git a/api/__pycache__/serializers.cpython-311.pyc b/api/__pycache__/serializers.cpython-311.pyc index 4ae63a8c37211baebe79a413393777f65578f150..e192a5ebecf36a9972e5ab2396dba3728364a5c1 100644 GIT binary patch literal 6806 zcmd5=-*4N-9Y2bsMB9`p+ltKmT9qYE;dHUuI%%9PE!rYokS0;mdEExKg}{n*szj8$ zqnx#wgLyz7yv=CymSRtS7_u07=|lgHfer{nATTUIpZexNdCJqi-#bZ;M1{^OH7I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.cpython-311.pyc index 3e0f9d4c8532279139aac0851d43f2d7692ba939..063efeba006869bbe48bae83f83fef29d7fd610a 100644 GIT binary patch delta 261 zcmZqSdB~%_oR^o20SN9T-%sskVPJR+;=lkWl=1n?M0IM%$&)Om~*A8#1acK^`R1}dHOb)c_mhvDRzFE{F8%N5}1m(Ca-5H;SvMd zzzD>}PbcfLMu?eTV8DVVPi2i)xWU5F;BtXeae>`M7NaXHMjv?D`I#EHL9j>!XaWFl C21PIc delta 169 zcmaFJ)54>^oR^o20SGjr@294)Ffcp@abSQ0%J_V1qPqRWEJbc^m`oPW#C_5eH~Mp> zvqtfz@CGwz@@-aNJj=w-c#EgFq%8T}}jJLSJO5>CBQ&NjTrYICifK+j173b&0gXM}8fC5TD zT&xQu8W`?!i_Z{WV7WGJeb%b19a2ZbPI$^+aSgku7k))A{DM-%1&PRu+)-D!qb{&S zeFo}a(BzmrpIOyJ1jsCs1rZ?sfK6S=P^1WAgRK0;VUwGmQks)$SELH$g4|MEJoz27 rxeJ4U-3@-_53I~wOdlA4L<8Fg9$`k24-9ZZkC8E&@dE>P5^MzkIX#IC diff --git a/api/migrations/__pycache__/0001_initial.cpython-311.pyc b/api/migrations/__pycache__/0001_initial.cpython-311.pyc index 5cfad12a1dc5c9bd356d7b7598c4d330d3ec2cd0..ed1272db24682732bc3aa9c0f314c0651d52714a 100644 GIT binary patch delta 19 ZcmbQPGF^phIWI340}z-cZsg(>0st$y1HAwM delta 19 ZcmbQPGF^phIWI340}yCLZ{*??0st#V1E~N2 diff --git a/api/migrations/__pycache__/0002_remove_student_id_remove_student_name_and_more.cpython-311.pyc b/api/migrations/__pycache__/0002_remove_student_id_remove_student_name_and_more.cpython-311.pyc index 35ec2e9115eda1201f688cfef5e8ad3c106cd610..52dfba9384e6c170c476a48673cfff36fc1bfd3b 100644 GIT binary patch delta 19 ZcmX@WeSn*5IWI340}z-cZsgj=3IH!~1bF}e delta 19 ZcmX@WeSn*5IWI340}yCLZ{*s>3IHzt1Z4mK diff --git a/api/migrations/__pycache__/0003_alter_student_subjects.cpython-311.pyc b/api/migrations/__pycache__/0003_alter_student_subjects.cpython-311.pyc index 5b421ad4ee7c87ed690075e9bc7548f3b6506fe8..ead4b8af7b1a3932d0012cc7c4f3b83ed8b9a57f 100644 GIT binary patch delta 19 ZcmbQvKAoLwIWI340}z-cZsh7^1^_6~1M~m@ delta 19 ZcmbQvKAoLwIWI340}yCLZ{+G_1^_5t1KIWI340}z-cPUPAK04Y}lKmY&$ delta 18 YcmX@Wcz}^>IWI340}yCLPvqJL04VtcEC2ui diff --git a/api/models.py b/api/models.py index 48557de3..aad210e6 100644 --- a/api/models.py +++ b/api/models.py @@ -12,7 +12,7 @@ def __str__(self): class Lesgever(models.Model): lesgever_id = models.AutoField(primary_key=True) name = models.CharField(max_length=100) - email = models.EmailField() + email = models.EmailField(default=False) subjects = models.ManyToManyField('Vak', related_name='lesgevers_enrolled', blank=True) is_admin = models.BooleanField(default=False) diff --git a/api/serializers.py b/api/serializers.py index 62c2db83..b349b04a 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -15,9 +15,6 @@ def create(self, validated_data): return Student.objects.create(**validated_data) def update(self, instance, validated_data): - # Update the regular fields - instance.name = validated_data.get('name', instance.name) - instance.email = validated_data.get('email', instance.email) # Update the subjects list subjects_data = validated_data.pop('subjects', None) if subjects_data is not None: diff --git a/api/settings.py b/api/settings.py index 5960c2f8..344fee43 100644 --- a/api/settings.py +++ b/api/settings.py @@ -54,7 +54,7 @@ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'api.middleware.RedirectAnonymousUserMiddleware', + #'api.middleware.RedirectAnonymousUserMiddleware', ] ROOT_URLCONF = 'api.urls' diff --git a/api/urls.py b/api/urls.py index 1eea2062..9b939fbe 100644 --- a/api/urls.py +++ b/api/urls.py @@ -18,12 +18,13 @@ from django.urls import path, include from .views.views import microsoft_association, login_redirect -from .views.student import student_list +from .views.student import student_list, student_detail urlpatterns = [ path('.well-known/microsoft-identity-association.json', microsoft_association), path('admin/', admin.site.urls), path('oauth2/', include('django_auth_adfs.urls')), path('login_redirect', login_redirect), - path('api/studenten', student_list) + path('api/studenten', student_list), + path('api/studenten/', student_detail) ] diff --git a/api/utils.py b/api/utils.py index 7504ceac..93852bbb 100644 --- a/api/utils.py +++ b/api/utils.py @@ -2,11 +2,6 @@ from django.http import JsonResponse import requests -ERRORS = { - 'no_perm': 'You do not have permission to view this data', - 'generic': 'There was an error' -} - def get_graph_token(): """ @@ -27,9 +22,4 @@ def get_graph_token(): response = requests.post(url=url, headers=headers, data=data) return response.json() except: - return None - - - -def json_error(error_code): - return JsonResponse({'error': {'message': ERRORS.get(error_code, ERRORS['generic'])}}) \ No newline at end of file + return None \ No newline at end of file diff --git a/api/views/__pycache__/student.cpython-311.pyc b/api/views/__pycache__/student.cpython-311.pyc index db48172ffe2d34d24125f283294b5eb6718cf4bc..cbc594538c983fd86a56c7e3ec5b7af2ca53e536 100644 GIT binary patch literal 2684 zcmaJ@-EY%Y6u-9foiu?24_asmgLaKnY6fLmVcJA#V6Zk}B-KPTDKfEvq)FUeyB|#H zgeD#$G--Q4qMAUeG>L)e1DfCu;6Jb{OJtU+P1+N0nRuy~H0@j`cH(q!b#r{~z31F} zeD3-EoL~F;0tni(pZ^f=xDon`46NpAE3Y4dat{eepvtI1&`sjIt<*RRyeex7Cb@i+s8Gt%wcgd@^geE~PWsf*m&akwh`@d;J^C-a|E1f;&e&Y- z*j63;qmK86+v&eb*XVVxwRiW^88My!J74#@r915?^tQN_sO5oB$t+Pa-taizJJaiL zXTjkgvi92PFCZuyZweE~EL^&)!dGu%;sCYb5_pBjB$tUk!&4EJ8GA8k1Ko7#Z$fB<(=a-;j1j8lsOClx-Gj@HR&0fkMKlWk%?B(Q{Y;xN0h!{&) zHujh+6UUC_r_N00FDJj8OJ=eO#_(eCn?+Gp44>SpN!bXF6W zg_}mGt>?={S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C+jjQG0vMD zz$nG&Iysv$OCW`%hAE2;rZJOo@hZ`N!kkVsKs2|rARfuV*0p$^r4Murkj?CRFA zO;%(QX5^UM$R<3wfQg^2$fSm80Vk9zq%Vr34apfLVhHgp9vFKK`{a*IqKX`TMIfON zpubph6Z0x>aTb@9rljVTq~;az0wpvj%P{NPFauddf?qzpS&PNeKzc^>3avHz z7i6q1@>^fwx4yt(eS=e=M{b7MB~HZ)oQiijcstU2axQX6U*V9xz#%=kj>TW-0~;Hw z#s>x<@fm0mgP$h<qAJ3SKsNx1kIW2A S(pMOzJ^*6_A_5i$+XMj6{*F)p diff --git a/api/views/__pycache__/views.cpython-311.pyc b/api/views/__pycache__/views.cpython-311.pyc index 00d54b346c175586d269780d2160f7818308bf20..bd0b3605f40d14c53cccbb07fc575fc60b009e5d 100644 GIT binary patch delta 19 ZcmX@aeu$lGIWI340}z-cZsgj*3;-`O1a$xa delta 19 ZcmX@aeu$lGIWI340}yCLZ{*s+3;-^`1YrOG diff --git a/api/views/student.py b/api/views/student.py index 5b9d3c84..cf38cb3b 100644 --- a/api/views/student.py +++ b/api/views/student.py @@ -5,8 +5,7 @@ from ..models import Student -from ..serializers import StudentSerializer -from ..utils import json_error +from ..serializers.student import StudentSerializer @api_view(['GET', 'POST']) @@ -14,19 +13,28 @@ def student_list(request): if request.method == 'GET': students = Student.objects.all() serializer = StudentSerializer(students, many=True) - return JsonResponse({'studenten': serializer.data}) + return Response(serializer.data) elif request.method == 'POST': - print(request.data) serializer = StudentSerializer(data=request.data) if serializer.is_valid(): serializer.save() return Response(serializer.data, status=status.HTTP_201_CREATED) - - - """if request.user.is_superuser: - students = Student.objects.all() - serializer = StudentSerializer(students, many=True) - return JsonResponse({'studenten': serializer.data}) + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) + - else: - return json_error('no_perm')""" \ No newline at end of file +@api_view(['GET', 'PUT']) +def student_detail(request, id): + try: + student = Student.objects.get(pk=id) + except Student.DoesNotExist: + return Response(status=status.HTTP_404_NOT_FOUND) + + if request.method == 'GET': + serializer = StudentSerializer(student) + return Response(serializer.data) + elif request.method == 'PUT': + serializer = StudentSerializer(student, data=request.data) + if serializer.is_valid(): + serializer.save() + return Response(serializer.data) + return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)