Beispiel #1
0
    def ready(self):
        """Register signals to update the Elasticsearch indexes."""
        from cms.signals import post_publish
        from .signals import on_page_publish

        post_publish.connect(on_page_publish,
                             dispatch_uid="search_post_publish")
Beispiel #2
0
    def _activate_signaling(self):
        """
        Activates the post_publish signal receiver if not already done.
        """

        if not self.signaling_activated:
            from cms.signals import post_publish
            post_publish.connect(self._receiver)
            self.signaling_activated = True
Beispiel #3
0
    def _activate_signaling(self):
        """
        Activates the post_publish signal receiver if not already done.
        """

        if not self.signaling_activated:
            from cms.signals import post_publish
            post_publish.connect(self._receiver)
            self.signaling_activated = True
Beispiel #4
0
def connect_all_plugins():
    from cms.signals import post_placeholder_operation, post_publish, pre_obj_operation

    post_placeholder_operation.connect(handle_placeholder_change,
                                       dispatch_uid='reversion2_placeholder')
    signals.post_save.connect(mark_title_dirty,
                              sender='cms.Title',
                              dispatch_uid='reversion2_title')
    signals.pre_delete.connect(handle_page_delete,
                               sender='cms.Page',
                               dispatch_uid='reversion2_page')
    # signals.pre_delete.connect(delete_hidden_page, sender='djangocms_reversion2.PageVersion',
    #                             dispatch_uid='reversion2_page_version')
    post_publish.connect(handle_page_publish,
                         dispatch_uid='reversion2_page_publish')
    pre_obj_operation.connect(handle_page_reverted_to_live,
                              dispatch_uid='reversion2_page_revert_to_live')
Beispiel #5
0
        # If an old teaser exists, overwrite. Otherwise create new
        teaser.pk = old_teasers.pop(teaser.language, None)
        teaser.page = target
        teaser.save()
    if old_teasers:
        Teaser.objects.filter(id__in=old_teasers.values()).delete()

# Patch the Page model class to add a _copy_teasers() method
setattr(Page, '_copy_teasers', _copy_teasers)

def copy_teasers(sender, instance, **kwargs):
    """Copy the teasers from a draft page to its corresponding public page"""
    public_page = instance.publisher_public
    instance._copy_teasers(public_page)

# When a page is published, copy the teaser from the draft page to 
post_publish.connect(copy_teasers, sender=Page)

class StoryPlugin(CMSPlugin):
    story = models.ForeignKey('storybase_story.Story', related_name='plugins')

    def __unicode__(self):
        return self.story.title


class HelpPlugin(CMSPlugin):
    help = models.ForeignKey('storybase_help.Help', related_name='plugins')

    def __unicode__(self):
        return self.help.title
Beispiel #6
0
        plugin_list = placeholder.cmsplugin_set.all()
        #plugin_list = CMSPlugin.objects.filter(placeholder_id=placeholder, language=page_language)

        plugin_instance_list = []
        for plugin in plugin_list:

            # Using Django CMS and Django CMS history get a serializable format of the plugin
            plugin_instance = _get_plugin_from_id(plugin_id=plugin.id)
            fetched_data = get_plugin_data(plugin=plugin_instance)

            plugin_instance_list.append(fetched_data)

        cms_plugin_instance_list[placeholder.id] = plugin_instance_list
        cms_plugin_list[placeholder.id] = serialize('json', plugin_list)

    version = VersionHistory(
        page_id=page_instance.id,
        title_id=title_instance.id,
        title_data=str(serialize('json', [title_instance])),
        page_data=str(serialize('json', [page_instance])),
        placeholders=str(page_placeholders),
        plugins=str(dump_json(cms_plugin_list)),
        plugin_instance=str(dump_json(cms_plugin_instance_list)),
    )

    version.save()


post_publish.connect(_create_version)
Beispiel #7
0
    if old_teasers:
        Teaser.objects.filter(id__in=old_teasers.values()).delete()


# Patch the Page model class to add a _copy_teasers() method
setattr(Page, '_copy_teasers', _copy_teasers)


def copy_teasers(sender, instance, **kwargs):
    """Copy the teasers from a draft page to its corresponding public page"""
    public_page = instance.publisher_public
    instance._copy_teasers(public_page)


# When a page is published, copy the teaser from the draft page to
post_publish.connect(copy_teasers, sender=Page)


class StoryPlugin(CMSPlugin):
    story = models.ForeignKey('storybase_story.Story', related_name='plugins')

    def __unicode__(self):
        return self.story.title


class HelpPlugin(CMSPlugin):
    help = models.ForeignKey('storybase_help.Help', related_name='plugins')

    def __unicode__(self):
        return self.help.title
Beispiel #8
0
			post_save.connect(f, sender=model)
			post_delete.connect(f, sender=model)
		return f
	return invalidate


from cms.signals import page_moved, application_post_changed, post_publish
from cms.models import Page, CMSPlugin

@on_change(Page, CMSPlugin)
def invalidate_cms(instance, **kwargs):
	quick_delete('/')

page_moved.connect(invalidate_cms)
application_post_changed.connect(invalidate_cms)
post_publish.connect(invalidate_cms)

from apps.services.models import Service
@on_change(Service)
def invalidate_service(instance, **kwargs):
	quick_delete('services/')

from apps.gallery.models import Album, Picture
@on_change(Album, Picture)
def invalidate_gallery(instance, **kwargs):
	quick_delete('gallery/')

from apps.img.models import Image
@on_change(Service)
def invalidate_img(instance, **kwargs):
	quick_delete('/')