From 7b3cbe1dbb93ef32c9b87f7ed62d0b897ca99fa2 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Mon, 10 Jul 2017 15:36:35 +0300 Subject: [PATCH 01/26] =?UTF-8?q?=D0=92=D0=B5=D1=80=D0=BD=D1=83=D0=BB=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82=D0=B8=D0=B5=20=D0=B4=D0=BE?= =?UTF-8?q?=D0=BC=D0=B0=D1=88=D0=B5=D0=BA=20=D0=B2=20=D0=B4=D0=B8=D0=BF?= =?UTF-8?q?=D0=BB=D0=BE=D0=BC=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- courses/models.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/courses/models.py b/courses/models.py index aac726d..c7209e8 100755 --- a/courses/models.py +++ b/courses/models.py @@ -684,14 +684,6 @@ class CourseMap(models.Model): return _next._type, _next.get_obj() - def get_lesson_before(self): - try: - _before = CourseMap.objects.get(course=self.course, sort=self.sort - 2) - except CourseMap.DoesNotExist: - _before = CourseMap.objects.get(course=self.course, sort=0) - - return _before._type, _before.get_obj() - def get_before(self): try: _next = CourseMap.objects.get(course=self.course, sort=self.sort - 1) From 747dd0883f44850c66972942df8e629ebc0b0187 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Mon, 10 Jul 2017 15:37:19 +0300 Subject: [PATCH 02/26] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B8=D1=81=D0=BA=20=D0=BF=D1=80=D0=BE=D1=88=D0=BB=D0=BE?= =?UTF-8?q?=D0=B3=D0=BE=20=D1=83=D1=80=D0=BE=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- courses/views.py | 6 +++--- journals/models.py | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/courses/views.py b/courses/views.py index d89d44e..0d65036 100755 --- a/courses/views.py +++ b/courses/views.py @@ -45,9 +45,9 @@ def course(request, slug): if created: check_journal(journal) _map = CourseMap.objects.filter(course=course).order_by('sort').first() - #_j = _map.get_obj() - #j = HomeworkJ.objects.get(material=_j, student=request.user) - #j.open_material() + _j = _map.get_obj() + j = HomeworkJ.objects.get(material=_j, student=request.user) + j.open_material() else: journal, created = TeacherJ.objects.get_or_create(course=course, student=user_fabric(request.user)) diff --git a/journals/models.py b/journals/models.py index 5666f53..152c1c9 100755 --- a/journals/models.py +++ b/journals/models.py @@ -591,9 +591,7 @@ class LessonJ(models.Model): if _type == 'L': obj = LessonJ elif _type == 'H': - _before = CourseMap.objects.get(token=_before.token) - _type, _before = _before.get_lesson_before() - obj = LessonJ + obj = HomeworkJ elif _type == 'E': obj = ExamJ From 635f72afeb5864ed0081fa4065afb09c0a1f7091 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Tue, 11 Jul 2017 16:57:03 +0300 Subject: [PATCH 03/26] =?UTF-8?q?=D0=A2=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20?= =?UTF-8?q?=D0=B7=D0=BD=D0=B0=D0=B5=D0=BC=20=D0=BA=D0=BE=D0=B3=D0=B4=D0=B0?= =?UTF-8?q?=20=D1=81=D0=BF=D0=B0=D0=B4=D0=B0=D0=B5=D1=82=20=D0=B3=D0=B0?= =?UTF-8?q?=D0=BB=D0=BE=D1=87=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- courses/models.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/courses/models.py b/courses/models.py index c7209e8..99ab1a9 100755 --- a/courses/models.py +++ b/courses/models.py @@ -322,13 +322,6 @@ class CourseTheme(models.Model): return Homework.objects.filter(theme=self).count() def save(self, *args, **kwargs): - # Костыль для поиска ошибки смены галочки - if self.empty != self.empty_old: - log = logging.getLogger('Themes_status_change') - log.error('status change') - self.public_old = self.public - # Костыль конец - if CourseTheme.objects.filter(course=self.course, sort=self.sort).exclude(id=self.id).exists(): # Переформировать порядок test_in = self.sort + 1 From 21ba623e4151fc5b7f8e72c15117c9e6d558977a Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Tue, 11 Jul 2017 17:03:25 +0300 Subject: [PATCH 04/26] =?UTF-8?q?=D0=9F=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F?= =?UTF-8?q?=D0=BB=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20?= =?UTF-8?q?=D1=83=D1=80=D0=BE=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- journals/models.py | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/journals/models.py b/journals/models.py index 152c1c9..d37b418 100755 --- a/journals/models.py +++ b/journals/models.py @@ -414,15 +414,6 @@ class CourseThemeJ(models.Model): p.save() return p - def check_lessons(self): - """ Проверка уроков темы на статус. Если сдано - сдана тема""" - for lessonj in LessonJ.objects.filter(parent=self, student=self.student): - if lessonj.success == False: - return False - - return True - - def save(self, *args, **kwargs): if not self.parent: self.parent = self.get_parent() @@ -437,8 +428,11 @@ class CourseThemeJ(models.Model): elif actual_lesson != self.actual_lesson.id: self.actual_lesson = Lesson.objects.get(id=self.make_actual_lesson()) - if self.check_lessons(): - self.success = True + if LessonJ.objects.filter(parent=self, student=self.student).exists(): + if LessonJ.objects.filter(parent=self, student=self.student, success=False).exists(): + self.success = False + else: + self.success = True if self.set_open: if Lesson.objects.filter(theme=self.material).order_by('sort').exists(): From 8865d431fbda0090cdb4d1589b3f956a8dd45b71 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Tue, 11 Jul 2017 17:07:48 +0300 Subject: [PATCH 05/26] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BD?= =?UTF-8?q?=D0=B5=20=D0=BD=D1=83=D0=B6=D0=BD=D0=BE=D0=B5=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BF=D0=BE=D0=BB=D0=B5=20=D0=B2=20?= =?UTF-8?q?=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- courses/migrations/0046_auto_20170711_1704.py | 38 +++++++++++++++++++ courses/models.py | 1 - 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 courses/migrations/0046_auto_20170711_1704.py diff --git a/courses/migrations/0046_auto_20170711_1704.py b/courses/migrations/0046_auto_20170711_1704.py new file mode 100644 index 0000000..7ad4302 --- /dev/null +++ b/courses/migrations/0046_auto_20170711_1704.py @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.3 on 2017-07-11 17:04 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('courses', '0045_merge'), + ] + + operations = [ + migrations.CreateModel( + name='Flow', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=255, verbose_name='Название')), + ('description', models.TextField(blank=True, default='', null=True, verbose_name='Описание')), + ('start_flow', models.DateTimeField(default=datetime.datetime.now, verbose_name='Дата начала потока')), + ('created', models.DateTimeField(default=datetime.datetime.now, editable=False, verbose_name='Создан')), + ('modified', models.DateTimeField(auto_now=True, verbose_name='Изменен')), + ('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='courses.Course', verbose_name='Курс')), + ], + options={ + 'ordering': ['-modified'], + 'verbose_name_plural': 'Потоки', + 'verbose_name': 'Поток', + }, + ), + migrations.RemoveField( + model_name='coursetheme', + name='empty_old', + ), + ] diff --git a/courses/models.py b/courses/models.py index 99ab1a9..880d5db 100755 --- a/courses/models.py +++ b/courses/models.py @@ -234,7 +234,6 @@ class CourseTheme(models.Model): empty = models.BooleanField(verbose_name=u'Ты не пройдешь!', help_text=u'Заблокировать дальнейшее прохождение курса. Из-за того, ' u'что курс не заполнен или что-то вроде того.', default=False) - empty_old = models.BooleanField(verbose_name=u'Для проверки галочки', default=False) def __unicode__(self): return u'%s:%s/%s' % (self.sort, self.course, self.title if self.title else self.get__type_display()) From 046b654bbf2cada82c1199abafafb0a6938dcbd3 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Tue, 11 Jul 2017 17:10:31 +0300 Subject: [PATCH 06/26] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D1=83=20=D0=B3=D0=B0=D0=BB?= =?UTF-8?q?=D0=BE=D1=87=D0=BA=D0=B8=20=D0=B2=20=D0=BA=D1=83=D1=80=D1=81?= =?UTF-8?q?=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../0047_remove_course_public_old.py | 19 +++++++++++++++++++ courses/models.py | 7 ------- 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 courses/migrations/0047_remove_course_public_old.py diff --git a/courses/migrations/0047_remove_course_public_old.py b/courses/migrations/0047_remove_course_public_old.py new file mode 100644 index 0000000..ae4455c --- /dev/null +++ b/courses/migrations/0047_remove_course_public_old.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.3 on 2017-07-11 17:09 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('courses', '0046_auto_20170711_1704'), + ] + + operations = [ + migrations.RemoveField( + model_name='course', + name='public_old', + ), + ] diff --git a/courses/models.py b/courses/models.py index 880d5db..fd25d8c 100755 --- a/courses/models.py +++ b/courses/models.py @@ -77,7 +77,6 @@ class Course(models.Model): direction = models.ForeignKey(MaterialDirection, verbose_name=u'Направление', null=True) mentors = models.ManyToManyField(User, verbose_name=u'Кураторы', null=True, blank=True, related_name='course_mentors') public = models.BooleanField(verbose_name=u'Опубликовать', default=False) - public_old = models.BooleanField(verbose_name=u'Старый статус', default=False) title = models.CharField(verbose_name=u"Заголовок", max_length=255) description = RedactorField(verbose_name=u'Описание', blank=True) image = models.ImageField(verbose_name=u'Изображение', upload_to='course', blank=True) @@ -206,12 +205,6 @@ class Course(models.Model): return '/courses/%s' % self.slug def save(self, *args, **kwargs): - # Костыль для поиска ошибки галочки - if self.public != self.public_old: - log = logging.getLogger('Course_public_change') - log.error('status change') - self.public_old = self.public - # if not self.slug: self.slug = '{0}'.format(translit(self.title)) super(Course, self).save(*args, **kwargs) From af41ee65633db100921b196533783f168149f9ac Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Wed, 12 Jul 2017 15:54:57 +0300 Subject: [PATCH 07/26] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=B3=D0=BE=20?= =?UTF-8?q?=D1=83=D1=80=D0=BE=D0=BA=D0=B0=20+=20=D1=81=D1=87=D0=B5=D1=82?= =?UTF-8?q?=D0=B0=20=D1=81=20=D0=BF=D0=BE=D1=82=D0=BE=D0=BA=D0=B0=D0=BC?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- courses/views.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/courses/views.py b/courses/views.py index 0d65036..54023b3 100755 --- a/courses/views.py +++ b/courses/views.py @@ -46,7 +46,10 @@ def course(request, slug): check_journal(journal) _map = CourseMap.objects.filter(course=course).order_by('sort').first() _j = _map.get_obj() - j = HomeworkJ.objects.get(material=_j, student=request.user) + if _map._type == 'H': + j = HomeworkJ.objects.get(material=_j, student=request.user) + if _map._type == 'L': + j = LessonJ.objects.get(material=_j, student=request.user) j.open_material() else: journal, created = TeacherJ.objects.get_or_create(course=course, student=user_fabric(request.user)) @@ -59,11 +62,12 @@ def course(request, slug): start_flow = None if request.user.is_authenticated() and not request.user.is_admin: try: - bill = Bill.objects.get( + bills = Bill.objects.filter( service__course=course, user=request.user, status='F') - if bill.flow: - flow = bill.flow.get_status() - start_flow = bill.flow.start_flow + for bill in bills: + if bill.flow: + flow = bill.flow.get_status() + start_flow = bill.flow.start_flow except Bill.DoesNotExist: pass From 24721e78d2a27a1ba974447e756c269a6204c9a1 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Wed, 12 Jul 2017 19:02:36 +0300 Subject: [PATCH 08/26] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B4=D0=BE=D0=B3=D0=BE=D0=B2=D0=BE=D1=80=20=D0=BE?= =?UTF-8?q?=D1=84=D0=B5=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lms/urls.py | 8 ++++++++ templates/activation.html | 1 + templates/no_auth_modals.html | 1 + 3 files changed, 10 insertions(+) diff --git a/lms/urls.py b/lms/urls.py index 85f4d58..c072573 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -5,9 +5,17 @@ from django.views.static import serve from lms import views from lms import settings from access.views import profile_view +from django.http import HttpResponse + +def show_oferta(request): + with open('oferta.pdf', 'rb') as pdf: + response = HttpResponse(pdf.read(), content_type='application/pdf') + response['Content-Disposition'] = 'filename=oferta.pdf' + return response urlpatterns = [ url(r'^$', views.index), + url(r'^oferta/', show_oferta), url(r'^test/$', views.test), url(r'^all_comments/$', views.all_comments), url(r'^reports/$', views.new_reports), diff --git a/templates/activation.html b/templates/activation.html index 9b564ce..0cd3bc5 100755 --- a/templates/activation.html +++ b/templates/activation.html @@ -301,6 +301,7 @@ + Регистрируясь, вы соглашаетесь с договором-оферты

{% now "Y" %} {{ NAME }} diff --git a/templates/no_auth_modals.html b/templates/no_auth_modals.html index 5d1c19b..aca2443 100755 --- a/templates/no_auth_modals.html +++ b/templates/no_auth_modals.html @@ -18,6 +18,7 @@

+ Регистрируясь, вы соглашаетесь с договором-оферты Я уже зарегистрирован From 9e68f87240526564b68fb85dfb7ff7fc7f0599fe Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Thu, 13 Jul 2017 15:31:23 +0300 Subject: [PATCH 09/26] =?UTF-8?q?=D0=9B=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D0=B3=D0=B0=D0=BB=D0=BE?= =?UTF-8?q?=D1=87=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/js/apis/access.js | 9 +++++++++ static/js/apis/activation.js | 31 +++++++++++++++++++------------ templates/activation.html | 5 ++++- templates/no_auth_modals.html | 5 ++++- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/static/js/apis/access.js b/static/js/apis/access.js index bbafc7d..f511241 100755 --- a/static/js/apis/access.js +++ b/static/js/apis/access.js @@ -95,9 +95,17 @@ function forgot(){ }) } function registry_go(){ + if ($('#checkBox').prop('checked') != true){ + console.log('NOT PASS') + $('#error_registration').html('Перед регистрацией ознакомтесь с договором-оферты'); + $('#error_registration').fadeIn('fast'); + + } else { + console.log('PASS') $('#error_registration').html(''); $('#error_registration').fadeIn('fast'); var theForm = $(document.forms['registration_form']).serialize(); + console.log(theForm) $.ajax({ type: 'POST', url: '/access/registration/', @@ -120,6 +128,7 @@ function registry_go(){ console.log('Возникла ошибка registry_go(): ' + str); } }); + } } function registry_go2(){ diff --git a/static/js/apis/activation.js b/static/js/apis/activation.js index 6edb105..cafe099 100755 --- a/static/js/apis/activation.js +++ b/static/js/apis/activation.js @@ -28,20 +28,27 @@ function sent_step(step){ return result; } function check_step(step){ - // Проверка данных этапа - > Отправка данных - var result = sent_step(step); - if (result[0]){ - if (step==3){ - final_button() - } - close_step(step); - enable_step(step+1); + if ($('#checkBox').prop('checked') != true){ + console.log('NOT PASS') + $('[name="error"]').html('Перед регистрацией ознакомтесь с договором-оферты'); + $('#error_registration').fadeIn('fast'); + } else { - visible_error(step, result[1]['inputs'], result[1]['message']) + // Проверка данных этапа - > Отправка данных + var result = sent_step(step); + if (result[0]){ + if (step==3){ + final_button() + } + close_step(step); + enable_step(step+1); + } else { + visible_error(step, result[1]['inputs'], result[1]['message']) + } + // Если все верно - > Переход на новый уровень + // Если нет - > Подсвечивание полей + //console.log('Получил запрос этапа '+step) } - // Если все верно - > Переход на новый уровень - // Если нет - > Подсвечивание полей - //console.log('Получил запрос этапа '+step) } function enable_step(step){ // Активация этапа diff --git a/templates/activation.html b/templates/activation.html index 0cd3bc5..b29db2d 100755 --- a/templates/activation.html +++ b/templates/activation.html @@ -301,7 +301,10 @@ - Регистрируясь, вы соглашаетесь с договором-оферты +

+ + Регистрируясь, вы соглашаетесь с договором-оферты +

{% now "Y" %} {{ NAME }} diff --git a/templates/no_auth_modals.html b/templates/no_auth_modals.html index aca2443..d6375b1 100755 --- a/templates/no_auth_modals.html +++ b/templates/no_auth_modals.html @@ -18,7 +18,10 @@

- Регистрируясь, вы соглашаетесь с договором-оферты +

+ + Регистрируясь, вы соглашаетесь с договором-оферты +
Я уже зарегистрирован From d8851e4199c53a1139f354e747a1ddd3e176cb1b Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Thu, 13 Jul 2017 19:03:07 +0300 Subject: [PATCH 10/26] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20=D0=BF=D1=83=D1=82=D1=8C=20=D0=B4=D0=BE=20=D1=84?= =?UTF-8?q?=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- storage/files_api.py | 2 +- storage/models.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/files_api.py b/storage/files_api.py index ce520a1..6a721cf 100755 --- a/storage/files_api.py +++ b/storage/files_api.py @@ -8,7 +8,7 @@ from lms.decors import api_decor from lms.tools import translit from storage.models import Storage, CroppedImage, FormatIndex -IMAGE_TMP = settings.MEDIA_ROOT + 'tmp/' +IMAGE_TMP = settings.MEDIA_ROOT + '/personal_files/' def save_gif(pil_img, path): diff --git a/storage/models.py b/storage/models.py index 839a8c4..6502b72 100755 --- a/storage/models.py +++ b/storage/models.py @@ -137,7 +137,7 @@ class CroppedImage(models.Model): verbose_name_plural = u'Картинки' -IMAGE_TMP = settings.MEDIA_ROOT + 'tmp/' +IMAGE_TMP = settings.MEDIA_ROOT + '/personal_files/' def save_resize_image(filename, pil_img, save_field, file_format): From 25d748810c9cd2b764454488f8bee4c6daa79638 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Mon, 17 Jul 2017 17:28:58 +0300 Subject: [PATCH 11/26] =?UTF-8?q?=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BE=D0=BC=D0=B0=D1=88=D0=B5=D0=BA=20?= =?UTF-8?q?=D0=B8=20=D1=83=D1=80=D0=BE=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- management/api.py | 90 ++++++++++++++++++++++++++++++++++++++++++++- management/urls.py | 8 +++- management/views.py | 5 +++ 3 files changed, 101 insertions(+), 2 deletions(-) diff --git a/management/api.py b/management/api.py index 9045c27..b043656 100755 --- a/management/api.py +++ b/management/api.py @@ -7,7 +7,8 @@ from lms.tools import out_date_format, condition_factory, user_fabric from finance.models import Price, Bill, ServiceRequest from management.letters import sent_new_bill, sent_clean_letter, send_burning_course_letter from management.models import News, Feedback, Comment - +from courses.models import Course, CourseTheme +from journals.models import TeacherJ, CourseThemeJ, LessonJ, HomeworkJ @api_decor(without_auth=False, need_keys=['title', 'content', 'to'], method='POST', check_request=True) def self_sent_letter(request, context): @@ -172,3 +173,90 @@ def burning_course(request): send_burning_course_letter(user, course) + +""" + Все функции снизу используются в подобии кабинета для отдела по работе с персоналом. + Если хочешь переписать - перепиши. +""" +@api_decor(without_auth=False) +def find_user(request, context): + try: + user = User.objects.get(id=request.GET['user']) + data = "%s | %s %s" % (user.id, user.name, user.fname) + except User.DoesNotExist: + data = '0' + except ValueError: + data = '0' + + return data + +@api_decor(without_auth=False) +def find_course(request, context): + try: + course = Course.objects.get(id=request.GET['course']) + data = course.title + except Course.DoesNotExist: + data = '0' + except ValueError: + data = '0' + + return data + +@api_decor(without_auth=False) +def open_lessons(request, context): + try: + user = User.objects.get(id=request.GET['user']) + course = Course.objects.get(id=request.GET['course']) + checkbox = True if request.GET.get('homes') == 'on' else False + themes = request.GET['themes'] + except Exception: + return '0' + + try: + teachj, status = TeacherJ.objects.get_or_create(student=user, course=course) + for t in CourseTheme.objects.filter(course=course): + for l in LessonJ.objects.filter(student=user, parent__material=t): + l.success = True + l.save() + if open_homes: + if HomeworkJ.objects.filter(student=user, parent__material=t).exists(): + homej = HomeworkJ.objects.get(student=user, parent__material=t) + homej.success = True + homej.save() + themej, status = CourseThemeJ.objects.get_or_create(student=user, material=t) + themej.success = True + themej.save() + teachj.reload_progress() + except Exception: + return '1' + + return '2' + +@api_decor(without_auth=False) +def open_homes(request, context): + try: + user = User.objects.get(id=request.GET['user']) + course = Course.objects.get(id=request.GET['course']) + except Exception: + return'0' + + try: + for t in CourseTheme.objects.filter(course=course): + if HomeworkJ.objects.filter(student=user, parent__material=t).exists(): + homej = HomeworkJ.objects.get(student=user, parent__material=t) + homej.success = True + homej.save() + except Exception: + return '1' + + return '2' + +@api_decor(without_auth=False) +def change_pass(request, context): + user = User.objects.get(id=request.GET['user']) + password = request.GET.get('pass') + + user.set_password(password) + user.save() + + return '2' diff --git a/management/urls.py b/management/urls.py index dcf5331..eb1b4bd 100755 --- a/management/urls.py +++ b/management/urls.py @@ -36,5 +36,11 @@ urlpatterns = [ url(r'reports_api/get_process_report/$', reports.get_process_report), url(r'reports_api/now_success_hw/$', reports.now_success_hw), url(r'reports_api/now_second_hw/$', reports.now_second_hw), - url(r'self_sent_letter/$', api.self_sent_letter) + url(r'self_sent_letter/$', api.self_sent_letter), + url(r'workcabinet/$', views.render_management_cabinet), + url(r'find_user/$', api.find_user), + url(r'find_course/$', api.find_course), + url(r'open_lessons/$', api.open_lessons), + url(r'open_homes/$', api.open_homes), + url(r'change_pass/$', api.change_pass), ] diff --git a/management/views.py b/management/views.py index 809b658..32ac4c5 100755 --- a/management/views.py +++ b/management/views.py @@ -129,3 +129,8 @@ def progress_report(request): 'journals': []} map.append(c) return {'map': map, 'get_now_success_hw': get_now_success_hw(), 'get_second_success_hw': get_second_success_hw()} + + +@response_decor(template='cabinet.html') +def render_management_cabinet(request): + return {} \ No newline at end of file From 13b94cc6277f076e56344a69866f11f07ed60c96 Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Wed, 19 Jul 2017 18:01:11 +0300 Subject: [PATCH 12/26] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=83=20=D1=81=20=D1=82?= =?UTF-8?q?=D0=B5=D0=BC=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- management/api.py | 37 +++++-- templates/cabinet.html | 222 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 252 insertions(+), 7 deletions(-) create mode 100644 templates/cabinet.html diff --git a/management/api.py b/management/api.py index b043656..1a5cf55 100755 --- a/management/api.py +++ b/management/api.py @@ -208,13 +208,21 @@ def open_lessons(request, context): user = User.objects.get(id=request.GET['user']) course = Course.objects.get(id=request.GET['course']) checkbox = True if request.GET.get('homes') == 'on' else False - themes = request.GET['themes'] + themes = request.GET['themes'].split(' ') + themes.remove('') + for t in themes: + t = int(t) + except Exception: return '0' try: teachj, status = TeacherJ.objects.get_or_create(student=user, course=course) - for t in CourseTheme.objects.filter(course=course): + if themes: + course_themes = CourseTheme.objects.filter(course=course, sort__in=themes) + else: + course_themes = CourseTheme.objects.filter(course=course) + for t in course_themes: for l in LessonJ.objects.filter(student=user, parent__material=t): l.success = True l.save() @@ -237,11 +245,20 @@ def open_homes(request, context): try: user = User.objects.get(id=request.GET['user']) course = Course.objects.get(id=request.GET['course']) + themes = request.GET['themes'].split(' ') + themes.remove('') + for t in themes: + t = int(t) + except Exception: return'0' try: - for t in CourseTheme.objects.filter(course=course): + if themes: + course_themes = CourseTheme.objects.filter(course=course, sort__in=themes) + else: + course_themes = CourseTheme.objects.filter(course=course) + for t in course_themes: if HomeworkJ.objects.filter(student=user, parent__material=t).exists(): homej = HomeworkJ.objects.get(student=user, parent__material=t) homej.success = True @@ -253,10 +270,16 @@ def open_homes(request, context): @api_decor(without_auth=False) def change_pass(request, context): - user = User.objects.get(id=request.GET['user']) - password = request.GET.get('pass') + try: + user = User.objects.get(id=request.GET['user']) + password = request.GET.get('pass') + except Exception: + return '0' - user.set_password(password) - user.save() + try: + user.set_password(password) + user.save() + except Exception: + return '1' return '2' diff --git a/templates/cabinet.html b/templates/cabinet.html new file mode 100644 index 0000000..f0f2dc2 --- /dev/null +++ b/templates/cabinet.html @@ -0,0 +1,222 @@ +{% extends 'base_index.html' %} +{% block title %}Рабочий кабинет{% endblock %} +{% block content %} + + +
+
+
Открыть уроки
+
+
+ Введите id пользователя + +
+
+
+ Введите id курса + +
+
+
+ Открыть домашки + +
+
+ Отдельные темы + +
+
+ +
+
+
+
Открыть домашки
+
+
+ Введите id пользователя + +
+
+
+ Введите id курса + +
+
+
+ Отдельные темы + +
+
+ +
+
+ +
+
+
+
Поменять пароль
+
+
+ Введите id пользователя + +
+
+
+ Введите новый пароль + +
+
+ +
+
+
+ + + +{% endblock %} From b888708a51b03859c1bcc503ebb0bcec166db843 Mon Sep 17 00:00:00 2001 From: Zolotarev Alexander Date: Thu, 20 Jul 2017 11:58:04 +0000 Subject: [PATCH 13/26] Update .gitlab-ci.yml --- .gitlab-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e858c2..3664577 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ # This file is a template, and might need editing before it works on your project. # Official docker image. -#image: docker:latest -#services: -# - docker:dind +image: docker:latest +services: + - docker:dind variables: CHANNEL: "skillbox" SERVER_URL: "lms.test.spicycms.com" From 4e71cb108f3f2c0db0bd7c85ed3303158fa0a5fe Mon Sep 17 00:00:00 2001 From: Mikhail Bortnikov Date: Thu, 20 Jul 2017 18:30:19 +0300 Subject: [PATCH 14/26] =?UTF-8?q?=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D1=82?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=B8=D0=BF=D0=BB=D0=BE=D0=BC=D0=BE=D0=B2?= =?UTF-8?q?=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitlab-ci.yml | 6 +++--- management/urls.py | 3 +++ management/views.py | 42 ++++++++++++++++++++++++++++++++++++++++-- templates/cabinet.html | 41 +++++++++++++++++++++++++++++++++++------ 4 files changed, 81 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7e858c2..3664577 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ # This file is a template, and might need editing before it works on your project. # Official docker image. -#image: docker:latest -#services: -# - docker:dind +image: docker:latest +services: + - docker:dind variables: CHANNEL: "skillbox" SERVER_URL: "lms.test.spicycms.com" diff --git a/management/urls.py b/management/urls.py index eb1b4bd..3a467c5 100755 --- a/management/urls.py +++ b/management/urls.py @@ -38,9 +38,12 @@ urlpatterns = [ url(r'reports_api/now_second_hw/$', reports.now_second_hw), url(r'self_sent_letter/$', api.self_sent_letter), url(r'workcabinet/$', views.render_management_cabinet), + url(r'diplomscabinet/$', views.render_diplom_cabinet), url(r'find_user/$', api.find_user), url(r'find_course/$', api.find_course), url(r'open_lessons/$', api.open_lessons), url(r'open_homes/$', api.open_homes), url(r'change_pass/$', api.change_pass), + url(r'open_diploms/$', api.open_diploms), + ] diff --git a/management/views.py b/management/views.py index 32ac4c5..5afab30 100755 --- a/management/views.py +++ b/management/views.py @@ -9,7 +9,8 @@ from finance.models import Bill, ServiceRequest, Price from management.models import News, Faq, FaqTitle from courses.models import Course, CourseTheme from management.reports import get_now_success_hw, get_second_success_hw - +from access.models import User +from finance.models import Bill, Price @response_decor(template='super_bill.html') def super_bill(request): @@ -133,4 +134,41 @@ def progress_report(request): @response_decor(template='cabinet.html') def render_management_cabinet(request): - return {} \ No newline at end of file + return {} + + +from .forms import UploadFileForm + +@response_decor(template='diplomscab.html') +def render_diplom_cabinet(request): + context = {} + if request.method == 'POST': + + form = UploadFileForm(request.POST, request.FILES) + print(form) + for l in request.FILES['file'].readlines(): + try: + user = User.objects.get(email=l.rstrip().lower()) + except User.DoesNotExist: + context['error'] = 'Плохая почта %s' % l + + try: + data = form.cleaned_data + id_ = int(data['service_id']) + service = Price.objects.get(id=id_) + bill = Bill.objects.create(user=user, status='F', service=service) + bill.save() + except Exception: + context['error'] = 'Не получилось создать счет для %s' % l + + + context['form'] = form + print(context) + return context + else: + form = UploadFileForm() + + context['form'] = form + print(context) + return context + diff --git a/templates/cabinet.html b/templates/cabinet.html index f0f2dc2..166568d 100644 --- a/templates/cabinet.html +++ b/templates/cabinet.html @@ -2,7 +2,7 @@ {% block title %}Рабочий кабинет{% endblock %} {% block content %}
@@ -110,6 +119,11 @@
+
+ {% for c in courses %} +
{{ c.id }}: {{ c.title }}
+ {% endfor %} +