|
|
|
|
@ -15,7 +15,7 @@ django.setup() |
|
|
|
|
|
|
|
|
|
from storage.models import Comment, File |
|
|
|
|
from courses.models import Lesson |
|
|
|
|
from access.models.progress import ProgressLesson |
|
|
|
|
from access.models.progress import ProgressLesson, Progress |
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
csv.field_size_limit(500 * 1024 * 1024) |
|
|
|
|
@ -31,28 +31,49 @@ if __name__ == '__main__': |
|
|
|
|
lesson_token=l.token, |
|
|
|
|
progress__user__email=row['student'], |
|
|
|
|
) |
|
|
|
|
files = [File.objects.get(id=file) for file in row['files'].split("[")[1].split("]")[0].split(',') |
|
|
|
|
if not file == ''] |
|
|
|
|
|
|
|
|
|
comment = Comment.objects.create( |
|
|
|
|
text=row['text'], |
|
|
|
|
email=row['owner__email'], |
|
|
|
|
except ProgressLesson.DoesNotExist: |
|
|
|
|
try: |
|
|
|
|
pr = Progress.objects.create( |
|
|
|
|
course_token=l.topic.course.token, |
|
|
|
|
user=get_user_model().objects.get(email=row['student']), |
|
|
|
|
teacher=get_user_model().objects.get(email=row['teacher']), |
|
|
|
|
) |
|
|
|
|
except IntegrityError: |
|
|
|
|
pr = Progress.objects.get( |
|
|
|
|
course_token=l.topic.course.token, |
|
|
|
|
user=get_user_model().objects.get(email=row['student']), |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
p = ProgressLesson.objects.create( |
|
|
|
|
lesson_token=l.token, |
|
|
|
|
teacher=get_user_model().objects.get(email=row['teacher']), |
|
|
|
|
progress=pr, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
if row['status'] == 'Одобренно': |
|
|
|
|
p.status = ProgressLesson.STATUSES.done |
|
|
|
|
p.date = row['date'] |
|
|
|
|
elif row['status'] == 'Отклонено': |
|
|
|
|
p.status = ProgressLesson.STATUSES.fail |
|
|
|
|
else: |
|
|
|
|
p.status = ProgressLesson.STATUSES.wait |
|
|
|
|
files = [File.objects.get(id=file) for file in row['files'].split("[")[1].split("]")[0].split(',') |
|
|
|
|
if not file == ''] |
|
|
|
|
|
|
|
|
|
p.save() |
|
|
|
|
comment = Comment.objects.create( |
|
|
|
|
text=row['text'], |
|
|
|
|
email=row['owner__email'], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
[comment.files.add(file) for file in files] |
|
|
|
|
comment.date = row['date'] |
|
|
|
|
comment.save() |
|
|
|
|
if row['status'] == 'Одобренно': |
|
|
|
|
p.status = ProgressLesson.STATUSES.done |
|
|
|
|
p.date = row['date'] |
|
|
|
|
|
|
|
|
|
p.comment_tokens.append(comment.token) |
|
|
|
|
except ProgressLesson.DoesNotExist: |
|
|
|
|
pass |
|
|
|
|
elif row['status'] == 'Отклонено': |
|
|
|
|
p.status = ProgressLesson.STATUSES.fail |
|
|
|
|
|
|
|
|
|
p.comment_tokens.append(comment.token) |
|
|
|
|
p.save() |
|
|
|
|
|
|
|
|
|
[comment.files.add(file) for file in files] |
|
|
|
|
comment.date = row['date'] |
|
|
|
|
comment.save() |
|
|
|
|
|
|
|
|
|
for i in ProgressLesson.objects.filter(comment_tokens__isnull=False): |
|
|
|
|
if len(i.comment_tokens) % 2 == 1: |
|
|
|
|
i.status = ProgressLesson.STATUSES.wait |
|
|
|
|
i.save() |
|
|
|
|
|