Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gnukhata
gkcore
Commits
559c42ab
Commit
559c42ab
authored
Dec 12, 2017
by
Nitesh Laxman Chaughule
Browse files
PUT is written for users.
parent
2ac1cdec
Changes
1
Hide whitespace changes
Inline
Side-by-side
gkcore/views/api_user.py
View file @
559c42ab
...
...
@@ -250,6 +250,45 @@ class api_user(object):
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"ConnectionFailed"
]
}
finally
:
self
.
con
.
close
()
@
view_config
(
request_method
=
'PUT'
,
request_param
=
'editdata'
,
renderer
=
'json'
)
def
addedituser
(
self
):
try
:
token
=
self
.
request
.
headers
[
"gktoken"
]
except
:
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"UnauthorisedAccess"
]}
authDetails
=
authCheck
(
token
)
if
authDetails
[
"auth"
]
==
False
:
return
{
"gkstatus"
:
enumdict
[
"UnauthorisedAcces"
]}
else
:
try
:
self
.
con
=
eng
.
connect
()
user
=
self
.
con
.
execute
(
select
([
gkdb
.
users
.
c
.
userrole
]).
where
(
gkdb
.
users
.
c
.
userid
==
authDetails
[
"userid"
]
))
userRole
=
getUserRole
(
authDetails
[
"userid"
])
dataset
=
self
.
request
.
json_body
print
dataset
[
"userrole"
]
if
userRole
[
"gkresult"
][
"userrole"
]
==
-
1
:
dataset
[
"orgcode"
]
=
authDetails
[
"orgcode"
]
if
dataset
[
"userrole"
]
==
"3"
:
result
=
self
.
con
.
execute
(
gkdb
.
usergodown
.
delete
().
where
(
gkdb
.
usergodown
.
c
.
userid
==
dataset
[
"userid"
]))
golist
=
tuple
(
dataset
.
pop
(
"golist"
))
result
=
self
.
con
.
execute
(
gkdb
.
users
.
update
().
where
(
gkdb
.
users
.
c
.
userid
==
dataset
[
"userid"
]).
values
(
dataset
))
userdata
=
self
.
con
.
execute
(
select
([
gkdb
.
users
.
c
.
userid
]).
where
(
and_
(
gkdb
.
users
.
c
.
username
==
dataset
[
"username"
],
gkdb
.
users
.
c
.
orgcode
==
dataset
[
"orgcode"
])))
userRow
=
userdata
.
fetchone
()
lastid
=
userRow
[
"userid"
]
for
goid
in
golist
:
godata
=
{
"userid"
:
lastid
,
"goid"
:
goid
,
"orgcode"
:
dataset
[
"orgcode"
]}
result
=
self
.
con
.
execute
(
gkdb
.
usergodown
.
insert
(),[
godata
])
else
:
result
=
self
.
con
.
execute
(
gkdb
.
users
.
update
().
where
(
gkdb
.
users
.
c
.
userid
==
dataset
[
"userid"
]).
values
(
dataset
))
else
:
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"ActionDisallowed"
]}
except
:
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"ConnectionFailed"
]
}
finally
:
self
.
con
.
close
()
@
view_config
(
request_method
=
'GET'
,
renderer
=
'json'
)
def
getAllUsers
(
self
):
try
:
...
...
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