From f0593b71c2a226d927f446031830f5598e255bb1 Mon Sep 17 00:00:00 2001 From: ilvas Date: Sun, 10 Jan 2021 15:51:59 +0300 Subject: [PATCH] commit --- evgenApp/__pycache__/schema.cpython-36.pyc | Bin 395 -> 606 bytes evgenApp/__pycache__/settings.cpython-36.pyc | Bin 2520 -> 2837 bytes evgenApp/schema.py | 8 +- evgenApp/settings.py | 19 ++- lessons/__init__.py | 0 lessons/__pycache__/__init__.cpython-36.pyc | Bin 0 -> 136 bytes lessons/__pycache__/admin.cpython-36.pyc | Bin 0 -> 177 bytes lessons/__pycache__/models.cpython-36.pyc | Bin 0 -> 3545 bytes lessons/admin.py | 3 + lessons/apps.py | 5 + lessons/db_functions.py | 21 ++++ lessons/migrations/0001_initial.py | 35 ++++++ lessons/migrations/0002_auto_20210109_1220.py | 91 ++++++++++++++ lessons/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-36.pyc | Bin 0 -> 1136 bytes .../0002_auto_20210109_1220.cpython-36.pyc | Bin 0 -> 1932 bytes .../__pycache__/__init__.cpython-36.pyc | Bin 0 -> 147 bytes lessons/models.py | 74 ++++++++++++ lessons/tests.py | 3 + lessons/views.py | 3 + organisations/__init__.py | 0 .../__pycache__/__init__.cpython-36.pyc | Bin 0 -> 142 bytes .../__pycache__/admin.cpython-36.pyc | Bin 0 -> 183 bytes .../__pycache__/gqlTypes.cpython-36.pyc | Bin 0 -> 1774 bytes .../__pycache__/models.cpython-36.pyc | Bin 0 -> 1843 bytes .../__pycache__/mutation.cpython-36.pyc | Bin 0 -> 5443 bytes .../__pycache__/query.cpython-36.pyc | Bin 0 -> 863 bytes .../__pycache__/schema.cpython-36.pyc | Bin 0 -> 312 bytes organisations/admin.py | 3 + organisations/apps.py | 5 + organisations/gqlTypes.py | 27 +++++ organisations/migrations/0001_initial.py | 75 ++++++++++++ .../migrations/0002_auto_20210107_2139.py | 20 ++++ .../migrations/0003_auto_20210107_2142.py | 20 ++++ .../migrations/0004_auto_20210108_2013.py | 20 ++++ organisations/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-36.pyc | Bin 0 -> 1659 bytes .../0002_auto_20210107_2139.cpython-36.pyc | Bin 0 -> 709 bytes .../0003_auto_20210107_2142.cpython-36.pyc | Bin 0 -> 732 bytes .../0004_auto_20210108_2013.cpython-36.pyc | Bin 0 -> 578 bytes .../__pycache__/__init__.cpython-36.pyc | Bin 0 -> 153 bytes organisations/models.py | 43 +++++++ organisations/mutation.py | 111 ++++++++++++++++++ organisations/query.py | 15 +++ organisations/schema.py | 9 ++ organisations/tests.py | 3 + organisations/views.py | 3 + users/__pycache__/admin.cpython-36.pyc | Bin 0 -> 175 bytes users/__pycache__/models.cpython-36.pyc | Bin 0 -> 765 bytes users/__pycache__/schema.cpython-36.pyc | Bin 528 -> 2803 bytes users/migrations/0001_initial.py | 24 ++++ .../__pycache__/0001_initial.cpython-36.pyc | Bin 0 -> 813 bytes .../__pycache__/__init__.cpython-36.pyc | Bin 0 -> 145 bytes users/models.py | 12 +- users/schema.py | 48 +++++++- 55 files changed, 693 insertions(+), 7 deletions(-) create mode 100644 lessons/__init__.py create mode 100644 lessons/__pycache__/__init__.cpython-36.pyc create mode 100644 lessons/__pycache__/admin.cpython-36.pyc create mode 100644 lessons/__pycache__/models.cpython-36.pyc create mode 100644 lessons/admin.py create mode 100644 lessons/apps.py create mode 100644 lessons/db_functions.py create mode 100644 lessons/migrations/0001_initial.py create mode 100644 lessons/migrations/0002_auto_20210109_1220.py create mode 100644 lessons/migrations/__init__.py create mode 100644 lessons/migrations/__pycache__/0001_initial.cpython-36.pyc create mode 100644 lessons/migrations/__pycache__/0002_auto_20210109_1220.cpython-36.pyc create mode 100644 lessons/migrations/__pycache__/__init__.cpython-36.pyc create mode 100644 lessons/models.py create mode 100644 lessons/tests.py create mode 100644 lessons/views.py create mode 100644 organisations/__init__.py create mode 100644 organisations/__pycache__/__init__.cpython-36.pyc create mode 100644 organisations/__pycache__/admin.cpython-36.pyc create mode 100644 organisations/__pycache__/gqlTypes.cpython-36.pyc create mode 100644 organisations/__pycache__/models.cpython-36.pyc create mode 100644 organisations/__pycache__/mutation.cpython-36.pyc create mode 100644 organisations/__pycache__/query.cpython-36.pyc create mode 100644 organisations/__pycache__/schema.cpython-36.pyc create mode 100644 organisations/admin.py create mode 100644 organisations/apps.py create mode 100644 organisations/gqlTypes.py create mode 100644 organisations/migrations/0001_initial.py create mode 100644 organisations/migrations/0002_auto_20210107_2139.py create mode 100644 organisations/migrations/0003_auto_20210107_2142.py create mode 100644 organisations/migrations/0004_auto_20210108_2013.py create mode 100644 organisations/migrations/__init__.py create mode 100644 organisations/migrations/__pycache__/0001_initial.cpython-36.pyc create mode 100644 organisations/migrations/__pycache__/0002_auto_20210107_2139.cpython-36.pyc create mode 100644 organisations/migrations/__pycache__/0003_auto_20210107_2142.cpython-36.pyc create mode 100644 organisations/migrations/__pycache__/0004_auto_20210108_2013.cpython-36.pyc create mode 100644 organisations/migrations/__pycache__/__init__.cpython-36.pyc create mode 100644 organisations/models.py create mode 100644 organisations/mutation.py create mode 100644 organisations/query.py create mode 100644 organisations/schema.py create mode 100644 organisations/tests.py create mode 100644 organisations/views.py create mode 100644 users/__pycache__/admin.cpython-36.pyc create mode 100644 users/__pycache__/models.cpython-36.pyc create mode 100644 users/migrations/0001_initial.py create mode 100644 users/migrations/__pycache__/0001_initial.cpython-36.pyc create mode 100644 users/migrations/__pycache__/__init__.cpython-36.pyc diff --git a/evgenApp/__pycache__/schema.cpython-36.pyc b/evgenApp/__pycache__/schema.cpython-36.pyc index 6ef9f5399e3c9c3628abdeab244beec64b8e5280..2b499712bb3bf19f543f0e1600d2f22bb6c6a522 100644 GIT binary patch delta 331 zcmeBXzQxtW--``V!h(zjMUu3 fTfE4klWiEKSi$B_4rA2j;{sX02!u>>%yKLM0g6H! delta 203 zcmcb|(#@P;%*)HQrSx-rCj$e+V<3hDRv^m(h>I(L6Z;kivw)0Y0umgIMIcI(@fK@g zX=+iWCi^Xp^rFOqjMTi;D4x>d)S_a&;^d6f+{9a~VBRe@2p6pF7MFigR%&udNM%9l QWK||@E;g`{983}{02i?@MF0Q* diff --git a/evgenApp/__pycache__/settings.cpython-36.pyc b/evgenApp/__pycache__/settings.cpython-36.pyc index 0ffb747a4d8f974f16762f93c6c39aa0b5769d19..285217a6ce9302cdcf01c990f9bd826a3f184cc5 100644 GIT binary patch delta 695 zcmY*X-EI;=6lR8D%a1?-p??%>t+i;oRjd8+$}L@5DnD94lDXL|oXN7d-EDWFB;0Ue zd;qi2tKNCx1N0?)0%Pi>4`Je!LnTd}lk=UEGx@%6W->n#pHfR3;czgS|E;`;dOW{8 zH&%%EFL^pa^l>RagfK)Ps)c9}CLyLFh@WE`f&{$<+cXSGNWm0L!wkn+n1eJ-Ye5=; zdB|v(@86+OSkOE`;4Un}Jy?SK8qpCfpA!wyNq9hGumV|zI=B;O0z7<=;n6wP5lz4< ztmy^Bi^vJ9uzrP)b)*q`8=k;ZZjgix;Bqtt&*&69r_-=WXMoUIo^w3YutnzqS3TLC zi#S@qLtoEfwnM{~t*NH&s9oJM9Xeq!$KlN&#m+QlN+&0x(`vJ0bzBB(nysF+PYtEh z?~2DdfWi8z&BViMrQBf6n)QyErR#APQ=ytWkW12KuvFOFE6NS&NY4L>7;fF`xEZqJ ze)GP)Xpjm_vAuaEQ*_)4+TjqfrQ6jDv)D3Bkzy9N0?u_>A~55eOcK@E84c Bzx4nB delta 341 zcmYk1Jxc>Y5Qgvemd)mpOH3{wm&E9)QFDHO6e3s{yhs#-Xu!ZWHg7mCm8cL9#KK=7 zi;bl77f61Fh=q;V+S%Gzx{8G}JTEiz4h(afd$lX8mSy(NKacM$O?%h=MO4+Bin9;x zrm}q%aACqiBGg3;NfF1Au#iF;HZsT}hddnEK~yAAKrtZ7Er}$C0}T{qj9?Tl#sV7Z z81K_S7ekm3DO51o(YvIZ?l4SU6HNDsx?rOUPiaMO7fZC$KTB6j_>c)+qJ{G>_yu$V*1Qg{;4Yu%v~L_ZlgX`yS5#1dl-k3@`#24nSPY0whuxf*CX!{Z=v*frJsnFH`-D{M=Oi%$&?b z{nWDb)I8n9f&$&5)Eo%Uv7kUdC$+dZKd)FnK0Y%qvm`!Vub}c4hfQvNN@-529mu$1 HAZ7pn_VXYp literal 0 HcmV?d00001 diff --git a/lessons/__pycache__/admin.cpython-36.pyc b/lessons/__pycache__/admin.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..53860670ebbb2955617c2a2834e92cf9b92ff511 GIT binary patch literal 177 zcmXr!<>lgX`yOx4z`*brh~a<<$Z`PUVgVqL!jQt4!;s4u#mLBz!W7J)$@~&1%Am=3 zi#0JNH#5&qlPQWXB`Yy6Jzp<5Kd+=HGpPtZg{a yr{?J<78K|frRG3*js*q!IjP0P`FX|qU_-AKPz$o literal 0 HcmV?d00001 diff --git a/lessons/__pycache__/models.cpython-36.pyc b/lessons/__pycache__/models.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7c50a9785318b8e44f6e8e07b56d5781d6995dfc GIT binary patch literal 3545 zcmai1OLH4V5Z={3C9P~laU6$)NAV~S5IYdwgkZ;x1C_*3L=;t9MQyD$6FsupRc6*n zOqo-1;gBoEjWd5~uAK4{;KbLnDtd_b`0e+VWu|s>}gwDhbU5#6bH}OMX_wA%UX@m{axMnbi zxsMFya&z2#XoUd~kNH6S5@`Xcvj&hxi7WwWvH(a>BFjKpYzfFxiL`+%vo?@+iJSm( zf^~p&N~8niBwGQpQX(gToMNj$R!d|B$Z56)WUWL_ai2GMo1J-FV=u6?kBo*^ z#?H+!_Tnw0`_dDlt!pZGk};mhuC0P^#2`*bGR{X?s=OYL`$I02b4_FiQ{`+AM+w6M zU+_L3-QxoN`ZSYyB;$L$PoJCp=5BZ&2sc8L8DWiEW1E?*_Sg&^^j+>j`pkM<3+w1L zcoPZ-%!YD~@@^gMk9j|T!te!b)R@E%qJ*b|d`R17X#}Nt&iA@4!vK#1p1$!c}886MQsCuk%A;(F|{U>(=(x&ebr;7P(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f --- /dev/null +++ b/lessons/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/lessons/apps.py b/lessons/apps.py new file mode 100644 index 0000000..4d07a9e --- /dev/null +++ b/lessons/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class LessonsConfig(AppConfig): + name = 'lessons' diff --git a/lessons/db_functions.py b/lessons/db_functions.py new file mode 100644 index 0000000..16c97d0 --- /dev/null +++ b/lessons/db_functions.py @@ -0,0 +1,21 @@ +from .models import Subject, SubjectClassLocal +from organisations.models import Organisation + + +def extendOrganisationSubject(org, sub_name): + Subject.objects.create(name=sub_name, organisation=org) + + +def addSubjectToGroup(group, subName, subject): + SubjectClassLocal.objects.create(name=subName, subject=subject, group=group) + + +def addClassToTeacher(classLocal, teacher): + classLocal.teachers.add(teacher) + + +def removeTeacherFromClass(classLocal, teacher): + classLocal.teachers.remove(teacher) + +def addLessonToClass(classLocal): + Lesson \ No newline at end of file diff --git a/lessons/migrations/0001_initial.py b/lessons/migrations/0001_initial.py new file mode 100644 index 0000000..7f712da --- /dev/null +++ b/lessons/migrations/0001_initial.py @@ -0,0 +1,35 @@ +# Generated by Django 3.1.5 on 2021-01-08 20:17 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('organisations', '0004_auto_20210108_2013'), + ] + + operations = [ + migrations.CreateModel( + name='Subject', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('organisation', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.organisation')), + ('teachers_give', models.ManyToManyField(to='organisations.Teacher')), + ], + ), + migrations.CreateModel( + name='SubjectClassLocal', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.group')), + ('subject', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.subject')), + ('teachers', models.ManyToManyField(to='organisations.Teacher')), + ], + ), + ] diff --git a/lessons/migrations/0002_auto_20210109_1220.py b/lessons/migrations/0002_auto_20210109_1220.py new file mode 100644 index 0000000..566d0ec --- /dev/null +++ b/lessons/migrations/0002_auto_20210109_1220.py @@ -0,0 +1,91 @@ +# Generated by Django 3.1.5 on 2021-01-09 12:20 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('organisations', '0004_auto_20210108_2013'), + ('lessons', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Lesson', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('type_lesson', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.subjectclasslocal')), + ], + ), + migrations.CreateModel( + name='Materials', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('link', models.URLField()), + ('name', models.CharField(blank=True, max_length=100)), + ], + ), + migrations.CreateModel( + name='Task', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('theory', models.TextField()), + ('practise', models.TextField()), + ('number', models.IntegerField()), + ], + ), + migrations.CreateModel( + name='Type', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.TextField(max_length=150)), + ], + ), + migrations.CreateModel( + name='Theme', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=150)), + ('tasks', models.ManyToManyField(to='lessons.Task')), + ], + ), + migrations.CreateModel( + name='Tests', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=150)), + ('deadline', models.DateTimeField()), + ('lesson', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.lesson')), + ], + ), + migrations.AddField( + model_name='task', + name='test', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tests'), + ), + migrations.AddField( + model_name='task', + name='type', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='lessons.type'), + ), + migrations.CreateModel( + name='AnswerSheet', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('completed', models.BooleanField(default=False)), + ('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='organisations.child')), + ('test', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.tests')), + ], + ), + migrations.CreateModel( + name='Answer', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('content', models.TextField()), + ('number', models.IntegerField()), + ('sheet', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='lessons.answersheet')), + ], + ), + ] diff --git a/lessons/migrations/__init__.py b/lessons/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/lessons/migrations/__pycache__/0001_initial.cpython-36.pyc b/lessons/migrations/__pycache__/0001_initial.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..caf0e16b0b9e3f2dc7a610e212ec0c4c886bbc3f GIT binary patch literal 1136 zcma)5OLNmO5VjQO{b);D`e23&r!dnbZ8>mYm}XMSFiEo zGKWpM!sLW`T_?D1R+EW#DI4w|qlqtS;A$sqaaV`f;RmWf}v9>f^+$ z-Hs+HM>LftftJI-ayT%j1iKz{Y%B*Au%V3ApazV-3RI!CurD~&39CZ`nhQo&i>wAV zgH})t+Cc}}&{=T8R|sE$Rai5-JR2S@c;<8cKYVUH@VQy|eEb04D)8-lvC1Zv$DLK! zAx56)`spnd=eiwBPei^dnAsW(1}|JOOJnz7aIinvAG{=G|4>)YX5#=SspdYMX#VcF zYwK3FZz55o2)da_e=6j)`w6dgU7_?v=+9BNu27C+g>EFKsBI%}fGF-Vx)brm4Kec4 zOWj&dWWKv>sot_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F9gA;u Mo25={)68Z51rDkr3jhEB literal 0 HcmV?d00001 diff --git a/lessons/migrations/__pycache__/__init__.cpython-36.pyc b/lessons/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..62c0defe4aa72ece2c1b0e44ab076b6d3d4b7a3b GIT binary patch literal 147 zcmXr!<>k7t_eVSf5IhDEFu(|8H~?`m3y?@*2xib^^jpbL1QJFNzZ~>4@^e%5GjlQ% z^;65zQ}c8a3kr0LQga|Y$ASX=oYdmt{JdiQ+|2Z%#F9)9Gd?~uFS8^*Uaz3?7Kcr4 QeoARhsvXGWVjyM!08a%a-2eap literal 0 HcmV?d00001 diff --git a/lessons/models.py b/lessons/models.py new file mode 100644 index 0000000..cdde3d3 --- /dev/null +++ b/lessons/models.py @@ -0,0 +1,74 @@ +from django.db import models +from organisations.models import Organisation, Teacher, Group, Child + +from django.dispatch import receiver +from django.db.models.signals import post_save + + +class Subject(models.Model): + name = models.CharField(max_length=100) + organisation = models.ForeignKey(Organisation, on_delete=models.CASCADE) + teachers_give = models.ManyToManyField(Teacher) + +class SubjectClassLocal(models.Model): + subject = models.ForeignKey(Subject, on_delete=models.CASCADE) + teachers = models.ManyToManyField(Teacher) + group = models.ForeignKey(Group, on_delete=models.CASCADE) + name = models.CharField(max_length=100, unique=False) + + def __str__(self): + return self.name + + +class Lesson(models.Model): + type_lesson = models.ForeignKey(SubjectClassLocal, on_delete=models.CASCADE) + + +class Materials(models.Model): + link = models.URLField() + name = models.CharField(max_length=100, blank=True) + + +class Tests(models.Model): + name = models.CharField(max_length=150) + deadline = models.DateTimeField() + lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE) + +class Type(models.Model): + name = models.TextField(max_length=150) + +class Task(models.Model): + theory = models.TextField() + practise = models.TextField() + test = models.ForeignKey(Tests, on_delete=models.CASCADE) + type = models.ForeignKey(Type, on_delete=models.PROTECT) + number = models.IntegerField() + + + +class Theme(models.Model): + tasks = models.ManyToManyField(Task) + name = models.CharField(max_length=150) + +class AnswerSheet(models.Model): + child = models.ForeignKey(Child, on_delete=models.CASCADE) + completed = models.BooleanField(default=False) + test = models.ForeignKey(Tests, on_delete=models.CASCADE) + +class Answer(models.Model): + sheet = models.ForeignKey(AnswerSheet, on_delete=models.CASCADE) + content = models.TextField() + number = models.IntegerField() + + +@receiver(post_save, sender=Tests) +def _post_save_receiver(sender, instance, created, **kwargs): + if created: + for child in instance.lesson.type_lesson.group.child_set.all(): + AnswerSheet.objects.create(child=child, completed=False, test=instance) + +@receiver(post_save, sender=Task) +def _post_save_receiver(sender, instance, created, **kwargs): + if created: + for child in instance.test.lesson.type_lesson.group.child_set.all(): + Answer.objects.create(number=instance.number, sheet=child.answer_sheet_set.all().filter(test=instance.test)[0], content="") \ No newline at end of file diff --git a/lessons/tests.py b/lessons/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/lessons/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/lessons/views.py b/lessons/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/lessons/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/organisations/__init__.py b/organisations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/organisations/__pycache__/__init__.cpython-36.pyc b/organisations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3fa8778abbef5a22cddc6f5da643647f5ca3d660 GIT binary patch literal 142 zcmXr!<>fNm^EI9U2p)q77+?f49Dul(1xTbY1T$zd`mJOr0tq9CU)K5=`MIh3nK_w> z`l)57I1qHfAsW}jyV?lv_eo=a2US@G(NoIatv3`7fW?p7Ve7s&kfNm^EKX{fq~&M5W@izkmUfx#R5Pgg&~D8has0Sijk2ag(;Xplldi3ltGj6 z7HeWkZf2gJCQ}q&N>*ZCdcIzAeqKpYW>OKzfRzkI%s>iE{Ibx`$j?pH&&JQOEUBGiuJ)p>lIYq;;_lhPbtkwwPOStRt&@p E05e`LjQ{`u literal 0 HcmV?d00001 diff --git a/organisations/__pycache__/gqlTypes.cpython-36.pyc b/organisations/__pycache__/gqlTypes.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..865fe61457df7f38130742e8b80c383768aca100 GIT binary patch literal 1774 zcmbVM&u`N(6n30AP12?-g&jbgxb?90z!8LoK-!5;f}MPcvf64h<=31RX-J&Pk$;4L z$yZMM3y?VRp4*gcq7`W>zxsX2XMg@|zn5VcTz&l&y`Y5rB#p;`{u#9DI|M<5l@d+_ z6?ST6l+(=ScII#=W1M9!cP%12l1X<(EpkqTBiJ`0m?YQU%H}>GuIK>L*&qQRp6~(j zH%J$dKy(4=Zjc@zJrM#DZjew|pU9|x2a3q#&Vo2%x_6;wah_E1A}Mn1d@NF_*|{o~ zrS4qHcsiF#vv>0(6;tHZj}4tOXw@?al5k59PGLq%P?(XfD7S?TvpIUuoZ#}dl=sF# z6=s}4V;pI7$7rQrjvum5KgdNq0pVU0<#8sXNC#1r6=IoUzZXR}%Q#)XQK(Wgcq!8# zM1_!<@cY$xUSx8dq)9xMpJy^ZiOcdt$#k8)Ez5Dyu%#N$Zc>z9otC%SK?NNctAb4@ zo~4f9Z!&U}kK+dzx)>1tJLkIBN6drZLaX_h-!tX^&Gm4A%}H%-Kz~cyl(AvZuKW6L-g+rRO8n_9~0G zZLZ<^EzKUwdG zeRhOR|B6O1!4)fc$~pOta!NOKt?w$Y^i$vZo(jq^4LN(rgfD^@OazjjMVD?mKqV9r zDp9Azs0>7mO57I)acc*gsoR`TjI zoP=+R%lvt!WVPOImb1V_Syttx%rX;a8Ggr3k)LGQvt6#*5pZy&87wwAoD@1TP#Fhk7r1xtf2)8xBeloiJX^rI)W1vX9beqm<}$?)Zj!wCC` z#nVzfeVq|ZP&Q$f=`Cd09a>1=!T8U2`ymdy3Cmdslmx_NhGb~E8Jx=JTMNy`fhmpL zU~4^!1P5qH*R)|H9ywOI#lgpsBbq{m>~pxTHda26A=*f|!h4C^w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@y=I6`~Qfcokv1&06m#5T;2sXFZRW2g>TtqyVk-(z%vnJU1QFsmrdx^i-N?lb~jL2gBy zV;B+NfutzP0mTcBD^SIN`VrdQ23i(-=diQzT@8?*(GcFdVcsz>cW)Y~LdW{hR7TuEEw^C81Y@}o_V=*!^^iteG6;x{tr-F9Ii#o$96xUt3tg?sE2Gd>hDv_{}l6E zAIU_%_Nzr>k|x4mixPharPotpjbo@>;+UzBVr+$Ej>(Kv@7loYX*26nj5~h;HSL^@ zCPMv!=2JgK0b1rI6A(j}=TV^-n$hEz%g500`^WfStjd?(0gMuyduowd#tVc)X%(q+XrQYk- zV$3tw{)DtEFkim)w3g^o{Tw}N+a~7q3Z6 zURq*QE5UC!Tcg+atw^h_G@2mn%b(+2|ySN3<{+iZ(iXD_k3Oozh zjU!cOiXTx+#j|xDz~G2|8NikF_QOt!TarU!+>skB-;`T?-!Ae49sIuh>~Y-dE@uS% zKKc%=6-TH14Wds$lJnxYt>mx|Kd`8cKJBs(2R;rG@pj!SpY{tmQl@x|f@1O9rv^+4 z`iR?t$*$}P_2d0g#7mtK7nF@~)Up>pB-uG#8NOgtDM)cwXzT6s`#>BFpC|Z0mK86( zAbI|>p*{NgB$KS*WFKOrEX7+60sN4c2JQ%~UGuKhwz{ou*xjRYvm12x{tF`5`@jGI literal 0 HcmV?d00001 diff --git a/organisations/__pycache__/query.cpython-36.pyc b/organisations/__pycache__/query.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4607a8731b9434b6eaefe55892780568a2e54744 GIT binary patch literal 863 zcma)4y^a$x5VqI*7}X4uD0c} z?z{KvK{@`m*9tZ8j`zJTM9&ieLpt6+%f^luMOU_}C|p_;Z7)|E^>I-wR;B*q;gu9(~q{5}@%@c=5a--ZRx9{>OV literal 0 HcmV?d00001 diff --git a/organisations/__pycache__/schema.cpython-36.pyc b/organisations/__pycache__/schema.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..eabc0ba07b20473f888f77736b05e819d42e3245 GIT binary patch literal 312 zcmX|*O-{ow5QY5{2dlK=1RNlXk_D?Ggx~-mq3*n?Ts%rr*^Y4+U)D9m9m|>WDT+#t1?F{kB7me)qB1@Gev9ddj zIhL!h{15y~dxVq!0%kbzc4a3H(4LWI-@do|K7Vg_KW{eczyJJaaL_c2Ka8EvBK{$b zvP%REV5u=zy#|T11w~T{n8xSz%LBnUXzXCb6KCokqGB;o|UpT z%K_8!$wcjKze8dk(kQ>+hJnV2fidF1Mkah5v5|##QUeQYbP^XB{WWmFU0IhLJX-Uh z4tpzh$s-Pp71!F$S8CT^8n-lCuhjHl|6hLFuhG6!X~O~Kw1F_tW1sVhyRD{BS+;MIio}Ph|bz4(mUTCvZ1sWC5louPESui4dN`G z$6+e%$0A=8lE-i+`FD?eOE$vAJP#%U!#RT7D?~gC#Z~YOucSu~$S7W-Y&=IX&Pxok zaE8)SblsuD>N7gn;fo-}ESgV!E?TrGYnL&mK(U{SD9qwgAA4#2n5Ve@Oer`Qi*bUJ z`5KgD<|1025V_VZySozI9xu-Vx-vLN$>+Irh8Rw!DAvEK9JsW{X_!3|ZSA{U2%V)f zi$OEBNEKZ!4|koGT@8iL#If>WihDGPBSqALbPADQ#wjkF8prNNl#Q}VJqQW1<=xvZ zH)Tm%NAyhsN8NOdS_O@*p^^4r8mI7t0JBxZ8WF!E-9T#wfvg7sSuRo}z7YgJEy7fl zLXxv>WdpFl3^1F-SPFVG47oSZZ9G>og{fA&K6Up@bwhfCX(%@A5MRtIwtkiijHB!a z>URy2FpF}@VJuyZHoaET8T2m({YT%*{qr!p8s>^tw#}y*4s#-v==K3NPV)jcZ{2T( z_)=A<$Y0<0ruhteaT&!;AS{Xp0@F(B7e((Dp1qqlv$uPUyTz4IkFrCf91?N4 zW!5Z$A>FU5zJ8r4`%r*Z87HP!< literal 0 HcmV?d00001 diff --git a/organisations/migrations/__pycache__/0002_auto_20210107_2139.cpython-36.pyc b/organisations/migrations/__pycache__/0002_auto_20210107_2139.cpython-36.pyc new file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Ih3nK_w> z`l)57I1qHfAsW}jyV?lv_eo=a2US@G(NoIatv3_o5dJ&WvAD@|*SrQ+wS5SG2 T!zMRBr8Fni4rG2Y5HkP(IQ1wj literal 0 HcmV?d00001 diff --git a/organisations/models.py b/organisations/models.py new file mode 100644 index 0000000..ab3a051 --- /dev/null +++ b/organisations/models.py @@ -0,0 +1,43 @@ +from django.db import models + + +from django.db.models.signals import post_save +from django.dispatch import receiver + +from users.models import Profile + +class Role(models.Model): + name = models.CharField(max_length=50) + + + +class Organisation(models.Model): + name = models.TextField() + + def __str__(self): + return self.name + + +class Group(models.Model): + name = models.CharField(max_length=20) + org = models.ForeignKey(Organisation, models.CASCADE, unique=False) + + def __str__(self): + return self.name + + +class Teacher(models.Model): + org = models.ForeignKey(Organisation, models.CASCADE, blank=True) + profile = models.ForeignKey(Profile, models.CASCADE) + groups = models.ManyToManyField(Group) + name = models.CharField(max_length=150, blank=True) + surname = models.CharField(max_length=150, blank=True) + midname = models.CharField(max_length=150, blank=True) + +class Child(models.Model): + profile = models.ForeignKey(Profile, models.CASCADE) + org = models.ForeignKey(Organisation, models.CASCADE, blank=True) + groups = models.ManyToManyField(Group) + name = models.CharField(max_length=150, blank=True) + surname = models.CharField(max_length=150, blank=True) + midname = models.CharField(max_length=150, blank=True) \ No newline at end of file diff --git a/organisations/mutation.py b/organisations/mutation.py new file mode 100644 index 0000000..7f9602c --- /dev/null +++ b/organisations/mutation.py @@ -0,0 +1,111 @@ +import graphene + +from .gqlTypes import OrganisationType, RoleType, GroupType +from .models import Organisation, Role, Group, Teacher, Child + +from users.schema import UserType + +class CreateGroup(graphene.Mutation): + class Arguments: + org_name = graphene.String() + groupName = graphene.String() + + group = graphene.Field(GroupType) + + def mutate(self, info, org_name, groupName, **kwargs): + return CreateGroup(group=Group.objects.create(name=groupName, org=Organisation.objects.get(name=org_name))) + + +class CreateOrg(graphene.Mutation): + class Arguments: + name = graphene.String() + + Org = graphene.Field(OrganisationType) + + def mutate(self, info, name, **kwargs): + return CreateOrg(Org=Organisation.objects.create(name=name)) + +class RegUserOrg(graphene.Mutation): + class Arguments: + token = graphene.String() + orgName = graphene.String() + isTeacher = graphene.Boolean() + name = graphene.String(required=False) + surname = graphene.String(required=False) + midname = graphene.String(required=False) + + ok = graphene.Boolean() + + def mutate(self, info, token, orgName, isTeacher, **kwargs): + org = Organisation.objects.get(name=orgName) + if isTeacher: + t = Teacher.objects.create(profile=info.context.user.profile, org=org) + else: + t = Child.objects.create(profile=info.context.user.profile, org=org) + return RegUserOrg(ok=True) + + + +class AddGroupToOrg(graphene.Mutation): + class Arguments: + orgName = graphene.String() + groupName = graphene.String() + + group = graphene.Field(GroupType) + def mutate(self, info, orgName, groupName): + group = Group.objects.create(name=groupName, org=Organisation.objects.get(name=orgName)) + return AddGroupToOrg(group=group) + + +class RegUserGroup(graphene.Mutation): + class Arguments: + token = graphene.String() + orgName = graphene.String() + groupName = graphene.String() + is_teacher = graphene.Boolean() + user = graphene.Field(UserType) + def mutate(self, info, token, orgName, groupName, is_teacher, **kwargs): + group = Organisation.objects.get(name=orgName).group_set.all().filter(name=groupName)[0] + if is_teacher: + info.context.user.profile.teacher_set.all().filter(org__name=orgName)[0].groups.add(group) + else: + info.context.user.profile.child_set.all().filter(org__name=orgName)[0].groups.add(group) + return RegUserGroup(info.context.user) + +class DeleteGroup(graphene.Mutation): + class Arguments: + orgName = graphene.String() + groupName = graphene.String() + ok = graphene.Boolean() + def mutate(self, info, orgName, groupName, **kwargs): + Organisation.objects.find(name=orgName).objects.groups.all().filter(name=groupName)[0].delete() + +class DeleteUserFromGroup(graphene.Mutation): + class Arguments: + orgName = graphene.String() + groupName = graphene.String() + token = graphene.String() + is_teacher = graphene.Boolean() + user = graphene.Field(UserType) + def mutate(self, info, orgName, groupName, token, is_teacher, **kwargs): + if is_teacher: + group = info.context.user.profile.teacher_set.all().filter(org__name=orgName)[0].groups.all().filter(name=groupName)[0] + org = info.context.user.profile.teacher_set.all().filter(org__name=orgName)[0] + print(group, org) + org.groups.remove(group) + return DeleteuserFromGroup(info.context.user) + else: + group = info.context.user.profile.child_set.all().filter(org__name=orgName)[0].groups.all().filter(name=groupName)[0] + org = info.context.user.profile.child_set.all().filter(org__name=orgName)[0] + print(group, org) + org.groups.remove(group) + + +class Mutation(graphene.ObjectType): + create_org = CreateOrg.Field() + reg_user_org = RegUserOrg.Field() + create_group = CreateGroup.Field() + reg_user_to_group = RegUserGroup.Field() + add_group_to_org = AddGroupToOrg.Field() + delete_group = DeleteGroup.Field() + delete_user_from_group = DeleteUserFromGroup.Field() \ No newline at end of file diff --git a/organisations/query.py b/organisations/query.py new file mode 100644 index 0000000..41736e2 --- /dev/null +++ b/organisations/query.py @@ -0,0 +1,15 @@ +import graphene + +from .gqlTypes import OrganisationType, RoleType +from .models import Organisation, Role + + +class Query(graphene.ObjectType): + organisations = graphene.Field(graphene.List(OrganisationType)) + roles = graphene.Field(graphene.List(RoleType)) + + def resolve_organisations(self, info, **kwargs): + return Organisation.objects.all() + + def resolve_roles(self, info, **kwargs): + return Role.objects.all() \ No newline at end of file diff --git a/organisations/schema.py b/organisations/schema.py new file mode 100644 index 0000000..fbdb59c --- /dev/null +++ b/organisations/schema.py @@ -0,0 +1,9 @@ +import graphene_django +import graphene + + +from .mutation import Mutation + +from .query import Query + +schema = graphene.Schema(query=Query, mutation=Mutation) \ No newline at end of file diff --git a/organisations/tests.py b/organisations/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/organisations/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/organisations/views.py b/organisations/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/organisations/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/users/__pycache__/admin.cpython-36.pyc b/users/__pycache__/admin.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..87ddc048a5136b42c3fd030b76110cce8f374dd9 GIT binary patch literal 175 zcmXr!<>k6u@;Tm~fq~&M5W@izkmUfx#R5Pgg&~D8has0Sijk2ag(;Xplldi3ltGj6 z7HeWkZf2gJCQ}q&N>*ZCdcIzAeqKpYW>OKzfRzkI%s>iE{4&tb$j?pH&&J?Pp;;_lhPbtkwwPOStQVhfl0OYJIjsO4v literal 0 HcmV?d00001 diff --git a/users/__pycache__/models.cpython-36.pyc b/users/__pycache__/models.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5644b04ba0fdb8f540e0e93fd9a0dec1e9ab0cac GIT binary patch literal 765 zcmYjPy>1jS5VpPlmt2BUAcS~ncK(meITMu`;cz>|>4k4vW+T%TV zCAU;O01cvG>`g+v^6WP=_RRO$elnd-zW@Er_mq&IIXNf!!7r>& za%$tIlb{Tu@S_2Z|E%xKz>U}eI;n;dsvYRkt-l$!EFWP6NI@kj7zB0by4A6ydsZZp zVV}Sz?{)X7Qm$CmwH%wl0LwhJDd(+dfO9+H99e9Y!-t%I*$OpgG{gFK`mTi!9hz4a zD5(P%OU@SOXNwmvZMa3&KZriUs5gHe&o^BI^Ga1>4!bq9r=ssqHK@^B^!?oJG4oOR ztpBEC+??Pvu3t*Mk9=bTtwiarqZ>}P!*6h!`)DqhJ{d?&Yj#0Vw7(`4&6YXUQ_Saq zFJ+T%RYN%#8&0f3-g`tQ1zGK`KC|D8-0ckoES&WMiY0(p4ssuJ>!H# zdrPkQAzb)DeMKDh2keClRQ32Vwk)B=R==vds=uoKs(U_fG`v^;yo&y^4dYLv^0T0S z2qpgmDsFI+8DZIykmxZDDYP^*M^a z+~MTd2s$qTv(XEPvVP8md`Vyg1NTQcIZHCp$Jxctgw7$9d=DyNpl>0CT?nVJ3%#MC z$xX0nDTcOAuBPkyXj|*IEBe9=Esca;Hx^pmr=o~^fvs2+jpLDsBIQNVXu@Y1_WdY2 zpT$`@BPkeDHcX1_cSCwG($(Le9t}3cV!R(ur~6W5<><+DdN2c&`9a+=(M?I^Y@ zii<#QI)IFoHLRBLs(69!wV*7#c-<&8K(|@Z$M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YOGLW)*AtBRl19Gn2yqs6clvww97G+fdQ7-c&g3SWTQBv0< z1+u$c)pgW1pqi*jGboaAz12enO(i$LEw^u4S{?N1*s2=;%TL2V2b`Bl0i5eT=S3x2 zY2pFrt2U9}nP8!kI)f6lcawt@+MlgeUM`elv<3&kztUCDyqV6X!cHB~0kbb5)!xc% tDD>0-v$}uxxP)~5u&u!sAiJGM``uiBXzgwcw+=2kt(RuCT?2OHe*qm9d@29{ diff --git a/users/migrations/0001_initial.py b/users/migrations/0001_initial.py new file mode 100644 index 0000000..2a13751 --- /dev/null +++ b/users/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 3.1.5 on 2021-01-07 21:23 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Profile', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/users/migrations/__pycache__/0001_initial.cpython-36.pyc b/users/migrations/__pycache__/0001_initial.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4e3c3a824d836a80b1995a966f2d384c68b89cbc GIT binary patch literal 813 zcmYjP&2G~`5caMe$99~ypk9!;z%7R+McfcV4Q&cYq(!v7SV$`;I|*z2$F5TpIKs6L z0*^FDIPnBXoEY0_%dU1bGdnZ;eKY&G-w%F%`6GUC%lc*gw;a+B=$I!Yq$OEuWh`Q> z)_KY^JF+t;avIxCJCXasl8)?rvt$SCr2Ey5y3#(g2JUalw+0M7168H+r5SJxGPTrk zrHb63n-vmLb26{vu9r{B0Uh&>1XvN1R>UQXY;ckexKy7lS>%!BOD=5)lAdI=34wI4 zoCTL%@`cb(wvr&(PIl@X>0R*!UvlYRamv0U1H#use|in(9J_CHu}~=>SMnJ7tD}K~ zVZ5peG1m}RAhB0!mBo53KEN7%16swY`V1Ief}RxyL>^~=&Wdh`s9)rQ*g-`VtAZR( zbL}n^q|%%W?xH7}3?VQOf?Bakf%H&_kE=MXgURZuTvharwy7JqYd*zg8P6zCLJ7Hq ze7@E+KMS|V7w0d<#o6Son4TU@USoI@p}=78upu$68?NgCqdz8Y$2A!2pXP90kZ4U; zCUL$jkjoi*4F#GOb`QsAhvTCO21N;*34XWq1FF@Czt2bSiws68Rq+Temyquf);$er zYmLitRJX>AZhydNe}Dgx*iamnYu%x09vu_b3U}-+$6=iBvgT&sVXwtDoEQ0`CGKxL ua@O>yC3o+}Ic)#f@S2CdUjwe+xrN?p56Oq#({>Qg>V6xSM96lSXa55tKj}XJ literal 0 HcmV?d00001 diff --git a/users/migrations/__pycache__/__init__.cpython-36.pyc b/users/migrations/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8e8997d4bf5d1df25575bf70cd88e1adfaff5a06 GIT binary patch literal 145 zcmXr!<>h)*{XL!m2p)q77+?f49Dul(1xTbY1T$zd`mJOr0tq9CUv~N#`MIh3nK_w> z`l)57I1qHfAsW}jyV?lv_X>n>%v3_o5dQoCYW`16=etdjpUS>&ryk0@&Ee@O9 Q{FKt1R6CHl#X!se0N@QI)c^nh literal 0 HcmV?d00001 diff --git a/users/models.py b/users/models.py index 71a8362..f65540d 100644 --- a/users/models.py +++ b/users/models.py @@ -1,3 +1,13 @@ from django.db import models +from django.contrib.auth.models import User +from django.db.models.signals import post_save +from django.dispatch import receiver -# Create your models here. + +class Profile(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE) + +@receiver(post_save, sender=User) +def create_profile(sender, instance, created, **kwargs): + if created: + Profile.objects.create(user=instance) \ No newline at end of file diff --git a/users/schema.py b/users/schema.py index d7dfaa5..e57530e 100644 --- a/users/schema.py +++ b/users/schema.py @@ -1,9 +1,51 @@ import graphene +import graphql_jwt + +import graphene_django + +from django.contrib.auth.models import User + +from .models import Profile + +class UserType(graphene_django.DjangoObjectType): + class Meta: + model = User + +class ProfileType(graphene_django.DjangoObjectType): + class Meta: + model = Profile + +class RegisterUserInput(graphene.InputObjectType): + username = graphene.String() + password = graphene.String() + +class RegisterUser(graphene.Mutation): + class Arguments: + input = RegisterUserInput(required=True) + user = graphene.Field(UserType) + + def mutate(self, info, input=None): + return RegisterUser(User.objects.create_user(username=input.username, password=input.password)) + +class Mutation(graphene.ObjectType): + token_auth = graphql_jwt.ObtainJSONWebToken.Field() + verify_token = graphql_jwt.Verify.Field() + refresh_token = graphql_jwt.Refresh.Field() + register_user = RegisterUser.Field() class Query(graphene.ObjectType): - hello = graphene.Field(graphene.String) + hello = graphene.Field(graphene.String, token=graphene.String(required=True)) + user_info = graphene.Field(UserType, token=graphene.String(required=True)) + user_profile = graphene.Field(ProfileType, token=graphene.String(required=True)) - def resolve_hello(self, info): + def resolve_hello(self, info, **kwargs): + print(info.context.user.id) return "hello" -schema = graphene.Schema(query=Query) \ No newline at end of file + def resolve_user_info(self, info, **kwargs): + return info.context.user + + def resolve_user_profile(self, info, **kwargs): + return info.context.user.profile + +schema = graphene.Schema(query=Query, mutation=Mutation) \ No newline at end of file