Skip to content

Commit

Permalink
Merge pull request MaxBo#650 from MaxBo/feature/Frontend
Browse files Browse the repository at this point in the history
Feature/frontend
  • Loading branch information
ChrFr authored Dec 11, 2019
2 parents fe6f75c + d4cfa9f commit e1ab987
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
34 changes: 18 additions & 16 deletions repair/apps/asmfa/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ def build(self):
Q(id__in=actorflows.values('origin_id')) |
Q(id__in=actorflows.values('destination_id')) |
Q(id__in=stockflows.values('origin_id'))
)
flows = list(chain(actorflows, stockflows))
).values()
flows = list(chain(actorflows.values(), stockflows.values()))

self.graph = gt.Graph(directed=True)

Expand All @@ -220,10 +220,11 @@ def build(self):

actorids = {}
for i in range(len(actors)):
self.graph.vp.id[i] = actors[i].id
self.graph.vp.bvdid[i] = actors[i].BvDid
self.graph.vp.name[i] = actors[i].name
actorids[actors[i].id] = i
actor_id = actors[i]['id']
self.graph.vp.id[i] = actors[i]['id']
self.graph.vp.bvdid[i] = actors[i]['BvDid']
self.graph.vp.name[i] = actors[i]['name']
actorids[actor_id] = i

# Add the flows to the graph
# need a persistent edge id, because graph-tool can reindex the edges
Expand All @@ -242,22 +243,23 @@ def build(self):
for i in range(len(flows)):
# get the start and and actor id's
flow = flows[i]
v0 = actorids.get(flow.origin.id)
if not flow.to_stock:
v1 = actorids.get(flow.destination.id)
v0 = actorids.get(flow['origin_id'])
if not flow['to_stock']:
v1 = actorids.get(flow['destination_id'])
else:
v1 = v0

if (v0 != None and v1 != None):
e = self.graph.add_edge(
self.graph.vertex(v0), self.graph.vertex(v1))
self.graph.ep.id[e] = flow.id
self.graph.ep.material[e] = flow.material_id
self.graph.ep.waste[e] = flow.waste
self.graph.ep.hazardous[e] = flow.hazardous
self.graph.ep.process[e] = \
flow.process_id if flow.process_id is not None else - 1
self.graph.ep.amount[e] = flow.amount
self.graph.ep.id[e] = flow['id']
self.graph.ep.material[e] = flow['material_id']
self.graph.ep.waste[e] = flow['waste']
self.graph.ep.hazardous[e] = flow['hazardous']
process_id = flow['process_id']
self.graph.ep.process[e] = process_id\
if process_id is not None else - 1
self.graph.ep.amount[e] = flow['amount']

# get the original order of the vertices and edges in the graph
edge_index = np.fromiter(self.graph.edge_index, dtype=int)
Expand Down
2 changes: 1 addition & 1 deletion repair/apps/changes/serializers/solutions.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def update(self, instance, validated_data):
affected_flows = validated_data.pop('affected_flows', None)
flow_reference = validated_data.pop('flow_reference', None)
flow_changes = validated_data.pop('flow_changes', None)
question = validated_data.pop('question', None)
question = validated_data.get('question', None)
instance = super().update(instance, validated_data)
if flow_reference:
if instance.flow_reference:
Expand Down
2 changes: 1 addition & 1 deletion repair/js/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ require(['models/casestudy', 'models/gdsemodel', 'collections/gdsecollection',
var btn = document.getElementById('build-graph'),
note = document.getElementById('graph-note'),
clone = btn.cloneNode(true);
note.innerHTML = keyflow.get('graph_build') || '-';
note.innerHTML = keyflow.get('graph_date') || '-';
btn.parentNode.replaceChild(clone, btn);
clone.addEventListener('click', function(){
loader.activate();
Expand Down

0 comments on commit e1ab987

Please sign in to comment.