Commit a6eacdad authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

make it possible to specify expiration date of credential requests whose...

make it possible to specify expiration date of credential requests whose default is still current date + 1 day.
parent 580558db
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>mode</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/int</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>The life of time of credential recovery.</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>preferred_credential_recovery_expiration_day_property</string> </value>
</item>
<item>
<key> <string>mode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>preference</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>property_default</string> </key>
<value> <string>python:1</string> </value>
</item>
<item>
<key> <string>write_permission</string> </key>
<value> <string>Manage properties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
<value> <value>
<list> <list>
<string>listbox_delivery_start_date</string> <string>listbox_delivery_start_date</string>
<string>listbox_delivery_stop_date</string>
</list> </list>
</value> </value>
</item> </item>
......
...@@ -10,15 +10,15 @@ ...@@ -10,15 +10,15 @@
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list> <list>
<string>all_columns</string>
<string>columns</string>
<string>editable_columns</string> <string>editable_columns</string>
<string>sort</string>
<string>title</string>
<string>portal_types</string> <string>portal_types</string>
<string>columns</string>
<string>selection_name</string>
<string>search_columns</string> <string>search_columns</string>
<string>selection_name</string>
<string>sort</string>
<string>sort_columns</string> <string>sort_columns</string>
<string>all_columns</string> <string>title</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -104,7 +104,11 @@ ...@@ -104,7 +104,11 @@
</tuple> </tuple>
<tuple> <tuple>
<string>delivery.start_date</string> <string>delivery.start_date</string>
<string>Date</string> <string>Creation Date</string>
</tuple>
<tuple>
<string>delivery.stop_date</string>
<string>Expiration Date</string>
</tuple> </tuple>
<tuple> <tuple>
<string>translated_validation_state_title</string> <string>translated_validation_state_title</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>listbox_delivery_stop_date</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_module_listbox_delivery_start_date</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewCredentialFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:cell.hasStopDate() and cell.getStopDate() or cell.getStartDate()+1</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -65,10 +65,16 @@ notification_message = portal.NotificationTool_getDocumentValue(message_referenc ...@@ -65,10 +65,16 @@ notification_message = portal.NotificationTool_getDocumentValue(message_referenc
\n \n
context.REQUEST.set(\'came_from\', portal.absolute_url())\n context.REQUEST.set(\'came_from\', portal.absolute_url())\n
\n \n
if context.hasStopDate():\n
kw = {\'expiration_date\':context.getStopDate()}\n
else:\n
kw = {}\n
\n
portal.portal_password.mailPasswordResetRequest(user_login=reference,\n portal.portal_password.mailPasswordResetRequest(user_login=reference,\n
REQUEST=context.REQUEST,\n REQUEST=context.REQUEST,\n
notification_message=notification_message,\n notification_message=notification_message,\n
store_as_event=portal.portal_preferences.isPreferredStoreEvents())\n store_as_event=portal.portal_preferences.isPreferredStoreEvents(),\n
**kw)\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
...@@ -9,7 +9,9 @@ ...@@ -9,7 +9,9 @@
<item> <item>
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list/> <list>
<string>title</string>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -81,6 +83,10 @@ ...@@ -81,6 +83,10 @@
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value> <value> <string>Click to edit the target</string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string>Creation Date</string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
......
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
<item> <item>
<key> <string>delegated_list</string> </key> <key> <string>delegated_list</string> </key>
<value> <value>
<list/> <list>
<string>default</string>
<string>title</string>
</list>
</value> </value>
</item> </item>
<item> <item>
...@@ -50,6 +53,12 @@ ...@@ -50,6 +53,12 @@
<key> <string>tales</string> </key> <key> <string>tales</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -69,6 +78,12 @@ ...@@ -69,6 +78,12 @@
<key> <string>values</string> </key> <key> <string>values</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>default</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string>my_view_mode_read_only_stop_date</string> </value> <value> <string>my_view_mode_read_only_stop_date</string> </value>
...@@ -81,10 +96,27 @@ ...@@ -81,10 +96,27 @@
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value> <value> <string>Click to edit the target</string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string>Expiration Date</string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python:here.hasStopDate() and here.getStopDate() or here.getStartDate()+1</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData> </ZopeData>
...@@ -101,6 +101,7 @@ ...@@ -101,6 +101,7 @@
<string>my_preferred_credential_request_automatic_approval</string> <string>my_preferred_credential_request_automatic_approval</string>
<string>my_preferred_organisation_credential_update_automatic_approval</string> <string>my_preferred_organisation_credential_update_automatic_approval</string>
<string>my_preferred_credential_recovery_automatic_approval</string> <string>my_preferred_credential_recovery_automatic_approval</string>
<string>my_preferred_credential_recovery_expiration_day</string>
<string>my_preferred_ask_login_on_password_recovery</string> <string>my_preferred_ask_login_on_password_recovery</string>
<string>my_preferred_person_credential_update_automatic_approval</string> <string>my_preferred_person_credential_update_automatic_approval</string>
<string>my_preferred_credential_alarm_automatic_call</string> <string>my_preferred_credential_alarm_automatic_call</string>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_preferred_credential_recovery_expiration_day</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_integer_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewFieldLibrary</string> </value>
</item>
<item>
<key> <string>target</string> </key>
<value> <string>Click to edit the target</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Expiration day of credential recovery</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -51,7 +51,12 @@ ...@@ -51,7 +51,12 @@
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""Specify the start date of the credential with the transition date"""\n <value> <string>"""Specify the start date of the credential with the transition date"""\n
state_change[\'object\'].setStartDate(state_change.getDateTime())\n document = state_change[\'object\']\n
if not document.hasStartDate():\n
document.setStartDate(state_change.getDateTime())\n
if not document.hasStopDate():\n
portal_preferences = document.getPortalObject().portal_preferences\n
document.setStopDate(document.getStartDate() + portal_preferences.getPreferredCredentialRecoveryExpirationDay())\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
......
410 411
\ No newline at end of file
...@@ -70,9 +70,10 @@ class PasswordTool(BaseTool): ...@@ -70,9 +70,10 @@ class PasswordTool(BaseTool):
# BaseTool.__init__(self, id) # BaseTool.__init__(self, id)
security.declareProtected('Manage users', 'getResetPasswordKey') security.declareProtected('Manage users', 'getResetPasswordKey')
def getResetPasswordKey(self, user_login): def getResetPasswordKey(self, user_login, expiration_date=None):
# generate expiration date if expiration_date is None:
expiration_date = DateTime() + self._expiration_day # generate expiration date
expiration_date = DateTime() + self._expiration_day
# generate a random string # generate a random string
key = self._generateUUID() key = self._generateUUID()
...@@ -110,8 +111,9 @@ class PasswordTool(BaseTool): ...@@ -110,8 +111,9 @@ class PasswordTool(BaseTool):
def mailPasswordResetRequest(self, user_login=None, REQUEST=None, def mailPasswordResetRequest(self, user_login=None, REQUEST=None,
notification_message=None, sender=None, notification_message=None, sender=None,
store_as_event=False): store_as_event=False,
expiration_date=None):
""" """
Create a random string and expiration date for request Create a random string and expiration date for request
Parameters: Parameters:
...@@ -123,6 +125,7 @@ class PasswordTool(BaseTool): ...@@ -123,6 +125,7 @@ class PasswordTool(BaseTool):
As default, the default email address will be used As default, the default email address will be used
store_as_event -- whenever CRM is available, store store_as_event -- whenever CRM is available, store
notifications as events notifications as events
expiration_date -- If not set, expiration date is current date + 1 day.
""" """
if REQUEST is None: if REQUEST is None:
REQUEST = get_request() REQUEST = get_request()
...@@ -159,7 +162,8 @@ class PasswordTool(BaseTool): ...@@ -159,7 +162,8 @@ class PasswordTool(BaseTool):
return REQUEST.RESPONSE.redirect( ret_url ) return REQUEST.RESPONSE.redirect( ret_url )
return msg return msg
key = self.getResetPasswordKey(user_login=user_login) key = self.getResetPasswordKey(user_login=user_login,
expiration_date=expiration_date)
url = self.getResetPasswordUrl(key=key, site_url=site_url) url = self.getResetPasswordUrl(key=key, site_url=site_url)
# send mail # send mail
......
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