Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kszkepzes-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
JetBrains YouTrack
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
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
KSZK
DevTeam
kszkepzes
old
kszkepzes-backend
Commits
bf8d040d
Commit
bf8d040d
authored
7 years ago
by
Chif Gergo
Browse files
Options
Downloads
Patches
Plain Diff
Login resz nagyjabol meg van profile create neven, ezen kivul az elkeszult profilt meg lehet nezni.
parent
f74ebced
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/account/serializers.py
+32
-0
32 additions, 0 deletions
src/account/serializers.py
src/account/urls.py
+2
-1
2 additions, 1 deletion
src/account/urls.py
src/account/views.py
+7
-1
7 additions, 1 deletion
src/account/views.py
with
41 additions
and
2 deletions
src/account/serializers.py
+
32
−
0
View file @
bf8d040d
...
...
@@ -84,3 +84,35 @@ class ProfileUpdateSerializer(serializers.ModelSerializer):
pref_group
=
pref_group
,
)
profile_obj
.
save
()
class
ProfileDetailSerializer
(
serializers
.
ModelSerializer
):
def
current_user
(
self
):
user
=
self
.
context
[
'
request
'
].
user
return
user
first_name
=
serializers
.
SerializerMethodField
()
last_name
=
serializers
.
SerializerMethodField
()
email
=
serializers
.
SerializerMethodField
()
class
Meta
:
model
=
Profile
fields
=
[
'
first_name
'
,
'
last_name
'
,
'
email
'
,
'
nick
'
,
'
pref_group
'
,
]
def
get_first_name
(
self
):
user
=
self
.
current_user
()
return
user
.
first_name
def
get_last_name
(
self
):
user
=
self
.
ccurrent_user
()
return
user
.
last_name
def
get_email
(
self
):
user
=
self
.
ccurrent_user
()
return
user
.
email
This diff is collapsed.
Click to expand it.
src/account/urls.py
+
2
−
1
View file @
bf8d040d
...
...
@@ -7,6 +7,7 @@ router = routers.DefaultRouter(trailing_slash=False)
router
.
register
(
r
'
profiles
'
,
views
.
ProfileViewSet
)
urlpatterns
=
[
url
(
r
'
^profiles/create
'
,
views
.
ProfileCreateView
.
as_view
()),
url
(
r
'
^profiles/update/<pk>
'
,
views
.
ProfileUpdateView
.
as_view
())
url
(
r
'
^profiles/(?P<pk>\d+)/$
'
,
views
.
ProfileDetailView
.
as_view
()),
url
(
r
'
^profiles/(?P<pk>\d+)/update/$
'
,
views
.
ProfileUpdateView
.
as_view
()),
]
urlpatterns
+=
router
.
urls
This diff is collapsed.
Click to expand it.
src/account/views.py
+
7
−
1
View file @
bf8d040d
...
...
@@ -11,7 +11,13 @@ class ProfileCreateView(generics.CreateAPIView):
permission_classes
=
[
IsAuthenticated
,
]
class
ProfileUpdateView
(
generics
.
RetrieveAPIView
):
class
ProfileDetailView
(
generics
.
RetrieveAPIView
):
serializer_class
=
serializers
.
ProfileDetailSerializer
queryset
=
models
.
Profile
.
objects
.
all
()
permission_classes
=
[
IsAuthenticated
,
]
class
ProfileUpdateView
(
generics
.
RetrieveUpdateAPIView
):
serializer_class
=
serializers
.
ProfileUpdateSerializer
queryset
=
models
.
Profile
.
objects
.
all
()
permission_classes
=
[
IsAuthenticated
,
]
...
...
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