parent
14824738b2
commit
af4261f409
22 changed files with 416 additions and 60 deletions
@ -0,0 +1,22 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.3 on 2017-09-21 17:07 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('access', '0090_auto_20170918_0811'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='Privilege', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('value', models.CharField(choices=[('r', 'Отображение'), ('u', 'Использование'), ('w', 'Изменение')], default='r', max_length=1, verbose_name='Права')), |
||||
], |
||||
), |
||||
] |
||||
@ -0,0 +1,28 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.3 on 2017-09-21 17:07 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.conf import settings |
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('access', '0091_privilege'), |
||||
('courses', '0046_auto_20170921_1707'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='privilege', |
||||
name='subject', |
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Vertex', verbose_name='Объект'), |
||||
), |
||||
migrations.AddField( |
||||
model_name='privilege', |
||||
name='user', |
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Правообладатель'), |
||||
), |
||||
] |
||||
@ -0,0 +1,75 @@ |
||||
import os, sys |
||||
import django, json |
||||
|
||||
sys.path.append("../") |
||||
os.environ['PG_PORT_5432_TCP_ADDR'] = '127.0.0.1' |
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.settings") |
||||
django.setup() |
||||
|
||||
from django.contrib.contenttypes.models import ContentType |
||||
from courses.models import Course, NormalMap, CourseTheme, Lesson, Homework, Exam, \ |
||||
Tutorial, Task, Topic, Vertex |
||||
|
||||
if __name__ == '__main__': |
||||
for course in Course.objects.all(): |
||||
tree = [] |
||||
for theme in CourseTheme.objects.filter(course=course).order_by('sort'): |
||||
|
||||
topic_vertex = Vertex.manager.create_with_dependencies( |
||||
course=course, |
||||
title=theme.title, |
||||
description=theme.description, |
||||
model='topic', |
||||
icon=theme.icon, |
||||
) |
||||
|
||||
tree.append(topic_vertex.id) |
||||
children = [] |
||||
for i in Lesson.objects.filter(theme=theme).order_by('sort'): |
||||
on_comment = i.on_comment == 'N' or i.on_comment == 'T' and i.theme.on_comment |
||||
tutor = Tutorial.objects.create(video=i.video, on_comment=on_comment) |
||||
[tutor.materials.add(j) for j in i.materials.all()] |
||||
lesson_type = ContentType.objects.get(app_label="courses", model="tutorial") |
||||
vertex = Vertex.objects.create( |
||||
course=course, |
||||
title=i.title, |
||||
description=i.description, |
||||
content_type=lesson_type, |
||||
object_id=tutor.id, |
||||
) |
||||
topic_vertex.children.add(vertex) |
||||
children.append(vertex.id) |
||||
|
||||
for i in Homework.objects.filter(theme=theme).order_by('sort'): |
||||
task = Task.objects.create(is_exam=False,) |
||||
[task.materials.add(j) for j in i.materials.all()] |
||||
task_type = ContentType.objects.get(app_label="courses", model="task") |
||||
vertex = Vertex.objects.create( |
||||
course=course, |
||||
title='Домашняя работа', |
||||
description=i.description, |
||||
content_type=task_type, |
||||
object_id=task.id, |
||||
) |
||||
topic_vertex.children.add(vertex) |
||||
children.append(vertex.id) |
||||
|
||||
for i in Exam.objects.filter(theme=theme).order_by('sort'): |
||||
task=Task.objects.create(is_exam=True,) |
||||
[task.materials.add(j) for j in i.materials.all()] |
||||
task_type = ContentType.objects.get(app_label="courses", model="task") |
||||
vertex = Vertex.objects.create( |
||||
course=course, |
||||
title='Экзамен', |
||||
description=i.description, |
||||
content_type=task_type, |
||||
object_id=task.id, |
||||
) |
||||
topic_vertex.children.add(vertex) |
||||
children.append(vertex.id) |
||||
|
||||
tree.append(children) |
||||
|
||||
course_map, _is_create = NormalMap.objects.get_or_create(course=course) |
||||
course_map.json_tree=json.dumps(tree) |
||||
course_map.save() |
||||
@ -0,0 +1,29 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.3 on 2017-09-21 17:46 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('courses', '0046_auto_20170921_1707'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='NormalMap', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('json_tree', models.TextField(default='')), |
||||
('independent_elements', models.TextField(default='')), |
||||
], |
||||
), |
||||
migrations.AddField( |
||||
model_name='normalmap', |
||||
name='course', |
||||
field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='courses.Course'), |
||||
), |
||||
] |
||||
@ -0,0 +1,9 @@ |
||||
from django.db.models.signals import pre_delete |
||||
from django.dispatch import receiver |
||||
|
||||
from courses.models import Vertex |
||||
|
||||
|
||||
@receiver(pre_delete, sender=Vertex) |
||||
def delete_dependencies(instance, **kwargs): |
||||
instance.content_object.delete() |
||||
@ -0,0 +1,40 @@ |
||||
import os, sys, django |
||||
|
||||
sys.path.append("../") |
||||
os.environ['PG_PORT_5432_TCP_ADDR'] = '127.0.0.1' |
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.settings") |
||||
django.setup() |
||||
|
||||
from journals.models import Thread |
||||
from django.contrib.auth import get_user_model |
||||
|
||||
if __name__ == '__main__': |
||||
support_list = [ |
||||
'kate.gazukina@skillbox.ru', |
||||
'katerina.ragozina@skillbox.ru', |
||||
] |
||||
|
||||
admin_list = [ |
||||
'andrey.korolev@skillbox.ru', |
||||
'pavel.matveev@skillbox.ru', |
||||
] |
||||
|
||||
admin_thread, _is_create = Thread.objects.get_or_create( |
||||
key='Admin', |
||||
text='Тред для админов сюда падают все журналируемые сообщения в системе', |
||||
is_staff=True, |
||||
) |
||||
|
||||
for i in get_user_model().objects.filter(email__in=admin_list): |
||||
admin_thread.subscribers.add(i) |
||||
|
||||
support_thread, _is_create = Thread.objects.get_or_create( |
||||
key='Support', |
||||
text='Тред сапортов занимаются поддержкой клиента', |
||||
is_staff=True, |
||||
) |
||||
|
||||
support_thread.parent.add(admin_thread) |
||||
|
||||
for i in get_user_model().objects.filter(email__in=support_list): |
||||
support_thread.subscribers.add(i) |
||||
@ -0,0 +1,25 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.3 on 2017-09-22 11:16 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('journals', '0075_remove_journal_body'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AddField( |
||||
model_name='thread', |
||||
name='is_staff', |
||||
field=models.BooleanField(default=True, verbose_name='Видно ли в админке'), |
||||
), |
||||
migrations.AlterField( |
||||
model_name='thread', |
||||
name='text', |
||||
field=models.TextField(default='', verbose_name='Описание треда'), |
||||
), |
||||
] |
||||
@ -0,0 +1,20 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.3 on 2017-09-22 11:17 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('journals', '0076_auto_20170922_1116'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AlterField( |
||||
model_name='thread', |
||||
name='is_staff', |
||||
field=models.BooleanField(default=False, verbose_name='Видно ли в админке'), |
||||
), |
||||
] |
||||
@ -0,0 +1,20 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.3 on 2017-09-22 11:18 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('journals', '0077_auto_20170922_1117'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.AlterField( |
||||
model_name='thread', |
||||
name='is_staff', |
||||
field=models.BooleanField(default=False, verbose_name='Админская ли табличка'), |
||||
), |
||||
] |
||||
@ -0,0 +1,24 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.3 on 2017-09-22 11:23 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('journals', '0078_auto_20170922_1118'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.RemoveField( |
||||
model_name='thread', |
||||
name='children', |
||||
), |
||||
migrations.AddField( |
||||
model_name='thread', |
||||
name='parent', |
||||
field=models.ManyToManyField(blank=True, related_name='_thread_parent_+', to='journals.Thread'), |
||||
), |
||||
] |
||||
@ -0,0 +1,29 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# Generated by Django 1.9.3 on 2017-09-21 17:58 |
||||
from __future__ import unicode_literals |
||||
|
||||
from django.conf import settings |
||||
from django.db import migrations, models |
||||
import django.db.models.deletion |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
||||
('contenttypes', '0002_remove_content_type_name'), |
||||
('reactions', '0001_initial'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='Like', |
||||
fields=[ |
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('is_positive', models.BooleanField(default=True)), |
||||
('object_id', models.PositiveIntegerField()), |
||||
('content_type', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='contenttypes.ContentType')), |
||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Инициатор действия')), |
||||
], |
||||
), |
||||
] |
||||
Loading…
Reference in new issue