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.
 
 
 
 
 
 

63 lines
2.2 KiB

м# coding=utf-8
import os
import django
from post_fixtures import main
from _utils.clear_db import main as clear_main
print '==== Загружаю DJANGO'
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lms.settings")
django.setup()
from storage.models import Storage, CroppedImage
print '==== Загрузил DJANGO'
# == Загрузка данных
print '==== Обрабатываю модели'
# Загрузка материалов
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
print BASE_DIR
APPS = ('storage', 'access', 'management', 'courses', 'finance', )
#courses_models = ('courses.course', 'courses.coursetheme', 'courses.lesson', 'courses.homework', 'courses.exam')
#journal_models = ('courses.teacherj', 'courses.lessonj', 'courses.homeworkj', 'courses.examj')
#finance_models = ("courses.bill", 'courses.price', 'courses.servicerequest')
clear_main()
os.system('python merge_fixtures.py')
# Загрузить фикстуры не изменившихся моделей
print '==== Заливаю модели'
for app in APPS:
print app.upper()
os.system('python manage.py loaddata fixtures/{0}.json'.format(app))
print '==== Заливаю MEDIA'
os.system('tar xfz media.tar.gz')
print '==== Проверка заливки'
# Проверить существование файлов из storage
errors = []
for store in Storage.objects.all():
# Проверить original, f_format.icon
obj = (store.original.path if store.original else '',
store.f_format.icon.path if store.f_format and store.f_format.icon else '')
for i in obj:
if i and not os.path.exists(i):
errors.append(i)
#print 'Ошибки файлов: {0}'.format(len(errors))
for store in CroppedImage.objects.all():
# croppedimage.big, croppedimage.middle, croppedimage.small
obj = (store.big.path if store.big else '',
store.middle.path if store.middle else '',
store.small.path if store.small else '')
for i in obj:
if i and not os.path.exists(i):
errors.append(i)
#print 'Ошибки файлов: {0}'.format(len(errors))
print 'Ошибки файлов: {0}'.format(len(errors))
#print errors
main()