示例#1
0
def trigger_pusher_dj_user(sender, instance: DjUser, created=None, **kwargs):
    """
    Trigger pusher when someone connects to a DJ or disconnects from a DJ
    """
    data = {
        'id': instance.pk,
        'dj': instance.dj.pk,
        'user': instance.user.pk,
    }
    model_trigger(instance, created, data=json.dumps(data))
示例#2
0
def trigger_pusher_dj(sender, instance: Dj, created=None, **kwargs):
    """
    Trigger pusher when someone becomes DJ or stops being a DJ
    """
    data = {
        'id': instance.pk,
        'user': instance.user.pk,
        'party': str(instance.party.pk),
        'song': instance.song.pk if instance.song else None,
        'time': str(instance.time) if instance.time else None,
        'data': str(instance.date),
    }
    model_trigger(instance, created, data=json.dumps(data))
示例#3
0
def trigger_pusher_like(sender, instance, created=None, **kwargs):
    """
    Trigger pusher for liking a party, category or song
    """
    # No pusher trigger for a user being liked (not party related)
    if instance.kind != Like.Kind.USER and instance.like_object:
        channel = get_channel_name(
            instance.like_object.pk if instance.kind ==
            Like.Kind.PARTY else instance.like_object.party.pk)
        data = {
            'id': instance.pk,
            'user': instance.user.username,
            'kind': instance.kind,
            'like': instance.like,
            'data': str(instance.date),
        }
        model_trigger(instance, created, channel, json.dumps(data))
示例#4
0
def trigger_pusher_song_category(sender, instance, created=None, **kwargs):
    model_trigger(instance, created)
示例#5
0
def trigger_pusher_party_user(sender, instance, created=None, **kwargs):
    model_trigger(instance, created)
示例#6
0
def trigger_pusher_party(sender, instance, created=None, **kwargs):
    # No one subscribes to a party that has not been created yet
    if not created:
        model_trigger(instance, created, get_channel_name(instance.pk))