mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
code style
This commit is contained in:
parent
6d39dfeb3b
commit
49be87fe37
@ -340,7 +340,11 @@ class SavedViewFilterRule(models.Model):
|
|||||||
(17, "Does not have tag"),
|
(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)
|
rule_type = models.PositiveIntegerField(choices=RULE_TYPES)
|
||||||
|
|
||||||
|
@ -167,14 +167,16 @@ class SavedViewSerializer(serializers.ModelSerializer):
|
|||||||
if rules_data:
|
if rules_data:
|
||||||
SavedViewFilterRule.objects.filter(saved_view=instance).delete()
|
SavedViewFilterRule.objects.filter(saved_view=instance).delete()
|
||||||
for rule_data in rules_data:
|
for rule_data in rules_data:
|
||||||
SavedViewFilterRule.objects.create(saved_view=instance, **rule_data)
|
SavedViewFilterRule.objects.create(
|
||||||
|
saved_view=instance, **rule_data)
|
||||||
return instance
|
return instance
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
rules_data = validated_data.pop('filter_rules')
|
rules_data = validated_data.pop('filter_rules')
|
||||||
saved_view = SavedView.objects.create(**validated_data)
|
saved_view = SavedView.objects.create(**validated_data)
|
||||||
for rule_data in rules_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
|
return saved_view
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user