You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.7 KiB
60 lines
1.7 KiB
# coding=utf-8
|
|
import os
|
|
|
|
import datetime
|
|
import django
|
|
import sys
|
|
sys.path.append("/var/www/projects/lms/")
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.settings")
|
|
django.setup()
|
|
|
|
from courses.models import CourseMap
|
|
from finance.models import Price, Bill
|
|
from access.models import User
|
|
__point = CourseMap.objects.get(token='1#6')
|
|
course = __point.course
|
|
prices = Price.objects.filter(included=__point).values_list('included__token', flat=True)
|
|
user = User.objects.get(email='t@lms.ru')
|
|
bill = Bill.objects.filter(service__included__token__in=prices, user=user, status='F')
|
|
for b in bill:
|
|
if b:
|
|
if b.service.by_time:
|
|
if b.finish_date + datetime.timedelta(days=b.service.by_time) > datetime.datetime.now():
|
|
print '1 True'
|
|
else:
|
|
print '1 False'
|
|
else:
|
|
print '1 True'
|
|
|
|
m_type = ['']
|
|
theme_type = 'B'
|
|
if theme_type == 'B' or theme_type == 'M':
|
|
m_type = ['B', 'E', 'P']
|
|
|
|
elif theme_type == 'E':
|
|
m_type = ['E', 'P']
|
|
|
|
elif theme_type == 'P':
|
|
m_type = ['P']
|
|
|
|
if m_type:
|
|
bill = Bill.objects.filter(service__included=None, service__course=course, user=user, status='F',
|
|
service__m_type__in=m_type)
|
|
if bill.exists():
|
|
check = []
|
|
for b in bill:
|
|
if b.service.by_time:
|
|
check.append(b)
|
|
if not check:
|
|
print '2 True'
|
|
|
|
else:
|
|
result = False
|
|
for b in check:
|
|
if b.finish_date + datetime.timedelta(days=b.service.by_time) > datetime.datetime.now():
|
|
result = True
|
|
if result:
|
|
print '3 True'
|
|
else:
|
|
print '4 False'
|
|
print '5 False'
|
|
|