|
|
|
|
@ -1,3 +1,4 @@ |
|
|
|
|
import csv |
|
|
|
|
import datetime |
|
|
|
|
import random |
|
|
|
|
import string |
|
|
|
|
@ -7,6 +8,7 @@ from django.contrib.auth import get_user_model |
|
|
|
|
from django.core.exceptions import ValidationError |
|
|
|
|
from django.core.mail import send_mail |
|
|
|
|
from django.db.models import Q |
|
|
|
|
from django.http import HttpResponse |
|
|
|
|
from django.shortcuts import redirect |
|
|
|
|
from rest_framework.permissions import IsAuthenticated |
|
|
|
|
from rest_framework.renderers import JSONRenderer |
|
|
|
|
@ -340,6 +342,34 @@ class CourseProgressUserView(APIView): |
|
|
|
|
return Response(status=403) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UploadCourseProgressUserView(APIView): |
|
|
|
|
renderer_classes = (JSONRenderer,) |
|
|
|
|
|
|
|
|
|
@staticmethod |
|
|
|
|
def get(request, token): |
|
|
|
|
if request.user.is_authenticated() and request.user.is_staff: |
|
|
|
|
try: |
|
|
|
|
response = HttpResponse(content_type='text/csv') |
|
|
|
|
response['Content-Disposition'] = 'attachment; filename="%s.csv"' % token |
|
|
|
|
sorted_token_list = CourseProgressApi.get_topic_lesson(token) |
|
|
|
|
writer = csv.writer(response) |
|
|
|
|
writer.writerow(['Имя', 'Почта', 'Последняя тема', 'Последний урок']) |
|
|
|
|
|
|
|
|
|
for p in Progress.objects.filter(course_token=token): |
|
|
|
|
progress = ProgressAnalyticSerializer(p).data |
|
|
|
|
progress['progress_course'] = p.progress_status(sorted_token_list) |
|
|
|
|
writer.writerow([ |
|
|
|
|
progress['name'], |
|
|
|
|
progress['email'], |
|
|
|
|
progress['progress_course'] and progress['progress_course'][0], |
|
|
|
|
progress['progress_course'] and progress['progress_course'][1], |
|
|
|
|
]) |
|
|
|
|
return response |
|
|
|
|
except ValidationError: |
|
|
|
|
return Response("Bad request", status=400) |
|
|
|
|
return Response(status=403) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MinUserView(APIView): |
|
|
|
|
renderer_classes = (JSONRenderer,) |
|
|
|
|
|
|
|
|
|
|