Commit 5f903703 authored by Vincent Bechu's avatar Vincent Bechu

Appstore update

/reviewed-on !5
parents ced0603a 4a97693c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="System Preference" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>officejs_system_preference</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>System Preference</string> </value>
</item>
<item>
<key> <string>preferred_credential_alarm_automatic_call</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>preferred_credential_recovery_automatic_approval</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>preferred_credential_request_automatic_approval</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>preferred_document_conversion_server_url</string> </key>
<value>
<tuple>
<string>https://cloudooo.erp5.net/</string>
</tuple>
</value>
</item>
<item>
<key> <string>preferred_subscription_assignment_category</string> </key>
<value>
<tuple>
<string>role/author</string>
</tuple>
</value>
</item>
<item>
<key> <string>preferred_system_generate_password</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS System Preference</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>preference_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.49393.60016.53896</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1534947704.91</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>global_enable</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>preference_state</string> </key>
<value> <string>global</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1534944796.77</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
<registered_skin_selection>
<skin_folder_selection>
<skin_folder>officejs_credential</skin_folder>
<skin_selection>RJS</skin_selection>
</skin_folder_selection>
</registered_skin_selection>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Folder" module="OFS.Folder"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>business_template_skin_layer_priority</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>float</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>business_template_skin_layer_priority</string> </key>
<value> <float>99.1</float> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>officejs_credential</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Credential</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.Message import translateString
REQUEST = context.REQUEST
RESPONSE = REQUEST.RESPONSE
portal = context.getPortalObject()
assert key
mail_message = portal.portal_catalog.getResultValue(portal_type="Mail Message", reference=key)
credential_request = mail_message.getFollowUpValue()
if credential_request.getValidationState() in ('submitted', 'accepted'):
message = translateString("Your account is already active.")
notification_status = "error"
else:
credential_request.submit(comment=translateString('Created by subscription form'))
mail_message.deliver()
message = translateString("Account activation processing, an email will be sent on finish")
notification_status = "success"
url = '%s/login_form?portal_status_message=%s&notification_status=%s' % (context.absolute_url(), message, notification_status)
RESPONSE.redirect(url)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>key</string> </value>
</item>
<item>
<key> <string>_proxy_roles</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_activeLogin</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""Call by dialog to create a new credential request and redirect to the context
Paramameter list :
reference -- User login is mandatory (String)
default_email_text -- Email is mandatory (String)"""
# create the credential request
portal = context.getPortalObject()
module = portal.getDefaultModule(portal_type='Credential Request')
portal_preferences = portal.portal_preferences
category_list = portal_preferences.getPreferredSubscriptionAssignmentCategoryList()
if password != password_confirmation:
message_str = "Password and Confirmation Password must be same"
notification_status = "error"
return context.REQUEST.RESPONSE.redirect(context.absolute_url() + "/join_form?portal_status_message=" + context.Base_translateString(message_str) + '&notification_status=' + notification_status )
if not context.CredentialRequest_checkLoginAvailability(reference):
message_str = "Selected email is already in use, please choose different one."
notification_status = "error"
return context.REQUEST.RESPONSE.redirect(context.absolute_url() + "/join_form?portal_status_message=" + context.Base_translateString(message_str) + '&notification_status=' + notification_status)
credential_request = module.newContent(
portal_type="Credential Request",
first_name=first_name,
last_name=last_name,
reference=reference,
password=password,
default_credential_question_question=default_credential_question_question,
default_credential_question_question_free_text=default_credential_question_question_free_text,
default_credential_question_answer=default_credential_question_answer,
default_email_text=reference,
default_telephone_text=default_telephone_text,
default_mobile_telephone_text=default_mobile_telephone_text,
default_fax_text=default_fax_text,
default_address_street_address=default_address_street_address,
default_address_city=default_address_city,
default_address_zip_code=default_address_zip_code,
default_address_region=default_address_region,
role_list=role_list,
function=function,
site=site,
activity_list=activity_list,
corporate_name=corporate_name,
date_of_birth=date_of_birth)
credential_request.setCategoryList(category_list)
# Same tag is used as in ERP5 Login._setReference, in order to protect against
# concurrency between Credential Request and Person object too
credential_request.reindexObject(activate_kw=dict(tag='set_login_%s' % reference.encode('hex')))
if portal_preferences.getPreferredCredentialAlarmAutomaticCall():
credential_request.submit("Automatic submit")
message_str = "Credential Request Created."
notification_status = "success"
else:
if portal_preferences.isPreferredEmailVerificationCheck():
# after_path_and_method_id argument is used below to not activate when
# Crededial request object is not indexed yet. This is needed because when
# the method searchAndActivate from catalog is called, if the object is not
# indexed, the e-mail is not sent.
method_id_list = ('immediateReindexObject', 'recursiveImmediateReindexObject')
path_and_method_id = (credential_request.getPath(), method_id_list)
activity_kw = dict(activity='SQLQueue',
after_path_and_method_id=path_and_method_id)
credential_request.activate(**activity_kw).CredentialRequest_sendSubmittedNotification(
context_url=context.absolute_url(),
notification_reference='ojs_credential_request-subscription')
message_str = "Thanks for your registration. You will receive an email to activate your account."
notification_status = "success"
else:
# no email verification is needed
credential_request.submit("Automatic submit")
message_str = "Credential Request Created."
notification_status = "success"
if batch_mode:
return credential_request
return context.REQUEST.RESPONSE.redirect(context.absolute_url() + "/login_form?portal_status_message=" + context.Base_translateString(message_str) + "&notification_status=" + notification_status)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>reference, first_name=None, last_name=None, password=None, password_confirmation=None, date_of_birth=None, default_telephone_text=None, default_mobile_telephone_text=None, default_fax_text=None, corporate_name=None, default_credential_question_question=None, default_credential_question_question_free_text=None, default_credential_question_answer=None, role_list=None, function=None, site=None, activity_list=None, default_address_city=None, default_address_street_address=None, default_address_zip_code=None, default_address_region=None, dialog_id=\'\', batch_mode=False, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>WebSection_newCredentialRequest</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
import re
REQUEST = context.REQUEST
RESPONSE = REQUEST.RESPONSE
from ZTUtils import make_query
portal = context.getPortalObject()
if (came_from is None):
#XXX Hardcoded for JS app's url end with '/'
came_from = "%s/" % context.getPermanentURL(context.getWebSiteValue())
portal.portal_skins.updateSkinCookie()
portal.setupCurrentSkin(REQUEST)
if (portal.portal_membership.isAnonymousUser()):
RESPONSE.expireCookie('__ac', path='/')
is_user_account_blocked = REQUEST.get('is_user_account_blocked', False)
is_user_account_password_expired = REQUEST.get('is_user_account_password_expired', False)
if is_user_account_blocked:
message = context.Base_translateString('Account is blocked.')
elif is_user_account_password_expired:
if (portal.portal_preferences.isPreferredSystemRecoverExpiredPassword()):
message = context.Base_translateString('Password is expired. You will soon receive an email with details about how you can recover it.')
else:
message = context.Base_translateString('Password is expired.')
else:
credential_request = portal.portal_catalog(portal_type="Credential Request", reference=REQUEST.get('__ac_name'))
user = context.getPortalObject().portal_membership.getAuthenticatedMember()
context.log(user.getUserValue())
context.log(user.getLoginValue())
if credential_request and credential_request[0].getValidationStateTitle() == 'Draft':
message = context.Base_translateString('Please validate your account')
else:
message = context.Base_translateString('Can not connect')
url = '%s/login_form?portal_status_message=%s&notification_status=error' % (context.absolute_url(), message)
url = came_from and '%s&came_from=%s' % (url, came_from) or url
RESPONSE.redirect(url)
else:
# XXX How to warn user that password will expire?
# is_user_account_password_expired_expire_date = REQUEST.get('is_user_account_password_expired_expire_date', 0)
# XXX Hardcoded behaviour for JS app.
# Expect came_from to be an URL template
person = portal.portal_membership.getAuthenticatedMember().getUserValue()
url_parameter = "n.me"
pattern = '{[&|?]%s}' % url_parameter
if (person is None or not portal.portal_membership.checkPermission('View', person)):
came_from = re.sub(pattern, '', came_from)
else:
prefix = "&" if "&%s" % url_parameter in came_from else "?"
came_from = re.sub(pattern, '%s%s' % (prefix, make_query({url_parameter: person.getRelativeUrl()})), came_from)
# RESPONSE.redirect(came_from or context.getPermanentURL(context));
RESPONSE.setHeader('Location', came_from or context.getPermanentURL(context))
RESPONSE.setStatus(303)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>