10000 changed API view to readonly · FeverCode/GAwards@ba48300 · GitHub
[go: up one dir, main page]

Skip to content

Commit ba48300

Browse files
committed
changed API view to readonly
1 parent 1e94d76 commit ba48300

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

app/views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
from django.urls import reverse_lazy
1616
from django.core.mail import send_mail
1717
from django.contrib import messages
18+
from rest_framework.permissions import IsAuthenticated
19+
from rest_framework.response import Response
1820

1921
# Create your views here.
2022
def dispatch(self, request, *args, **kwargs):
@@ -69,16 +71,18 @@ def form_valid(self, form):
6971
return super(CustomLoginView, self).form_valid(form)
7072

7173

72-
class ProfileViewSet(LoginRequiredMixin,viewsets.ModelViewSet):
74+
class ProfileViewSet(viewsets.ReadOnlyModelViewSet):
7375
queryset = Profile.objects.all()
7476
serializer_class = ProfileSerializer
77+
permission_classes = [IsAuthenticated]
7578

7679

77-
class PostViewSet(LoginRequiredMixin, viewsets.ModelViewSet):
80+
class PostViewSet(viewsets.ReadOnlyModelViewSet):
7881
queryset = Post.objects.all()
7982
serializer_class = PostSerializer
8083

81-
class UserViewSet(LoginRequiredMixin, viewsets.ModelViewSet):
84+
85+
class UserViewSet(LoginRequiredMixin, viewsets.ReadOnlyModelViewSet):
8286
queryset = User.objects.all()
8387
serializer_class = UserSerializer
8488

awards/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
REST_FRAMEWORK = {
5353
'DEFAULT_AUTHENTICATION_CLASSES': (
5454
'rest_framework.authentication.TokenAuthentication',
55+
'rest_framework.authentication.BasicAuthentication',
56+
'rest_framework.authentication.SessionAuthentication',
5557
)
5658
}
5759

0 commit comments

Comments
 (0)
0