Update queries and mutations with some more fields
This commit is contained in:
parent
ce46f14c4c
commit
829f724ca9
|
|
@ -267,6 +267,7 @@ type CourseObjectType {
|
|||
learning_path: LearningPathObjectType!
|
||||
action_competences: [ActionCompetenceObjectType!]!
|
||||
profiles: [String]
|
||||
course_session_users: [CourseSessionUserType]!
|
||||
}
|
||||
|
||||
type ActionCompetenceObjectType implements CoursePageInterface {
|
||||
|
|
@ -332,46 +333,38 @@ type CircleLightObjectType {
|
|||
slug: String!
|
||||
}
|
||||
|
||||
type TopicObjectType implements CoursePageInterface {
|
||||
is_visible: Boolean!
|
||||
id: ID!
|
||||
title: String!
|
||||
slug: String!
|
||||
content_type: String!
|
||||
live: Boolean!
|
||||
translation_key: String!
|
||||
frontend_url: String!
|
||||
course: CourseObjectType
|
||||
circles: [CircleObjectType!]!
|
||||
type CourseSessionUserType {
|
||||
id: UUID!
|
||||
chosen_profile: String
|
||||
course_session: CourseSessionObjectType!
|
||||
}
|
||||
|
||||
type CircleObjectType implements CoursePageInterface {
|
||||
description: String!
|
||||
goals: String!
|
||||
"""
|
||||
Leverages the internal Python implementation of UUID (uuid.UUID) to provide native UUID objects
|
||||
in fields, resolvers and input.
|
||||
"""
|
||||
scalar UUID
|
||||
|
||||
type CourseSessionObjectType {
|
||||
id: ID!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
course: CourseObjectType!
|
||||
title: String!
|
||||
slug: String!
|
||||
content_type: String!
|
||||
live: Boolean!
|
||||
translation_key: String!
|
||||
frontend_url: String!
|
||||
course: CourseObjectType
|
||||
learning_sequences: [LearningSequenceObjectType!]!
|
||||
profiles: [String]!
|
||||
start_date: Date
|
||||
end_date: Date
|
||||
attendance_courses: [CourseSessionAttendanceCourseObjectType!]!
|
||||
assignments: [CourseSessionAssignmentObjectType!]!
|
||||
edoniq_tests: [CourseSessionEdoniqTestObjectType!]!
|
||||
users: [CourseSessionUserObjectsType!]!
|
||||
}
|
||||
|
||||
type LearningSequenceObjectType implements CoursePageInterface {
|
||||
icon: String!
|
||||
id: ID!
|
||||
title: String!
|
||||
slug: String!
|
||||
content_type: String!
|
||||
live: Boolean!
|
||||
translation_key: String!
|
||||
frontend_url: String!
|
||||
course: CourseObjectType
|
||||
learning_units: [LearningUnitObjectType!]!
|
||||
}
|
||||
"""
|
||||
The `Date` scalar type represents a Date
|
||||
value as specified by
|
||||
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
|
||||
"""
|
||||
scalar Date
|
||||
|
||||
type CourseSessionAttendanceCourseObjectType {
|
||||
id: ID!
|
||||
|
|
@ -433,26 +426,19 @@ type DueDateObjectType {
|
|||
course_session: CourseSessionObjectType!
|
||||
}
|
||||
|
||||
type CourseSessionObjectType {
|
||||
id: ID!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
course: CourseObjectType!
|
||||
title: String!
|
||||
start_date: Date
|
||||
end_date: Date
|
||||
attendance_courses: [CourseSessionAttendanceCourseObjectType!]!
|
||||
assignments: [CourseSessionAssignmentObjectType!]!
|
||||
edoniq_tests: [CourseSessionEdoniqTestObjectType!]!
|
||||
users: [CourseSessionUserObjectsType!]!
|
||||
type AttendanceUserObjectType {
|
||||
user_id: UUID!
|
||||
status: AttendanceUserStatus!
|
||||
first_name: String
|
||||
last_name: String
|
||||
email: String
|
||||
}
|
||||
|
||||
"""
|
||||
The `Date` scalar type represents a Date
|
||||
value as specified by
|
||||
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
|
||||
"""
|
||||
scalar Date
|
||||
"""An enumeration."""
|
||||
enum AttendanceUserStatus {
|
||||
PRESENT
|
||||
ABSENT
|
||||
}
|
||||
|
||||
type CourseSessionAssignmentObjectType {
|
||||
id: ID!
|
||||
|
|
@ -580,12 +566,6 @@ type AssignmentCompletionObjectType {
|
|||
evaluation_max_points: Float
|
||||
}
|
||||
|
||||
"""
|
||||
Leverages the internal Python implementation of UUID (uuid.UUID) to provide native UUID objects
|
||||
in fields, resolvers and input.
|
||||
"""
|
||||
scalar UUID
|
||||
|
||||
type UserObjectType {
|
||||
"""
|
||||
Erforderlich. 150 Zeichen oder weniger. Nur Buchstaben, Ziffern und @/./+/-/_.
|
||||
|
|
@ -724,18 +704,45 @@ type CourseSessionUserExpertCircleType {
|
|||
slug: String!
|
||||
}
|
||||
|
||||
type AttendanceUserObjectType {
|
||||
user_id: UUID!
|
||||
status: AttendanceUserStatus!
|
||||
first_name: String
|
||||
last_name: String
|
||||
email: String
|
||||
type TopicObjectType implements CoursePageInterface {
|
||||
is_visible: Boolean!
|
||||
id: ID!
|
||||
title: String!
|
||||
slug: String!
|
||||
content_type: String!
|
||||
live: Boolean!
|
||||
translation_key: String!
|
||||
frontend_url: String!
|
||||
course: CourseObjectType
|
||||
circles: [CircleObjectType!]!
|
||||
}
|
||||
|
||||
"""An enumeration."""
|
||||
enum AttendanceUserStatus {
|
||||
PRESENT
|
||||
ABSENT
|
||||
type CircleObjectType implements CoursePageInterface {
|
||||
description: String!
|
||||
goals: String!
|
||||
id: ID!
|
||||
title: String!
|
||||
slug: String!
|
||||
content_type: String!
|
||||
live: Boolean!
|
||||
translation_key: String!
|
||||
frontend_url: String!
|
||||
course: CourseObjectType
|
||||
learning_sequences: [LearningSequenceObjectType!]!
|
||||
profiles: [String]!
|
||||
}
|
||||
|
||||
type LearningSequenceObjectType implements CoursePageInterface {
|
||||
icon: String!
|
||||
id: ID!
|
||||
title: String!
|
||||
slug: String!
|
||||
content_type: String!
|
||||
live: Boolean!
|
||||
translation_key: String!
|
||||
frontend_url: String!
|
||||
course: CourseObjectType
|
||||
learning_units: [LearningUnitObjectType!]!
|
||||
}
|
||||
|
||||
type LearningContentMediaLibraryObjectType implements CoursePageInterface & LearningContentInterface {
|
||||
|
|
@ -934,16 +941,16 @@ type CourseSessionProfileMutationPayload {
|
|||
clientMutationId: String
|
||||
}
|
||||
|
||||
union UpdateCourseProfileResult = UpdateCourseProfileSuccess | UpdateCourseProfileError
|
||||
|
||||
type UpdateCourseProfileSuccess {
|
||||
message: String
|
||||
}
|
||||
union UpdateCourseProfileResult = UpdateCourseProfileError | UpdateCourseProfileSuccess
|
||||
|
||||
type UpdateCourseProfileError {
|
||||
message: String
|
||||
}
|
||||
|
||||
type UpdateCourseProfileSuccess {
|
||||
user: CourseSessionUserType!
|
||||
}
|
||||
|
||||
input CourseSessionProfileMutationInput {
|
||||
course_profile: String!
|
||||
course_slug: String!
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ export const CourseSessionProfileMutationInput = "CourseSessionProfileMutationIn
|
|||
export const CourseSessionProfileMutationPayload = "CourseSessionProfileMutationPayload";
|
||||
export const CourseSessionUserExpertCircleType = "CourseSessionUserExpertCircleType";
|
||||
export const CourseSessionUserObjectsType = "CourseSessionUserObjectsType";
|
||||
export const CourseSessionUserType = "CourseSessionUserType";
|
||||
export const CourseStatisticsType = "CourseStatisticsType";
|
||||
export const DashboardConfigType = "DashboardConfigType";
|
||||
export const DashboardType = "DashboardType";
|
||||
|
|
|
|||
|
|
@ -66,7 +66,10 @@ export const UPDATE_COURSE_PROFILE_MUTATION = graphql(`
|
|||
result {
|
||||
__typename
|
||||
... on UpdateCourseProfileSuccess {
|
||||
message
|
||||
user {
|
||||
id
|
||||
chosen_profile
|
||||
}
|
||||
}
|
||||
... on UpdateCourseProfileError {
|
||||
message
|
||||
|
|
|
|||
|
|
@ -271,6 +271,14 @@ export const COURSE_QUERY = graphql(`
|
|||
slug
|
||||
category_name
|
||||
profiles
|
||||
course_session_users {
|
||||
id
|
||||
__typename
|
||||
chosen_profile
|
||||
course_session {
|
||||
id
|
||||
}
|
||||
}
|
||||
configuration {
|
||||
id
|
||||
enable_circle_documents
|
||||
|
|
|
|||
|
|
@ -107,6 +107,9 @@ class CourseObjectType(DjangoObjectType):
|
|||
)
|
||||
configuration = graphene.Field(CourseConfigurationObjectType, required=True)
|
||||
profiles = graphene.List(graphene.String)
|
||||
course_session_users = graphene.List(
|
||||
"course.graphql.types.CourseSessionUserType", required=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Course
|
||||
|
|
@ -130,6 +133,12 @@ class CourseObjectType(DjangoObjectType):
|
|||
def resolve_profiles(root: Course, info, **kwargs):
|
||||
return CourseProfile.objects.all().values_list("code", flat=True)
|
||||
|
||||
@staticmethod
|
||||
def resolve_course_session_users(root: Course, info, **kwargs):
|
||||
user = info.context.user
|
||||
users = CourseSessionUser.objects.filter(user=user, course_session__course=root)
|
||||
return users
|
||||
|
||||
|
||||
class CourseSessionUserExpertCircleType(ObjectType):
|
||||
id = graphene.ID(required=True)
|
||||
|
|
@ -137,6 +146,21 @@ class CourseSessionUserExpertCircleType(ObjectType):
|
|||
slug = graphene.String(required=True)
|
||||
|
||||
|
||||
class CourseSessionUserType(DjangoObjectType):
|
||||
chosen_profile = graphene.String()
|
||||
course_session = graphene.Field(
|
||||
"course.graphql.types.CourseSessionObjectType", required=True
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = CourseSessionUser
|
||||
fields = ["chosen_profile", "id"]
|
||||
|
||||
@staticmethod
|
||||
def resolve_chosen_profile(root: CourseSessionUser, info, **kwargs):
|
||||
return root.chosen_profile.code
|
||||
|
||||
|
||||
class CourseSessionUserObjectsType(ObjectType):
|
||||
"""
|
||||
WORKAROUND:
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import structlog
|
|||
from graphene import relay
|
||||
from rest_framework.exceptions import PermissionDenied
|
||||
|
||||
from vbv_lernwelt.course.graphql.types import CourseSessionUserType
|
||||
from vbv_lernwelt.course.models import CourseSessionUser
|
||||
from vbv_lernwelt.course_session.graphql.types import (
|
||||
CourseSessionAttendanceCourseObjectType,
|
||||
|
|
@ -19,10 +20,7 @@ logger = structlog.get_logger(__name__)
|
|||
|
||||
|
||||
class UpdateCourseProfileSuccess(graphene.ObjectType):
|
||||
message = graphene.String()
|
||||
|
||||
def resolve_message(cls, instance, **kwargs):
|
||||
return "Update successful"
|
||||
user = graphene.Field(CourseSessionUserType(), required=True)
|
||||
|
||||
|
||||
class UpdateCourseProfileError(graphene.ObjectType):
|
||||
|
|
@ -31,13 +29,16 @@ class UpdateCourseProfileError(graphene.ObjectType):
|
|||
|
||||
class UpdateCourseProfileResult(graphene.Union):
|
||||
class Meta:
|
||||
types = (UpdateCourseProfileSuccess, UpdateCourseProfileError)
|
||||
types = (
|
||||
UpdateCourseProfileError,
|
||||
UpdateCourseProfileSuccess,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def resolve_type(cls, instance, info):
|
||||
if type(instance).__name__ == "UpdateCourseProfileError":
|
||||
return UpdateCourseProfileError
|
||||
return UpdateCourseProfileSuccess
|
||||
if type(instance).__name__ == "UpdateCourseProfileSuccess":
|
||||
return UpdateCourseProfileSuccess
|
||||
return UpdateCourseProfileError
|
||||
|
||||
|
||||
class AttendanceUserInputType(graphene.InputObjectType):
|
||||
|
|
@ -104,7 +105,7 @@ class CourseSessionProfileMutation(relay.ClientIDMutation):
|
|||
csu.chosen_profile = profile
|
||||
csu.save()
|
||||
print(user)
|
||||
return cls(result=True)
|
||||
return cls(result=UpdateCourseProfileSuccess(user=csu))
|
||||
except CourseProfile.DoesNotExist:
|
||||
return cls(result=UpdateCourseProfileError("Course Profile does not exist"))
|
||||
except CourseSessionUser.DoesNotExist:
|
||||
|
|
|
|||
Loading…
Reference in New Issue