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.4 KiB
60 lines
1.4 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 journals.models import HomeworkTry, HomeworkJ
|
|
|
|
|
|
def good(tr):
|
|
if not tr.success:
|
|
tr.success = True
|
|
if not tr.f_date:
|
|
tr.f_date = tr.date
|
|
tr.save()
|
|
|
|
|
|
def fail(tr):
|
|
if tr.success:
|
|
tr.success = False
|
|
if not tr.f_date:
|
|
if tr.date:
|
|
tr.f_date = tr.date
|
|
else:
|
|
tr.f_date = datetime.datetime.now()
|
|
tr.save()
|
|
|
|
|
|
def empty(tr):
|
|
tr.delete()
|
|
|
|
for i in HomeworkTry.objects.all():
|
|
if i.comments.all():
|
|
for comment in i.comments.all():
|
|
if comment.owner.in_role == 'T':
|
|
if u'Задача принята!' in comment.text:
|
|
good(i)
|
|
break
|
|
elif u'Отправлено на доработку!' in comment.text:
|
|
fail(i)
|
|
break
|
|
else:
|
|
print comment.text
|
|
result = raw_input(u'Сдано? Y/N: ')
|
|
if result in ['y', 'Y', 'н', 'Н']:
|
|
good(i)
|
|
elif result in ['n', 'N', 'т', 'Т']:
|
|
fail(i)
|
|
else:
|
|
empty(i)
|
|
|
|
#for i in HomeworkJ.objects.all():
|
|
# if i.date and i.f_date and not i.success:
|
|
# i.success = True
|
|
# i.save()
|
|
|