Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
humanities
gargantext
Commits
271a506c
Commit
271a506c
authored
Oct 26, 2016
by
c24b
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
API method PUT parameters for authenticated user
parent
d705d4db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
users.py
gargantext/views/api/users.py
+25
-0
No files found.
gargantext/views/api/users.py
0 → 100644
View file @
271a506c
from
.api
import
*
#notamment APIView, check_rights, format_response
from
gargantext.util.http
import
*
from
django.core.exceptions
import
*
from
collections
import
defaultdict
from
gargantext.util.toolchain
import
*
import
copy
from
gargantext.util.db
import
session
class
UserItem
(
APIView
):
'''API endpoint that represent the parameters of the user'''
def
put
(
self
,
request
):
if
request
.
user
.
id
is
None
:
raise
TypeError
(
"This API request must come from an authenticated user."
)
else
:
# we query among the nodes that belong to this user
user
=
cache
.
User
[
request
.
user
.
id
]
node_user
=
session
.
query
(
Node
)
.
filter
(
Node
.
user_id
==
user
.
id
,
Node
.
typename
==
"USER"
)
.
first
()
if
node_user
is
None
:
raise
TypeError
(
"This API request must come from an authenticated user."
)
for
k
,
v
in
request
.
data
.
items
():
setattr
(
node_user
.
hyperdata
,
key
,
val
)
session
.
add
(
node_user
)
session
.
commit
()
return
Response
({
"detail"
:
"Updated user parameters"
,
status
=
HTTP_202_ACCEPTED
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment