Add test when create credential recovery

We should test the response before send submit the credential recovery.
Fix typo by using named parameters
parent edcd5b37
......@@ -68,7 +68,7 @@ if password:\n
\n
#Get message from catalog\n
notification_reference = \'crendential_request-confirmation-%s\' % notification_type\n
notification_message = context.NotificationTool_getDocumentValue(notification_reference, recipient.getLanguage())\n
notification_message = context.NotificationTool_getDocumentValue(reference=notification_reference, language=recipient.getLanguage())\n
if notification_message is None:\n
raise ValueError, \'Unable to found Notification Message with reference "%s".\' % notification_reference\n
\n
......
......@@ -55,31 +55,47 @@
Proxy : Manager proxy role is required to make possible for \n
anonymous to create a new Credential Recovery\n
\'\'\'\n
\n
person_module = context.getDefaultModule(\'Person\')\n
portal = context.getPortalObject()\n
person_module = portal.getDefaultModule(\'Person\')\n
result = person_module.searchFolder(reference=reference)\n
if len(result) != 1:\n
portal_status_message = context.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n
portal_status_message = portal.Base_translateString("Can\'t find corresponding person, it\'s not possible to update your credentials.")\n
return context.Base_redirect(\'\', keep_items = dict(portal_status_message=portal_status_message ))\n
\n
person = result[0].getObject()\n
# create the credential recovery\n
module = context.getDefaultModule(portal_type=\'Credential Recovery\')\n
credential_recovery = module.newContent(\n
\n
# Check the response\n
question_free_text = person.getDefaultCredentialQuestionQuestionFreeText()\n
question_title = person.getDefaultCredentialQuestionQuestionTitle()\n
question_answer = person.getDefaultCredentialQuestionAnswer().lower()\n
answer = default_credential_question_answer and default_credential_question_answer.lower() or \'\'\n
\n
if (question_title or question_title) and (answer == question_answer):\n
# create the credential recovery\n
module = portal.getDefaultModule(portal_type=\'Credential Recovery\')\n
credential_recovery = module.newContent(\n
\t\tportal_type="Credential Recovery",\n
reference=reference,\n
default_credential_question_answer=default_credential_question_answer,\n
destination_decision=person.getRelativeUrl(),\n
language=portal.Localizer.get_selected_language())\n
credential_recovery.submit()\n
credential_recovery.submit()\n
message = "Credential Recovery Created."\n
keep_items = {}\n
dialog_id = \'login_form\'\n
else:\n
message = "You didn\'t enter the correct answer."\n
keep_items = {\'default_credential_question_question_free_text\': question_free_text,\n
\'default_credential_question_question_title\': question_title,\n
\'reference\': reference}\n
\n
portal_status_message = context.Base_translateString("Credential Recovery Created.")\n
return context.Base_redirect(\'login_form\', keep_items = dict(portal_status_message=portal_status_message ))\n
keep_items[\'portal_status_message\'] = portal.Base_translateString(message)\n
return context.Base_redirect(dialog_id, keep_items = keep_items)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>reference=None, default_credential_question_answer=None, **kw</string> </value>
<value> <string>reference=None, default_credential_question_answer=None, dialog_id=None, **kw</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
......
332
\ No newline at end of file
333
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment