mirror of https://github.com/zulip/zulip.git
emails: Redirect to /emails after generating emails.
This commit is contained in:
parent
8964e04238
commit
4c2e787ffc
|
@ -2,7 +2,9 @@
|
|||
{% block content %}
|
||||
<div class="container">
|
||||
<div class="alert">
|
||||
{{ message |safe }}
|
||||
All the emails sent in the Zulip development environment are logged here. You can also
|
||||
manually generate most of the emails by clicking <a href="/emails/generate">here</a>.
|
||||
To clear this log click <a href="/emails/clear">here</a>
|
||||
</div>
|
||||
{{ log |safe }}
|
||||
</div>
|
||||
|
|
|
@ -77,13 +77,17 @@ class DocPageTest(ZulipTestCase):
|
|||
self._test('/errors/5xx/', 'Internal server error')
|
||||
|
||||
# For reaching full coverage for clear_emails function
|
||||
os.remove(settings.EMAIL_CONTENT_LOG_PATH)
|
||||
self._test('/emails/', 'manually generate most of the emails by clicking')
|
||||
if os.path.isfile(settings.EMAIL_CONTENT_LOG_PATH):
|
||||
os.remove(settings.EMAIL_CONTENT_LOG_PATH)
|
||||
result = self.client_get('/emails/clear/')
|
||||
self.assertEqual(result.status_code, 302)
|
||||
self.assertIn('emails', result['Location'])
|
||||
result = self.client_get(result['Location'])
|
||||
self.assertIn('manually generate most of the emails by clicking', str(result.content))
|
||||
|
||||
self._test('/emails/', 'manually generate most of the emails by clicking')
|
||||
self._test('/emails/generate/', 'Emails generated successfully')
|
||||
result = self.client_get('/emails/generate/')
|
||||
self.assertEqual(result.status_code, 302)
|
||||
self.assertIn('emails', result['Location'])
|
||||
self._test('/register/', 'Sign up for Zulip')
|
||||
|
||||
result = self.client_get('/integrations/doc-html/nonexistent_integration', follow=True)
|
||||
|
|
|
@ -17,20 +17,14 @@ import datetime
|
|||
ZULIP_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../')
|
||||
client = Client()
|
||||
|
||||
def email_page(request, message=None):
|
||||
# type: (HttpRequest, Optional[str]) -> HttpResponse
|
||||
if message is None:
|
||||
message = '''
|
||||
All the emails sent in the Zulip development environment are logged here. You can also
|
||||
manually generate most of the emails by clicking <a href="/emails/generate">here</a>.
|
||||
To clear this log click <a href="/emails/clear">here</a>.
|
||||
'''
|
||||
def email_page(request):
|
||||
# type: (HttpRequest) -> HttpResponse
|
||||
try:
|
||||
with open(settings.EMAIL_CONTENT_LOG_PATH, "r+") as f:
|
||||
content = f.read()
|
||||
except FileNotFoundError:
|
||||
content = ""
|
||||
return render(request, 'zerver/email_log.html', {'log': content, 'message': message})
|
||||
return render(request, 'zerver/email_log.html', {'log': content})
|
||||
|
||||
def clear_emails(request):
|
||||
# type: (HttpRequest) -> HttpResponse
|
||||
|
@ -79,8 +73,4 @@ def generate_all_emails(request):
|
|||
|
||||
# Follow up day1 day2 emails
|
||||
enqueue_welcome_emails(user_profile)
|
||||
message = '''
|
||||
Emails generated successfully. Reload this page to generate them again.
|
||||
To clear this log click <a href="/emails/clear">here</a>.
|
||||
'''
|
||||
return email_page(request, message)
|
||||
return redirect(email_page)
|
||||
|
|
Loading…
Reference in New Issue