Skip to content
Snippets Groups Projects
Commit 6b2bbcdc authored by jan.bednarik's avatar jan.bednarik
Browse files

ReportDoc extra field is using property instead of get method.

parent 72d92792
No related branches found
No related tags found
No related merge requests found
...@@ -18,13 +18,14 @@ class ReportDoc(DocType): ...@@ -18,13 +18,14 @@ class ReportDoc(DocType):
our_participants = fields.TextField(analyzer=settings.ES_TEXT_ANALYZER) our_participants = fields.TextField(analyzer=settings.ES_TEXT_ANALYZER)
other_participants = fields.TextField(analyzer=settings.ES_TEXT_ANALYZER) other_participants = fields.TextField(analyzer=settings.ES_TEXT_ANALYZER)
# there is no support for JSONField now, so we serialize it to keyword # there is no support for JSONField now, so we serialize it to keyword
extra = fields.KeywordField() extra_serialized = fields.KeywordField()
def prepare_extra(self, instance): def prepare_extra_serialized(self, instance):
return json.dumps(instance.extra) return json.dumps(instance.extra)
def get_extra(self): @property
return json.loads(self.extra) def extra(self):
return json.loads(self.extra_serialized)
class Meta: class Meta:
model = Report model = Report
......
...@@ -46,4 +46,4 @@ def test_report_is_saved_in_elasticsearch(): ...@@ -46,4 +46,4 @@ def test_report_is_saved_in_elasticsearch():
assert doc.provided_benefit == 'tea' assert doc.provided_benefit == 'tea'
assert doc.our_participants == 'me' assert doc.our_participants == 'me'
assert doc.other_participants == 'them' assert doc.other_participants == 'them'
assert doc.get_extra() == {'a': 3} assert doc.extra == {'a': 3}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment