New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sponsor_renew_request not redirecting after sending mail #841
Comments
Ah, that's great. Thanks @lentinj. Shall I add the Do we need a "unit" test for this behaviour? I'm guessing that's a bit tricky with the current setup. |
I've done a bit of testing here. The first time I requested I got two e-mails because after clicking the 'submit' button nothing was obviously happening and so I clicked it again. A little while later I tested it with what was consciously a single click and I got a single e-mail. |
I'll have a look if I've time Monday.
It's straying into unit-test-configuration territory, but it's still worthwhile. The main faff with the unit test setup is mocking the mailer. We could probably achieve that with something similar to https://github.com/OneZoom/OZtree/blob/2f51d56262182e70c09fe30ce62c44d9b423e74c/tests/unit/test_controllers_default_sponsor.py. But worst case, we don't actually care here. As long as we use an example.com address we'll have no side effects, even if the site configuration specifies a working mailer. All we care about is we managed to call |
That would be great. Thanks @lentinj |
To avoid potential resent emails on refresh, send a 303 redirect to the current page after successful e-mail send. This means we need to store the flash message in the session, which isn't ideal, but is already on our radar anyway.
The controller isn't redirecting back to a GET version of the page:
OZtree/controllers/default.py
Lines 625 to 640 in 2f51d56
It should have a
redirect()
on success, kinda like: http://web2py.com/books/default/chapter/34/07/forms-and-validators#Forms-and-redirection, so a reload of the page doesn't send another e-mail.@hyanwong this isn't necessarily the root of your late night email avalanche, I've no idea why a browser would try and reload 8 times, but if it does it again then there should be no problems in doing so.
The text was updated successfully, but these errors were encountered: