Ejemplo n.º 1
0
def data_center_broadcast(request):
    dc_id, level, title, content = retrieve_params(
        request.data, 'data_center', 'level', 'title', 'content')

    for receiver in UserProxy.normal_users. \
            filter(userdatacenter__data_center__pk=dc_id, is_active=True):
        Notification.create(receiver, title, content, level)

    return Response({"success": True,
                     "msg": _('Notification is sent successfully!')})
Ejemplo n.º 2
0
def broadcast(request):
    receiver_ids = request.data.getlist('receiver_ids[]')
    level, title, content = retrieve_params(request.data,
                                            'level', 'title', 'content')

    receivers = UserProxy.normal_users.filter(is_active=True)
    if receiver_ids:
        receivers = UserProxy.normal_users.filter(pk__in=receiver_ids)

    for receiver in receivers:
        Notification.create(receiver, title, content, level)

    return Response({"success": True,
                     "msg": _('Notification is sent successfully!')})