открытие дипломов файлом

remotes/origin/pm_task_31703
Mikhail Bortnikov 9 years ago
parent 13b94cc627
commit 4e71cb108f
  1. 6
      .gitlab-ci.yml
  2. 3
      management/urls.py
  3. 42
      management/views.py
  4. 41
      templates/cabinet.html

@ -1,8 +1,8 @@
# This file is a template, and might need editing before it works on your project. # This file is a template, and might need editing before it works on your project.
# Official docker image. # Official docker image.
#image: docker:latest image: docker:latest
#services: services:
# - docker:dind - docker:dind
variables: variables:
CHANNEL: "skillbox" CHANNEL: "skillbox"
SERVER_URL: "lms.test.spicycms.com" SERVER_URL: "lms.test.spicycms.com"

@ -38,9 +38,12 @@ urlpatterns = [
url(r'reports_api/now_second_hw/$', reports.now_second_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'workcabinet/$', views.render_management_cabinet),
url(r'diplomscabinet/$', views.render_diplom_cabinet),
url(r'find_user/$', api.find_user), url(r'find_user/$', api.find_user),
url(r'find_course/$', api.find_course), url(r'find_course/$', api.find_course),
url(r'open_lessons/$', api.open_lessons), url(r'open_lessons/$', api.open_lessons),
url(r'open_homes/$', api.open_homes), url(r'open_homes/$', api.open_homes),
url(r'change_pass/$', api.change_pass), url(r'change_pass/$', api.change_pass),
url(r'open_diploms/$', api.open_diploms),
] ]

@ -9,7 +9,8 @@ from finance.models import Bill, ServiceRequest, Price
from management.models import News, Faq, FaqTitle from management.models import News, Faq, FaqTitle
from courses.models import Course, CourseTheme from courses.models import Course, CourseTheme
from management.reports import get_now_success_hw, get_second_success_hw 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') @response_decor(template='super_bill.html')
def super_bill(request): def super_bill(request):
@ -133,4 +134,41 @@ def progress_report(request):
@response_decor(template='cabinet.html') @response_decor(template='cabinet.html')
def render_management_cabinet(request): def render_management_cabinet(request):
return {} 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

@ -2,7 +2,7 @@
{% block title %}Рабочий кабинет{% endblock %} {% block title %}Рабочий кабинет{% endblock %}
{% block content %} {% block content %}
<style type="text/css"> <style type="text/css">
.themes, .homes, .password-change{ .themes, .homes, .password-change, .open-diplom{
width: 600px; width: 600px;
height: auto; height: auto;
margin-left: 100px; margin-left: 100px;
@ -29,6 +29,11 @@
input{ input{
float: right; float: right;
} }
textarea{
float: right;
width: 200px;
height: 300px;
}
.submit{ .submit{
float: none; float: none;
margin-left: 190px; margin-left: 190px;
@ -47,12 +52,12 @@
<form id='lessons'> <form id='lessons'>
<div class="input-block"> <div class="input-block">
<span>Введите id пользователя</span> <span>Введите id пользователя</span>
<input type="text" class="id-user" name='user'> <input type="text" class="id-user" name='user' required>
<div id='output-user'></div> <div id='output-user'></div>
</div> </div>
<div class="input-block"> <div class="input-block">
<span>Введите id курса</span> <span>Введите id курса</span>
<input type="text" class="id-course" name="course"> <input type="text" class="id-course" name="course" required>
<div class="output-course"></div> <div class="output-course"></div>
</div> </div>
<div class="input-block"> <div class="input-block">
@ -72,12 +77,12 @@
<form id='homes'> <form id='homes'>
<div class="input-block"> <div class="input-block">
<span>Введите id пользователя</span> <span>Введите id пользователя</span>
<input type="text" class="id-user" name="user"> <input type="text" class="id-user" name="user" required>
<div id='output-user'></div> <div id='output-user'></div>
</div> </div>
<div class="input-block"> <div class="input-block">
<span>Введите id курса</span> <span>Введите id курса</span>
<input type="text" class="id-course" name="course"> <input type="text" class="id-course" name="course" required>
<div class="output-course"></div> <div class="output-course"></div>
</div> </div>
<div class="input-block"> <div class="input-block">
@ -89,7 +94,6 @@
</form> </form>
</div> </div>
<div class="open-diplom"></div>
<div class="change-diplom"></div> <div class="change-diplom"></div>
<div class="password-change"> <div class="password-change">
<div class="name">Поменять пароль</div> <div class="name">Поменять пароль</div>
@ -107,6 +111,17 @@
<input type="submit" name="" class='submit'> <input type="submit" name="" class='submit'>
</form> </form>
</div> </div>
<div class="open-diplom">
<div class="name">Массовое открытие дипломов</div>
<form method="POST" enctype="multipart/form-data" action='http://127.0.0.1:8000/management/open_diploms'>
{% csrf_token %}
<div class="input-block" style="height: 310px;">
<span>Много почт чуваков</span>
<input type="file" name="file">
<button type="submit">Upload</button>
</div>
</form>
</div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
@ -217,6 +232,20 @@
} }
}) })
}) })
// $('#diploms').on('submit', function(event){
// event.preventDefault()
// data = $(this).serialize()
// console.log(data)
// $.ajax({
// url: 'open_diploms/',
// type: 'POST',
// data: data,
// success: function(data){
// console.log('ser')
// }
// })
// })
</script> </script>
{% endblock %} {% endblock %}

Loading…
Cancel
Save