-
Notifications
You must be signed in to change notification settings - Fork 1
/
import.py
41 lines (29 loc) · 1.4 KB
/
import.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
##!/usr/bin/env python
import os, sys, django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "lw.core.settings.dev")
django.setup()
from lw.home.models import HomePage
from lw.translations.models.book_page import BookPage
from lw.translations.models.translation_index_page import TranslationIndexPage
from services.data_migrations.importers.book.book_importer import BookImporter
from services.data_migrations.importers.translation_page.translation_page_importer import TranslationPageImporter
from services.data_migrations.importers.users.users_importer import UsersImporter
from django.contrib.contenttypes.models import ContentType
from wagtail.core.models import Page
def patched_save(self, *args, **kwargs):
self.full_clean()
self.set_url_path(self.get_parent())
result = super(Page, self).save(*args, **kwargs)
return result
Page.save = patched_save
home_page = HomePage.objects.live()[0]
index_page_type = ContentType.objects.get(app_label='translations', model='TranslationIndexPage')
index_page = TranslationIndexPage(id=253, intro='', title='Переводы', slug='w', content_type=index_page_type)
home_page.add_child(instance=index_page)
index_page.save_revision().publish()
json_path = '/work/books_lw_dump.json'
BookImporter(json_path).run()
json_path = '/work/translations_lw_dump.json'
TranslationPageImporter(json_path).run()
csv_path = '/work/users.csv'
UsersImporter(csv_path).run()