New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Affiche les permissions dans les réponses de l'API #3264
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from django.conf import settings | ||
from dry_rest_permissions.generics import DRYPermissions | ||
from rest_framework import status | ||
from rest_framework.generics import CreateAPIView, DestroyAPIView | ||
from rest_framework.permissions import IsAuthenticated | ||
|
@@ -18,7 +19,6 @@ class CreateDestroyMemberSanctionAPIView(CreateAPIView, DestroyAPIView): | |
|
||
queryset = Profile.objects.all() | ||
serializer_class = ProfileSanctionSerializer | ||
permission_classes = (IsAuthenticated, IsStaffUser) | ||
|
||
def post(self, request, *args, **kwargs): | ||
return self.process_request(request) | ||
|
@@ -55,5 +55,11 @@ def process_request(self, request): | |
state.notify_member(ban, msg) | ||
return Response(serializer.data) | ||
|
||
def get_permissions(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. peux-tu ajouter un docstring pour qu'on comprenne ce qui est vraiment retourné stp? Car pour quelqu'un qui ne connait pas bien le système c'est pas immédiat. (après c'est pas obligatoire) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Est-ce nécessaire ? Ce sont des méthodes surchargées avec une documentation au niveau de la méthode parente. Je peux le faire mais je vais me contenter de faire un copier/coller de la documentation officielle de la bibliothèque (chose que je ne trouve pas très pertinent). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. De plus, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Donc effectivement, ce n'était pas nécessaire. Le 02/01/2016 18:38, Gérard Paligot a écrit :
|
||
permission_classes = [IsAuthenticated, IsStaffUser, ] | ||
if self.request.method == 'POST' or self.request.method == 'DELETE': | ||
permission_classes.append(DRYPermissions) | ||
return [permission() for permission in permission_classes] | ||
|
||
def get_state_instance(self, request): | ||
raise NotImplementedError('`get_state_instance()` must be implemented.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je vois que la 0.1.6 est sortie :)