Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
YaBoyya committed Apr 19, 2024
1 parent 808ed5e commit 2ef19e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions backend/events/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def validate(self, attrs):
return attrs


class LocationSerializer(serializers.Serializer):
class LocationSerializer(serializers.ModelSerializer):
class Meta:
model = models.Location
fields = '__all__'
Expand Down Expand Up @@ -84,7 +84,7 @@ class RoleSerializer(ValidateUserInContextMixin,
serializers.ModelSerializer):
class Meta:
model = models.Role
fields = ['event', 'user', 'name']
fields = ['id', 'event', 'user', 'name']
extra_kwargs = {
'user': {'read_only': True},
'name': {'required': False},
Expand Down
11 changes: 7 additions & 4 deletions backend/events/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from events import permissions as event_permissions
from events import serializers
from events.models import Event, Role, SocialMedia
from events.models import Event, Location, Role, SocialMedia


class LocationViewSet(mixins.ListModelMixin,
Expand All @@ -13,6 +13,9 @@ class LocationViewSet(mixins.ListModelMixin,
serializer_class = serializers.LocationSerializer
permission_classes = [permissions.IsAuthenticatedOrReadOnly]

def get_queryset(self):
return Location.objects.all()


class EventViewSet(viewsets.ModelViewSet):
def get_queryset(self):
Expand All @@ -26,7 +29,7 @@ def get_serializer_class(self):
return serializers.EventFeedSerializer

def get_permissions(self):
if self.action in ['list', 'retrieve']:
if self.request.method in permissions.SAFE_METHODS:
permission_classes = [permissions.AllowAny]
elif self.action == 'create':
permission_classes = [permissions.IsAuthenticated]
Expand All @@ -35,7 +38,7 @@ def get_permissions(self):
permissions.IsAuthenticated,
event_permissions.IsEventModerator
]
elif self.action == 'destroy':
else: # destroy
permission_classes = [
permissions.IsAuthenticated,
event_permissions.IsEventOwner
Expand All @@ -60,7 +63,7 @@ def get_permissions(self):
permissions.IsAuthenticated,
event_permissions.DestroyRolePermission
]
elif self.action in ['update', 'partial_update']:
else: # update, partial_update
permission_classes = [
permissions.IsAuthenticated,
event_permissions.IsEventOwner
Expand Down

0 comments on commit 2ef19e6

Please sign in to comment.