cms/apps/pages/utils.py
def overlay_page_obj(original_page, overlay_page, commit=False):
    '''
        A function that takes a page and overlay the fields and linked objects from a different page.
    '''
    from .admin import page_admin
    original_content = original_page.content
    page_fields_exclude = ['pk', 'id', 'version_for', 'left', 'right']
    content_fields_exclude = ['pk', 'id', 'page']

    checked_models = []
    related_fields = []

    def do_model_inline(cls):
        checked_models.append(cls.model)
        fk = _get_foreign_key(Page, cls.model, fk_name=cls.fk_name)

        return fk.related_query_name()

    for _, admin_cls in page_admin.content_inlines:

        if admin_cls.model in checked_models:
            continue

        related_fields.append(do_model_inline(admin_cls))

    # Overlay page fields
    overlay_obj(original_page, overlay_page, page_fields_exclude, related_fields, commit=commit)

    # Overlay page content fields
    overlay_obj(original_content, overlay_page.content, content_fields_exclude, [], commit=commit)

    return original_page

        A function that takes a page and overlay the fields and linked objects from a different page.
    
A function that takes a page and overlay the fields and linked objects from a different page.
A function that takes a page and overlay the fields and linked objects from a different page .
def overlay_page_obj(original_page, overlay_page, commit=False):
    from .admin import page_admin
    original_content = original_page.content
    page_fields_exclude = ['pk', 'id', 'version_for', 'left', 'right']
    content_fields_exclude = ['pk', 'id', 'page']
    checked_models = []
    related_fields = []
    def do_model_inline(cls):
        checked_models.append(cls.model)
        fk = _get_foreign_key(Page, cls.model, fk_name=cls.fk_name)
        return fk.related_query_name()
    for _, admin_cls in page_admin.content_inlines:
        if admin_cls.model in checked_models:
            continue
        related_fields.append(do_model_inline(admin_cls))
    overlay_obj(original_page, overlay_page, page_fields_exclude, related_fields, commit=commit)
    overlay_obj(original_content, overlay_page.content, content_fields_exclude, [], commit=commit)
    return original_page
def overlay_page_obj ( original_page , overlay_page , commit = False ) : from . admin import page_admin original_content = original_page . content page_fields_exclude = [ 'pk' , 'id' , 'version_for' , 'left' , 'right' ] content_fields_exclude = [ 'pk' , 'id' , 'page' ] checked_models = [ ] related_fields = [ ] def do_model_inline ( cls ) : checked_models . append ( cls . model ) fk = _get_foreign_key ( Page , cls . model , fk_name = cls . fk_name ) return fk . related_query_name ( ) for _ , admin_cls in page_admin . content_inlines : if admin_cls . model in checked_models : continue related_fields . append ( do_model_inline ( admin_cls ) ) overlay_obj ( original_page , overlay_page , page_fields_exclude , related_fields , commit = commit ) overlay_obj ( original_content , overlay_page . content , content_fields_exclude , [ ] , commit = commit ) return original_page
A function that takes a page and overlay the fields and linked objects from a different page.
A function that takes a page and overlay the fields and linked objects from a different page .
'''
        A function that takes a page and overlay the fields and linked objects from a different page.
    ''' # Overlay page fields # Overlay page content fields
original_page
overlay_page
commit