Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
beat
beat.web
Commits
60d0be4f
Commit
60d0be4f
authored
6 years ago
by
Samuel GAIST
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix_database_retrieval' into 'master'
Fix database retrieval See merge request
!259
parents
425aab16
9d6e4f99
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!259
Fix database retrieval
Pipeline
#24943
passed
6 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/common/testutils.py
+1
-3
1 addition, 3 deletions
beat/web/common/testutils.py
beat/web/databases/api.py
+8
-10
8 additions, 10 deletions
beat/web/databases/api.py
with
9 additions
and
13 deletions
beat/web/common/testutils.py
+
1
−
3
View file @
60d0be4f
...
...
@@ -36,8 +36,6 @@ try:
except
ImportError
:
from
urllib.parse
import
urlparse
import
simplejson
as
json
from
.models
import
Shareable
...
...
@@ -119,7 +117,7 @@ class BaseTestCase(TestCase):
self
.
assertNotEqual
(
len
(
response
.
content
),
0
)
if
content_type
==
'
application/json
'
:
return
json
.
loads
(
response
.
content
)
return
response
.
json
(
)
else
:
return
response
.
content
else
:
...
...
This diff is collapsed.
Click to expand it.
beat/web/databases/api.py
+
8
−
10
View file @
60d0be4f
...
...
@@ -98,17 +98,16 @@ def database_to_json(database, request_user, fields_to_return,
def
clean_paths
(
declaration
):
pseudo_path
=
'
/path_to_db_folder
'
json_data
=
json
.
loads
(
declaration
)
root_folder
=
json_data
[
'
root_folder
'
]
root_folder
=
declaration
[
'
root_folder
'
]
cleaned_folder
=
os
.
path
.
basename
(
os
.
path
.
normpath
(
root_folder
))
json_data
[
'
root_folder
'
]
=
os
.
path
.
join
(
pseudo_path
,
cleaned_folder
)
for
protocol
in
json_data
[
'
protocols
'
]:
declaration
[
'
root_folder
'
]
=
os
.
path
.
join
(
pseudo_path
,
cleaned_folder
)
for
protocol
in
declaration
[
'
protocols
'
]:
for
set_
in
protocol
[
'
sets
'
]:
if
'
parameters
'
in
set_
and
'
annotations
'
in
set_
[
'
parameters
'
]:
annotations_folder
=
set_
[
'
parameters
'
][
'
annotations
'
]
cleaned_folder
=
annotations_folder
.
split
(
'
/
'
)[
-
2
:]
set_
[
'
parameters
'
][
'
annotations
'
]
=
os
.
path
.
join
(
pseudo_path
,
*
cleaned_folder
)
return
json
.
dumps
(
json_data
)
return
declaration
#----------------------------------------------------------
...
...
@@ -240,21 +239,20 @@ class RetrieveDatabaseView(views.APIView):
result
=
database_to_json
(
database
,
request
.
user
,
fields_to_return
,
last_version
=
last_version
)
# Retrieve the code
if
'
declaration
'
in
fields_to_return
:
try
:
declaration
=
database
.
declaration
_file
.
read
()
declaration
=
database
.
declaration
except
:
logger
.
error
(
traceback
.
format_exc
())
return
HttpResponse
(
status
=
500
)
result
[
'
declaration
'
]
=
clean_paths
(
declaration
)
cleaned_declaration
=
clean_paths
(
declaration
)
result
[
'
declaration
'
]
=
json
.
dumps
(
cleaned_
declaration
)
# Retrieve the source code
if
'
code
'
in
fields_to_return
:
try
:
result
[
'
code
'
]
=
database
.
source_code
_file
.
read
()
result
[
'
code
'
]
=
database
.
source_code
except
:
logger
.
error
(
traceback
.
format_exc
())
return
HttpResponse
(
status
=
500
)
...
...
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