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.
 
 
 
 
 
 

24 lines
723 B

# coding=utf-8
import os
import django
import sys
sys.path.append("/var/www/projects/codemy/")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.settings")
django.setup()
# Переназначение перподавателя
from journals.models import TeacherJ, HomeworkJ, HomeworkTry
from access.models import User
old = User.objects.get(id=1324)
for tj in TeacherJ.objects.filter(teacher=old).exclude(student=None):
if not (tj.student.is_admin and tj.student.is_staff):
print(tj.id)
tj.teacher = None
tj.save()
ht = tj.get_current_ht()
hw = tj.get_last_hw()
hw.teacher=None
hw.save()
ht.teacher=None
ht.save()
print(ht.teacher)