Ticket #16180: ticket_16180_for_r16345.diff

File ticket_16180_for_r16345.diff, 2.4 KB (added by Manuel Saelices, 13 years ago)

A new patch with tests for the [16345] version

  • tests/regressiontests/admin_views/tests.py

     
    507507        try:
    508508            self.client.get("/test_admin/admin/admin_views/thing/?color__value__startswith=red")
    509509            self.client.get("/test_admin/admin/admin_views/thing/?color__value=red")
     510            # allowed explicitly in a custom changelist
     511            self.client.get("/test_admin/admin/admin_views/album/?allowed_param=1")
    510512        except SuspiciousOperation:
    511513            self.fail("Filters are allowed if explicitly included in list_filter")
    512514
  • tests/regressiontests/admin_views/models.py

     
    620620    def get_query_set(self, request):
    621621        return self.root_query_set.filter(pk=9999) # Does not exist
    622622
     623class AllowedParamChangeList(ChangeList):
     624
     625    def get_ignored_lookup_params(self):
     626        return super(AllowedParamChangeList, self).get_ignored_lookup_params() + ('allowed_param', )
     627
    623628class GadgetAdmin(admin.ModelAdmin):
    624629    def get_changelist(self, request, **kwargs):
    625630        return CustomChangeList
     
    706711class AlbumAdmin(admin.ModelAdmin):
    707712    list_filter = ['title']
    708713
     714    def get_changelist(self, request, **kwargs):
     715        return AllowedParamChangeList
     716
    709717class Employee(Person):
    710718    code = models.CharField(max_length=20)
    711719
  • django/contrib/admin/views/main.py

     
    252252                ordering_fields[idx] = 'desc' if pfx == '-' else 'asc'
    253253        return ordering_fields
    254254
     255    def get_ignored_lookup_params(self):
     256        return IGNORED_PARAMS
     257
    255258    def get_lookup_params(self, use_distinct=False):
    256259        lookup_params = self.params.copy() # a dictionary of the query string
    257260
    258         for ignored in IGNORED_PARAMS:
     261        for ignored in self.get_ignored_lookup_params():
    259262            if ignored in lookup_params:
    260263                del lookup_params[ignored]
    261264
Back to Top