Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tdt4242-group16
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ole-Christian Bjerkeset
tdt4242-group16
Commits
cbf8b460
Commit
cbf8b460
authored
2 years ago
by
Ole-Christian Bjerkeset
Browse files
Options
Downloads
Patches
Plain Diff
Adding docstring to all classes in users/views.py
parent
846a70c6
No related branches found
No related tags found
1 merge request
!7
merging refactor/gallery into master
Pipeline
#171836
passed
2 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/secfit/users/urls.py
+2
-0
2 additions, 0 deletions
backend/secfit/users/urls.py
backend/secfit/users/views.py
+39
-13
39 additions, 13 deletions
backend/secfit/users/views.py
with
41 additions
and
13 deletions
backend/secfit/users/urls.py
+
2
−
0
View file @
cbf8b460
"""
Contains paths in the api for the users application.
"""
from
django.urls
import
path
from
users
import
views
...
...
This diff is collapsed.
Click to expand it.
backend/secfit/users/views.py
+
39
−
13
View file @
cbf8b460
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
)]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment