def small_statistics(): doctor = doc_operations.doctor_by_request(request) doctors = all_doctors() if not doctor else [doctor] data = [] today = datetime.datetime.strptime(_today_date(), ("%d.%m.%Y")) monthrange = calendar.monthrange(today.year, today.month)[1] #holters count for every day for doc in doctors: holters_count = get_doctor_holters_count(doc, DOCTORS, int(_today_date().split('.')[1])) for i in range(monthrange): if not i + 1 in holters_count: holters_count[i + 1] = -1 # sum for all month (raw-sum): holters_sum = 0 for hc in holters_count: if holters_count[hc] != -1: holters_sum += holters_count[hc] holters_count['sum'] = holters_sum data.append([doc.name, holters_count]) #every day sum(column sum) if len(doctors) > 1: ed_sum = {} for day in holters_count: day_counts = [d[1][day] for d in data if d[1][day] != -1] ed_sum[day] = sum(day_counts) data.append(['Сумма за день', ed_sum]) return render_template('small_statistics.html', data=data, monthrange=monthrange)
def schedule(): doctor = doc_operations.doctor_by_request(request) if request.method == 'POST': doctor.unworking_dates = [date for date in request.form] print doctor.unworking_dates doctor.save_doctor() flash(u"Расписание успешно сохранено", 'normal') return redirect(url_for('first')) monthes = get_monthes(doctor) return render_template('calendar.html', monthes=monthes, doctor=doctor)
def doctor_action(action): ''' Deletes doctor or creates new ''' if action == 'delete': doctor = doc_operations.doctor_by_request(request) if not doctor: flash("Неправильное имя доктора", 'error') return redirect(url_for('doctor_control')) doc_operations.delete_doctor(doctor) flash('Доктор успешно удален', 'normal') return redirect(url_for('doctor_control')) if action == 'create': return redirect(url_for('doctor'))
def doctor(): ''' changes doctors parameters or creates new doctor ''' doctor = doc_operations.doctor_by_request(request) if request.method == 'POST': if not doctor: try: doctor = doc_operations.create_doctor(request.form) flash(u"Доктор успешно создан", 'normal') return redirect(url_for('first')) except: flash(u'Неправильно заполнены поля', 'error') return render_template('doctor.html', doctor=doctor) else: try: doc_operations.init_doctors_parameters(doctor, request.form) flash(u"Настройки успешно сохранены", 'normal') return redirect(url_for('doctor_control')) except: flash(u'Неправильно заполнен общий лимит или аб-лимит', 'error') return redirect(url_for('doctor') + '?name=' + doctor.engname) return render_template('doctor.html', doctor=doctor)