Skip to content

Commit

Permalink
Merge pull request #966 from ubyssey/upgrade-djangorestframework
Browse files Browse the repository at this point in the history
Upgrade djangorestframework
  • Loading branch information
keeganland authored Jun 4, 2020
2 parents df973f1 + 5963c93 commit 495aeec
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions dispatch/api/mixins.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from rest_framework.response import Response
from rest_framework.decorators import detail_route
from rest_framework.decorators import action
from rest_framework.viewsets import ModelViewSet
from rest_framework.serializers import HyperlinkedModelSerializer
from django.db.models import F
Expand Down Expand Up @@ -61,7 +61,7 @@ def perform_unpublish(self, serializer):
instance=instance,
user=self.request.user)

@detail_route(methods=['post'])
@action(detail=True, methods=['post'])
def publish(self, request, parent_id=None):

instance = self.get_object()
Expand All @@ -72,7 +72,7 @@ def publish(self, request, parent_id=None):

return Response(serializer.data)

@detail_route(methods=['post'])
@action(detail=True, methods=['post'])
def unpublish(self, request, parent_id=None):

instance = self.get_object()
Expand Down
44 changes: 22 additions & 22 deletions dispatch/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,28 @@

router = routers.DefaultRouter()

router.register(r'articles', views.ArticleViewSet, base_name='api-articles')
router.register(r'pages', views.PageViewSet, base_name='api-pages')
router.register(r'sections', views.SectionViewSet, base_name='api-sections')
router.register(r'persons', views.PersonViewSet, base_name='api-persons')
router.register(r'users', views.UserViewSet, base_name='api-users')
router.register(r'tags', views.TagViewSet, base_name='api-tags')
router.register(r'topics', views.TopicViewSet, base_name='api-topics')
router.register(r'images', views.ImageViewSet, base_name='api-images')
router.register(r'galleries', views.ImageGalleryViewSet, base_name='api-galleries')
router.register(r'templates', views.TemplateViewSet, base_name='api-templates')
router.register(r'dashboard', views.DashboardViewSet, base_name='api-dashboard')
router.register(r'integrations', views.IntegrationViewSet, base_name='api-integrations')
router.register(r'files',views.FileViewSet, base_name='api-files')
router.register(r'issues',views.IssueViewSet, base_name='api-issues')
router.register(r'zones', views.ZoneViewSet, base_name='api-zones')
router.register(r'token', views.TokenViewSet, base_name='api-token')
router.register(r'videos', views.VideoViewSet, base_name='api-videos')
router.register(r'invites', views.InviteViewSet, base_name='api-invites')
router.register(r'polls', views.PollViewSet, base_name='api-polls')
router.register(r'subsections', views.SubsectionViewSet, base_name='api-subsections')
router.register(r'podcasts/podcasts', views.PodcastViewSet, base_name='api-podcasts')
router.register(r'podcasts/episodes', views.PodcastEpisodeViewSet, base_name='api-podcast-episodes')
router.register(r'articles', views.ArticleViewSet, basename='api-articles')
router.register(r'pages', views.PageViewSet, basename='api-pages')
router.register(r'sections', views.SectionViewSet, basename='api-sections')
router.register(r'persons', views.PersonViewSet, basename='api-persons')
router.register(r'users', views.UserViewSet, basename='api-users')
router.register(r'tags', views.TagViewSet, basename='api-tags')
router.register(r'topics', views.TopicViewSet, basename='api-topics')
router.register(r'images', views.ImageViewSet, basename='api-images')
router.register(r'galleries', views.ImageGalleryViewSet, basename='api-galleries')
router.register(r'templates', views.TemplateViewSet, basename='api-templates')
router.register(r'dashboard', views.DashboardViewSet, basename='api-dashboard')
router.register(r'integrations', views.IntegrationViewSet, basename='api-integrations')
router.register(r'files',views.FileViewSet, basename='api-files')
router.register(r'issues',views.IssueViewSet, basename='api-issues')
router.register(r'zones', views.ZoneViewSet, basename='api-zones')
router.register(r'token', views.TokenViewSet, basename='api-token')
router.register(r'videos', views.VideoViewSet, basename='api-videos')
router.register(r'invites', views.InviteViewSet, basename='api-invites')
router.register(r'polls', views.PollViewSet, basename='api-polls')
router.register(r'subsections', views.SubsectionViewSet, basename='api-subsections')
router.register(r'podcasts/podcasts', views.PodcastViewSet, basename='api-podcasts')
router.register(r'podcasts/episodes', views.PodcastEpisodeViewSet, basename='api-podcast-episodes')

dashboard_recent_articles = views.DashboardViewSet.as_view({'get': 'list_recent_articles'})
dashboard_user_actions = views.DashboardViewSet.as_view({'get': 'list_actions'})
Expand Down
14 changes: 7 additions & 7 deletions dispatch/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from rest_framework.permissions import (
AllowAny, IsAuthenticated, DjangoModelPermissions)
from rest_framework.decorators import (
detail_route, api_view, authentication_classes, permission_classes)
action, api_view, authentication_classes, permission_classes)
from rest_framework.generics import get_object_or_404
from rest_framework.exceptions import APIException, NotFound, ValidationError
from rest_framework.authtoken.models import Token
Expand Down Expand Up @@ -162,7 +162,7 @@ def perform_destroy(self, instance):
'Deletion failed because person belongs to a user'
)

@detail_route(methods=['get'])
@action(detail=True, methods=['get'])
def user(self, request, pk=None):
queryset = Person.objects.all()

Expand All @@ -176,7 +176,7 @@ def user(self, request, pk=None):

return Response(serializer.data)

@detail_route(methods=['get'])
@action(detail=True, methods=['get'])
def invite(self, request, pk=None):
queryset = Person.objects.all()

Expand Down Expand Up @@ -249,7 +249,7 @@ def partial_update(self, request, pk=None):

return super(UserViewSet, self).partial_update(request)

@detail_route(methods=['post'])
@action(detail=True, methods=['post'])
def reset_password(self, request, pk=None):
user = get_object_or_404(User.objects.all(), pk=pk)

Expand Down Expand Up @@ -394,7 +394,7 @@ def get_queryset(self):
queryset = queryset.filter(Q(name__icontains=q) | Q(question__icontains=q) )
return queryset

@detail_route(permission_classes=[AllowAny], methods=['post'],)
@action(detail=True, permission_classes=[AllowAny], methods=['post'],)
def vote(self, request, pk=None):
poll = get_object_or_404(Poll.objects.all(), pk=pk)

Expand Down Expand Up @@ -497,7 +497,7 @@ def destroy(self, request, pk=None):

return Response(status=status.HTTP_204_NO_CONTENT)

@detail_route(methods=['get'],)
@action(detail=True, methods=['get'],)
def callback(self, request, pk=None):
integration = self.get_object_or_404(pk)

Expand Down Expand Up @@ -552,7 +552,7 @@ def partial_update(self, request, pk=None):

return Response(serializer.data)

@detail_route(methods=['get'])
@action(detail=True, methods=['get'])
def widgets(self, request, pk=None):
zone = self.get_object_or_404(pk)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
include_package_data=True,
install_requires=[
'django == 2.2.10',
'djangorestframework == 3.8.2',
'djangorestframework == 3.11.0',
'pillow',
'requests',
'jsonfield',
Expand Down

0 comments on commit 495aeec

Please sign in to comment.