Skip to content
Snippets Groups Projects
Commit fa241a27 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch '865-graphql-error-dummyperson-needs-a-primary-key' into 'master'

Resolve "GraphQL error "DummyPerson needs a primary key""

Closes #865

See merge request !1254
parents 0c772aa7 badb9ff5
No related branches found
No related tags found
1 merge request!1254Resolve "GraphQL error "DummyPerson needs a primary key""
Pipeline #134452 canceled
......@@ -14,6 +14,7 @@ Fixed
* Progress page didn't work properly.
* About page failed to load for apps with an unknown licence.
* Notification query failed on admin users without persons.
* Querying for notification caused unnecessary database requests.
* Loading bar didn't disappear on some pages after loading was finished.
......
......@@ -62,7 +62,7 @@ class PersonType(DjangoObjectType):
secondary_image_url = graphene.String()
notifications = graphene.List(NotificationType)
unread_notifications_count = graphene.Int()
unread_notifications_count = graphene.Int(required=False)
is_dummy = graphene.Boolean()
preferences = graphene.Field(PersonPreferencesType)
......@@ -150,7 +150,11 @@ class PersonType(DjangoObjectType):
return root.user.id if root.user else None
def resolve_unread_notifications_count(root, info, **kwargs): # noqa
return root.unread_notifications_count
if root.pk and has_person(info.context) and root == info.context.user.person:
return root.unread_notifications_count
elif root.pk:
return 0
return None
def resolve_photo(root, info, **kwargs):
if info.context.user.has_perm("core.view_photo_rule", root):
......@@ -199,11 +203,11 @@ class PersonType(DjangoObjectType):
return root.is_dummy if hasattr(root, "is_dummy") else False
def resolve_notifications(root: Person, info, **kwargs):
if has_person(info.context.user) and info.context.user.person == root:
if root.pk and has_person(info.context) and root == info.context.user.person:
return root.notifications.filter(send_at__lte=timezone.now()).order_by(
"read", "-created"
)
raise PermissionDenied()
return []
def resolve_can_edit_person(root, info, **kwargs): # noqa
return info.context.user.has_perm("core.edit_person_rule", root)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment