bgneal@763: """Custom views for searching.""" bgneal@763: bgneal@763: from haystack.views import SearchView bgneal@763: bgneal@763: bgneal@763: class UserSearchView(SearchView): bgneal@763: """This class passes the user making the search as an __init__ argument to bgneal@763: the search form as the keyword argument 'user'. bgneal@763: bgneal@763: """ bgneal@763: def build_form(self, form_kwargs=None): bgneal@763: """Pass the request.user object to the form's constructor.""" bgneal@763: if not form_kwargs: bgneal@763: form_kwargs = {} bgneal@763: if 'user' not in form_kwargs: bgneal@763: form_kwargs['user'] = self.request.user bgneal@763: return super(UserSearchView, self).build_form(form_kwargs)