Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cosy-Bio
Drugst.One
backend
Merge requests
!2
Production
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Production
production
into
development
Overview
0
Commits
4
Pipelines
1
Changes
1
Merged
Maier, Andreas
requested to merge
production
into
development
2 years ago
Overview
0
Commits
4
Pipelines
1
Changes
1
Expand
0
0
Merge request reports
Viewing commit
1d253825
Prev
Next
Show latest version
1 file
+
17
−
6
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
1d253825
fixed json download
· 1d253825
AndiMajore
authored
2 years ago
drugstone/views.py
+
17
−
6
Options
@@ -467,11 +467,6 @@ def graph_export(request) -> Response:
G
=
nx
.
Graph
()
node_map
=
dict
()
for
node
in
nodes
:
# drugstone_id is not interesting outside of drugstone
# try:
# del node['drugstone_id']
# except KeyError:
# pass
# networkx does not support datatypes such as lists or dicts
for
key
in
list
(
node
.
keys
()):
if
isinstance
(
node
[
key
],
list
)
or
isinstance
(
node
[
key
],
dict
):
@@ -506,7 +501,23 @@ def graph_export(request) -> Response:
data
=
nx
.
generate_graphml
(
G
)
response
=
HttpResponse
(
data
,
content_type
=
'
application/xml
'
)
elif
fmt
==
'
json
'
:
data
=
json
.
dumps
(
nx
.
readwrite
.
json_graph
.
node_link_data
(
G
))
data
=
nx
.
readwrite
.
json_graph
.
node_link_data
(
G
)
del
data
[
'
graph
'
]
del
data
[
'
multigraph
'
]
remove_node_properties
=
[
'
color
'
,
'
shape
'
,
'
border_width
'
,
'
group_name
'
,
'
border_width_selected
'
,
'
shadow
'
,
'
group_id
'
,
'
drugstone_type
'
,
'
font
'
]
remove_edge_properties
=
[
'
group_name
'
,
'
color
'
,
'
dashes
'
,
'
shadow
'
,
'
id
'
]
for
node
in
data
[
'
nodes
'
]:
for
prop
in
remove_node_properties
:
if
prop
in
node
:
del
node
[
prop
]
for
edge
in
data
[
'
links
'
]:
for
prop
in
remove_edge_properties
:
if
prop
in
edge
:
del
edge
[
prop
]
data
[
"
edges
"
]
=
data
.
pop
(
"
links
"
)
data
=
json
.
dumps
(
data
)
data
=
data
.
replace
(
'"
{
'
,
'
{
'
).
replace
(
'
}
"'
,
'
}
'
).
replace
(
'"
[
'
,
'
[
'
).
replace
(
'
]
"'
,
'
]
'
).
replace
(
'
\\
"'
,
'"'
)
response
=
HttpResponse
(
data
,
content_type
=
'
application/json
'
)
elif
fmt
==
'
csv
'
:
data
=
pd
.
DataFrame
(
nx
.
to_numpy_array
(
G
),
columns
=
G
.
nodes
(),
index
=
G
.
nodes
())
Loading