Skip to content
Snippets Groups Projects
Commit cbf8b460 authored by Ole-Christian Bjerkeset's avatar Ole-Christian Bjerkeset
Browse files

Adding docstring to all classes in users/views.py

parent 846a70c6
No related branches found
No related tags found
1 merge request!7merging refactor/gallery into master
Pipeline #171836 passed
"""Contains paths in the api for the users application.
"""
from django.urls import path
from users import views
......
import django
from rest_framework import mixins, generics
from rest_framework import mixins, generics, permissions
from rest_framework.permissions import IsAuthenticatedOrReadOnly
from django.contrib.auth import get_user_model
from django.db.models import Q
from rest_framework.parsers import MultiPartParser, FormParser
from workouts.mixins import CreateListModelMixin
from rest_framework import permissions
from users.serializers import (
UserSerializer,
OfferSerializer,
......@@ -10,22 +12,17 @@ from users.serializers import (
UserGetSerializer,
ProfilePutSerializer
)
from rest_framework.permissions import (
AllowAny,
IsAdminUser,
IsAuthenticated,
IsAuthenticatedOrReadOnly,
)
from users.models import Offer, AthleteFile
from django.contrib.auth import get_user_model
from django.db.models import Q
from django.shortcuts import get_object_or_404
from rest_framework.parsers import MultiPartParser, FormParser
from users.permissions import IsCurrentUser, IsAthlete, IsCoach
from workouts.permissions import IsOwner, IsReadOnly
# Create your views here.
class UserList(mixins.ListModelMixin, mixins.CreateModelMixin, generics.GenericAPIView):
"""Class defining the web response for the creation of users, or
a list of users.
HTTP methods: GET, POST
"""
serializer_class = UserSerializer
users = []
admins = []
......@@ -55,6 +52,11 @@ class UserDetail(
mixins.DestroyModelMixin,
generics.GenericAPIView,
):
"""Class defining the web response for the retrieval of a user, or
updating/deleting a user.
HTTP methods: GET, DELETE, PUT, PATCH
"""
lookup_field_options = ["pk", "username"]
serializer_class = UserSerializer
queryset = get_user_model().objects.all()
......@@ -87,6 +89,10 @@ class ProfileUpdate(
mixins.UpdateModelMixin,
generics.GenericAPIView,
):
"""Class defining the web response for updating a profile.
HTTP methods: PUT
"""
serializer_class = ProfilePutSerializer
queryset = get_user_model().objects.all()
permission_classes = [permissions.IsAuthenticated & IsCurrentUser]
......@@ -97,6 +103,11 @@ class ProfileUpdate(
class OfferList(
mixins.ListModelMixin, mixins.CreateModelMixin, generics.GenericAPIView
):
"""Class defining the web response for the creation of offers, or
a list of offers.
HTTP methods: GET, POST
"""
permission_classes = [IsAuthenticatedOrReadOnly]
serializer_class = OfferSerializer
......@@ -145,6 +156,11 @@ class OfferDetail(
mixins.DestroyModelMixin,
generics.GenericAPIView,
):
"""Class defining the web response for the retrieval of an offer, or
updating/deleting an offer.
HTTP methods: GET, DELETE, PUT, PATCH
"""
permission_classes = [IsAuthenticatedOrReadOnly]
queryset = Offer.objects.all()
serializer_class = OfferSerializer
......@@ -168,6 +184,11 @@ class AthleteFileList(
CreateListModelMixin,
generics.GenericAPIView,
):
"""Class defining the web response for the creation of athlete files, or
a list of athlete files.
HTTP methods: GET, POST
"""
queryset = AthleteFile.objects.all()
serializer_class = AthleteFileSerializer
permission_classes = [permissions.IsAuthenticated & (IsAthlete | IsCoach)]
......@@ -199,6 +220,11 @@ class AthleteFileDetail(
mixins.DestroyModelMixin,
generics.GenericAPIView,
):
"""Class defining the web response for the retrieval of an athlete file, or
deleting an athlete file.
HTTP methods: GET, DELETE
"""
queryset = AthleteFile.objects.all()
serializer_class = AthleteFileSerializer
permission_classes = [permissions.IsAuthenticated & (IsAthlete | IsOwner)]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment