diff options
author | Tomasz Zielinski <tomasz.zielinski@pyconsultant.eu> | 2012-01-11 22:31:16 +0100 |
---|---|---|
committer | Tomasz Zielinski <tomasz.zielinski@pyconsultant.eu> | 2012-01-11 22:31:16 +0100 |
commit | 2f399da2fd6d353804c1c92c47c5baea552c9817 (patch) | |
tree | f54432209273ad07dc0f0841eebdee2598a16b78 /askbot/search | |
parent | 8d2e82e66a578615205a8a705b30e2cd5d8e8cbe (diff) | |
download | askbot-2f399da2fd6d353804c1c92c47c5baea552c9817.tar.gz askbot-2f399da2fd6d353804c1c92c47c5baea552c9817.tar.bz2 askbot-2f399da2fd6d353804c1c92c47c5baea552c9817.zip |
Initial refactor to remove SearchState from the session
Diffstat (limited to 'askbot/search')
-rw-r--r-- | askbot/search/state_manager.py | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/askbot/search/state_manager.py b/askbot/search/state_manager.py index 1ea4e405..ae5157e3 100644 --- a/askbot/search/state_manager.py +++ b/askbot/search/state_manager.py @@ -123,21 +123,6 @@ class SearchState(object): out += 'logged_in=%s\n' % str(self.logged_in) return out - def is_default(self): - """True if search state is default - False otherwise, but with a few exceptions - notably page_size has no effect here - """ - if self.scope != const.DEFAULT_POST_SCOPE: - return False - if self.author: - return False - if self.query: - return False - if self.tags: - return False - return True - def set_logged_out(self): if self.scope == 'favorite': self.scope = None @@ -167,7 +152,7 @@ class SearchState(object): self.reset() #todo also relax if 'all' scope was clicked twice - def update_from_user_input(self, input_dict): + def update_from_user_input(self, input_dict, user_logged_in): #todo: this function will probably not #fit the case of multiple parameters entered at the same tiem if 'start_over' in input_dict: @@ -183,7 +168,7 @@ class SearchState(object): self.reset_page()#todo may be smarter here - start with ~same q if 'scope' in input_dict: - if input_dict['scope'] == 'favorite' and self.logged_in == False: + if input_dict['scope'] == 'favorite' and user_logged_in is False: self.reset_scope() else: self.update_value('scope', input_dict, reset_page=reset_page) @@ -259,22 +244,6 @@ class SearchState(object): if self.sort == 'relevance-desc': self.reset_sort() - def update(self, input_dict, view_log, user): - """update the search state according to the - user input and the queue of the page hits that - user made""" - if 'preserve_state' in input_dict: - return - - if view_log.should_reset_search_state(): - self.reset() - - if user.is_authenticated(): - self.set_logged_in() - - self.update_from_user_input(input_dict) - self.relax_stickiness(input_dict, view_log) - def reset_page(self): self.page = 1 @@ -340,14 +309,6 @@ class ViewLog(object): else: return None - def should_reset_search_state(self): - """return True if user stepped too far from the home page - and False otherwise""" - if self.get_previous(1) != 'questions': - if self.get_previous(2) != 'questions': - return True - return False - def set_current(self, view_name): """insert a new record""" self.views.insert(0, view_name) |