Opened 17 years ago
Closed 14 years ago
#6932 closed (fixed)
Flatpages does not provide a list of available flat pages to the context
Reported by: | Owned by: | faldridge | |
---|---|---|---|
Component: | Contrib apps | Version: | dev |
Severity: | Keywords: | flatpages list templatetag | |
Cc: | mmitar@… | 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 want to be able to create a menu of all available flat pages. So I wrote this patch that puts a list of flatpages into the context.
It is registration sensitive and does not list restricted pages if user is not logged in.
{% for page in flatpages %} <h3><a href="{{page.url}}">{{page.title}}</a></h3> {% endfor %}
Attachments (5)
Change History (22)
by , 17 years ago
Attachment: | flatpages_list.diff added |
---|
comment:1 by , 17 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
This probably isn't something that belongs in the app itself. I'd suggest instead using a template tag.
comment:2 by , 16 years ago
Keywords: | templatetag added |
---|---|
Needs documentation: | set |
Needs tests: | set |
Owner: | changed from | to
Patch needs improvement: | set |
Status: | new → assigned |
I do like this idea as a templatetag. I will try my hand at it while waiting for a design decision.
comment:3 by , 16 years ago
Triage Stage: | Design decision needed → Accepted |
---|
I'd be +1 for a template tag -- bonus points if it lists flatpages with a given prefix (something like {% get_flatpage_list [prefix <prefix>] as <varname> %
}. Seems silly to always have in the context, though.
by , 16 years ago
Attachment: | 6932-template-tag-for-flatpages.diff added |
---|
Patch for a new template tag, this patch also includes tests for flatpages in general (on top of the test for the new code) and documentation
comment:4 by , 16 years ago
Needs documentation: | unset |
---|---|
Needs tests: | unset |
Patch needs improvement: | unset |
Good to see this accepted. Wasn't too much work so, I just did it quick. It's good to know that I was on the same wavelength as Jacob, and scored the bonus points! Decided against the filtering for registration, because it is an easy boolean test and might limit some cases. This is documented, in the new documentation.
comment:5 by , 16 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
comment:6 by , 16 years ago
milestone: | → post-1.0 |
---|
comment:7 by , 16 years ago
I'd love to use this, though it doesn't seem to be present in the current trunk?
comment:8 by , 16 years ago
Needs documentation: | set |
---|---|
Owner: | set to |
Status: | new → assigned |
antonius; nice thing about template tags is they can live your own code. Just copy out the code from templatetags.flatpages and put it in template tags in your own projects and it should just work. Or if you would prefer, I am sure this patch will get accepted faster when someone other than myself tests it out, patch it into your django trunk and report back on how it goes. I know right now the documentation doesn't match the refactor so those will need to be updated before being merged (I also just noticed a few typos).
comment:10 by , 15 years ago
Mnewman,
Are you still working on this? And if so, do the tests pass for you? They don't for me.
I need this exact functionality, so I'd like to pick up this ticket with your permission and get the tests working and patch up the documentation changes to meet the Django documentation guidelines.
comment:11 by , 15 years ago
Owner: | removed |
---|---|
Status: | assigned → new |
It's all yours if you want to spend time on it.
comment:12 by , 15 years ago
Owner: | set to |
---|
comment:13 by , 15 years ago
Needs documentation: | unset |
---|
OK, the final patch, 6932-template-tag-for-flatpage-2.diff should be ready for merging.
- The tag implementation no longer saves a queryset on the node to ensure thread safety.
- All unit tests pass using django's runtests script.
- Documentation changes now use more semantic markup.
- Patch applies cleanly to trunk (r12843).
I know everybody is busy right now, but could someone with privileges please merge this or let me know what else is needed?
by , 14 years ago
Attachment: | 6932-template-tag-for-flatpage-2.diff added |
---|
by , 14 years ago
Attachment: | 6932-template-tag-for-flatpages-2.diff added |
---|
comment:15 by , 14 years ago
Cc: | added |
---|
comment:16 by , 14 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Appears to adhere to what Jacob wanted as well as providing the necessary docs + tests. Applies cleanly to trunk and tests pass for sqlite.
by , 14 years ago
Fix template logic and wording in example usage, DRY out exceptions, etc. (NB: uploaded after RFC)
comment:17 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Put a list of flatpages into the context.