def getExplanationText(self): # Returns an explanation of the movement o = self.getObject() if o is not None: # Get the delivery/order if not getattr(o, 'isDelivery', 0): delivery = o.getExplanationValue() else: # Additional inventory movements are catalogged in stock table # with the inventory's uid. Then they are their own explanation. delivery = o if delivery is not None: mapping = { 'delivery_portal_type' : delivery.getTranslatedPortalType(), 'delivery_title' : delivery.getTitleOrId() } causality = delivery.getCausalityValue() if causality is not None: mapping['causality_portal_type'] = causality.getTranslatedPortalType() mapping['causality_title'] = causality.getTitleOrId() return translateString( "${delivery_portal_type} ${delivery_title} " "(${causality_portal_type} ${causality_title})", mapping=mapping) else : return translateString("${delivery_portal_type} ${delivery_title}", mapping=mapping) return translateString('Unknown')
def addKeywordSearchStringField(column_id, column_title, default_search_key='ExactMatch'): addStringField(column_id, column_title) request_key = column_id field_id = 'your_%s_search_key' % column_id temp_form.manage_addField(field_id, column_title, 'ProxyField') field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict( form_id='Base_viewDialogFieldLibrary', field_id='your_category')) field._surcharged_edit(dict(title=translateString('${key} ${usage}', mapping=dict(key=translateString(column_title), usage=translateString('Search Key'))), description='', items=[(translateString('Default (${search_key})', mapping=dict(search_key= translateString(default_search_key))), ''), (translateString('Exact Match'), 'ExactMatch' ), (translateString('Keyword'), 'Keyword'), ]), ['title', 'items']) field._surcharged_tales( dict( default=TALESMethod( 'here/portal_selections/%s/%s_search_key | nothing' % (selection_name, request_key))), ['title', 'items', 'default'])
def getExplanationText(self): # Returns an explanation of the movement o = self.getObject() if o is not None: # Get the delivery/order if not getattr(o, 'isDelivery', 0): delivery = o.getExplanationValue() else: # Additional inventory movements are catalogged in stock table # with the inventory's uid. Then they are their own explanation. delivery = o if delivery is not None: mapping = { 'delivery_portal_type': delivery.getTranslatedPortalType(), 'delivery_title': delivery.getTitleOrId() } causality = delivery.getCausalityValue() if causality is not None: mapping[ 'causality_portal_type'] = causality.getTranslatedPortalType( ) mapping['causality_title'] = causality.getTitleOrId() return translateString( "${delivery_portal_type} ${delivery_title} " "(${causality_portal_type} ${causality_title})", mapping=mapping) else: return translateString( "${delivery_portal_type} ${delivery_title}", mapping=mapping) return translateString('Unknown')
def addKeywordSearchStringField(column_id, column_title, default_search_key='ExactMatch'): addStringField(column_id, column_title) request_key = column_id field_id = 'your_%s_search_key' % column_id if field_id not in temp_form.objectIds(): temp_form.manage_addField(field_id, column_title, 'ProxyField') field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict( form_id='Base_viewDialogFieldLibrary', field_id='your_category')) field._surcharged_edit(dict(title=translateString('${key} ${usage}', mapping=dict(key=translateString(column_title), usage=translateString('Search Key'))), description='', items=[(translateString('Default (${search_key})', mapping=dict(search_key= translateString(default_search_key))), ''), (translateString('Exact Match'), 'ExactMatch' ), (translateString('Keyword'), 'Keyword'), ]), ['title', 'items']) field._surcharged_tales( dict( default=TALESMethod( 'here/portal_selections/%s/%s_search_key | nothing' % (selection_name, request_key))), ['title', 'items', 'default'])
def _checkConsistency(self, fixit=False, filter=None, **kw): error_list = [] person = self.portal_catalog.getResultValue( reference=self.getReference(), portal_type="Person") if person is None: error_list.append("Person %s should be created" % self.getReference()) if fixit: person_module = self.getPortalObject().person_module person = person_module.newContent(portal_type="Person") group_id = getattr(aq_base(self), 'group_id', None) site_id = getattr(aq_base(self), 'site_id', None) business_configuration = self.getBusinessConfigurationValue() organisation_id = getattr(aq_base(self), 'organisation_id', None) if organisation_id is None: organisation_id = business_configuration.\ getGlobalConfigurationAttr('organisation_id') if organisation_id is not None: person.setCareerSubordination('organisation_module/%s' % \ organisation_id) # save person.edit( **{ 'default_email_text': self.getDefaultEmailText(), 'default_telephone_text': self.getDefaultTelephoneText(), 'first_name': self.getFirstName(), 'career_function': self.getFunction(), 'last_name': self.getLastName(), 'reference': self.getReference(), 'password': self.getPassword(), }) assignment = person.newContent(portal_type="Assignment", function=self.getFunction(), group=group_id, site=site_id) # Set dates are required to create valid assigments. now = DateTime() assignment.setStartDate(now) # XXX Is it required to set stop date? # Define valid for 10 years. assignment.setStopDate(now + (365 * 10)) # Validate the Person and Assigment person.validate( comment=translateString("Validated by Configurator")) assignment.open( comment=translateString("Open by Configuration")) ## add to customer template business_configuration = self.getBusinessConfigurationValue() self.install(person, business_configuration) return error_list
def _checkConsistency(self, fixit=False, filter=None, **kw): error_list = [] person_list = self.acl_users.searchUsers(id=self.Person_getUserId(), exact_match=True) if not person_list: error_list.append("Person %s should be created" % self.Person_getUserId()) if fixit: person_module = self.getPortalObject().person_module person = person_module.newContent(portal_type="Person") group_id = getattr(aq_base(self), 'group_id', None) site_id = getattr(aq_base(self), 'site_id', None) business_configuration = self.getBusinessConfigurationValue() organisation_id = getattr(aq_base(self), 'organisation_id', None) if organisation_id is None: organisation_id = business_configuration.\ getGlobalConfigurationAttr('organisation_id') if organisation_id is not None: person.setCareerSubordination('organisation_module/%s' % \ organisation_id) # save person.edit(**{'default_email_text': self.getDefaultEmailText(), 'default_telephone_text': self.getDefaultTelephoneText(), 'first_name': self.getFirstName(), 'career_function': self.getFunction(), 'last_name': self.getLastName(), 'reference': self.getReference(), }) assignment = person.newContent(portal_type="Assignment", function = self.getFunction(), group = group_id, site = site_id) login = person.newContent(portal_type='ERP5 Login', reference=self.getReference(), password=self.getPassword()) # Set dates are required to create valid assigments. now = DateTime() assignment.setStartDate(now) # XXX Is it required to set stop date? # Define valid for 10 years. assignment.setStopDate(now + (365*10)) # Validate the Person, Assigment and Login person.validate(comment=translateString("Validated by Configurator")) assignment.open(comment=translateString("Open by Configuration")) login.validate(comment=translateString("Validated by Configurator")) ## add to customer template business_configuration = self.getBusinessConfigurationValue() self.install(person, business_configuration) return error_list
def getBusinessProcessGraph(business_process): graph = dict(node=dict( start=dict(_class='erp5.business_process.start', name=str(translateString('Start'))), end=dict(_class='erp5.business_process.end', name=str(translateString('End'))), ), edge=dict()) for trade_state in portal.portal_categories.trade_state.getCategoryChildValueList( ): # XXX do we really want to display all trade states ? state_id = trade_state.getReference() or trade_state.getId() graph['node'][state_id] = dict( _class='erp5.business_process.trade_state', name=trade_state.getTranslatedTitle()) for state_id in graph['node'].keys(): if position_graph and state_id in position_graph['node']: graph['node'][state_id]['coordinate'] = position_graph['node'][ state_id]['coordinate'] if business_process in visited_business_process_set: return graph visited_business_process_set.add(business_process) for link in business_process.contentValues(portal_type='Business Link'): predecessor = 'start' if link.getPredecessor(): predecessor = link.getPredecessorReference( ) or link.getPredecessorId() successor = 'end' if link.getSuccessor(): successor = link.getSuccessorReference() or link.getSuccessorId() graph['edge'][link.getRelativeUrl()] = dict( _class='erp5.business_process.business_link', source=predecessor, destination=successor, name=link.getTranslatedTitle(), business_link_url=link.getRelativeUrl(), trade_phase=link.getTradePhase() or '') for specialise in [context] + business_process.getSpecialiseValueList( portal_type='Business Process'): specialise_graph = getBusinessProcessGraph(specialise) for node_id, node_data in specialise_graph['node'].items(): graph['node'].setdefault(node_id, node_data) for node_id, node_data in specialise_graph['edge'].items(): graph['edge'].setdefault(node_id, node_data) return graph
def _checkConsistency(self, fixit=False, filter=None, **kw): """ Setup organisation. """ if fixit: portal = self.getPortalObject() organisation = portal.organisation_module.newContent(portal_type="Organisation") org_dict = {'price_currency': 'currency_module/%s' % self.getPriceCurrency(), 'group': self.getGroup(), 'title': self.getTitle(), 'corporate_name': self.getCorporateName(), 'default_address_city': self.getDefaultAddressCity(), 'default_email_text': self.getDefaultEmailText(), 'default_telephone_text': self.getDefaultTelephoneText(), 'default_address_zip_code': self.getDefaultAddressZipCode(), 'default_address_region': self.getDefaultAddressRegion(), 'default_address_street_address': self.getDefaultAddressStreetAddress(), 'site':'main', # First customer's organisation is always main site. } organisation.edit(**org_dict) business_configuration = self.getBusinessConfigurationValue() # store globally organization_id business_configuration.setGlobalConfigurationAttr(organisation_id=organisation.getId()) if self.portal_workflow.isTransitionPossible(organisation, 'validate'): organisation.validate(comment=translateString("Validated by Configurator")) ## add to customer template self.install(organisation, business_configuration) return ['Organisation should be created',]
def _build(self, business_configuration): portal = self.getPortalObject() business_process_id = \ business_configuration.getGlobalConfigurationAttr('business_process_id') organisation_id = \ business_configuration.getGlobalConfigurationAttr('organisation_id') currency_id = \ business_configuration.getGlobalConfigurationAttr('currency_id') trade_condition = portal.purchase_trade_condition_module.newContent( portal_type="Purchase Trade Condition", reference=self.getReference(), title=self.getTitle(), ) trade_condition.setSpecialise("business_process_module/%s" %\ business_process_id) trade_condition.setDestination("organisation_module/%s" % organisation_id) trade_condition.setDestinationSection("organisation_module/%s" % organisation_id) trade_condition.setPriceCurrency("currency_module/%s" % currency_id) trade_condition.validate(comment=translateString("Validated by Configurator")) self.install(trade_condition, business_configuration)
def commit(self, changelog, added=(), modified=(), removed=()): """Commit local changes. """ context = self.aq_parent # Pysvn wants unicode objects if isinstance(changelog, str): changelog = changelog.decode('utf8') def getRevisionNumber(revision): # get the revision number from a revision, # with backward compatibility support try: return revision.getNumber() except AttributeError: return revision # In order not to commit deleted files in a separate commit, # we revert unselected files before committing everything recursively. selected_set = set(added) selected_set.update(modified) selected_set.update(removed) assert selected_set, "nothing to commit" self.revert('.', recurse=True, exclude_set=selected_set) revision = self._getClient().checkin('.', changelog, True) return context.REQUEST.RESPONSE.redirect( '%s/view?%s' % (context.absolute_url_path(), make_query(portal_status_message=translateString( 'Files committed successfully in revision ${revision}', mapping=dict(revision=getRevisionNumber(revision))))))
def getDeliverySolverTranslatedItemList(self, portal_type_list=None): """ """ return sorted([(translateString(x), 'portal_solvers/%s' % x) \ for x in self.getPortalDeliverySolverTypeList() \ if portal_type_list is None or x in portal_type_list], key=lambda x:str(x[0]))
def _checkConsistency(self, fixit=False, filter=None, **kw): portal = self.getPortalObject() error_list = [] for service_id, service_dict in iter(self.getConfigurationListList()): if isinstance(service_dict, basestring): warn( DeprecationWarning, "ServiceConfiguratorItem now use (service_id, service_dict) as configuration list" ) service_dict = dict(title=service_dict) document = getattr(portal.service_module, service_id, None) if document is None: error_list.append( self._createConstraintMessage( "Service %s should be created")) if fixit: document = portal.service_module.newContent( portal_type='Service', id=service_id, **service_dict) document.validate( comment=translateString("Validated by Configurator")) if document: ## add to customer template business_configuration = self.getBusinessConfigurationValue() self.install(document, business_configuration) return error_list
def displayParallelChangeMessage(): message = translateString( "Workflow state may have been updated by other user. Please try again." ) return context.Base_redirect(form_id, keep_items={'portal_status_message': message}, **kw)
def resetPassword(self, reset_key=None, REQUEST=None): """ """ # XXX-Aurel : is it used ? if REQUEST is None: REQUEST = get_request() user_login, expiration_date = self._password_request_dict.get(reset_key, (None, None)) site_url = self.getPortalObject().absolute_url() if REQUEST and 'came_from' in REQUEST: site_url = REQUEST.came_from if reset_key is None or user_login is None: ret_url = '%s/login_form' % site_url return REQUEST.RESPONSE.redirect( ret_url ) # check date current_date = DateTime() if current_date > expiration_date: msg = translateString("Date has expire.") parameter = urlencode(dict(portal_status_message=msg)) ret_url = '%s/login_form?%s' % (site_url, parameter) return REQUEST.RESPONSE.redirect( ret_url ) # redirect to form as all is ok REQUEST.set("password_key", reset_key) return self.reset_password_form(REQUEST=REQUEST)
def _build(self, business_configuration): portal = self.getPortalObject() business_process_id = \ business_configuration.getGlobalConfigurationAttr('business_process_id') organisation_id = \ business_configuration.getGlobalConfigurationAttr('organisation_id') currency_id = \ business_configuration.getGlobalConfigurationAttr('currency_id') trade_condition = portal.sale_trade_condition_module.newContent( portal_type="Sale Trade Condition", reference=self.getReference(), title=self.getTitle()) trade_condition.setSpecialise("business_process_module/%s" %\ business_process_id) trade_condition.setSource("organisation_module/%s" % organisation_id) trade_condition.setSourceSection("organisation_module/%s" % organisation_id) trade_condition.setPriceCurrency("currency_module/%s" % currency_id) trade_condition.validate(comment=translateString("Validated by Configurator")) self.install(trade_condition, business_configuration)
def _checkConsistency(self, fixit=False, filter=None, **kw): currency_module = self.getPortalObject().currency_module error_list = [] title = self.getTitle() reference = self.getReference() # XXX FIXME This is not exactly desired behaviour currency = self.portal_catalog.getResultValue(id=reference, portal_type="Currency") if currency is None: error_list.append(self._createConstraintMessage("Currency %s should be created" % reference)) if fixit: currency = currency_module.newContent( portal_type="Currency", id=reference, title=title, reference=reference, base_unit_quantity=self.getBaseUnitQuantity(), ) currency.validate(comment=translateString("Validated by Configurator")) if currency: business_configuration = self.getBusinessConfigurationValue() business_configuration.setGlobalConfigurationAttr(currency_id=currency.getId()) ## add to customer template self.install(currency, business_configuration) return error_list
def resetPassword(self, reset_key=None, REQUEST=None): """ """ # XXX-Aurel : is it used ? if REQUEST is None: REQUEST = get_request() user_login, expiration_date = self._password_request_dict.get( reset_key, (None, None)) site_url = self.getPortalObject().absolute_url() if REQUEST and 'came_from' in REQUEST: site_url = REQUEST.came_from if reset_key is None or user_login is None: ret_url = '%s/login_form' % site_url return REQUEST.RESPONSE.redirect(ret_url) # check date current_date = DateTime() if current_date > expiration_date: msg = translateString("Date has expire.") parameter = urlencode(dict(portal_status_message=msg)) ret_url = '%s/login_form?%s' % (site_url, parameter) return REQUEST.RESPONSE.redirect(ret_url) # redirect to form as all is ok REQUEST.set("password_key", reset_key) return self.reset_password_form(REQUEST=REQUEST)
def _checkConsistency(self, fixit=False, filter=None, **kw): if fixit: portal = self.getPortalObject() business_configuration = self.getBusinessConfigurationValue() business_process_id = \ business_configuration.getGlobalConfigurationAttr('business_process_id') organisation_id = \ business_configuration.getGlobalConfigurationAttr('organisation_id') currency_id = \ business_configuration.getGlobalConfigurationAttr('currency_id') trade_condition = portal.purchase_trade_condition_module.newContent( portal_type="Purchase Trade Condition", reference=self.getReference(), title=self.getTitle(), ) trade_condition.setSpecialise("business_process_module/%s" %\ business_process_id) trade_condition.setDestination("organisation_module/%s" % organisation_id) trade_condition.setDestinationSection("organisation_module/%s" % organisation_id) trade_condition.setPriceCurrency("currency_module/%s" % currency_id) trade_condition.validate(comment=translateString("Validated by Configurator")) self.install(trade_condition, business_configuration) return ['Purchase Trade Condition with reference %s should be created' % \ self.getReference(),]
def commit(self, changelog, added=(), modified=(), removed=()): """Commit local changes. """ context = self.aq_parent # Pysvn wants unicode objects if isinstance(changelog, str): changelog = changelog.decode('utf8') def getRevisionNumber(revision): # get the revision number from a revision, # with backward compatibility support try: return revision.getNumber() except AttributeError: return revision # In order not to commit deleted files in a separate commit, # we revert unselected files before committing everything recursively. selected_set = set(added) selected_set.update(modified) selected_set.update(removed) assert selected_set, "nothing to commit" self.revert('.', recurse=True, exclude_set=selected_set) revision = self._getClient().checkin('.', changelog, True) return context.REQUEST.RESPONSE.redirect('%s/view?%s' % ( context.absolute_url_path(), make_query(portal_status_message=translateString( 'Files committed successfully in revision ${revision}', mapping=dict(revision=getRevisionNumber(revision))))))
def _checkConsistency(self, fixit=False, filter=None, **kw): currency_module = self.getPortalObject().currency_module error_list = [] title = self.getTitle() reference = self.getReference() # XXX FIXME This is not exactly desired behaviour currency = self.portal_catalog.getResultValue(id=reference, portal_type="Currency") if currency is None: error_list.append( self._createConstraintMessage("Currency %s should be created" % reference)) if fixit: currency = currency_module.newContent( portal_type="Currency", id=reference, title=title, reference=reference, base_unit_quantity=self.getBaseUnitQuantity()) currency.validate( comment=translateString("Validated by Configurator")) if currency: business_configuration = self.getBusinessConfigurationValue() business_configuration.setGlobalConfigurationAttr( currency_id=currency.getId()) ## add to customer template self.install(currency, business_configuration) return error_list
def getBusinessProcessGraph(business_process): graph = dict(node=dict(start=dict(_class='erp5.business_process.start', name=str(translateString('Start'))), end=dict(_class='erp5.business_process.end', name=str(translateString('End'))),), edge=dict()) for trade_state in portal.portal_categories.trade_state.getCategoryChildValueList(): # XXX do we really want to display all trade states ? state_id = trade_state.getReference() or trade_state.getId() graph['node'][state_id] = dict( _class='erp5.business_process.trade_state', name=trade_state.getTranslatedTitle()) for state_id in graph['node'].keys(): if position_graph and state_id in position_graph['node']: graph['node'][state_id]['coordinate'] = position_graph['node'][state_id]['coordinate'] if business_process in visited_business_process_set: return graph visited_business_process_set.add(business_process) for link in business_process.contentValues(portal_type='Business Link'): predecessor = 'start' if link.getPredecessor(): predecessor = link.getPredecessorReference() or link.getPredecessorId() successor = 'end' if link.getSuccessor(): successor = link.getSuccessorReference() or link.getSuccessorId() graph['edge'][link.getRelativeUrl()] = dict( _class='erp5.business_process.business_link', source=predecessor, destination=successor, name=link.getTranslatedTitle(), business_link_url=link.getRelativeUrl(), trade_phase=link.getTradePhase() or '') for specialise in [context] + business_process.getSpecialiseValueList(portal_type='Business Process'): specialise_graph = getBusinessProcessGraph(specialise) for node_id, node_data in specialise_graph['node'].items(): graph['node'].setdefault(node_id, node_data) for node_id, node_data in specialise_graph['edge'].items(): graph['edge'].setdefault(node_id, node_data) return graph
def addKeywordSearchStringField(column_id, column_title, default_search_key="ExactMatch"): addStringField(column_id, column_title) request_key = column_id field_id = "your_%s_search_key" % column_id if field_id not in temp_form.objectIds(): temp_form.manage_addField(field_id, column_title, "ProxyField") field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict(form_id="Base_viewDialogFieldLibrary", field_id="your_category")) field._surcharged_edit( dict( title=translateString( "${key} ${usage}", mapping=dict(key=translateString(column_title), usage=translateString("Search Key")), ), description="", items=[ ( translateString( "Default (${search_key})", mapping=dict(search_key=translateString(default_search_key)) ), "", ), (translateString("Exact Match"), "ExactMatch"), (translateString("Keyword"), "Keyword"), ], ), ["title", "items"], ) field._surcharged_tales( dict( default=TALESMethod("here/portal_selections/%s/%s_search_key | nothing" % (selection_name, request_key)) ), ["title", "items", "default"], )
def _checkConsistency(self, fixit=False, filter=None, **kw): error_list = [ "Business Process %s should be created" % self.getReference(), ] if fixit: portal = self.getPortalObject() business_process = portal.business_process_module.newContent( portal_type="Business Process", reference=self.getReference(), title=self.getTitle()) business_configuration = self.getBusinessConfigurationValue() business_configuration.setGlobalConfigurationAttr(\ business_process_id=business_process.getId()) business_process_dict = self._getBusinessProcessDict() int_index = 0 for path_dict in business_process_dict["Trade Model Path"]: int_index += 1 path_dict.setdefault("int_index", int_index) title = path_dict.pop('title') trade_phase = path_dict.pop('trade_phase') trade_date = path_dict.pop('trade_date') for key in path_dict: if path_dict[key] is None: path_dict.pop(key) self._addTradeModelPath(business_process=business_process, title=title, trade_phase=trade_phase, trade_date=trade_date, **path_dict) int_index = 0 for link_dict in business_process_dict["Business Link"]: int_index += 1 link_dict.setdefault("int_index", int_index) title = link_dict.pop('title') trade_phase = link_dict.pop('trade_phase') delivery_builder = link_dict.pop('delivery_builder', None) predecessor = link_dict.pop('predecessor', None) successor = link_dict.pop('successor', None) for key in path_dict: if path_dict[key] is None: path_dict.pop(key) self._addBusinessLink(business_process=business_process, title=title, trade_phase=trade_phase, predecessor=predecessor, successor=successor, delivery_builder=delivery_builder, **link_dict) business_process.validate( comment=translateString('Validated by configurator')) self.install(business_process, business_configuration) return error_list
def changeUserPassword(self, password, password_key, password_confirm=None, user_login=None, REQUEST=None, **kw): """ Reset the password for a given login """ # BBB: password_confirm: unused argument def error(message): # BBB: should "raise Redirect" instead of just returning, simplifying # calling code and making mistakes more difficult # BBB: should probably not translate message when REQUEST is None message = translateString(message) if REQUEST is None: return message return REQUEST.RESPONSE.redirect( site_url + '/login_form?' + urlencode({ 'portal_status_message': message, })) if REQUEST is None: REQUEST = get_request() if self.getWebSiteValue(): site_url = self.getWebSiteValue().absolute_url() elif REQUEST and 'came_from' in REQUEST: site_url = REQUEST.came_from else: site_url = self.getPortalObject().absolute_url() try: register_user_login, expiration_date = self._password_request_dict[ password_key] except KeyError: # XXX: incorrect grammar and not descriptive enough return error('Key not known. Please ask reset password.') if user_login is not None and register_user_login != user_login: # XXX: not descriptive enough return error("Bad login provided.") if DateTime() > expiration_date: # XXX: incorrect grammar return error("Date has expire.") del self._password_request_dict[password_key] persons = self.getPortalObject().acl_users.erp5_users.getUserByLogin( register_user_login) person = persons[0] person._forceSetPassword(password) person.reindexObject() if REQUEST is not None: return REQUEST.RESPONSE.redirect( site_url + '/login_form?' + urlencode({ 'portal_status_message': translateString("Password changed."), }))
def changeUserPassword(self, password, password_key, password_confirm=None, user_login=None, REQUEST=None, **kw): """ Reset the password for a given login """ # check the key register_user_login, expiration_date = self._password_request_dict.get( password_key, (None, None)) current_date = DateTime() msg = None if REQUEST is None: REQUEST = get_request() site_url = self.getPortalObject().absolute_url() if REQUEST and 'came_from' in REQUEST: site_url = REQUEST.came_from if self.getWebSiteValue(): site_url = self.getWebSiteValue().absolute_url() if register_user_login is None: msg = "Key not known. Please ask reset password." elif user_login is not None and register_user_login != user_login: msg = translateString("Bad login provided.") elif current_date > expiration_date: msg = translateString("Date has expire.") if msg is not None: if REQUEST is not None: parameter = urlencode(dict(portal_status_message=msg)) ret_url = '%s/login_form?%s' % (site_url, parameter) return REQUEST.RESPONSE.redirect( ret_url ) else: return msg # all is OK, change password and remove it from request dict self._password_request_dict.pop(password_key) persons = self.getPortalObject().acl_users.erp5_users.getUserByLogin(register_user_login) person = persons[0] person._forceSetPassword(password) person.reindexObject() if REQUEST is not None: msg = translateString("Password changed.") parameter = urlencode(dict(portal_status_message=msg)) ret_url = '%s/login_form?%s' % (site_url, parameter) return REQUEST.RESPONSE.redirect( ret_url )
def _checkConsistency(self, fixit=False, filter=None, **kw): account_module = self.getPortalObject().account_module account = None account_id = getattr(self, 'account_id', None) error_list = [] error_list_append = lambda msg: error_list.append( self._createConstraintMessage(msg)) extra_kw = {} if account_id: extra_kw['id'] = account_id account = getattr(account_module, account_id, None) if account is None: error_list_append("Account %s should be created" % self.getTitle()) if fixit: account = account_module.newContent( portal_type='Account', title=self.getTitle(), account_type=self.getAccountType(), gap=self.getGap(), financial_section=self.getFinancialSection(), credit_account=self.isCreditAccount(), description=self.getDescription(), **extra_kw) else: error_list_append("Account %s should be updated" % account.getRelativeUrl()) if fixit: # Update existing account if (self.getAccountType() != account.getAccountType()) and \ (self.getFinancialSection() != account.getFinancialSection()): raise ValueError( "The Configurator is trying to overwrite previous configuration information (%s)" % account.getRelativeUrl()) account.edit(title=self.getTitle(), description=self.getDescription()) gap_list = account.getGapList() # Only include only the additional gap that do not collide. if self.getGap() not in gap_list: gap_list.append(self.getGap()) account.setGapList(gap_list) account.setCreditAccount(self.isCreditAccount()) if account and fixit: if self.portal_workflow.isTransitionPossible(account, 'validate'): account.validate( comment=translateString("Validated by Configurator")) ## add to customer template business_configuration = self.getBusinessConfigurationValue() self.install(account, business_configuration) return error_list
def _checkConsistency(self, fixit=False, filter=None, **kw): error_list = ["Business Process %s should be created" % self.getReference(),] if fixit: portal = self.getPortalObject() business_process = portal.business_process_module.newContent( portal_type="Business Process", reference=self.getReference(), title=self.getTitle()) business_configuration = self.getBusinessConfigurationValue() business_configuration.setGlobalConfigurationAttr(\ business_process_id=business_process.getId()) business_process_dict = self._getBusinessProcessDict() int_index = 0 for path_dict in business_process_dict["Trade Model Path"]: int_index += 1 path_dict.setdefault("int_index", int_index) title = path_dict.pop('title') trade_phase = path_dict.pop('trade_phase') trade_date = path_dict.pop('trade_date') for key in path_dict: if path_dict[key] is None: path_dict.pop(key) self._addTradeModelPath(business_process=business_process, title=title, trade_phase=trade_phase, trade_date=trade_date, **path_dict) int_index = 0 for link_dict in business_process_dict["Business Link"]: int_index += 1 link_dict.setdefault("int_index", int_index) title = link_dict.pop('title') trade_phase = link_dict.pop('trade_phase') delivery_builder = link_dict.pop('delivery_builder', None) predecessor = link_dict.pop('predecessor', None) successor = link_dict.pop('successor', None) for key in path_dict: if path_dict[key] is None: path_dict.pop(key) self._addBusinessLink(business_process=business_process, title=title, trade_phase = trade_phase, predecessor = predecessor, successor = successor, delivery_builder = delivery_builder, **link_dict) business_process.validate(comment=translateString('Validated by configurator')) self.install(business_process, business_configuration) return error_list
def changeUserPassword(self, password, password_key, password_confirm=None, user_login=None, REQUEST=None, **kw): """ Reset the password for a given login """ # BBB: password_confirm: unused argument def error(message): # BBB: should "raise Redirect" instead of just returning, simplifying # calling code and making mistakes more difficult # BBB: should probably not translate message when REQUEST is None message = translateString(message) return redirect(REQUEST, site_url, message) if REQUEST is None: REQUEST = get_request() if self.getWebSiteValue(): site_url = self.getWebSiteValue().absolute_url() elif REQUEST and 'came_from' in REQUEST: site_url = REQUEST.came_from else: site_url = self.getPortalObject().absolute_url() try: register_user_login, expiration_date = self._password_request_dict[ password_key] except (KeyError, TypeError): # XXX: incorrect grammar and not descriptive enough return error('Key not known. Please ask reset password.') if user_login is not None and register_user_login != user_login: # XXX: not descriptive enough return error("Bad login provided.") if DateTime() > expiration_date: # XXX: incorrect grammar return error("Date has expire.") del self._password_request_dict[password_key] portal = self.getPortalObject() user_dict, = portal.acl_users.searchUsers( login=register_user_login, exact_match=True, ) login_dict, = user_dict['login_list'] login = portal.unrestrictedTraverse(login_dict['path']) login.checkPasswordValueAcceptable( password) # this will raise if password does not match policy login._forceSetPassword(password) login.reindexObject() return redirect(REQUEST, site_url, translateString("Password changed."))
def error(message): # BBB: should "raise Redirect" instead of just returning, simplifying # calling code and making mistakes more difficult # BBB: should probably not translate message when REQUEST is None message = translateString(message) if REQUEST is None: return message return REQUEST.RESPONSE.redirect( site_url + '/login_form?' + urlencode({ 'portal_status_message': message, }) )
def error(message): # BBB: should "raise Redirect" instead of just returning, simplifying # calling code and making mistakes more difficult # BBB: should probably not translate message when REQUEST is None message = translateString(message) if REQUEST is None: return message return REQUEST.RESPONSE.redirect( site_url + '/login_form?' + urlencode({ 'portal_status_message': message, }))
def addDateTimeField(field_id, field_title): request_key = field_id field_id = 'your_%s' % field_id temp_form.manage_addField(field_id, field_title, 'ProxyField') field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict( form_id='Base_viewDialogFieldLibrary', field_id='your_date')) field._surcharged_edit(dict(title=field_title), ['title']) field._surcharged_tales( dict(default=TALESMethod( 'here/portal_selections/%s/%s_value_ | nothing' % (selection_name, request_key))), ['title', 'default']) field_id = 'your_%s_usage_' % request_key temp_form.manage_addField(field_id, field_title, 'ProxyField') field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict( form_id='Base_viewDialogFieldLibrary', field_id='your_category')) field._surcharged_edit(dict(title=translateString('${key} ${usage}', mapping=dict(key=translateString(column_title), usage=translateString('Usage'))), items=[(translateString('Equals To'), ''), (translateString('Greater Than'), 'min'), (translateString('Less Than'),'max'), (translateString('Not Greater Than'), 'ngt'), (translateString('Not Less Than'), 'nlt'), ]), ['title', 'items']) field._surcharged_tales( dict( default=TALESMethod( 'here/portal_selections/%s/%s_usage_ | nothing' % (selection_name, request_key))), ['title', 'items', 'default'])
def report(field_type, message, mapping=None, field_category='', level=None): if level and level not in displayed_report: return detailed_report_append(newTempBase( folder=context, id='item', field_type=field_type, field_category=field_category, field_message=translateString( message, mapping=mapping, ), ))
def changeUserPassword(self, password, password_key, password_confirm=None, user_login=None, REQUEST=None, **kw): """ Reset the password for a given login """ # BBB: password_confirm: unused argument def error(message): # BBB: should "raise Redirect" instead of just returning, simplifying # calling code and making mistakes more difficult # BBB: should probably not translate message when REQUEST is None message = translateString(message) if REQUEST is None: return message return REQUEST.RESPONSE.redirect( site_url + '/login_form?' + urlencode({ 'portal_status_message': message, }) ) if REQUEST is None: REQUEST = get_request() if self.getWebSiteValue(): site_url = self.getWebSiteValue().absolute_url() elif REQUEST and 'came_from' in REQUEST: site_url = REQUEST.came_from else: site_url = self.getPortalObject().absolute_url() try: register_user_login, expiration_date = self._password_request_dict[ password_key] except KeyError: # XXX: incorrect grammar and not descriptive enough return error('Key not known. Please ask reset password.') if user_login is not None and register_user_login != user_login: # XXX: not descriptive enough return error("Bad login provided.") if DateTime() > expiration_date: # XXX: incorrect grammar return error("Date has expire.") del self._password_request_dict[password_key] persons = self.getPortalObject().acl_users.erp5_users.getUserByLogin( register_user_login) person = persons[0] person._forceSetPassword(password) person.reindexObject() if REQUEST is not None: return REQUEST.RESPONSE.redirect( site_url + '/login_form?' + urlencode({ 'portal_status_message': translateString("Password changed."), }) )
def _build(self, business_configuration): portal = self.getPortalObject() person = portal.person_module.newContent(portal_type="Person") group_id = getattr(aq_base(self), 'group_id', None) site_id = getattr(aq_base(self), 'site_id', None) if getattr(aq_base(self), 'organisation_id', None) is not None: person.setCareerSubordination('organisation_module/%s' % \ self.organisation_id) # save person.edit(**{'default_email_text': self.getDefaultEmailText(), 'default_telephone_text': self.getDefaultTelephoneText(), 'first_name': self.getFirstName(), 'career_function': self.getFunction(), 'last_name': self.getLastName(), 'reference': self.getReference(), 'password': self.getPassword(), }) assignment = person.newContent(portal_type="Assignment", function = self.getFunction(), group = group_id, site = site_id) # Set dates are required to create valid assigments. now = DateTime() assignment.setStartDate(now) # XXX Is it required to set stop date? # Define valid for 10 years. assignment.setStopDate(now + (365*10)) # Validate the Person and Assigment person.validate(comment=translateString("Validated by Configurator")) assignment.open(comment=translateString("Open by Configuration")) ## add to customer template self.install(person, business_configuration)
def report(field_type, message, mapping=None, field_category='', level=None): if level and level not in displayed_report: return detailed_report_append( newTempBase( folder=context, id='item', field_type=field_type, field_category=field_category, field_message=translateString( message, mapping=mapping, ), ))
def _checkConsistency(self, fixit=False, filter=None, **kw): account_module = self.getPortalObject().account_module account = None account_id = getattr(self, 'account_id', None) error_list = [] error_list_append = lambda msg: error_list.append( self._createConstraintMessage(msg)) extra_kw = {} if account_id: extra_kw['id'] = account_id account = getattr(account_module, account_id, None) if account is None: error_list_append("Account %s should be created" % self.getTitle()) if fixit: account = account_module.newContent( portal_type='Account', title=self.getTitle(), account_type=self.getAccountType(), gap=self.getGap(), financial_section=self.getFinancialSection(), credit_account=self.isCreditAccount(), description=self.getDescription(), **extra_kw) else: error_list_append("Account %s should be updated" % account.getRelativeUrl()) if fixit: # Update existing account if (self.getAccountType() != account.getAccountType()) and \ (self.getFinancialSection() != account.getFinancialSection()): raise ValueError("The Configurator is trying to overwrite previous configuration information (%s)" % account.getRelativeUrl()) account.edit(title=self.getTitle(), description=self.getDescription()) gap_list = account.getGapList() # Only include only the additional gap that do not collide. if self.getGap() not in gap_list: gap_list.append(self.getGap()) account.setGapList(gap_list) account.setCreditAccount(self.isCreditAccount()) if account and fixit: if self.portal_workflow.isTransitionPossible(account, 'validate'): account.validate(comment=translateString("Validated by Configurator")) ## add to customer template business_configuration = self.getBusinessConfigurationValue() self.install(account, business_configuration) return error_list
def _checkConsistency(self, fixit=False, **kw): if fixit: portal = self.getPortalObject() business_configuration = self.getBusinessConfigurationValue() business_process_id = \ business_configuration.getGlobalConfigurationAttr('sale_business_process_id') or\ business_configuration.getGlobalConfigurationAttr('business_process_id') organisation_id = \ business_configuration.getGlobalConfigurationAttr('organisation_id') currency_id = \ business_configuration.getGlobalConfigurationAttr('currency_id') bank_account_id = \ business_configuration.getGlobalConfigurationAttr('bank_account_id') trade_condition = portal.sale_trade_condition_module.newContent( portal_type="Sale Trade Condition", reference=self.getReference(), title=self.getTitle()) trade_condition.setSpecialise("business_process_module/%s" %\ business_process_id) trade_condition.setSource("organisation_module/%s" % organisation_id) trade_condition.setSourceSection("organisation_module/%s" % organisation_id) trade_condition.setPriceCurrency("currency_module/%s" % currency_id) trade_condition.setSourceDecision("organisation_module/%s" % organisation_id) trade_condition.setSourceAdministration("organisation_module/%s" % organisation_id) trade_condition.setSourcePayment( "organisation_module/%s/%s" % (organisation_id, bank_account_id)) trade_condition.validate( comment=translateString("Validated by Configurator")) self.install(trade_condition, business_configuration) return [self._createConstraintMessage('Sale Trade Condition with reference %s should be created' % \ self.getReference(),)]
def _build(self, business_configuration): portal = self.getPortalObject() for service_id, service_dict in iter(self.getConfigurationListList()): if isinstance(service_dict, basestring): warn(DeprecationWarning, "ServiceConfiguratorItem now use (service_id, service_dict) as configuration list") service_dict = dict(title=service_dict) document = getattr(portal.service_module, service_id, None) if document is None: document = portal.service_module.newContent(portal_type='Service', id=service_id, **service_dict) document.validate(comment=translateString("Validated by Configurator")) ## add to customer template self.install(document, business_configuration)
def getReportSectionListForObject(doc): """ Get all possible report section for object. """ report_section_list = [] doc = doc.getObject() title = doc.getTitle() report_section_list.append(ReportSection(level = 1, title = title, form_id = None)) for action in portal.portal_actions.listFilteredActionsFor(doc)['object_view']: form_id = action['url'].split('/')[-1].split('?')[0] action_title = action['title'] if action_title != 'History' and action_title != 'Metadata': report_section_list.append(ReportSection(path = doc.getPath(), form_id = form_id, level = 2, title = '%s - %s' % (title, translateString(action_title)))) return report_section_list
def _checkConsistency(self, fixit=False, **kw): organisation_module = self.getPortalObject().organisation_module error_list = [] business_configuration = self.getBusinessConfigurationValue() organisation_id = business_configuration.\ getGlobalConfigurationAttr('organisation_id') organisation = organisation_module.get(organisation_id, None) if organisation is not None: bank_account_list = organisation.objectValues(portal_type='Bank Account') if not bank_account_list: error_list.append(self._createConstraintMessage( "Bank Account should be created")) if fixit: bank_account = organisation.newContent(portal_type="Bank Account") now = DateTime() start_date = self.getStartDate(now) stop_date = self.getStopDate(now + (365*10)) bank_dict = {'bank_account_holder_name' : self.getBankAccountHolderName(), 'title': self.getTitle(), 'bank_account_key': self.getBankAccountKey(), 'bank_account_number': self.getBankAccountNumber(), 'bank_code': self.getBankCode(), 'bank_country_code': self.getBankCountryCode(), 'bic_code': self.getBicCode(), 'branch': self.getBranch(), 'iban': self.getIban(), 'internal_bank_account_number': self.getInternalBankAccountNumber(), 'overdraft_facility': self.getOverdraftFacility(), 'start_date': start_date, 'stop_date': stop_date, } bank_account.edit(**bank_dict) # store globally bank_account_id business_configuration.setGlobalConfigurationAttr(bank_account_id=bank_account.getId()) if self.portal_workflow.isTransitionPossible(bank_account, 'validate'): bank_account.validate(comment=translateString("Validated by Configurator")) return error_list
def _checkConsistency(self, fixit=False, filter=None, **kw): organisation_module = self.getPortalObject().organisation_module error_list = [] business_configuration = self.getBusinessConfigurationValue() organisation_id = business_configuration.\ getGlobalConfigurationAttr('organisation_id') organisation = organisation_module.get(organisation_id, None) if organisation is not None: bank_account_list = organisation.objectValues(portal_type='Bank Account') if not bank_account_list: error_list.append(self._createConstraintMessage( "Bank Account should be created")) if fixit: bank_account = organisation.newContent(portal_type="Bank Account") now = DateTime() start_date = self.getStartDate(now) stop_date = self.getStopDate(now + (365*10)) bank_dict = {'bank_account_holder_name' : self.getBankAccountHolderName(), 'title': self.getTitle(), 'bank_account_key': self.getBankAccountKey(), 'bank_account_number': self.getBankAccountNumber(), 'bank_code': self.getBankCode(), 'bank_country_code': self.getBankCountryCode(), 'bic_code': self.getBicCode(), 'branch': self.getBranch(), 'iban': self.getIban(), 'internal_bank_account_number': self.getInternalBankAccountNumber(), 'overdraft_facility': self.getOverdraftFacility(), 'start_date': start_date, 'stop_date': stop_date, } bank_account.edit(**bank_dict) # store globally bank_account_id business_configuration.setGlobalConfigurationAttr(bank_account_id=bank_account.getId()) if self.portal_workflow.isTransitionPossible(bank_account, 'validate'): bank_account.validate(comment=translateString("Validated by Configurator")) return error_list
def _build(self, business_configuration): account_module = self.getPortalObject().account_module account = None account_id = getattr(self, 'account_id', None) extra_kw = {} if account_id: extra_kw['id'] = account_id account = getattr(account_module, account_id, None) if account is None: account = account_module.newContent( portal_type='Account', title=self.getTitle(), account_type=self.getAccountType(), gap=self.getGap(), financial_section=self.getFinancialSection(), credit_account=self.isCreditAccount(), description=self.getDescription(), **extra_kw) else: # Update existing account if (self.getAccountType() != account.getAccountType()) and \ (self.getFinancialSection() != account.getFinancialSection()): raise ValueError( "The Configurator is trying to overwrite previous configuration information (%s)" % account.getRelativeUrl()) account.edit(title=self.getTitle(), description=self.getDescription()) gap_list = account.getGapList() # Only include only the additional gap that do not collide. if self.getGap() not in gap_list: gap_list.append(self.getGap()) account.setGapList(gap_list) account.setCreditAccount(self.isCreditAccount()) if self.portal_workflow.isTransitionPossible(account, 'validate'): account.validate( comment=translateString("Validated by Configurator")) ## add to customer template self.install(account, business_configuration)
def _build(self, business_configuration): currency_module = self.getPortalObject().currency_module title = self.getTitle() reference = self.getReference() base_unit_quantity = self.getBaseUnitQuantity() # XXX FIXME This is not exactly desired behaviour currency = self.portal_catalog.getResultValue(id=reference, portal_type="Currency") if currency is None: currency = currency_module.newContent(portal_type = "Currency", id = reference, title = title, reference = reference, base_unit_quantity = base_unit_quantity) currency.validate(comment=translateString("Validated by Configurator")) business_configuration.setGlobalConfigurationAttr(currency_id=currency.getId()) ## add to customer template self.install(currency, business_configuration)
def _build(self, business_configuration): portal = self.getPortalObject() for service_id, service_dict in iter(self.getConfigurationListList()): if isinstance(service_dict, basestring): warn( DeprecationWarning, "ServiceConfiguratorItem now use (service_id, service_dict) as configuration list" ) service_dict = dict(title=service_dict) document = getattr(portal.service_module, service_id, None) if document is None: document = portal.service_module.newContent( portal_type='Service', id=service_id, **service_dict) document.validate( comment=translateString("Validated by Configurator")) ## add to customer template self.install(document, business_configuration)
def getReportSectionListForObject(doc): """ Get all possible report section for object. """ report_section_list = [] doc = doc.getObject() title = doc.getTitle() report_section_list.append( ReportSection(level=1, title=title, form_id=None)) for action in portal.portal_actions.listFilteredActionsFor( doc)['object_view']: form_id = action['url'].split('/')[-1].split('?')[0] action_title = action['title'] if action_title != 'History' and action_title != 'Metadata': report_section_list.append( ReportSection(path=doc.getPath(), form_id=form_id, level=2, title='%s - %s' % (title, translateString(action_title)))) return report_section_list
def addFloatField(field_id, field_title): request_key = field_id field_id = 'your_%s' % field_id if field_id not in temp_form.objectIds(): temp_form.manage_addField(field_id, field_title, 'ProxyField') field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict( form_id='Base_viewDialogFieldLibrary', field_id='your_money_quantity')) field._surcharged_edit(dict(title=field_title), ['title']) field._surcharged_tales( dict(default=TALESMethod( 'here/portal_selections/%s/%s_value_ | nothing' % (selection_name, request_key))), ['title', 'default']) field_id = 'your_%s_usage_' % request_key if field_id not in temp_form.objectIds(): temp_form.manage_addField(field_id, field_title, 'ProxyField') field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict( form_id='Base_viewDialogFieldLibrary', field_id='your_category')) field._surcharged_edit(dict( title=translateString('${key} ${usage}', mapping=dict(key=translateString(column_title), usage=translateString('Usage'))), items=[(translateString('Equals To'), ''), (translateString('Greater Than'), 'min'), (translateString('Less Than'),'max'), (translateString('Not Greater Than'), 'ngt'), (translateString('Not Less Than'), 'nlt'), ]), ['title', 'items']) field._surcharged_tales( dict( default=TALESMethod( 'here/portal_selections/%s/%s_usage_ | nothing' % (selection_name, request_key))), ['title', 'items', 'default'])
def _build(self, business_configuration): currency_module = self.getPortalObject().currency_module title = self.getTitle() reference = self.getReference() base_unit_quantity = self.getBaseUnitQuantity() # XXX FIXME This is not exactly desired behaviour currency = self.portal_catalog.getResultValue(id=reference, portal_type="Currency") if currency is None: currency = currency_module.newContent( portal_type="Currency", id=reference, title=title, reference=reference, base_unit_quantity=base_unit_quantity) currency.validate( comment=translateString("Validated by Configurator")) business_configuration.setGlobalConfigurationAttr( currency_id=currency.getId()) ## add to customer template self.install(currency, business_configuration)
def _build(self, business_configuration): account_module = self.getPortalObject().account_module account = None account_id = getattr(self, 'account_id', None) extra_kw = {} if account_id: extra_kw['id'] = account_id account = getattr(account_module, account_id, None) if account is None: account = account_module.newContent( portal_type='Account', title=self.getTitle(), account_type=self.getAccountType(), gap=self.getGap(), financial_section=self.getFinancialSection(), credit_account=self.isCreditAccount(), description=self.getDescription(), **extra_kw) else: # Update existing account if (self.getAccountType() != account.getAccountType()) and \ (self.getFinancialSection() != account.getFinancialSection()): raise ValueError("The Configurator is trying to overwrite previous configuration information (%s)" % account.getRelativeUrl()) account.edit(title=self.getTitle(), description=self.getDescription()) gap_list = account.getGapList() # Only include only the additional gap that do not collide. if self.getGap() not in gap_list: gap_list.append(self.getGap()) account.setGapList(gap_list) account.setCreditAccount(self.isCreditAccount()) if self.portal_workflow.isTransitionPossible(account, 'validate'): account.validate(comment=translateString("Validated by Configurator")) ## add to customer template self.install(account, business_configuration)
def _checkConsistency(self, fixit=False, filter=None, **kw): portal = self.getPortalObject() error_list = [] for service_id, service_dict in iter(self.getConfigurationListList()): if isinstance(service_dict, basestring): warn(DeprecationWarning, "ServiceConfiguratorItem now use (service_id, service_dict) as configuration list") service_dict = dict(title=service_dict) document = getattr(portal.service_module, service_id, None) if document is None: error_list.append(self._createConstraintMessage( "Service %s should be created")) if fixit: document = portal.service_module.newContent(portal_type='Service', id=service_id, **service_dict) document.validate(comment=translateString("Validated by Configurator")) if document: ## add to customer template business_configuration = self.getBusinessConfigurationValue() self.install(document, business_configuration) return error_list
def addDateTimeField(field_id, field_title): request_key = field_id field_id = "your_%s" % field_id if field_id not in temp_form.objectIds(): temp_form.manage_addField(field_id, field_title, "ProxyField") field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict(form_id="Base_viewDialogFieldLibrary", field_id="your_date")) field._surcharged_edit(dict(title=field_title), ["title"]) field._surcharged_tales( dict(default=TALESMethod("here/portal_selections/%s/%s_value_ | nothing" % (selection_name, request_key))), ["title", "default"], ) field_id = "your_%s_usage_" % request_key if field_id not in temp_form.objectIds(): temp_form.manage_addField(field_id, field_title, "ProxyField") field = temp_form._getOb(field_id) field.manage_edit_xmlrpc(dict(form_id="Base_viewDialogFieldLibrary", field_id="your_category")) field._surcharged_edit( dict( title=translateString( "${key} ${usage}", mapping=dict(key=translateString(column_title), usage=translateString("Usage")) ), items=[ (translateString("Equals To"), ""), (translateString("Greater Than"), "min"), (translateString("Less Than"), "max"), (translateString("Not Greater Than"), "ngt"), (translateString("Not Less Than"), "nlt"), ], ), ["title", "items"], ) field._surcharged_tales( dict(default=TALESMethod("here/portal_selections/%s/%s_usage_ | nothing" % (selection_name, request_key))), ["title", "items", "default"], )
from Products.ERP5Type.Message import translateString context.Base_addEditWorkflowComment( comment=translateString('Select non reconciled transactions finished'))
'''Adds accounting transaction lines in an accounting transaction and redirects to the accounting transaction view which is easier to use. ''' from Products.ERP5Type.Message import translateString for _ in range(line_count): context.newContent(portal_type=line_portal_type) return context.Base_redirect( form_id, keep_items={ 'portal_status_message': translateString('Accounting Transaction Lines added.') })
else: skin_folder.manage_changeProperties({"business_template_skin_layer_priorty": skin_layer_priority}) if skin_layer_list: all_skin_layers_selected = len(skin_layer_list) == len(portal.portal_skins.getSkinPaths()) for skin_name, selection in portal.portal_skins.getSkinPaths(): if skin_name in skin_layer_list: selection = selection.split(",") if skin_folder_name not in selection: portal.portal_skins.manage_skinLayers( skinpath=[skin_folder_name] + list(selection), skinname=skin_name, add_skin=1 ) if not all_skin_layers_selected: registered_skin = "%s | %s" % (skin_folder_name, skin_name) registered_skin_selection_list = context.getTemplateRegisteredSkinSelectionList() or [] if registered_skin not in registered_skin_selection_list: context.setTemplateRegisteredSkinSelectionList( tuple(registered_skin_selection_list) + (registered_skin,) ) if not all_skin_layers_selected: marker = [] if skin_folder.getProperty("business_template_registered_skin_selections", marker) is marker: skin_folder.manage_addProperty( "business_template_registered_skin_selections", " ".join(skin_layer_list), "tokens" ) else: skin_folder.manage_changeProperties({"business_template_registered_skin_selections": skin_layer_list}) return context.Base_redirect(form_id, keep_items={"portal_status_message": translateString("Skin folder created.")})
kw = {} request = container.REQUEST for k in 'added', 'modified', 'removed': file_list = request.get(k, ()) # XXX: ERP5VCS_doCreateJavaScriptStatus should send lists if isinstance(file_list, basestring): file_list = file_list != 'none' and filter(None, file_list.split(',')) or () kw[k] = file_list changelog = request.get('changelog', '') if not changelog.strip(): from Products.ERP5Type.Message import translateString error_msg = "Please set a ChangeLog message." request.set('portal_status_message', translateString(error_msg)) request.set('cancel_url', context.absolute_url() + '/BusinessTemplate_viewVcsStatus?do_extract:int=0' '&portal_status_message=Commit%20cancelled.') return context.asContext(**kw).BusinessTemplate_viewVcsChangelog() try: return context.getVcsTool().commit(changelog, **kw) except Exception, error: return context.BusinessTemplate_handleException(error, script.id)
# override_logo_reference use as document header logo # # include_content_table include table of content (True*) # include_history_table include history/authors (XXX not done) # include_reference_table include table of links/images/tables # include_linked_content embed content of linked documents # include_report_content embed content of report documents # # display_svg format for svg images (svg, png*) from Products.ERP5Type.Message import translateString if dialog_id is not None: return context.Base_redirect( dialog_id, keep_items = dict( portal_status_message=translateString('Preview updated.'), cancel_url=cancel_url, portal_skin=portal_skin, format=format, display_svg=display_svg, document_save=document_save, document_download=document_download, override_document_description=override_document_description, override_document_short_title=override_document_short_title, override_document_title=override_document_title, override_document_version=override_document_version, override_logo_reference=override_logo_reference, override_source_person_title=override_source_person_title, override_document_reference=override_document_reference, override_source_organisation_title=override_source_organisation_title, transformation=transformation,