Exemple #1
0
def send_new_message_notification(message_id):
    from messages.models import Message
    try:
        message = Message.objects.get(pk=message_id)
    except Message.DoesNotExist:
        msg = '**send_new_message_notification**. Message does not exist. ID: %s' % message_id
        client.create_from_text(msg, logger='celery')
        return

    user = message.user

    if not user.email or not user.is_active or not user.notify_by_email:
        return

    if message.author:
        subject = _(u"New message from %(author)s on Amara: %(subject)s")
    else:
        subject = _("New message on Amara: %(subject)s")
    subject = fmt(subject, author=message.author, subject=message.subject)

    context = {
        "message": message,
        "domain":  Site.objects.get_current().domain,
        "STATIC_URL": settings.STATIC_URL,
    }
    Meter('templated-emails-sent-by-type.message-received').inc()
    send_templated_email(user, subject, "messages/email/message_received.html", context)
Exemple #2
0
def debug_log(request):
  if request.method != 'POST' or not settings.HAVE_RAVEN or not settings.HAVE_SENTRY:
    raise Http404('Method not supported')

  form = forms.DebugLogForm(request.POST)
  if not form.is_valid():
    raise krest.BadRequestError(_form_errors(form))
  client = LocalRavenClient([])
  message = form.cleaned_data['message']
  ident = client.get_ident(client.create_from_text(message))
  client.send()
  return {'log_id': ident}
Exemple #3
0
def debug_log(request):
    if request.method != 'POST' or not settings.HAVE_RAVEN or not settings.HAVE_SENTRY:
        raise Http404('Method not supported')

    form = forms.DebugLogForm(request.POST)
    if not form.is_valid():
        raise kbapi.BadRequestError(_form_errors(form))
    client = LocalRavenClient([])
    message = form.cleaned_data['message']
    ident = client.get_ident(client.create_from_text(message))
    client.send()
    return {'log_id': ident}