Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oser-backend
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
Hamza Touizrat
oser-backend
Commits
dd3260b3
Commit
dd3260b3
authored
2 years ago
by
salazard
Browse files
Options
Downloads
Patches
Plain Diff
add charte signe
parent
f993de64
Branches
Branches containing commit
No related tags found
1 merge request
!61
Verification mail
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
users/serializers.py
+11
-1
11 additions, 1 deletion
users/serializers.py
users/views.py
+37
-1
37 additions, 1 deletion
users/views.py
with
48 additions
and
2 deletions
users/serializers.py
+
11
−
1
View file @
dd3260b3
...
@@ -12,8 +12,18 @@ class UserSerializer(serializers.HyperlinkedModelSerializer):
...
@@ -12,8 +12,18 @@ class UserSerializer(serializers.HyperlinkedModelSerializer):
class
Meta
:
# noqa
class
Meta
:
# noqa
model
=
User
model
=
User
fields
=
(
'
id
'
,
'
email
'
,
'
profile_type
'
,
fields
=
(
'
id
'
,
'
email
'
,
'
profile_type
'
,
'
first_name
'
,
'
last_name
'
,
'
phone_number
'
,
'
url
'
,
)
'
first_name
'
,
'
last_name
'
,
'
phone_number
'
,
'
url
'
)
extra_kwargs
=
{
extra_kwargs
=
{
'
email
'
:
{
'
read_only
'
:
True
},
'
email
'
:
{
'
read_only
'
:
True
},
'
url
'
:
{
'
view_name
'
:
'
api:user-detail
'
},
'
url
'
:
{
'
view_name
'
:
'
api:user-detail
'
},
}
}
class
CharterSerializer
(
serializers
.
ModelSerializer
):
"""
Hyperlinked serializer for user objects.
"""
class
Meta
:
# noqa
model
=
User
fields
=
(
'
id
'
,
'
email
'
,
'
profile_type
'
,
'
first_name
'
,
'
last_name
'
,
'
phone_number
'
,
'
url
'
)
extra_kwargs
=
{
'
email
'
:
{
'
read_only
'
:
True
},
}
This diff is collapsed.
Click to expand it.
users/views.py
+
37
−
1
View file @
dd3260b3
"""
Users API views.
"""
"""
Users API views.
"""
import
email
from
django.contrib.auth
import
get_user_model
from
django.contrib.auth
import
get_user_model
from
dry_rest_permissions.generics
import
DRYPermissions
from
dry_rest_permissions.generics
import
DRYPermissions
from
rest_framework
import
viewsets
from
rest_framework
import
viewsets
from
.serializers
import
UserSerializer
from
.serializers
import
UserSerializer
,
CharterSerializer
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework.decorators
import
action
from
rest_framework
import
status
User
=
get_user_model
()
User
=
get_user_model
()
...
@@ -21,3 +27,33 @@ class UserViewSet(viewsets.ReadOnlyModelViewSet):
...
@@ -21,3 +27,33 @@ class UserViewSet(viewsets.ReadOnlyModelViewSet):
queryset
=
User
.
objects
.
all
()
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserSerializer
serializer_class
=
UserSerializer
permission_classes
=
(
DRYPermissions
,)
permission_classes
=
(
DRYPermissions
,)
class
UserCheckChartViewSet
(
APIView
):
"""
API endpoint that allows to see of user have signed charter.
retrieve:
Return a email .
list:
Return a boolean value.
"""
def
get
(
self
,
*
args
,
**
kwargs
):
user
=
User
.
objects
.
filter
(
email
=
self
.
request
.
query_params
.
get
(
'
email
'
))
if
user
[
0
].
HasSignedCharter
:
resp
=
status
.
HTTP_200_OK
else
:
resp
=
status
.
HTTP_404_NOT_FOUND
return
Response
(
status
=
resp
)
def
post
(
self
,
*
args
,
**
kwargs
):
user
=
User
.
objects
.
filter
(
email
=
self
.
request
.
query_params
.
get
(
'
email
'
))
if
len
(
user
)
!=
0
:
resp
=
status
.
HTTP_200_OK
else
:
resp
=
status
.
HTTP_404_NOT_FOUND
user
[
0
].
HasSignedCharter
=
True
user
[
0
].
save
()
return
Response
(
status
=
resp
)
\ No newline at end of file
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