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.
 
 
 
 
 
 

23 lines
677 B

# coding=utf-8
import os
from django.core.files import File
import django
import sys
from django.db.models import Q
sys.path.append("/var/www/projects/lms/")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.settings")
django.setup()
from journals.models import DiplomaJ
for tm in DiplomaJ.objects.filter(Q(in_image=None)|Q(out_image=None)):
if not tm.out_image or not tm.in_image:
_in, _out = tm.draw_key(*tm.draw_name(*tm.draw_date()))
if _in:
_in = open(_in)
tm.in_image.save(File(_in).name, File(_in), save=True)
if _out:
_out = open(_out)
tm.out_image.save(File(_out).name, File(_out), save=True)