website_membership_signup_required: accept terms & conditions in signup form. Redirect to cart
This commit is contained in:
parent
07b0e546c4
commit
ba52c72b78
6 changed files with 151 additions and 22 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import werkzeug.datastructures
|
||||
|
||||
from odoo.exceptions import UserError
|
||||
from odoo.fields import Date
|
||||
|
||||
from odoo.addons.website_membership_signup_required.controllers.main import (
|
||||
|
|
@ -117,6 +118,7 @@ class TestMembershipSignup(TransactionCase):
|
|||
"confirm_password": "verystrongpwd",
|
||||
"firstname": "John",
|
||||
"lastname": "Doe",
|
||||
"accepted_terms": "accepted",
|
||||
}
|
||||
with MockRequest(self.env, website=self.website):
|
||||
values = controller._prepare_signup_values(qcontext)
|
||||
|
|
@ -131,6 +133,34 @@ class TestMembershipSignup(TransactionCase):
|
|||
self.assertIn("John", values["name"])
|
||||
self.assertIn("Doe", values["name"])
|
||||
|
||||
def test_07b_prepare_signup_values_reject_without_terms(self):
|
||||
"""Signup must be rejected if the legal terms checkbox is not
|
||||
checked (`accepted_terms` missing or not 'accepted').
|
||||
"""
|
||||
import unittest
|
||||
controller = AuthSignupHome()
|
||||
base_qcontext = {
|
||||
"login": "no.terms@example.com",
|
||||
"password": "verystrongpwd",
|
||||
"confirm_password": "verystrongpwd",
|
||||
"firstname": "No",
|
||||
"lastname": "Terms",
|
||||
}
|
||||
# Missing the key entirely.
|
||||
with MockRequest(self.env, website=self.website):
|
||||
with self.assertRaises(UserError):
|
||||
controller._prepare_signup_values(dict(base_qcontext))
|
||||
# Present but not 'accepted'.
|
||||
qcontext = dict(base_qcontext, accepted_terms="")
|
||||
with MockRequest(self.env, website=self.website):
|
||||
with self.assertRaises(UserError):
|
||||
controller._prepare_signup_values(qcontext)
|
||||
# Present and 'accepted' -> does not raise.
|
||||
qcontext = dict(base_qcontext, accepted_terms="accepted")
|
||||
with MockRequest(self.env, website=self.website):
|
||||
values = controller._prepare_signup_values(qcontext)
|
||||
self.assertEqual(values.get("firstname"), "No")
|
||||
|
||||
# -- RF-08 -------------------------------------------------------------
|
||||
|
||||
def test_08_backend_sale_order_with_membership_product_without_user(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue