Example #1
0
def send_page_update(page, socket_id):
    """Send page create/update notification through Pusher."""
    model = page.__class__
    pusher_fields = permissions.get_model_default_readable_fields(model)
    dct = object_to_dict(page, pusher_fields)

    pusher_helpers.try_pusher_page_send(
        page.id, 'page-update', dct, socket_id)
Example #2
0
def send_batch_item_deletion(page, item_ghosts):
    """
    Send batch item deletion notification through Pusher.
    itemGhosts are dictionaries containing deleted item ids and item types
    """
    pusher_event = 'multi-event'
    multi_event_data = []
    for item_ghost in item_ghosts:
        dct = {'id': item_ghost['original_id'], 'type': item_ghost['type']}
        multi_event_data.append({'type': 'item-delete', 'data': dct})
    pusher_helpers.try_pusher_page_send(page.id, pusher_event, multi_event_data)
Example #3
0
def send_item_create_or_update(item, event_name, socket_id, full_user):
    """Send item create/update notification through Pusher."""

    model = item.__class__
    pusher_fields = permissions.get_model_default_readable_fields(model)
    modelDct = object_to_dict(item, pusher_fields)

    dct = {}
    # Client JS needs 'type' field
    dct['type'] = item.SHORTNAME
    
    # Lets keep a copy of the id at top level
    dct['id'] = item.id
    dct['creator_identifier'] = get_user_identifier(full_user, item.page_id) 
    if item.creator_id:
        creator = User.objects.get(id=item.creator_id)
        dct['creator_username'] = creator.username
    else:
        dct['creator_username'] = None 

    dct['model_data'] = modelDct
    pusher_helpers.try_pusher_page_send(
        item.page_id, event_name, dct, socket_id)
Example #4
0
def send_page_deletion(deleted_page_id):
    """Send page deletion notification through Pusher."""
    pusher_event = 'page-delete'
    dct = {'id': deleted_page_id}
    pusher_helpers.try_pusher_page_send(deleted_page_id, pusher_event, dct)
Example #5
0
def send_item_deletion(item, deleted_item_id):
    """Send item deletion notification through Pusher."""
    pusher_event = 'item-delete'
    dct = {'id': deleted_item_id, 'type': item.SHORTNAME}
    pusher_helpers.try_pusher_page_send(item.page_id, pusher_event, dct)