コード例 #1
0
    def mode(self):
        """Return the mode that we are in.

        This can be either ``FILTER`` if a search was already performed and we
        are on a search page or ``SEARCH`` otherwise.
        """
        form = self.request.form
        if listing_search.IListingSearch.providedBy(self.context) and \
                'form.buttons.search' in form.keys():
            return 'FILTER'
        elif listing_search.IListingSearch.providedBy(self.context) and \
                'form.buttons.search' not in form.keys():
            return 'HIDDEN'
        else:
            return 'SEARCH'
コード例 #2
0
    def LoadData(self):                
        context = aq_inner(self.context)
        form = context.REQUEST.form
                 
        if "el_range" in form.keys() and "el_begin" in form.keys():
            self.el_range = int(form['el_range'])
            self.el_begin = int(form['el_begin']) + self.el_range
            
        catalog = getToolByName(context, 'portal_catalog')
        query = catalog(object_provides=self.providesType,
                   path='/'.join(context.getPhysicalPath()),
                   sort_on='start'
                   )
                   
        elements = self.FilterElements(query)
        elements = elements[self.el_begin : self.el_begin + self.el_range]
        self.nonNullNextQuery = len(query) >= self.el_begin + self.el_range 

        self.queryCache = elements
コード例 #3
0
    def available(self):
        """Check the portlet availability."""
        """Show on ListingCollections, Recent Listings, Listing Search """
        form = self.request.form
        show = False

        # available for ListingCollections
        if listing_collection.IListingCollection.providedBy(self.context):
            show = True
        # available for Recent Listings
        if recent_listings.IRecentListings.providedBy(self.context):
            show = True
        # available for Listing Search in Result Mode

        if listing_search.IListingSearch.providedBy(self.context) and \
                'form.buttons.search' in form.keys():
            show = True

        # available for ListingDetails
        if getattr(self.request, 'listing_id', None) is not None:
            show = True

        return show
コード例 #4
0
    def load_list(self):
        form = self.request.form # var tipo 'dict' que guarda todas as informacoes do formulario (keys,items,values)
        form_keys = form.keys() # var tipo 'list' que guarda todas as chaves do formulario (keys)
        form_values = []
        if 'SearchSubmit' in form_keys:
            if 'filtro' in form_keys and 'title' in form_keys:

                filtro = form.get('filtro','')
                try:title = unicode(form.get('title',''),'utf-8')
                except:title = form.get('title','')
                status = int(form.get('status',''))
                L=[]

                form_values.append({filtro:title})

                data = ModelsDadosFuncdetails().get_FuncBusca(form_campos=form_values)

                if data:
                    for item in data:
                        D = {}
                        try:user = unicode(item.get('username',''), 'utf-8')
                        except:user = item.get('username',u'')

                        if status == 0:
                            D['user'] = item
                        elif status == 1:
                            result = ModelsUserDocuments().get_UserDocuments_byUsername(user)
                            if result:
                                D['user'] = item
                        elif status == 2:
                            result = ModelsUserDocuments().get_UserDocuments_byUsername(user)
                            if not result:
                                D['user'] = item
                        if D:
                            L.append(D)

                return L
コード例 #5
0
 def show_filter(self):
     """Decides if the filter should be shown or not."""
     form = self.request.form
     return listing_search.IListingSearch.providedBy(self.context) and \
         'form.buttons.search' in form.keys()