Ticket #4413: remember_change_list_params.diff
File remember_change_list_params.diff, 2.2 KB (added by , 17 years ago) |
---|
-
main.py
105 105 break 106 106 return js 107 107 108 def list_params_recall_key(model): 109 return "%s.%s.last_params" % (model._meta.app_label, model.__class__.__name__) 110 108 111 class AdminBoundField(object): 109 112 def __init__(self, field, field_mapping, original): 110 113 self.field = field … … 357 360 return HttpResponseRedirect("../add/") 358 361 else: 359 362 request.user.message_set.create(message=msg) 360 return HttpResponseRedirect("../") 363 last_params_key = list_params_recall_key(model) 364 print "last_params_key is %s" % repr(last_params_key) 365 if last_params_key in request.session: 366 print "got last_params, it was %s" % repr(request.session[last_params_key]) 367 last_params = request.session[last_params_key].items() 368 page = "?%s" % "&".join(["%s=%s" % kv for kv in last_params]) 369 print "page is %s" % repr(page) 370 else: 371 print "no last_page_key." 372 page = "" 373 return HttpResponseRedirect("../%s" % page) 361 374 else: 362 375 # Populate new_data with a "flattened" version of the current data. 363 376 new_data = manipulator.flatten_data() … … 558 571 self.page_num = int(request.GET.get(PAGE_VAR, 0)) 559 572 except ValueError: 560 573 self.page_num = 0 574 575 576 561 577 self.show_all = ALL_VAR in request.GET 562 578 self.is_popup = IS_POPUP_VAR in request.GET 563 579 self.params = dict(request.GET.items()) 564 if PAGE_VAR in self.params: 565 del self.params[PAGE_VAR] 580 566 581 if ERROR_FLAG in self.params: 567 582 del self.params[ERROR_FLAG] 568 583 584 # Remember which page the user was on (hackish) 585 request.session[list_params_recall_key(model)] = self.params.copy() 586 587 if PAGE_VAR in self.params: 588 del self.params[PAGE_VAR] 589 590 591 569 592 self.order_field, self.order_type = self.get_ordering() 570 593 self.query = request.GET.get(SEARCH_VAR, '') 571 594 self.query_set = self.get_query_set()