diff --git a/templates/zerver/email_log.html b/templates/zerver/email_log.html index 7f38fc5689..d23b72fb11 100644 --- a/templates/zerver/email_log.html +++ b/templates/zerver/email_log.html @@ -2,7 +2,9 @@ {% block content %}
diff --git a/zerver/tests/test_docs.py b/zerver/tests/test_docs.py index d2b057b91e..9795b6e009 100644 --- a/zerver/tests/test_docs.py +++ b/zerver/tests/test_docs.py @@ -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) diff --git a/zerver/views/email_log.py b/zerver/views/email_log.py index 3cd08f5648..eb23621076 100755 --- a/zerver/views/email_log.py +++ b/zerver/views/email_log.py @@ -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 here. -To clear this log click here. -''' +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 here. -''' - return email_page(request, message) + return redirect(email_page)