diff --git a/states.py b/states.py index d289c73..2d3cd4b 100644 --- a/states.py +++ b/states.py @@ -80,8 +80,7 @@ class States(PA): if request.method == "POST": self.url = request.form['orig_url'] else: - # GET's occur on redirect, and we don't have a form, so get it - # from pref + # GET's occur on redirect, and we don't have a form, so get it from pref pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type,PA_UserState.view_eid==self.view_eid).first() self.url = pref.orig_url @@ -131,22 +130,30 @@ class States(PA): pref=PA_UserState.query.filter(PA_UserState.pa_user_dn==current_user.dn,PA_UserState.path_type==self.path_type).first() if pref: - self.folders=pref.folders - self.noo=pref.noo self.grouping=pref.grouping self.how_many=pref.how_many self.offset=pref.st_offset self.size=pref.size - self.root=pref.root self.cwd=pref.cwd self.orig_ptype=pref.orig_ptype self.orig_search_term=pref.orig_search_term self.orig_url = pref.orig_url self.view_eid = pref.view_eid self.current = pref.current - self.first_eid = pref.first_eid - self.last_eid = pref.last_eid - self.num_entries = pref.num_entries + if self.path_type == "View": + self.root='static/' + self.orig_ptype + self.first_eid=orig_pref.first_eid + self.last_eid=orig_pref.last_eid + self.num_entries=orig_pref.num_entries + self.noo=orig_pref.noo + self.folders=orig_pref.folders + else: + self.root=pref.root + self.first_eid = pref.first_eid + self.last_eid = pref.last_eid + self.num_entries = pref.num_entries + self.noo=pref.noo + self.folders=pref.folders else: # retreive defaults from 'PAUser' where defaults are stored u=PAUser.query.filter(PAUser.dn==current_user.dn).one() @@ -185,7 +192,12 @@ class States(PA): # the above are defaults, if we are here, then we have current values, use them instead if they are set -- AI: searches dont set them so then we use those in the DB first if request.method=="POST": if self.path_type != "View" and 'noo' in request.form: - self.noo=request.form['noo'] + # we are changing values based on a POST to the form, if we changed the noo option, we need to reset things + if 'ChangeFileOpts' in request.path and self.noo != request.form['noo']: + self.noo=request.form['noo'] + self.first_eid=0 + self.last_eid=0 + self.offset=0 if 'how_many' in request.form: self.how_many=request.form['how_many'] if 'offset' in request.form: @@ -197,14 +209,18 @@ class States(PA): self.size = request.form['size'] # seems html cant do boolean, but uses strings so convert if self.path_type != "View" and 'folders' in request.form: - if request.form['folders'] == "False": - self.folders=False - else: - self.folders=True - # have to force grouping to None if we flick to folders from a flat - # view with grouping (otherwise we print out group headings for - # child content that is not in the CWD) - self.grouping=None + # we are changing values based on a POST to the form, if we changed the folders option, we need to reset things + if 'ChangeFileOpts' in request.path and self.folders != request.form['folders']: + self.num_entries=0 + self.first_eid=0 + self.last_eid=0 + if request.form['folders'] == "False": + self.folders=False + else: + self.folders=True + # have to force grouping to None if we flick to folders from a flat view with grouping (otherwise we print out + # group headings for child content that is not in the CWD) + self.grouping=None if 'orig_url' in request.form: self.orig_url = request.form['orig_url'] @@ -254,10 +270,11 @@ class States(PA): pref.orig_search_term = self.orig_search_term pref.orig_url = self.orig_url pref.last_used = last_used - + pref.first_eid = self.first_eid + pref.last_eid = self.last_eid + pref.num_entries = self.num_entries # only passed in (at the moment) in viewlist pref.current = self.current - # first_eid, last_eid, num_entries wont change in this func, set only in GetEntries() db.session.add(pref) db.session.commit()