Fix registration error

This commit is contained in:
Christian Cueni 2020-06-18 18:27:04 +02:00
parent 723a26b810
commit 6a7fbd54cf
2 changed files with 7 additions and 7 deletions

View File

@ -42,6 +42,7 @@ RESPONSE = {
}
DATA = {
'accepted_terms': True,
'customer': {
'firstname': 'Pesche',
'lastname': 'Zubrüti',
@ -61,8 +62,7 @@ DATA = {
'default_billing': True,
}
],
'password': '123454abasfd',
'accepted_terms': True
'password': '123454abasfd'
}
}
@ -88,7 +88,7 @@ class ProxyTest(TestCase):
def test_requires_accepted_terms(self):
del DATA['customer']['accepted_terms']
del DATA['accepted_terms']
response = self.client.post(reverse('api:registration:proxy'), json.dumps(DATA), content_type="application/json")
self.assertEquals(response.status_code, 400)

View File

@ -21,7 +21,7 @@ class RegistrationProxyView(View):
hep_client = HepClient()
data = json.loads(request.body)
if not self.terms_accepted(data['customer']):
if not self.terms_accepted(data):
return JsonResponse(
{
'message': 'Sie müssen hier zustimmen, damit Sie sich registrieren können.'
@ -40,9 +40,9 @@ class RegistrationProxyView(View):
return JsonResponse(response_data)
def terms_accepted(self, customer):
if 'accepted_terms' in customer and customer['accepted_terms']:
del customer['accepted_terms']
def terms_accepted(self, data):
if 'accepted_terms' in data and data['accepted_terms']:
del data['accepted_terms']
return True
return False