prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Don't send additional 500 email if no useful information in it.
  After the implementation if #1485 we get an additional email for _all_ 500 errors, even if there is no supplied information. Let's not send an email if there's no useful information in it.
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `onlineweb4/views.py`
  Content:
  ```
  1 # -*- coding: utf-8 -*-
  2 import logging
  3 from smtplib import SMTPException
  4 
  5 from django.conf import settings
  6 from django.contrib import messages
  7 from django.core.mail import send_mail
  8 from django.shortcuts import redirect, render
  9 from onlineweb4.forms import ErrorForm
  10 
  11 
  12 def server_error(request):
  13     log = logging.getLogger(__name__)
  14 
  15     if request.method == 'POST':
  16         form = ErrorForm(request.POST)
  17         message = request.POST.get('reason', 'Ingen forklaring oppgitt.')
  18         try: 
  19             log.error('%s triggered a 500 server error and provided the following description: %s' % (
  20                 request.user,
  21                 message
  22             ))
  23             send_mail('500error user-report', message,
  24                 settings.DEFAULT_FROM_EMAIL, [settings.EMAIL_DOTKOM])
  25             log.debug('Finished sending error email to %s' % settings.EMAIL_DOTKOM)
  26 
  27             messages.success(request, 'Feilmeldingen din ble sendt til %s' % settings.EMAIL_DOTKOM)
  28 
  29             return redirect('home')
  30         except SMTPException:
  31             messages.error(request, 'Det oppstod en uventet feil under sending av feilmeldingen')
  32             return redirect('home')
  33 
  34     return render(request, '500.html', {'error_form': ErrorForm})
  35
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/onlineweb4/views.py b/onlineweb4/views.py
  --- a/onlineweb4/views.py
  +++ b/onlineweb4/views.py
  @@ -1,21 +1,22 @@
   # -*- coding: utf-8 -*-
   import logging
  -from smtplib import SMTPException
   
   from django.conf import settings
   from django.contrib import messages
   from django.core.mail import send_mail
   from django.shortcuts import redirect, render
   from onlineweb4.forms import ErrorForm
  +from smtplib import SMTPException
   
   
   def server_error(request):
       log = logging.getLogger(__name__)
   
       if request.method == 'POST':
  -        form = ErrorForm(request.POST)
  -        message = request.POST.get('reason', 'Ingen forklaring oppgitt.')
  -        try: 
  +        message = request.POST.get('reason')
  +        if not message:
  +            return redirect('home')
  +        try:
               log.error('%s triggered a 500 server error and provided the following description: %s' % (
                   request.user,
                   message
  @@ -23,12 +24,9 @@
               send_mail('500error user-report', message,
                   settings.DEFAULT_FROM_EMAIL, [settings.EMAIL_DOTKOM])
               log.debug('Finished sending error email to %s' % settings.EMAIL_DOTKOM)
  -
               messages.success(request, 'Feilmeldingen din ble sendt til %s' % settings.EMAIL_DOTKOM)
  -
               return redirect('home')
           except SMTPException:
               messages.error(request, 'Det oppstod en uventet feil under sending av feilmeldingen')
               return redirect('home')
  -
       return render(request, '500.html', {'error_form': ErrorForm})
  
verification_info: {"golden_diff": "diff --git a/onlineweb4/views.py b/onlineweb4/views.py\n--- a/onlineweb4/views.py\n+++ b/onlineweb4/views.py\n@@ -1,21 +1,22 @@\n # -*- coding: utf-8 -*-\n import logging\n-from smtplib import SMTPException\n \n from django.conf import settings\n from django.contrib import messages\n from django.core.mail import send_mail\n from django.shortcuts import redirect, render\n from onlineweb4.forms import ErrorForm\n+from smtplib import SMTPException\n \n \n def server_error(request):\n     log = logging.getLogger(__name__)\n \n     if request.method == 'POST':\n-        form = ErrorForm(request.POST)\n-        message = request.POST.get('reason', 'Ingen forklaring oppgitt.')\n-        try: \n+        message = request.POST.get('reason')\n+        if not message:\n+            return redirect('home')\n+        try:\n             log.error('%s triggered a 500 server error and provided the following description: %s' % (\n                 request.user,\n                 message\n@@ -23,12 +24,9 @@\n             send_mail('500error user-report', message,\n                 settings.DEFAULT_FROM_EMAIL, [settings.EMAIL_DOTKOM])\n             log.debug('Finished sending error email to %s' % settings.EMAIL_DOTKOM)\n-\n             messages.success(request, 'Feilmeldingen din ble sendt til %s' % settings.EMAIL_DOTKOM)\n-\n             return redirect('home')\n         except SMTPException:\n             messages.error(request, 'Det oppstod en uventet feil under sending av feilmeldingen')\n             return redirect('home')\n-\n     return render(request, '500.html', {'error_form': ErrorForm})\n", "issue": "Don't send additional 500 email if no useful information in it.\nAfter the implementation if #1485 we get an additional email for _all_ 500 errors, even if there is no supplied information. Let's not send an email if there's no useful information in it.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\nimport logging\nfrom smtplib import SMTPException\n\nfrom django.conf import settings\nfrom django.contrib import messages\nfrom django.core.mail import send_mail\nfrom django.shortcuts import redirect, render\nfrom onlineweb4.forms import ErrorForm\n\n\ndef server_error(request):\n    log = logging.getLogger(__name__)\n\n    if request.method == 'POST':\n        form = ErrorForm(request.POST)\n        message = request.POST.get('reason', 'Ingen forklaring oppgitt.')\n        try: \n            log.error('%s triggered a 500 server error and provided the following description: %s' % (\n                request.user,\n                message\n            ))\n            send_mail('500error user-report', message,\n                settings.DEFAULT_FROM_EMAIL, [settings.EMAIL_DOTKOM])\n            log.debug('Finished sending error email to %s' % settings.EMAIL_DOTKOM)\n\n            messages.success(request, 'Feilmeldingen din ble sendt til %s' % settings.EMAIL_DOTKOM)\n\n            return redirect('home')\n        except SMTPException:\n            messages.error(request, 'Det oppstod en uventet feil under sending av feilmeldingen')\n            return redirect('home')\n\n    return render(request, '500.html', {'error_form': ErrorForm})\n", "path": "onlineweb4/views.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\nimport logging\n\nfrom django.conf import settings\nfrom django.contrib import messages\nfrom django.core.mail import send_mail\nfrom django.shortcuts import redirect, render\nfrom onlineweb4.forms import ErrorForm\nfrom smtplib import SMTPException\n\n\ndef server_error(request):\n    log = logging.getLogger(__name__)\n\n    if request.method == 'POST':\n        message = request.POST.get('reason')\n        if not message:\n            return redirect('home')\n        try:\n            log.error('%s triggered a 500 server error and provided the following description: %s' % (\n                request.user,\n                message\n            ))\n            send_mail('500error user-report', message,\n                settings.DEFAULT_FROM_EMAIL, [settings.EMAIL_DOTKOM])\n            log.debug('Finished sending error email to %s' % settings.EMAIL_DOTKOM)\n            messages.success(request, 'Feilmeldingen din ble sendt til %s' % settings.EMAIL_DOTKOM)\n            return redirect('home')\n        except SMTPException:\n            messages.error(request, 'Det oppstod en uventet feil under sending av feilmeldingen')\n            return redirect('home')\n    return render(request, '500.html', {'error_form': ErrorForm})\n", "path": "onlineweb4/views.py"}]}