code style

This commit is contained in:
jonaswinkler 2020-12-15 12:06:24 +01:00
parent 6d39dfeb3b
commit 49be87fe37
2 changed files with 9 additions and 3 deletions

View File

@ -340,7 +340,11 @@ class SavedViewFilterRule(models.Model):
(17, "Does not have tag"),
]
saved_view = models.ForeignKey(SavedView, on_delete=models.CASCADE, related_name="filter_rules")
saved_view = models.ForeignKey(
SavedView,
on_delete=models.CASCADE,
related_name="filter_rules"
)
rule_type = models.PositiveIntegerField(choices=RULE_TYPES)

View File

@ -167,14 +167,16 @@ class SavedViewSerializer(serializers.ModelSerializer):
if rules_data:
SavedViewFilterRule.objects.filter(saved_view=instance).delete()
for rule_data in rules_data:
SavedViewFilterRule.objects.create(saved_view=instance, **rule_data)
SavedViewFilterRule.objects.create(
saved_view=instance, **rule_data)
return instance
def create(self, validated_data):
rules_data = validated_data.pop('filter_rules')
saved_view = SavedView.objects.create(**validated_data)
for rule_data in rules_data:
SavedViewFilterRule.objects.create(saved_view=saved_view, **rule_data)
SavedViewFilterRule.objects.create(
saved_view=saved_view, **rule_data)
return saved_view