#11358 closed (fixed)
Flatpage sitemap shows all pages, even private pages
Reported by: | Dennis Burke | Owned by: | Karen Tracey |
---|---|---|---|
Component: | Contrib apps | Version: | 1.0 |
Severity: | Keywords: | sprintSep2010 | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I tried searching trac for this issue, but wasn't able to turn up anything relevant.
Flatpages allow you to make a page visible only to logged in users, but the flatpage sitemap reveals the url. Would it be possible to add a .filter(registration_required=False) to the queryset that populates the flatpage sitemap?
in django.contrib.sitemaps:
class FlatPageSitemap(Sitemap): def items(self): from django.contrib.sites.models import Site current_site = Site.objects.get_current() return current_site.flatpage_set.filter(registration_required=False)
Attachments (2)
Change History (15)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
Yeah, this solution is fine. Should be made a little more explicit in the Documentation? Or should we hope that google helps direct people seeking this solution here?
comment:3 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
A sitemap exists for the benefit of public spiders and crawlers, so there isn't much point having a sitemap that includes private pages.
comment:4 by , 14 years ago
Owner: | changed from | to
---|
comment:5 by , 14 years ago
Has patch: | set |
---|
comment:6 by , 14 years ago
The code change looks fine, however I'd like a small tweak in the documentation: rather then explaining the effect in code (registration_required=False
), try to do it in English (e.g. "pages which are visible to all users, including those not logged in" or something a little more concise). It can disrupt the reading flow to have to switch to understanding that flatpages model has an attribute called registration_required
and so on.
Are there any existing sitemap tests? If so, they might need to be updated here. If not, have a think about if there's some way to test them even a little bit. It might be hard to do so, but shouldn't be impossible (using test.Client to pull back a sample of the sitemap and examine the contents, perhaps?)
by , 14 years ago
Attachment: | 11358_with_test.patch added |
---|
Patch against [13714] to add tests and doc change
comment:7 by , 14 years ago
Keywords: | sprintSep2010 added |
---|
comment:8 by , 14 years ago
Owner: | changed from | to
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:9 by , 14 years ago
Owner: | changed from | to
---|
comment:10 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
follow-up: 12 comment:11 by , 14 years ago
Is there a reason this wasn't backported? I'm trying to backport another patch, and I've got a conflict because this hasn't been backported to 1.2.X.
comment:12 by , 14 years ago
Replying to lukeplant:
Is there a reason this wasn't backported? I'm trying to backport another patch, and I've got a conflict because this hasn't been backported to 1.2.X.
Hectic sprint day oversight, I think. On first read I think I thought this was more of a feature than a bugfix...on re-looking at it it seems to be more of a bugfix, so should probably be backported.
You almost answered it yourself.
I don't know if its worth doing a modification to sitemaps just for this.
Save your class but with another name like "FlatPagePublicSitemap" in a file called "sitemaps.py" for example.
Include ( from sitemaps include FlatPagePublicSitemap ) and use that class in your urls.py instead of the ordinary FlagPageSitemap.
Is that a good enough solution for you?