def __setProfilePage(self, agent_id): """Set the Agents Profile Page for this language -split @@params away from the views url @return: True or False """ #prepare link destination link_list = self.request['ACTUAL_URL'].split('@@') link=link_list[0] if not (len(link)): msg = _( u"We could not find a valid link to the Profile Page" ) msg_type = 'error' self.context.plone_utils.addPortalMessage(msg, msg_type) return False language = self.language # "field" is the language depending form field in the memberdata if language =='en': field = "agent_profile_en" elif language =='es': field = "agent_profile_es" elif language =='de': field = "agent_profile_de" else: msg = _( u"Currently we don't support this content language for AgentProfile Pages" ) msg_type = 'error' self.context.plone_utils.addPortalMessage(msg, msg_type) return False #update the Agents Member data if(len(agent_id)>0): membership = getToolByName(self.context, 'portal_membership') member = membership.getMemberById(agent_id) member.setMemberProperties(mapping={field:link}) msg = _( u"Agents Profile Page updated!" ) msg_type = 'info' self.context.plone_utils.addPortalMessage(msg, msg_type) return True else: msg = _( u"No Agent Id found" ) msg_type = 'error' self.context.plone_utils.addPortalMessage(msg, msg_type) return False
def __call__(self): msg_type = 'info' if IAgentProfile.providedBy(self.context): # Deactivate AgentProfile viewlet. noLongerProvides(self.context, IAgentProfile) self.context.reindexObject(idxs=['object_provides', ]) # unset marker interface for parent folder pf = self.context.aq_parent noLongerProvides(pf, IAgentFolder) pf.reindexObject(idxs=['object_provides', ]) msg = _(u"'AgentProfile' viewlet deactivated.") elif IPossibleAgentProfile.providedBy(self.context): alsoProvides(self.context, IAgentProfile) if ps_mls: #deactivate Localagency info for AgentProfilePage noLongerProvides(self.context, ILocalAgencyInfo) self.context.reindexObject(idxs=['object_provides', ]) # set marker interface for parent folder pf = self.context.aq_parent if INavigationRoot.providedBy(pf): """set message for incorrect parent folder""" pf_warn = _( u"The AgentFolder setting could not be set " u"bcause the Navigation root was found as parent folder." u"Please make sure you work in the correct location!" ) self.context.plone_utils.addPortalMessage(pf_warn, 'error') else: alsoProvides(pf, IAgentFolder) pf.reindexObject(idxs=['object_provides', ]) pf_suc = _( u"Agentfolder updated!" ) self.context.plone_utils.addPortalMessage(pf_suc, 'info') msg = _(u"'AgentProfile' viewlet activated.") else: msg = _( u"The 'AgentProfile' viewlet does't work with this content " u"type. Add 'IPossibleAgentProfile' to the provided " u"interfaces to enable this feature." ) msg_type = 'error' self.context.plone_utils.addPortalMessage(msg, msg_type) self.request.response.redirect(self.context.absolute_url())
def __getAgentProfilePage(self, agent_id=''): """Find the language-dependend AgentProfilePage @return: ProfilePage object or False """ language = self.language # "field" is the language depending form field in the memberdata if language =='en': field = "agent_profile_en" elif language =='es': field = "agent_profile_es" elif language =='de': field = "agent_profile_de" else: msg = _( u"Your Language is not supported yet. As fallback we will use the english version" ) msg_type = 'info' self.context.plone_utils.addPortalMessage(msg, msg_type) field = "agent_profile_en" if(len(agent_id)>0): membership = getToolByName(self.context, 'portal_membership') agent = membership.getMemberById(agent_id) ProfileAgent = {} profile_link = agent.getProperty(field) if(len(profile_link)>0): ProfileAgent['status'] = 'normal' ProfileAgent['url'] = profile_link ProfileAgent['language'] = language return ProfileAgent else: ProfileAgent['status'] = 'fallback' if(len(agent.getProperty("agent_profile_en"))>0): ProfileAgent['url'] = agent.getProperty("agent_profile_en") ProfileAgent['language'] = 'en' return ProfileAgent if(len(agent.getProperty("agent_profile_es"))>0): ProfileAgent['url'] = agent.getProperty("agent_profile_es") ProfileAgent['language'] = 'es' return ProfileAgent if(len(agent.getProperty("agent_profile_de"))>0): ProfileAgent['url'] = agent.getProperty("agent_profile_de") ProfileAgent['language'] = 'de' return ProfileAgent #we dont have a normal or fallback page, return False return False else: return False
def __call__(self): msg_type = 'info' if IAgentSearch.providedBy(self.context): # Deactivate AgentProfile viewlet. noLongerProvides(self.context, IAgentSearch) self.context.reindexObject(idxs=['object_provides', ]) msg = _(u"'AgentSearch' viewlet deactivated.") elif IPossibleAgentSearch.providedBy(self.context): alsoProvides(self.context, IAgentSearch) self.context.reindexObject(idxs=['object_provides', ]) msg = _(u"'AgentSearch' viewlet activated.") else: msg = _( u"The 'AgentSearch' viewlet does't work with this content " u"type. Add 'IPossibleAgentProfile' to the provided " u"interfaces to enable this feature." ) msg_type = 'error' self.context.plone_utils.addPortalMessage(msg, msg_type) self.request.response.redirect(self.context.absolute_url())