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
arunkelkar
gkcore
Commits
7eb9fc57
Commit
7eb9fc57
authored
Apr 20, 2017
by
Prajkta Patkar
Browse files
Revert "Merge branch 'delchal' into 'master'"
This reverts merge request !317
parent
1c81edd9
Changes
3
Hide whitespace changes
Inline
Side-by-side
gkcore/tests/test_user.py
View file @
7eb9fc57
...
...
@@ -78,30 +78,6 @@ class TestUser:
result
=
requests
.
get
(
"http://127.0.0.1:6543/users"
,
headers
=
self
.
header
)
assert
result
.
json
()[
"gkstatus"
]
==
0
#You can run this file with nosetests -s --verbose test_user.py. It will show the list of users with godowns whenever godown is there.
def
test_get_listof_users
(
self
):
#godown 1
gkdata
=
{
"goname"
:
"Test Godown 1"
,
"state"
:
"Maharashtra"
,
"goaddr"
:
"Pune"
,
"contactname"
:
"Bhavesh Bavdhane"
,
"designation"
:
"Designation"
,
"gocontact"
:
"8446611103"
}
result
=
requests
.
post
(
"http://127.0.0.1:6543/godown"
,
data
=
json
.
dumps
(
gkdata
),
headers
=
self
.
header
)
result
=
requests
.
get
(
"http://127.0.0.1:6543/godown"
,
headers
=
self
.
header
)
for
record
in
result
.
json
()[
"gkresult"
]:
if
record
[
"goname"
]
==
"Test Godown 1"
:
self
.
goid
=
record
[
"goid"
]
break
#godown 2
gkdata
=
{
"goname"
:
"Test Godown 2"
,
"state"
:
"Maharashtra"
,
"goaddr"
:
"Pune"
,
"contactname"
:
"Bhavesh Bavdhane"
,
"designation"
:
"Designation"
,
"gocontact"
:
"8446611103"
}
result
=
requests
.
post
(
"http://127.0.0.1:6543/godown"
,
data
=
json
.
dumps
(
gkdata
),
headers
=
self
.
header
)
result
=
requests
.
get
(
"http://127.0.0.1:6543/godown"
,
headers
=
self
.
header
)
for
record
in
result
.
json
()[
"gkresult"
]:
if
record
[
"goname"
]
==
"Test Godown 2"
:
self
.
goid2
=
record
[
"goid"
]
break
gkdata
=
{
"username"
:
"test"
,
"userpassword"
:
"test"
,
"userrole"
:
3
,
"userquestion"
:
"test"
,
"useranswer"
:
"test"
,
"golist"
:
json
.
loads
(
str
([
self
.
goid
,
self
.
goid2
]))}
result
=
requests
.
post
(
"http://127.0.0.1:6543/users"
,
data
=
json
.
dumps
(
gkdata
),
headers
=
self
.
header
)
result
=
requests
.
get
(
"http://127.0.0.1:6543/users?type=list"
,
headers
=
self
.
header
)
print
result
.
json
()[
"gkresult"
]
assert
result
.
json
()[
"gkstatus"
]
==
0
def
test_get_single_user
(
self
):
""" No need to insert data.
Because, ultimately, in api_user::getUser(): userid is taken as the currently logged in user's id and
...
...
gkcore/views/api_godown.py
View file @
7eb9fc57
...
...
@@ -30,7 +30,7 @@ Contributors:
from
gkcore
import
eng
,
enumdict
from
gkcore.models.gkdb
import
godown
,
usergodown
,
stock
,
goprod
from
gkcore.models.gkdb
import
godown
,
usergodown
,
stock
from
sqlalchemy.sql
import
select
import
json
from
sqlalchemy.engine.base
import
Connection
...
...
@@ -204,33 +204,6 @@ class api_godown(object):
finally
:
self
.
con
.
close
()
"""
The below function "getNumberOfProductInGodown" will be called when user select a
godown for deletetion, it will return number of products a selected godown content.
"""
@
view_config
(
request_method
=
'GET'
,
request_param
=
'type=goproduct'
,
renderer
=
'json'
)
def
getNumberOfProductInGodown
(
self
):
try
:
token
=
self
.
request
.
headers
[
"gktoken"
]
except
:
return
{
"gkstatus"
:
enumdict
[
"UnauthorisedAccess"
]}
authDetails
=
authCheck
(
token
)
if
authDetails
[
"auth"
]
==
False
:
return
{
"gkstatus"
:
enumdict
[
"UnauthorisedAccess"
]}
else
:
try
:
self
.
con
=
eng
.
connect
()
goid
=
self
.
request
.
params
[
"goid"
]
result
=
self
.
con
.
execute
(
select
([
func
.
count
(
goprod
.
c
.
productcode
)]).
where
(
goprod
.
c
.
goid
==
goid
))
row
=
result
.
fetchone
()
return
{
"gkstatus"
:
enumdict
[
"Success"
],
"gkresult"
:
row
[
0
]}
except
:
self
.
con
.
close
()
return
{
"gkstatus"
:
enumdict
[
"ConnectionFailed"
]}
finally
:
self
.
con
.
close
()
@
view_config
(
request_method
=
'DELETE'
,
renderer
=
'json'
)
def
deleteGodown
(
self
):
try
:
...
...
gkcore/views/api_user.py
View file @
7eb9fc57
...
...
@@ -186,45 +186,6 @@ class api_user(object):
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"ConnectionFailed"
]
}
finally
:
self
.
con
.
close
()
#This method makes a list of users. If the user is godown incharge then its respective godowns is also added in list. This method will be used to make list of users report.
@
view_config
(
request_method
=
'GET'
,
request_param
=
"type=list"
,
renderer
=
'json'
)
def
getListofUsers
(
self
):
try
:
token
=
self
.
request
.
headers
[
"gktoken"
]
except
:
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"UnauthorisedAccess"
]}
authDetails
=
authCheck
(
token
)
if
authDetails
[
"auth"
]
==
False
:
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"UnauthorisedAccess"
]}
else
:
try
:
self
.
con
=
eng
.
connect
()
result
=
self
.
con
.
execute
(
select
([
gkdb
.
users
.
c
.
username
,
gkdb
.
users
.
c
.
userid
,
gkdb
.
users
.
c
.
userrole
]).
where
(
gkdb
.
users
.
c
.
orgcode
==
authDetails
[
"orgcode"
]).
order_by
(
gkdb
.
users
.
c
.
username
))
users
=
[]
for
row
in
result
:
godowns
=
[]
urole
=
""
if
(
row
[
"userrole"
]
==
-
1
):
urole
=
"Admin"
elif
(
row
[
"userrole"
]
==
0
):
urole
=
"Manager"
elif
(
row
[
"userrole"
]
==
1
):
urole
=
"Operator"
elif
(
row
[
"userrole"
]
==
2
):
urole
=
"Internal Auditor"
else
:
urole
=
"Godown In Charge"
godownresult
=
self
.
con
.
execute
(
select
([
gkdb
.
usergodown
.
c
.
goid
]).
where
(
and_
(
gkdb
.
usergodown
.
c
.
orgcode
==
authDetails
[
"orgcode"
],
gkdb
.
usergodown
.
c
.
userid
==
row
[
"userid"
])))
for
goid
in
godownresult
:
godownnameres
=
self
.
con
.
execute
(
select
([
gkdb
.
godown
.
c
.
goname
,
gkdb
.
godown
.
c
.
goaddr
]).
where
(
gkdb
.
godown
.
c
.
goid
==
goid
[
0
]))
goname
=
godownnameres
.
fetchone
()
godowns
.
append
(
str
(
goname
[
"goname"
]
+
"("
+
goname
[
"goaddr"
]
+
")"
))
users
.
append
({
"userid"
:
row
[
"userid"
],
"username"
:
row
[
"username"
],
"userrole"
:
urole
,
"godowns"
:
godowns
})
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"Success"
],
"gkresult"
:
users
}
except
:
return
{
"gkstatus"
:
gkcore
.
enumdict
[
"ConnectionFailed"
]
}
finally
:
self
.
con
.
close
()
@
view_config
(
request_method
=
'DELETE'
,
renderer
=
'json'
)
def
deleteuser
(
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