Skip to content

Commit

Permalink
fix pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
drewbrew committed Jul 23, 2019
1 parent 76d5677 commit 3f0b546
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
1 change: 0 additions & 1 deletion beers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.http import HttpResponse, HttpResponseRedirect

from . import models
from . import forms


class BeerAlternateNameInline(admin.TabularInline):
Expand Down
5 changes: 1 addition & 4 deletions hsv_dot_beer/users/permissions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.urls import reverse

from rest_framework import permissions


Expand All @@ -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')

Expand Down
2 changes: 1 addition & 1 deletion hsv_dot_beer/users/test/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
4 changes: 1 addition & 3 deletions hsv_dot_beer/users/views.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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'])
Expand Down

0 comments on commit 3f0b546

Please sign in to comment.