summaryrefslogtreecommitdiffstats
path: root/askbot/search
diff options
context:
space:
mode:
authorTomasz Zielinski <tomasz.zielinski@pyconsultant.eu>2012-01-11 23:06:30 +0100
committerTomasz Zielinski <tomasz.zielinski@pyconsultant.eu>2012-01-11 23:11:23 +0100
commit9ba647898a7f181848d54d1af08ef2a8b211eefc (patch)
tree737574219f240ffa4c5ea53d88f02a3d756f1595 /askbot/search
parent2f399da2fd6d353804c1c92c47c5baea552c9817 (diff)
downloadaskbot-9ba647898a7f181848d54d1af08ef2a8b211eefc.tar.gz
askbot-9ba647898a7f181848d54d1af08ef2a8b211eefc.tar.bz2
askbot-9ba647898a7f181848d54d1af08ef2a8b211eefc.zip
Removed some unused code related directly or indirectly to SearchState
Diffstat (limited to 'askbot/search')
-rw-r--r--askbot/search/state_manager.py53
1 files changed, 2 insertions, 51 deletions
diff --git a/askbot/search/state_manager.py b/askbot/search/state_manager.py
index ae5157e3..adb56138 100644
--- a/askbot/search/state_manager.py
+++ b/askbot/search/state_manager.py
@@ -123,14 +123,6 @@ class SearchState(object):
out += 'logged_in=%s\n' % str(self.logged_in)
return out
- def set_logged_out(self):
- if self.scope == 'favorite':
- self.scope = None
- self.logged_in = False
-
- def set_logged_in(self):
- self.logged_in = True
-
def reset(self):
#re-initialize, but keep login state
is_logged_in = self.logged_in
@@ -146,12 +138,6 @@ class SearchState(object):
if reset_page == True:
self.reset_page()
- def relax_stickiness(self, input_dict, view_log):
- if view_log.get_previous(1) == 'questions':
- if not some_in(ACTIVE_COMMANDS, input_dict):
- self.reset()
- #todo also relax if 'all' scope was clicked twice
-
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
@@ -168,8 +154,8 @@ 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 user_logged_in is False:
- self.reset_scope()
+ if input_dict['scope'] == 'favorite' and not user_logged_in:
+ self.scope = const.DEFAULT_POST_SCOPE
else:
self.update_value('scope', input_dict, reset_page=reset_page)
@@ -260,8 +246,6 @@ class SearchState(object):
def reset_sort(self):
self.sort = const.DEFAULT_POST_SORT_METHOD
- def reset_scope(self):
- self.scope = const.DEFAULT_POST_SCOPE
def query_string(self):
out = 'section:%s' % self.scope
@@ -284,36 +268,3 @@ class SearchState(object):
'page_size': self.page_size
}
return params_dict
-
-class ViewLog(object):
- """The ViewLog helper obejcts store the trail of the page visits for a
- given user. The trail is recorded only up to a certain depth.
-
- The purpose to record this info is to reset the search state
- when the user walks "too far away" from the search page.
-
- These objects must be modified only in this middlware.
- """
- def __init__(self):
- self.views = []
- self.depth = 3 #todo maybe move this to const.py
-
- def get_previous(self, num):
- """get a previous record from a certain depth"""
- if num > self.depth - 1:
- raise Exception("view log depth exceeded")
- elif num < 0:
- raise Exception("num must be positive")
- elif num <= len(self.views) - 1:
- return self.views[num]
- else:
- return None
-
- def set_current(self, view_name):
- """insert a new record"""
- self.views.insert(0, view_name)
- if len(self.views) > self.depth:
- self.views.pop()
-
- def __str__(self):
- return str(self.views) + ' depth=%d' % self.depth