Skip to content

Commit

Permalink
feat: added to serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
rb-25 committed Apr 28, 2024
1 parent 34d19d2 commit 205caf7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gibspons/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Django==5.0.1
django-cors-headers==4.3.1
djangorestframework==3.14.0
djangorestframework-simplejwt==5.3.1
django-filter==23.5.0
django-filter==24.2
google-ai-generativelanguage==0.4.0
google-api-core==2.16.1
google-auth==2.27.0
Expand Down
2 changes: 1 addition & 1 deletion gibspons/spons_app/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SponsorshipSerializer(serializers.ModelSerializer):

class Meta:
model=Sponsorship
fields=['id','company','poc','event','event_name','contacted_by','user_name','status','type_of_sponsorship','money_donated','additional','company_name']
fields=['id','company','poc','event','event_name','contacted_by','user_name','updated_at','status','type_of_sponsorship','money_donated','additional','company_name']

#---------AI SERIALIZER-------------------------

Expand Down
3 changes: 3 additions & 0 deletions gibspons/spons_app/views/sponsorship.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def patch(request,sponsor_id):
if 'status' in serializer.validated_data and serializer.validated_data['status']=='Accepted' and request.user.role not in ['admin','owner']:
return Response({'detail':'Permission denied'},status=status.HTTP_401_UNAUTHORIZED)

if any(serializer.validated_data.get(key) for key in ['money_donated', 'additional', 'type_of_sponsorship']) and serializer.validated_data['status']!='Accepted':
return Response({'detail':'Status must be accepted for this action'})

serializer.save()
return Response(serializer.data,status=status.HTTP_200_OK)
return Response({"detail" : serializer.errors},status=status.HTTP_400_BAD_REQUEST)
Expand Down
5 changes: 3 additions & 2 deletions gibspons/sponsorship/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.staticfiles',
'django_filters',
'corsheaders',
'users',
'spons_app',
Expand Down Expand Up @@ -139,7 +140,7 @@
#"rest_framework.authentication.TokenAuthentication",
),
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
"DEFAULT_FILTER_BACKENDS": ["django_filters.rest_framework.DjangoFilterBackend"],
'DEFAULT_FILTER_BACKENDS': ['django_filters.rest_framework.DjangoFilterBackend']
}

SIMPLE_JWT = {
Expand Down

0 comments on commit 205caf7

Please sign in to comment.