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

Create schema for holidays

parent 6cbd1436
No related branches found
No related tags found
1 merge request!1261Manage holidays
Pipeline #131083 failed
......@@ -30,6 +30,13 @@ from .celery_progress import CeleryProgressFetchedMutation, CeleryProgressType
from .custom_menu import CustomMenuType
from .dynamic_routes import DynamicRouteType
from .group import GroupType
from .holiday import (
HolidayBatchDeleteMutation,
HolidayBatchPatchMutation,
HolidayCreateMutation,
HolidayDeleteMutation,
HolidayType,
)
from .installed_apps import AppType
from .message import MessageType
from .notification import MarkNotificationReadMutation, NotificationType
......@@ -94,6 +101,8 @@ class Query(graphene.ObjectType):
school_terms = FilterOrderList(SchoolTermType)
holidays = FilterOrderList(HolidayType)
def resolve_ping(root, info, payload) -> str:
return payload
......@@ -236,6 +245,11 @@ class Mutation(graphene.ObjectType):
delete_school_terms = SchoolTermBatchDeleteMutation.Field()
update_school_terms = SchoolTermBatchPatchMutation.Field()
create_holiday = HolidayCreateMutation.Field()
delete_holiday = HolidayDeleteMutation.Field()
delete_holidays = HolidayBatchDeleteMutation.Field()
update_holidays = HolidayBatchPatchMutation.Field()
def build_global_schema():
"""Build global GraphQL schema from all apps."""
......
from graphene_django import DjangoObjectType
from graphene_django_cud.mutations import DjangoBatchDeleteMutation, DjangoBatchPatchMutation, DjangoCreateMutation
from ..models import Holiday
from .base import (
DeleteMutation,
DjangoFilterMixin,
PermissionBatchPatchMixin,
PermissionsTypeMixin,
PermissionBatchDeleteMixin,
)
class HolidayType(PermissionsTypeMixin, DjangoFilterMixin, DjangoObjectType):
class Meta:
model = Holiday
fields = ("id", "holiday_name", "date_start", "date_end")
filter_fields = {
"id": ["exact", "lte", "gte"],
"holiday_name": ["icontains"],
"date_start": ["exact", "lte", "gte"],
"date_end": ["exact", "lte", "gte"],
}
@classmethod
def get_queryset(cls, queryset, info):
return queryset # FIXME filter this queryset based on permissions
class HolidayCreateMutation(DjangoCreateMutation):
class Meta:
model = Holiday
permissions = ("core.create_holiday",)
only_fields = ("holiday_name", "date_start", "date_end")
class HolidayDeleteMutation(DeleteMutation):
klass = Holiday
permission_required = "core.delete_holiday"
class HolidayBatchDeleteMutation(PermissionBatchDeleteMixin, DjangoBatchDeleteMutation):
class Meta:
model = Holiday
permissions = ("core.delete_holiday",)
class HolidayBatchPatchMutation(PermissionBatchPatchMixin, DjangoBatchPatchMutation):
class Meta:
model = Holiday
permissions = ("core.change_holiday",)
only_fields = ("holiday_name", "date_start", "date_end")
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