diff --git a/beers/admin.py b/beers/admin.py index e7908a06..17760d43 100644 --- a/beers/admin.py +++ b/beers/admin.py @@ -5,7 +5,6 @@ from django.http import HttpResponse, HttpResponseRedirect from . import models -from . import forms class BeerAlternateNameInline(admin.TabularInline): diff --git a/hsv_dot_beer/users/permissions.py b/hsv_dot_beer/users/permissions.py index 9e80ce4c..796a37cf 100644 --- a/hsv_dot_beer/users/permissions.py +++ b/hsv_dot_beer/users/permissions.py @@ -1,4 +1,4 @@ -from django.urls import reverse + from rest_framework import permissions @@ -12,11 +12,8 @@ class UserPermission(permissions.BasePermission): def has_permission(self, request, view): if request.user.is_staff: - print('it staff') return True - print('request method', request.method) if request.method == 'POST' and 'subscribe' in request.path: - print('letting detail trhough') return True return request.method in permissions.SAFE_METHODS + ('PUT', 'PATCH') diff --git a/hsv_dot_beer/users/test/test_views.py b/hsv_dot_beer/users/test/test_views.py index 398972a6..6a554e51 100644 --- a/hsv_dot_beer/users/test/test_views.py +++ b/hsv_dot_beer/users/test/test_views.py @@ -121,7 +121,7 @@ def test_update_subscription_to_beer(self): def test_unsubscribe_from_beer(self): beer = BeerFactory() - sub = UserFavoriteBeer.objects.create( + UserFavoriteBeer.objects.create( beer=beer, user=self.user, notifications_enabled=True, ) url = reverse('user-unsubscribefrombeer', kwargs={'pk': self.user.pk}) diff --git a/hsv_dot_beer/users/views.py b/hsv_dot_beer/users/views.py index 43d5aa4b..99b11a8c 100644 --- a/hsv_dot_beer/users/views.py +++ b/hsv_dot_beer/users/views.py @@ -1,7 +1,6 @@ from rest_framework import viewsets from rest_framework.decorators import action from rest_framework.generics import get_object_or_404 -from rest_framework.permissions import IsAdminUser from rest_framework.response import Response from rest_framework.serializers import ValidationError @@ -19,7 +18,6 @@ class UserViewSet(viewsets.ModelViewSet): @action(detail=True, methods=['POST']) def subscribetobeer(self, request, pk): - print('wheeeeee') user = get_object_or_404(self.get_queryset(), id=pk) body = request.data.copy() body['user'] = user.id @@ -53,7 +51,7 @@ def subscribetobeer(self, request, pk): return Response(serializer.data) # serializer is missing required fields raise exc - instance = serializer.save() + serializer.save() return Response(serializer.data) @action(detail=True, methods=['POST'])