Closed BenBarker closed 8 years ago
Hi Ben,
Could you explain me a bit what are you trying to achieve?
As far as I see it, this is the intended behavior. The logic behind it is that the filters that have a value other than None
(e.g. search_titles, posted_today, pets_cat, ...) can be turned on to use the filter, but cannot be turned off. To explain a bit better, if you go to Craigslist and add postedToday=1
in the URL, the results shown are going to be the ones posted today. But this doesn't work the other way around, meaning that if you add postedToday=0
to the URL, it doesn't mean I will exclude the ones posted today, it only means the "posted today filter" is not activated, and all results will be shown (same as if you hadn't added postedToday
at all).
For this reason is that for those filters, it makes sense to say {'posted_today': True}
, but it doesn't to say {'posted_today': False}
, because you get the same results by just not adding the filter at all.
I hope I explained myself correctly. Let me know if you haver any questions :)
I tweaked the code a bit so that posted_today: False/0/None
doesn't add postedToday=1
in the URL. New version (v1.0.2) released with that change. Thanks!
I found that the 'posted_today' filter always appeared to be 1, even when passed a value of 0. I believe this line in the init of CraigslistBase is to blame (around line 91):
self.filters[filter['url_key']] = filter['value'] or value
I believe that my desired value, 0, was causing the 'or' test to fail and using the default filter value of 1 in all cases. I changed it to this and it appears to work: