Skip to content
Snippets Groups Projects
Commit 49260ce2 authored by Julian's avatar Julian
Browse files

Create schema for Rooms

parent ed6a225c
No related branches found
No related tags found
3 merge requests!1237Release 3.0,!1202Resolve "Supply Room ID and Name via Graphql",!1183Release 3.0
......@@ -9,6 +9,11 @@ and this project adheres to `Semantic Versioning`_.
Unreleased
----------
Added
~~~~~
* GraphQL schema for Rooms
Fixed
~~~~~
......
......@@ -9,7 +9,15 @@ from haystack.inputs import AutoQuery
from haystack.query import SearchQuerySet
from haystack.utils.loading import UnifiedIndex
from ..models import CustomMenu, DynamicRoute, Notification, PDFFile, Person, TaskUserAssignment
from ..models import (
CustomMenu,
DynamicRoute,
Notification,
PDFFile,
Person,
Room,
TaskUserAssignment,
)
from ..util.apps import AppConfig
from ..util.core_helpers import get_allowed_object_ids, get_app_module, get_app_packages, has_person
from .celery_progress import CeleryProgressFetchedMutation, CeleryProgressType
......@@ -21,6 +29,7 @@ from .message import MessageType
from .notification import MarkNotificationReadMutation, NotificationType
from .pdf import PDFFileType
from .person import PersonMutation, PersonType
from .room import RoomType
from .school_term import SchoolTermType # noqa
from .search import SearchResultType
from .system_properties import SystemPropertiesType
......@@ -59,6 +68,8 @@ class Query(graphene.ObjectType):
two_factor = graphene.Field(TwoFactorType)
rooms = graphene.List(RoomType)
def resolve_ping(root, info, payload) -> str:
return payload
......@@ -157,6 +168,12 @@ class Query(graphene.ObjectType):
return None
return info.context.user
@staticmethod
def resolve_rooms(root, info, **kwargs):
if info.context.user.is_anonymous:
return []
return Room.objects.all()
class Mutation(graphene.ObjectType):
update_person = PersonMutation.Field()
......
from graphene_django import DjangoObjectType
from ..models import Room
class RoomType(DjangoObjectType):
class Meta:
model = Room
fields = ("id", "name", "short_name")
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