| Total Complexity | 2 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | from django.db import models |
||
| 2 | import json |
||
| 3 | |||
| 4 | from .graph import Graph |
||
| 5 | |||
| 6 | |||
| 7 | class Configuration(models.Model): |
||
| 8 | |||
| 9 | """ |
||
| 10 | Class: Project |
||
| 11 | |||
| 12 | Fields: |
||
| 13 | {Graph} graph - |
||
| 14 | {int} costs - |
||
| 15 | """ |
||
| 16 | |||
| 17 | class Meta: |
||
| 18 | app_label = 'ore' |
||
| 19 | |||
| 20 | graph = models.ForeignKey(Graph, related_name='configurations') |
||
| 21 | costs = models.IntegerField() |
||
| 22 | |||
| 23 | def to_dict(self): |
||
| 24 | ''' |
||
| 25 | Returns the specific node configurations in this graph configuration |
||
| 26 | as JSON dictionary data structure. The keys are node client ID's, so that the |
||
| 27 | JS code can identify them. |
||
| 28 | ''' |
||
| 29 | result = {} |
||
| 30 | for node_conf in self.node_configurations.all(): |
||
| 31 | result[node_conf.node.client_id] = json.loads(node_conf.setting) |
||
| 32 | return result |
||
| 33 |