Ejemplo n.º 1
0
def connect_signals():
    from django.contrib.comments.signals import comment_was_posted
    from ella.core.signals import content_published, content_unpublished
    from django.db.models.signals import post_save
    content_published.connect(publishable_published)
    content_unpublished.connect(publishable_unpublished)

    comment_was_posted.connect(comment_posted, sender=comments.get_model())

    post_save.connect(comment_post_save, sender=comments.get_model())
Ejemplo n.º 2
0
def connect_signals():
    from django.db.models.signals import pre_save, post_save, post_delete, pre_delete
    from ella.core.signals import content_published, content_unpublished
    from ella.core.models import Listing
    content_published.connect(publishable_published)
    content_unpublished.connect(publishable_unpublished)

    pre_save.connect(listing_pre_save, sender=Listing)
    post_save.connect(listing_post_save, sender=Listing)

    pre_delete.connect(listing_pre_delete, sender=Listing)
    post_delete.connect(listing_post_delete, sender=Listing)
Ejemplo n.º 3
0
Archivo: redis.py Proyecto: Pheox/ella
def connect_signals():
    from django.db.models.signals import pre_save, post_save, post_delete, pre_delete
    from ella.core.signals import content_published, content_unpublished
    from ella.core.models import Listing
    content_published.connect(publishable_published)
    content_unpublished.connect(publishable_unpublished)

    pre_save.connect(listing_pre_save, sender=Listing)
    post_save.connect(listing_post_save, sender=Listing)

    pre_delete.connect(listing_pre_delete, sender=Listing)
    post_delete.connect(listing_post_delete, sender=Listing)
Ejemplo n.º 4
0
def connect_signals():
    from django.db.models.signals import pre_save, post_save, post_delete, pre_delete, m2m_changed
    from ella.core.signals import content_published, content_unpublished
    from ella.core.models import Listing, Publishable

    if not core_settings.USE_REDIS_FOR_LISTINGS:
        return
    # when redis is availible, use it for authors
    m2m_changed.connect(update_authors, sender=Publishable._meta.get_field('authors').rel.through)

    content_published.connect(publishable_published)
    content_unpublished.connect(publishable_unpublished)

    pre_save.connect(listing_pre_save, sender=Listing)
    post_save.connect(listing_post_save, sender=Listing)

    pre_delete.connect(listing_pre_delete, sender=Listing)
    post_delete.connect(listing_post_delete, sender=Listing)
Ejemplo n.º 5
0
    if isinstance(obj, Publishable) and obj.is_published():
        publishable_published(obj, delta=1)
    # invalidate the objects boxes
    invalidate_cache_for_object(obj)


def publishable_unpublished(publishable, **kwargs):
    pipe = None
    for lh in _get_listing_handlers():
        pipe = lh.remove_publishable(publishable.category, publishable, pipe=pipe, commit=False)
    if pipe:
        pipe.execute()


def publishable_published(publishable, delta=0, **kwargs):
    pipe = None
    for lh in _get_listing_handlers():
        if issubclass(lh, SlidingListingHandler):
            if delta != 0:
                pipe = lh.incr_score(publishable.category, publishable, incr_by=delta, pipe=pipe, commit=False)
        else:
            pipe = lh.add_publishable(publishable.category, publishable, pipe=pipe, commit=False)
    if pipe:
        pipe.execute()

content_published.connect(publishable_published)
content_unpublished.connect(publishable_unpublished)

comment_was_posted.connect(comment_posted, sender=FlatComment)
comment_was_moderated.connect(comment_moderated, sender=FlatComment)
Ejemplo n.º 6
0
                                     pipe=pipe,
                                     commit=False)
    if pipe:
        pipe.execute()


def publishable_published(publishable, delta=0, **kwargs):
    pipe = None
    for lh in _get_listing_handlers():
        if issubclass(lh, SlidingListingHandler):
            if delta != 0:
                pipe = lh.incr_score(publishable.category,
                                     publishable,
                                     incr_by=delta,
                                     pipe=pipe,
                                     commit=False)
        else:
            pipe = lh.add_publishable(publishable.category,
                                      publishable,
                                      pipe=pipe,
                                      commit=False)
    if pipe:
        pipe.execute()


content_published.connect(publishable_published)
content_unpublished.connect(publishable_unpublished)

comment_was_posted.connect(comment_posted, sender=FlatComment)
comment_was_moderated.connect(comment_moderated, sender=FlatComment)