See #890: include notes in reports API representations

This commit is contained in:
Eliot Berriot 2019-08-29 14:12:26 +02:00
parent 7a7cc55143
commit eb5b63c008
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
3 changed files with 34 additions and 13 deletions

View file

@ -1,8 +1,7 @@
import urllib.parse
import uuid
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType
from django.contrib.postgres.fields import JSONField
from django.db import models
@ -149,6 +148,12 @@ class Report(federation_models.FederationMixin):
# delete
target_state = JSONField(null=True)
notes = GenericRelation(
"Note",
content_type_field="target_content_type",
object_id_field="target_id",
)
def get_federation_id(self):
if self.fid:
return self.fid