mirror of
https://github.com/evgen-app/evg-app-back.git
synced 2024-11-24 17:53:44 +03:00
change backend to communicate with frontend without shit part 1
This commit is contained in:
parent
c102376dc5
commit
2aa03e4c6b
Binary file not shown.
|
@ -13,9 +13,9 @@ class HyperLink(models.Model):
|
||||||
child = models.OneToOneField(Child, null=True, on_delete=models.CASCADE, unique=False)
|
child = models.OneToOneField(Child, null=True, on_delete=models.CASCADE, unique=False)
|
||||||
organ = models.OneToOneField(Organisator, null=True, on_delete=models.CASCADE, unique=False)
|
organ = models.OneToOneField(Organisator, null=True, on_delete=models.CASCADE, unique=False)
|
||||||
|
|
||||||
@receiver(signal=post_save, sender=Organisator)
|
#@receiver(signal=post_save, sender=Organisator)
|
||||||
def org_recieve(sender, instance, **kwargs):
|
#def org_recieve(sender, instance, **kwargs):
|
||||||
HyperLink.objects.create(organ=instance)
|
# HyperLink.objects.create(organ=instance)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
37
lessons/LessonType.py
Normal file
37
lessons/LessonType.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
from .models import Lesson
|
||||||
|
import graphene
|
||||||
|
import graphene_django
|
||||||
|
from graphene import relay
|
||||||
|
from .gqlTypes import TestsType
|
||||||
|
|
||||||
|
|
||||||
|
class LessonType(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model=Lesson
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
filter_fields = {
|
||||||
|
"name": ["exact", "contains"],
|
||||||
|
"descr": ["exact", "contains"]
|
||||||
|
}
|
||||||
|
pk = graphene.Int()
|
||||||
|
tests = graphene.List(TestsType)
|
||||||
|
testsLen = graphene.Int()
|
||||||
|
materialsLen = graphene.Int()
|
||||||
|
materials = graphene.List(Material)
|
||||||
|
|
||||||
|
def resolve_tests(self, info):
|
||||||
|
return self.tests_set.all()
|
||||||
|
|
||||||
|
def resolve_pk(self, info):
|
||||||
|
return self.pk
|
||||||
|
|
||||||
|
def resolve_testsLen(self, info):
|
||||||
|
return len(self.tests_set.all())
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_materialsLen(self, info):
|
||||||
|
return len(self.materials_set.all())
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_materials(self, info):
|
||||||
|
return self.materials_set.all()
|
BIN
lessons/__pycache__/LessonType.cpython-37.pyc
Normal file
BIN
lessons/__pycache__/LessonType.cpython-37.pyc
Normal file
Binary file not shown.
BIN
lessons/__pycache__/gqlTypes.cpython-37.pyc
Normal file
BIN
lessons/__pycache__/gqlTypes.cpython-37.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
146
lessons/gqlTypes.py
Normal file
146
lessons/gqlTypes.py
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
import graphene
|
||||||
|
import graphene_django
|
||||||
|
|
||||||
|
from .models import Subject, Lesson, SubjectClassLocal, Tests, Task, AnswerSheet, Answer, Materials
|
||||||
|
from organisations.gqlTypes import ChildType, TeacherType
|
||||||
|
|
||||||
|
from organisations.models import Organisation, Group, Child, Teacher
|
||||||
|
|
||||||
|
from graphene import relay
|
||||||
|
from graphene_django.filter import DjangoFilterConnectionField
|
||||||
|
from users.models import Profile
|
||||||
|
|
||||||
|
from django.db.models import Model
|
||||||
|
|
||||||
|
|
||||||
|
class Material(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model = Materials
|
||||||
|
|
||||||
|
class AnswerType(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model = Answer
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
filter_fields = {
|
||||||
|
"sheet" : ("exact",),
|
||||||
|
}
|
||||||
|
pk = graphene.Int()
|
||||||
|
|
||||||
|
def resolve_pk(self, info): return self.pk
|
||||||
|
|
||||||
|
class AnswerSheetType(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model = AnswerSheet
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
filter_fields = {
|
||||||
|
"test" : ("exact",),
|
||||||
|
"child": ("exact",)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class TaskType(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model = Task
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
filter_fields = {
|
||||||
|
"test": ("exact",),
|
||||||
|
"types": ("contains",)
|
||||||
|
}
|
||||||
|
pk = graphene.Int()
|
||||||
|
|
||||||
|
def resolve_pk(self, info):
|
||||||
|
return self.pk
|
||||||
|
|
||||||
|
|
||||||
|
class TestsType(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model = Tests
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
filter_fields = {
|
||||||
|
"name": ("exact", "contains"),
|
||||||
|
"lesson": ("exact",)
|
||||||
|
}
|
||||||
|
pk = graphene.Int()
|
||||||
|
taskLen = graphene.Int()
|
||||||
|
|
||||||
|
def resolve_pk(self, info):
|
||||||
|
return self.id
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_taskLen(self, info):
|
||||||
|
return len(self.task_set.all())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class SubjectType(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model=Subject
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
|
||||||
|
filter_fields = {
|
||||||
|
"name" : ("exact", "contains",),
|
||||||
|
"organisation" : ("exact",),
|
||||||
|
"teachers_give" : ("contains",)
|
||||||
|
}
|
||||||
|
pk = graphene.Int()
|
||||||
|
|
||||||
|
def resolve_pk(self, info): return self.pk
|
||||||
|
|
||||||
|
|
||||||
|
class LessonType(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model=Lesson
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
filter_fields = {
|
||||||
|
"name": ["exact", "contains"],
|
||||||
|
"descr": ["exact", "contains"]
|
||||||
|
}
|
||||||
|
pk = graphene.Int()
|
||||||
|
tests = graphene.List(TestsType)
|
||||||
|
testsLen = graphene.Int()
|
||||||
|
materialsLen = graphene.Int()
|
||||||
|
materials = graphene.List(Material)
|
||||||
|
|
||||||
|
def resolve_tests(self, info):
|
||||||
|
return self.tests_set.all()
|
||||||
|
|
||||||
|
def resolve_pk(self, info):
|
||||||
|
return self.pk
|
||||||
|
|
||||||
|
def resolve_testsLen(self, info):
|
||||||
|
return len(self.tests_set.all())
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_materialsLen(self, info):
|
||||||
|
return len(self.materials_set.all())
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_materials(self, info):
|
||||||
|
return self.materials_set.all()
|
||||||
|
|
||||||
|
|
||||||
|
class LocalSubjectType(graphene_django.DjangoObjectType):
|
||||||
|
class Meta:
|
||||||
|
model=SubjectClassLocal
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
filter_fields = {
|
||||||
|
"name": ("exact", "contains"),
|
||||||
|
"id": ("exact",),
|
||||||
|
"group": ("exact",)
|
||||||
|
}
|
||||||
|
pk = graphene.Int()
|
||||||
|
teachers_set = graphene.List(TeacherType)
|
||||||
|
lessonsLen = graphene.Int()
|
||||||
|
|
||||||
|
def resolve_pk(self, info):
|
||||||
|
return self.pk
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_teachers_set(self, info):
|
||||||
|
return self.teachers.all()
|
||||||
|
|
||||||
|
|
||||||
|
def resolve_lessonsLen(self, info):
|
||||||
|
return len(self.lesson_set.all())
|
||||||
|
|
||||||
|
|
18
lessons/migrations/0007_lesson_time_lesson.py
Normal file
18
lessons/migrations/0007_lesson_time_lesson.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.1.5 on 2021-01-30 11:27
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lessons', '0006_auto_20210117_2008'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='lesson',
|
||||||
|
name='time_lesson',
|
||||||
|
field=models.DateTimeField(auto_now=True),
|
||||||
|
),
|
||||||
|
]
|
19
lessons/migrations/0008_materials_lesson.py
Normal file
19
lessons/migrations/0008_materials_lesson.py
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 3.1.5 on 2021-01-30 12:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lessons', '0007_lesson_time_lesson'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='materials',
|
||||||
|
name='lesson',
|
||||||
|
field=models.ForeignKey(default=3, on_delete=django.db.models.deletion.CASCADE, to='lessons.lesson'),
|
||||||
|
),
|
||||||
|
]
|
18
lessons/migrations/0009_lesson_content.py
Normal file
18
lessons/migrations/0009_lesson_content.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.1.5 on 2021-01-30 17:08
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lessons', '0008_materials_lesson'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='lesson',
|
||||||
|
name='content',
|
||||||
|
field=models.TextField(default=''),
|
||||||
|
),
|
||||||
|
]
|
23
lessons/migrations/0010_auto_20210203_0122.py
Normal file
23
lessons/migrations/0010_auto_20210203_0122.py
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 3.1.5 on 2021-02-02 22:22
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('lessons', '0009_lesson_content'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='materials',
|
||||||
|
name='Type',
|
||||||
|
field=models.CharField(default='link', max_length=100),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='materials',
|
||||||
|
name='data',
|
||||||
|
field=models.TextField(blank=True),
|
||||||
|
),
|
||||||
|
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -24,11 +24,16 @@ class Lesson(models.Model):
|
||||||
type_lesson = models.ForeignKey(SubjectClassLocal, on_delete=models.CASCADE)
|
type_lesson = models.ForeignKey(SubjectClassLocal, on_delete=models.CASCADE)
|
||||||
name = models.TextField(default="")
|
name = models.TextField(default="")
|
||||||
descr = models.TextField(default="")
|
descr = models.TextField(default="")
|
||||||
|
content = models.TextField(default="")
|
||||||
|
time_lesson = models.DateTimeField(auto_now=True)
|
||||||
|
|
||||||
|
|
||||||
class Materials(models.Model):
|
class Materials(models.Model):
|
||||||
link = models.URLField()
|
link = models.URLField()
|
||||||
name = models.CharField(max_length=100, blank=True)
|
name = models.CharField(max_length=100, blank=True)
|
||||||
|
data = models.TextField(blank=True)
|
||||||
|
Type = models.CharField(max_length=100, default="link")
|
||||||
|
lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE, default=3)
|
||||||
|
|
||||||
|
|
||||||
class Tests(models.Model):
|
class Tests(models.Model):
|
||||||
|
|
|
@ -12,99 +12,10 @@ from users.models import Profile
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
|
from .gqlTypes import *
|
||||||
class AnswerType(graphene_django.DjangoObjectType):
|
|
||||||
class Meta:
|
|
||||||
model = Answer
|
|
||||||
interfaces = (relay.Node,)
|
|
||||||
filter_fields = {
|
|
||||||
"sheet" : ("exact",),
|
|
||||||
}
|
|
||||||
pk = graphene.Int()
|
|
||||||
|
|
||||||
def resolve_pk(self, info): return self.pk
|
|
||||||
|
|
||||||
class AnswerSheetType(graphene_django.DjangoObjectType):
|
|
||||||
class Meta:
|
|
||||||
model = AnswerSheet
|
|
||||||
interfaces = (relay.Node,)
|
|
||||||
filter_fields = {
|
|
||||||
"test" : ("exact",),
|
|
||||||
"child": ("exact",)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class TaskType(graphene_django.DjangoObjectType):
|
from graphql_relay.node.node import from_global_id
|
||||||
class Meta:
|
|
||||||
model = Task
|
|
||||||
interfaces = (relay.Node,)
|
|
||||||
filter_fields = {
|
|
||||||
"test": ("exact",),
|
|
||||||
"types": ("contains",)
|
|
||||||
}
|
|
||||||
pk = graphene.Int()
|
|
||||||
|
|
||||||
def resolve_pk(self, info):
|
|
||||||
return self.pk
|
|
||||||
|
|
||||||
|
|
||||||
class TestsType(graphene_django.DjangoObjectType):
|
|
||||||
class Meta:
|
|
||||||
model = Tests
|
|
||||||
interfaces = (relay.Node,)
|
|
||||||
filter_fields = {
|
|
||||||
"name": ("exact", "contains"),
|
|
||||||
"lesson": ("exact",)
|
|
||||||
}
|
|
||||||
pk = graphene.Int()
|
|
||||||
|
|
||||||
def resolve_pk(self, info):
|
|
||||||
return self.id
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SubjectType(graphene_django.DjangoObjectType):
|
|
||||||
class Meta:
|
|
||||||
model=Subject
|
|
||||||
interfaces = (relay.Node,)
|
|
||||||
|
|
||||||
filter_fields = {
|
|
||||||
"name" : ("exact", "contains",),
|
|
||||||
"organisation" : ("exact",),
|
|
||||||
"teachers_give" : ("contains",)
|
|
||||||
}
|
|
||||||
pk = graphene.Int()
|
|
||||||
|
|
||||||
def resolve_pk(self, info): return self.pk
|
|
||||||
|
|
||||||
|
|
||||||
class LessonType(graphene_django.DjangoObjectType):
|
|
||||||
class Meta:
|
|
||||||
model=Lesson
|
|
||||||
interfaces = (relay.Node,)
|
|
||||||
filter_fields = {
|
|
||||||
"name": ["exact", "contains"],
|
|
||||||
"descr": ["exact", "contains"]
|
|
||||||
}
|
|
||||||
pk = graphene.Int()
|
|
||||||
|
|
||||||
def resolve(self, info):
|
|
||||||
return self.pk
|
|
||||||
|
|
||||||
|
|
||||||
class LocalSubjectType(graphene_django.DjangoObjectType):
|
|
||||||
class Meta:
|
|
||||||
model=SubjectClassLocal
|
|
||||||
interfaces = (relay.Node,)
|
|
||||||
filter_fields = {
|
|
||||||
"name": ("exact", "contains"),
|
|
||||||
"id": ("exact",),
|
|
||||||
"group": ("exact",)
|
|
||||||
}
|
|
||||||
pk = graphene.Int()
|
|
||||||
|
|
||||||
def resolve_pk(self, info):
|
|
||||||
return self.pk
|
|
||||||
|
|
||||||
class CreateLesson(graphene.Mutation):
|
class CreateLesson(graphene.Mutation):
|
||||||
class Arguments:
|
class Arguments:
|
||||||
|
@ -412,6 +323,23 @@ class AnswerQuestion(graphene.Mutation):
|
||||||
return AnswerQuestion(answer=answerT)
|
return AnswerQuestion(answer=answerT)
|
||||||
|
|
||||||
|
|
||||||
|
class CreateMaterial(graphene.Mutation):
|
||||||
|
class Arguments:
|
||||||
|
lesson_id = graphene.ID()
|
||||||
|
data = graphene.String()
|
||||||
|
name = graphene.String()
|
||||||
|
|
||||||
|
material = graphene.Field(Material)
|
||||||
|
|
||||||
|
|
||||||
|
def mutate(self, info, lesson_id, data, name):
|
||||||
|
lessonId = from_global_id(lesson_id)[1]
|
||||||
|
print(lessonId)
|
||||||
|
lesson = Lesson.objects.get(id=lessonId)
|
||||||
|
material = Materials.objects.create(lesson=lesson, data=data, link="google.com", name=name)
|
||||||
|
return CreateMaterial(material=material)
|
||||||
|
|
||||||
|
|
||||||
class Mutation(graphene.ObjectType):
|
class Mutation(graphene.ObjectType):
|
||||||
create_lesson = CreateLesson.Field()
|
create_lesson = CreateLesson.Field()
|
||||||
update_lesson_registration = UpdateLessonRegistration.Field()
|
update_lesson_registration = UpdateLessonRegistration.Field()
|
||||||
|
@ -441,6 +369,9 @@ class Mutation(graphene.ObjectType):
|
||||||
|
|
||||||
answer_question = AnswerQuestion.Field()
|
answer_question = AnswerQuestion.Field()
|
||||||
|
|
||||||
|
|
||||||
|
create_material = CreateMaterial.Field()
|
||||||
|
|
||||||
class Query(graphene.ObjectType):
|
class Query(graphene.ObjectType):
|
||||||
|
|
||||||
all_test = DjangoFilterConnectionField(TestsType)
|
all_test = DjangoFilterConnectionField(TestsType)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -3,7 +3,6 @@ from .models import Organisation, Role, Group, Teacher, Child, Organisator
|
||||||
from graphene import relay
|
from graphene import relay
|
||||||
import graphene
|
import graphene
|
||||||
|
|
||||||
print(Teacher, Child)
|
|
||||||
|
|
||||||
class OrganisatorType(graphene_django.DjangoObjectType):
|
class OrganisatorType(graphene_django.DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -25,28 +24,26 @@ class OrganisationType(graphene_django.DjangoObjectType):
|
||||||
filter_fields = {
|
filter_fields = {
|
||||||
"name" : ("exact", "contains",),
|
"name" : ("exact", "contains",),
|
||||||
}
|
}
|
||||||
|
children_length = graphene.Int()
|
||||||
|
classes_length = graphene.Int()
|
||||||
|
|
||||||
|
subjects = graphene.List(graphene.String)
|
||||||
|
|
||||||
|
def resolve_children_length(self, info):
|
||||||
|
print(self, self._meta.fields)
|
||||||
|
return len(self.child_set.all())
|
||||||
|
|
||||||
|
def resolve_classes_length(self, info):
|
||||||
|
return len(self.group_set.all())
|
||||||
|
|
||||||
|
def resolve_subjects(self, info):
|
||||||
|
return list(map(lambda x : x.name, self.subject_set.all()))
|
||||||
|
|
||||||
class RoleType(graphene_django.DjangoObjectType):
|
class RoleType(graphene_django.DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Role
|
model = Role
|
||||||
|
|
||||||
|
|
||||||
class TeacherType(graphene_django.DjangoObjectType):
|
|
||||||
class Meta:
|
|
||||||
model = Teacher
|
|
||||||
interfaces = (relay.Node,)
|
|
||||||
|
|
||||||
filter_fields = {
|
|
||||||
"name": ("exact", "contains"),
|
|
||||||
"surname": ("exact", "contains"),
|
|
||||||
"midname": ("exact", "contains"),
|
|
||||||
"org" : ("exact",),
|
|
||||||
"profile" : ("exact",),
|
|
||||||
"groups" : ("contains",)
|
|
||||||
}
|
|
||||||
pk = graphene.Int()
|
|
||||||
|
|
||||||
def resolve_pk(self, info): return self.pk
|
|
||||||
|
|
||||||
|
|
||||||
class ChildType(graphene_django.DjangoObjectType):
|
class ChildType(graphene_django.DjangoObjectType):
|
||||||
|
@ -68,6 +65,30 @@ class ChildType(graphene_django.DjangoObjectType):
|
||||||
def resolve_pk(self, info): return self.pk
|
def resolve_pk(self, info): return self.pk
|
||||||
|
|
||||||
|
|
||||||
|
class TeacherType(graphene_django.DjangoObjectType):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Teacher
|
||||||
|
interfaces = (relay.Node,)
|
||||||
|
|
||||||
|
filter_fields = {
|
||||||
|
"name": ("exact", "contains"),
|
||||||
|
"surname": ("exact", "contains"),
|
||||||
|
"midname": ("exact", "contains"),
|
||||||
|
"org" : ("exact",),
|
||||||
|
"profile" : ("exact",),
|
||||||
|
"groups" : ("contains",)
|
||||||
|
}
|
||||||
|
pk = graphene.Int()
|
||||||
|
|
||||||
|
def resolve_pk(self, info): return self.pk
|
||||||
|
|
||||||
|
def resolve_local_lessons(self, info):
|
||||||
|
return self.subjectclasslocal_set.all()
|
||||||
|
|
||||||
|
|
||||||
|
from lessons.gqlTypes import LocalSubjectType
|
||||||
|
|
||||||
class GroupType(graphene_django.DjangoObjectType):
|
class GroupType(graphene_django.DjangoObjectType):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Group
|
model = Group
|
||||||
|
@ -77,6 +98,14 @@ class GroupType(graphene_django.DjangoObjectType):
|
||||||
"name" : ("exact", "contains"),
|
"name" : ("exact", "contains"),
|
||||||
}
|
}
|
||||||
pk = graphene.Int()
|
pk = graphene.Int()
|
||||||
|
classes = graphene.List(LocalSubjectType)
|
||||||
|
childrenLen = graphene.Int()
|
||||||
|
|
||||||
def resolve(self, info):
|
def resolve(self, info):
|
||||||
return self.pk
|
return self.pk
|
||||||
|
|
||||||
|
def resolve_classes(self, info):
|
||||||
|
return self.subjectclasslocal_set.all()
|
||||||
|
|
||||||
|
def resolve_childrenLen(self, info):
|
||||||
|
return len(self.child_set.all())
|
Binary file not shown.
|
@ -38,10 +38,14 @@ class RegisterUserInput(graphene.InputObjectType):
|
||||||
class RegisterUser(graphene.Mutation):
|
class RegisterUser(graphene.Mutation):
|
||||||
class Arguments:
|
class Arguments:
|
||||||
input = RegisterUserInput(required=True)
|
input = RegisterUserInput(required=True)
|
||||||
user = graphene.Field(UserType)
|
ok = graphene.Boolean()
|
||||||
|
|
||||||
def mutate(self, info, input=None):
|
def mutate(self, info, input=None):
|
||||||
return RegisterUser(User.objects.create_user(username=input.username, password=input.password))
|
try:
|
||||||
|
User.objects.create_user(username=input.username, password=input.password)
|
||||||
|
except:
|
||||||
|
return RegisterUser(ok=False)
|
||||||
|
return RegisterUser(ok=True)
|
||||||
|
|
||||||
class Mutation(graphene.ObjectType):
|
class Mutation(graphene.ObjectType):
|
||||||
token_auth = graphql_jwt.ObtainJSONWebToken.Field()
|
token_auth = graphql_jwt.ObtainJSONWebToken.Field()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user