From 81dee6bda3f8044f7718fdeedf3055939082e1f7 Mon Sep 17 00:00:00 2001 From: Valeria Vitti Date: Tue, 11 Jul 2023 17:03:53 +0200 Subject: [PATCH] api --- api/views.py | 9 +++++---- sistema/models.py | 2 +- socoin_atlas/settings.py | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/api/views.py b/api/views.py index 8bc2904..ac11571 100644 --- a/api/views.py +++ b/api/views.py @@ -126,6 +126,7 @@ class RegistrationAPI(APIView): class ListaPercorsiAPI(APIView): + def get(self, request): errors = [] error = False @@ -218,16 +219,16 @@ class SendFeedbackAPI(APIView): if id_utente and id_percorso and valutazione: - utente = User.objects.get(pk=int(id_utente)) + utente = User.objects.filter(pk=int(id_utente)) if utente: - percorso = Percorso.objects.get(pk=int(id_percorso)) + percorso = Percorso.objects.filter(pk=int(id_percorso)) if percorso: try: Feedback.objects.create( - utente=utente, - percorso=percorso, + utente=utente.last(), + percorso=percorso.last(), valutazione=int(valutazione), commento=commento ) diff --git a/sistema/models.py b/sistema/models.py index b847717..64138cd 100644 --- a/sistema/models.py +++ b/sistema/models.py @@ -121,4 +121,4 @@ class PoiSerializer(serializers.ModelSerializer): class MultimediaSerializer(serializers.ModelSerializer): class Meta: model = Multimedia - fields = ('id', 'nome', 'tipologia__nome', 'media', 'nome', 'descrizione', 'testo') \ No newline at end of file + fields = ('id', 'nome', 'tipologia', 'media', 'nome', 'descrizione', 'testo') \ No newline at end of file diff --git a/socoin_atlas/settings.py b/socoin_atlas/settings.py index 64a8646..747dcb0 100644 --- a/socoin_atlas/settings.py +++ b/socoin_atlas/settings.py @@ -42,6 +42,7 @@ INSTALLED_APPS = [ 'sistema', 'utenti', 'api', + 'rest_framework' ] @@ -63,6 +64,7 @@ REST_FRAMEWORK = { 'rest_framework_simplejwt.authentication.JWTAuthentication', 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.BasicAuthentication', + 'rest_framework.authentication.TokenAuthentication', ), } -- 2.43.0