Ejemplo n.º 1
0
class SidebarSearch(object):
    def __init__(self, *args, **kwargs):
        super(SidebarSearch, self).__init__(*args, **kwargs)
        self.searchform = None

    def set_searchform(self):
        if self.searchform:
            return
        self.searchform = SearchForm(self.request.GET)
        if not self.searchform.is_valid():
            messages.error(self.request, "Invalid search query.")

    def get_context_data(self, **kwargs):
        ret = super(SidebarSearch, self).get_context_data(**kwargs)
        self.set_searchform()
        ret.update({
            'section': 'home',
            'subsection': 'search',
            'searchform': self.searchform,
        })
        return ret
Ejemplo n.º 2
0
class SidebarSearch(object):
    section = 'search'

    def __init__(self, *args, **kwargs):
        super(SidebarSearch, self).__init__(*args, **kwargs)
        self.searchform = None

    def set_searchform(self):
        if self.searchform:
            return
        self.searchform = SearchForm(self.request.GET)
        if not self.searchform.is_valid():
            messages.error(self.request, "Invalid search query.")

    def get_context_data(self, **kwargs):
        ret = super(SidebarSearch, self).get_context_data(**kwargs)
        self.set_searchform()
        ret.update({
            'subsection': 'search',
            'searchform': self.searchform,
        })
        return ret
Ejemplo n.º 3
0
 def set_searchform(self):
     if self.searchform:
         return
     self.searchform = SearchForm(self.request.GET)
     if not self.searchform.is_valid():
         messages.error(self.request, "Invalid search query.")
Ejemplo n.º 4
0
 def set_searchform(self):
     if self.searchform:
         return
     self.searchform = SearchForm(self.request.GET)
     if not self.searchform.is_valid():
         messages.error(self.request, "Invalid search query.")