Skip to content

Commit

Permalink
Merge pull request #681 from Samfundet/feature/fixauthenticated
Browse files Browse the repository at this point in the history
set model permission instead of authenticated
  • Loading branch information
magsyg authored Sep 26, 2023
2 parents e31ac3f + 75be4e0 commit 5bdfd15
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions backend/samfundet/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,14 @@ class KeyValueView(ReadOnlyModelViewSet):

# Images
class ImageView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = ImageSerializer
queryset = Image.objects.all().order_by('-pk')


# Image tags
class TagView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = TagSerializer
queryset = Tag.objects.all()

Expand All @@ -144,6 +146,7 @@ class TagView(ModelViewSet):


class EventView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = EventSerializer
queryset = Event.objects.all()

Expand Down Expand Up @@ -176,7 +179,7 @@ def get(self, request: Request) -> Response:


class EventGroupView(ModelViewSet):
http_method_names = ['get']
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = EventGroupSerializer
queryset = EventGroup.objects.all()

Expand All @@ -187,13 +190,14 @@ class EventGroupView(ModelViewSet):


class VenueView(ModelViewSet):
permission_classes = [AllowAny]
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = VenueSerializer
queryset = Venue.objects.all()
lookup_field = 'slug'


class ClosedPeriodView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = ClosedPeriodSerializer
queryset = ClosedPeriod.objects.all()

Expand All @@ -210,24 +214,25 @@ def get_queryset(self) -> QuerySet:


class SaksdokumentView(ModelViewSet):
permission_classes = [AllowAny]
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = SaksdokumentSerializer
queryset = Saksdokument.objects.all()


class OrganizationView(ModelViewSet):
permission_classes = [AllowAny]
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = OrganizationSerializer
queryset = Organization.objects.all()


class GangView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = GangSerializer
queryset = Gang.objects.all()


class GangTypeView(ModelViewSet):
http_method_names = ['get']
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = GangTypeSerializer
queryset = GangType.objects.all()

Expand Down Expand Up @@ -256,31 +261,37 @@ class BlogPostView(ModelViewSet):


class MenuView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = MenuSerializer
queryset = Menu.objects.all()


class MenuItemView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = MenuItemSerializer
queryset = MenuItem.objects.all()


class FoodCategoryView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = FoodCategorySerializer
queryset = FoodCategory.objects.all()


class FoodPreferenceView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = FoodPreferenceSerializer
queryset = FoodPreference.objects.all()


class TableView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = TableSerializer
queryset = Table.objects.all()


class BookingView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = BookingSerializer
queryset = Booking.objects.all()

Expand Down Expand Up @@ -359,7 +370,7 @@ def get(self, request: Request) -> Response:


class AllUsersView(ListAPIView):
permission_classes = [IsAuthenticated]
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = UserSerializer
queryset = User.objects.all()

Expand All @@ -375,7 +386,7 @@ def post(self, request: Request) -> Response:


class AllGroupsView(ListAPIView):
permission_classes = [IsAuthenticated]
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = GroupSerializer
queryset = Group.objects.all()

Expand All @@ -396,6 +407,7 @@ class UserPreferenceView(ModelViewSet):


class ProfileView(ModelViewSet):
permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
serializer_class = ProfileSerializer
queryset = Profile.objects.all()

Expand Down

0 comments on commit 5bdfd15

Please sign in to comment.