Skip to content

Commit

Permalink
deprecate @index and ignore when determining empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Dec 23, 2020
1 parent 9c549e0 commit af1b7fa
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions patterns/base/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from wq.db.rest.serializers import ModelSerializer
from rest_framework import serializers
from natural_keys import NaturalKeySerializer, NaturalKeyModelSerializer
from django.conf import settings


class AttachmentListSerializer(serializers.ListSerializer):
Expand All @@ -15,8 +16,11 @@ def to_representation(self, data):
if self.parent.instance and not self.parent.instance.pk:
data = self.default_attachments(initial)

for i, row in enumerate(data):
row['@index'] = i
if not getattr(settings, 'WQ_APP_TEMPLATE', None):
# FIXME: remove in 2.0
for i, row in enumerate(data):
row['@index'] = i

return data

def default_attachments(self, initial):
Expand Down Expand Up @@ -44,7 +48,7 @@ def get_value(self, dictionary):
empty = True
if isinstance(row, dict):
for key, val in row.items():
if key == self.child.Meta.type_field:
if key in ('@index', self.child.Meta.type_field):
continue
elif not self.check_empty(val):
empty = False
Expand Down

0 comments on commit af1b7fa

Please sign in to comment.