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.
 
 
 
 
 
 

31 lines
860 B

# coding=utf-8
import os
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
for ht in HomeworkTry.objects.all():
c = ht.comments.all().order_by('date').first()
if ht.date != c.date:
ht.date = c.date
ht.save()
for hw in HomeworkJ.objects.all():
if HomeworkTry.objects.filter(parent=hw).exists():
f = HomeworkTry.objects.filter(parent=hw).order_by('date').first()
l = HomeworkTry.objects.filter(parent=hw).order_by('date').last()
s = False
if hw.date and hw.date != f.date:
hw.date = f.date
s = True
if hw.f_date and hw.f_date != l.f_date:
hw.f_date = l.f_date
s = True
if s: hw.save()