2021-08-03 11:38:18 -04:00
|
|
|
import graphene
|
2021-08-03 13:49:12 -04:00
|
|
|
from graphene.types.generic import GenericScalar
|
2021-08-03 11:38:18 -04:00
|
|
|
|
|
|
|
__all__ = (
|
2021-08-03 14:51:56 -04:00
|
|
|
'ChangelogMixin',
|
2021-08-03 13:49:12 -04:00
|
|
|
'CustomFieldsMixin',
|
2021-08-03 11:38:18 -04:00
|
|
|
'ImageAttachmentsMixin',
|
2021-08-03 13:58:08 -04:00
|
|
|
'JournalEntriesMixin',
|
2021-08-03 13:49:12 -04:00
|
|
|
'TagsMixin',
|
2021-08-03 11:38:18 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2021-08-03 14:51:56 -04:00
|
|
|
class ChangelogMixin:
|
|
|
|
changelog = graphene.List('extras.graphql.types.ObjectChangeType')
|
|
|
|
|
|
|
|
def resolve_changelog(self, info):
|
|
|
|
return self.object_changes.restrict(info.context.user, 'view')
|
|
|
|
|
|
|
|
|
2021-08-03 13:49:12 -04:00
|
|
|
class CustomFieldsMixin:
|
|
|
|
custom_fields = GenericScalar()
|
|
|
|
|
|
|
|
def resolve_custom_fields(self, info):
|
|
|
|
return self.custom_field_data
|
|
|
|
|
|
|
|
|
2021-08-03 11:38:18 -04:00
|
|
|
class ImageAttachmentsMixin:
|
|
|
|
image_attachments = graphene.List('extras.graphql.types.ImageAttachmentType')
|
|
|
|
|
|
|
|
def resolve_image_attachments(self, info):
|
|
|
|
return self.images.restrict(info.context.user, 'view')
|
2021-08-03 13:49:12 -04:00
|
|
|
|
|
|
|
|
2021-08-03 13:58:08 -04:00
|
|
|
class JournalEntriesMixin:
|
|
|
|
journal_entries = graphene.List('extras.graphql.types.JournalEntryType')
|
|
|
|
|
|
|
|
def resolve_journal_entries(self, info):
|
|
|
|
return self.journal_entries.restrict(info.context.user, 'view')
|
|
|
|
|
|
|
|
|
2021-08-03 13:49:12 -04:00
|
|
|
class TagsMixin:
|
|
|
|
tags = graphene.List(graphene.String)
|
|
|
|
|
|
|
|
def resolve_tags(self, info):
|
|
|
|
return self.tags.all()
|