Пример #1
0
def _send_test_messages(request, domain, config_id, actually):
    performance_config = PerformanceConfiguration.get(config_id)
    assert performance_config.domain == domain
    sent_messages = send_messages_for_config(performance_config, actually_send=actually)
    heading = (
        _('The following messages have been sent') if actually else
        _('Would send the following messages')
    )
    if sent_messages:
        messages.success(
            request,
            mark_safe(_(u"{}: <br>{}").format(
                heading,
                '<br>'.join([
                    u' - {} (to {} via {})'.format(
                        result.message, result.user.raw_username, result.user.phone_number
                    )
                    for result in sent_messages
                ])
            )),
            extra_tags='html'
        )
    else:
        messages.info(request, _('Unfortunately, here were no valid recipients for this message.'))
    return HttpResponseRedirect(reverse('performance_sms.list_performance_configs', args=[domain]))
Пример #2
0
def _send_test_messages(request, domain, config_id, actually):
    performance_config = PerformanceConfiguration.get(config_id)
    assert performance_config.domain == domain
    sent_messages = send_messages_for_config(performance_config,
                                             actually_send=actually)
    heading = (_('The following messages have been sent')
               if actually else _('Would send the following messages'))
    if sent_messages:
        messages.success(request,
                         mark_safe(
                             _(u"{}: <br>{}").format(
                                 heading, '<br>'.join([
                                     u' - {} (to {} via {})'.format(
                                         result.message,
                                         result.user.raw_username,
                                         result.user.phone_number)
                                     for result in sent_messages
                                 ]))),
                         extra_tags='html')
    else:
        messages.info(
            request,
            _('Unfortunately, here were no valid recipients for this message.')
        )
    return HttpResponseRedirect(
        reverse(ListPerformanceConfigsView.urlname, args=[domain]))
Пример #3
0
def fire_performance_sms():
    for config in get_message_configs_at_this_hour():
        send_messages_for_config(config)