コード例 #1
0
ファイル: api.py プロジェクト: zcashero/plone.mls.listing
def _local_agency_info(context):
    """Get local agency information."""
    settings = None
    obj = context
    while not IPloneSiteRoot.providedBy(obj) and not ILocalAgencyInfo.providedBy(obj):
        parent = aq_parent(aq_inner(obj))
        if parent is None:
            return
        obj = parent
    if ILocalAgencyInfo.providedBy(obj):
        annotations = IAnnotations(obj)
        settings = annotations.get(CONFIGURATION_KEY, annotations.setdefault(CONFIGURATION_KEY, {}))
    return settings
    def _update_AgentInfoPortlet_ProfilePage(self, folders, data):
        """Override Annotation for plone.mls.listing AgentInfo inside AgentProfilePages"""
        #get agents portrait/ avatar url
        avatar_url = self.membershiptool.getPersonalPortrait(id=self.userid).absolute_url()
        #get AgencyInfo
        agency = self.__AgencyInfo

        for folder in folders:

            if IAgentFolder.providedBy(folder) and ILocalAgencyInfo.providedBy(folder):
                #get annotations for this folder
                mls_ano = IAnnotations(folder).get("plone.mls.listing.localagencyinfo", None)

                if mls_ano is None:
                    #initialize Annotations
                    anno = IAnnotations(folder)
                    anno.get("plone.mls.listing.localagencyinfo", anno.setdefault("plone.mls.listing.localagencyinfo", {}))
                    mls_ano = IAnnotations(folder).get("plone.mls.listing.localagencyinfo", {})

                # set global Agency Info
                mls_ano['agency_name'] = agency.get('agency_name', u'Krain Real Estate')
                mls_ano['agency_logo_url'] = agency.get('agency_logo_url', u'')
                mls_ano['agency_office_phone'] = agency.get('agency_office_phone', u'')
                mls_ano['agency_website'] = agency.get('agency_website', u'')
                
                #Agent Info
                mls_ano['agent_name'] = data.get('fullname', u'')
                mls_ano['agent_office_phone'] = data.get('office_phone', u'')
                mls_ano['agent_cell_phone'] = data.get('cell_phone', u'')
                mls_ano['agent_email'] = data.get('email', u'')
                mls_ano['agent_avatar_url'] = avatar_url

                #force overrding of Any other agent
                mls_ano['force'] = 'selected'
コード例 #3
0
    def __call__(self):
        """Perform the toggle."""
        msg_type = 'info'

        if ILocalAgencyInfo.providedBy(self.context):
            # Deactivate local agency information.
            noLongerProvides(self.context, ILocalAgencyInfo)
            self.context.reindexObject(idxs=['object_provides', ])
            msg = _(u'Local agency information deactivated.')
        elif IPossibleLocalAgencyInfo.providedBy(self.context):
            alsoProvides(self.context, ILocalAgencyInfo)
            self.context.reindexObject(idxs=['object_provides', ])
            msg = _(u'Local agency information activated.')
        else:
            msg = _(
                u'The local agency information don\'t work with this '
                u'content type. Add \'IPossibleLocalAgencyInfo\' to the '
                u'provided interfaces to enable this feature.'
            )
            msg_type = 'error'

        self.context.plone_utils.addPortalMessage(msg, msg_type)
        self.request.response.redirect(self.context.absolute_url())
コード例 #4
0
 def active(self):
     """Is the local agency information active for this context?"""
     return ILocalAgencyInfo.providedBy(self.context)
コード例 #5
0
 def can_activate(self):
     """Can the local agency information be activated for this context?"""
     return IPossibleLocalAgencyInfo.providedBy(self.context) and \
         not ILocalAgencyInfo.providedBy(self.context)