Skip to content

Commit

Permalink
Fix error when save dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
meomancer committed Aug 14, 2023
1 parent a5146e8 commit 57039f9
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions django_project/geosight/data/models/dashboard/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,21 +308,23 @@ def save_relations(self, data):

rules_ids = []
rules = model.dashboardindicatorlayerrule_set.all()
for idx, rule in enumerate(layer_data.get('style', [])):
if 'indicator' in rule:
continue
_rule, created = DSLayerRule.objects.get_or_create(
object=model,
name=rule['name']
)
_rule.rule = rule['rule']
_rule.color = rule['color']
_rule.outline_color = rule['outline_color']
_rule.outline_size = rule['outline_size']
_rule.active = rule['active']
_rule.order = idx
_rule.save()
rules_ids.append(_rule.id)
layer_data_style = layer_data.get('style', [])
if isinstance(layer_data_style, list):
for idx, rule in enumerate(layer_data_style):
if 'indicator' in rule:
continue
_rule, created = DSLayerRule.objects.get_or_create(
object=model,
name=rule['name']
)
_rule.rule = rule['rule']
_rule.color = rule['color']
_rule.outline_color = rule['outline_color']
_rule.outline_size = rule['outline_size']
_rule.active = rule['active']
_rule.order = idx
_rule.save()
rules_ids.append(_rule.id)
rules.exclude(id__in=rules_ids).delete()

# -----------------------------------------------------
Expand Down

0 comments on commit 57039f9

Please sign in to comment.