Exemple #1
0
def create_test_recipe_page(title='Test Recipe page', path='1111', depth=0, theme=None):
    if not theme:
        theme = create_test_theme()
    if PHEImage.objects.count() == 0:
        create_default_test_image(id=1)

    site = Site.objects.first()
    if not site.site_name:
        site.site_name = 'oneyoutest'
        site.save()

    site_settings = SiteSettings.objects.filter(site_id=site.id).first()
    if not site_settings:
        site_settings = SiteSettings(site_id=site.id)
    site_settings.menu = create_test_menu()
    site_settings.save()

    root_page = site.root_page

    page = RecipePage(title=title, path=path, depth=depth, theme=theme)
    root_page.add_child(instance=page)

    page.save_revision().publish()

    return page
Exemple #2
0
def create_test_page(model, parent=None, title='Test page', path='1111', depth=0, theme=None):
    if not theme:
        theme = create_test_theme()
    if PHEImage.objects.count() == 0:
        create_default_test_image(id=1)

    site = Site.objects.first()
    if not site.site_name:
        site.site_name = 'test'
        site.save()

    site_settings = SiteSettings.objects.filter(site_id=site.id).first()
    if not site_settings:
        site_settings = SiteSettings(site_id=site.id)
    site_settings.menu = create_test_menu()
    site_settings.save()

    if parent is None:
        parent = site.root_page

    page = model(title=title, path=path, depth=depth, page_theme=theme, live=True)
    parent.add_child(instance=page)
    page.save_revision().publish()

    return page