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
1d4522ef
Commit
1d4522ef
authored
Dec 20, 2017
by
Nitesh Laxman Chaughule
Browse files
If godown in charge is request to update here it gives gkstatus.
Documentation is done.
parent
fc795c35
Changes
1
Hide whitespace changes
Inline
Side-by-side
gkcore/views/api_user.py
View file @
1d4522ef
...
...
@@ -241,8 +241,6 @@ class api_user(object):
user
=
self
.
con
.
execute
(
select
([
gkdb
.
users
.
c
.
userrole
]).
where
(
gkdb
.
users
.
c
.
userid
==
authDetails
[
"userid"
]
))
userRole
=
user
.
fetchone
()
dataset
=
self
.
request
.
json_body
print
dataset
print
authDetails
[
"userid"
]
if
userRole
[
0
]
==-
1
or
int
(
authDetails
[
"userid"
])
==
int
(
dataset
[
"userid"
]):
result
=
self
.
con
.
execute
(
gkdb
.
users
.
update
().
where
(
gkdb
.
users
.
c
.
userid
==
dataset
[
"userid"
]).
values
(
dataset
))
return
{
"gkstatus"
:
enumdict
[
"Success"
]}
...
...
@@ -252,8 +250,11 @@ class api_user(object):
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"ConnectionFailed"
]
}
finally
:
self
.
con
.
close
()
"""
Following function check status (i.e valid or not) of field current password in edituser.
"""
@
view_config
(
request_method
=
'POST'
,
request_param
=
"userloginstatus"
,
renderer
=
'json'
)
@
view_config
(
request_method
=
'POST'
,
request_param
=
"userloginstatus"
,
renderer
=
'json'
)
def
userLoginstatus
(
self
):
try
:
self
.
con
=
eng
.
connect
()
...
...
@@ -279,11 +280,10 @@ class api_user(object):
"""
Following function update user in the users table.
It may also have a list of goids for the godowns associated with this user.
This is only true if goflag is True.
The frontend must send the role as Godown In Charge for this.
"""
@
view_config
(
request_method
=
'PUT'
,
request_param
=
'editdata'
,
renderer
=
'json'
)
def
addedit
user
(
self
):
def
update
user
(
self
):
try
:
token
=
self
.
request
.
headers
[
"gktoken"
]
except
:
...
...
@@ -296,22 +296,22 @@ class api_user(object):
self
.
con
=
eng
.
connect
()
userRole
=
getUserRole
(
authDetails
[
"userid"
])
dataset
=
self
.
request
.
json_body
print
dataset
if
userRole
[
"gkresult"
][
"userrole"
]
==
-
1
:
dataset
[
"orgcode"
]
=
authDetails
[
"orgcode"
]
#This is give userrole of old user
originalrole
=
getUserRole
(
dataset
[
"userid"
])
if
int
(
userR
ole
[
"gkresult"
][
"userrole"
]
==
3
):
if
int
(
originalr
ole
[
"gkresult"
][
"userrole"
]
==
3
):
result
=
self
.
con
.
execute
(
gkdb
.
usergodown
.
delete
().
where
(
gkdb
.
usergodown
.
c
.
userid
==
dataset
[
"userid"
]))
#
t
his is give userrole of new user
#
T
his is give userrole of new user
if
dataset
.
has_key
(
"userrole"
):
if
int
(
dataset
[
"userrole"
])
==
3
:
golist
=
tuple
(
dataset
.
pop
(
"golist"
))
golist
s
=
tuple
(
dataset
.
pop
(
"golist"
))
result
=
self
.
con
.
execute
(
gkdb
.
users
.
update
().
where
(
gkdb
.
users
.
c
.
userid
==
dataset
[
"userid"
]).
values
(
dataset
))
las
tid
=
dataset
[
"userid"
]
for
goid
in
golist
:
godata
=
{
"userid"
:
las
tid
,
"goid"
:
goid
,
"orgcode"
:
dataset
[
"orgcode"
]}
curren
tid
=
dataset
[
"userid"
]
for
goid
in
golist
s
:
godata
=
{
"userid"
:
curren
tid
,
"goid"
:
goid
,
"orgcode"
:
dataset
[
"orgcode"
]}
result
=
self
.
con
.
execute
(
gkdb
.
usergodown
.
insert
(),[
godata
])
return
{
"gkstatus"
:
enumdict
[
"Success"
]}
else
:
result
=
self
.
con
.
execute
(
gkdb
.
users
.
update
().
where
(
gkdb
.
users
.
c
.
userid
==
dataset
[
"userid"
]).
values
(
dataset
))
return
{
"gkstatus"
:
enumdict
[
"Success"
]}
...
...
@@ -323,9 +323,9 @@ class api_user(object):
except
exc
.
IntegrityError
:
return
{
"gkstatus"
:
enumdict
[
"DuplicateEntry"
]}
except
:
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"ConnectionFailed"
]
}
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"ConnectionFailed"
]
}
finally
:
self
.
con
.
close
()
self
.
con
.
close
()
@
view_config
(
request_method
=
'GET'
,
renderer
=
'json'
)
def
getAllUsers
(
self
):
...
...
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