Skip to content
This repository has been archived by the owner on Dec 9, 2019. It is now read-only.

'flatblock' with default content feature #9

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

mandx
Copy link

@mandx mandx commented Jun 15, 2011

This references my previous issue.

See the commit message for changes, I used the syntax specified by @zerok

mandx/django-flatblocks@b233a39

Armando Pérez Marqués added 6 commits June 15, 2011 15:43
This 'flatblock_default' template tag allows providing a default block of
text for the flatblock, and not using the slug for this. Also, the content
of the flatblock is ready-to-edit by final users, and allowing the site
builders to specify suitable (and even ready to use) default content.
Introduces a new parameter to the `flatblock` tag: 'with-default'. When
this parameter is present, the tag parses the template until the
`end_flatblock` tag is found, and everything between the tags is saved
for later rendering and used as default content for the FlatBlock
instance if it doesn't exists.

Also introduces two new settings:
`FLATBLOCKS_STRICT_DEFAULT_CHECK`: If True, when the tag founds a
Flatblock instance that matches the slug but its fields are empty,
the tag fields the instance's fields with the defaults values, if
provided.
`FLATBLOCKS_STRICT_DEFAULT_CHECK_UPDATE`: If True and the above
situation occurs then the instance is saved to the DB with the
defaults values.
- If a block name is specified in a template variable, and it is not
  allowed to autocreate blocks, but a default was specified, a dummy
  (unsaved) flatblock is created with the default values, and then
  rendered.
- The default cache timeout for flatblocks is specified as a setting,
  `FLATBLOCKS_CACHE_TIMEOUT`, and defaults to Django's cache timeout.
  This allows to specify different a timeout value than the default
  cache one, and without setting it on every template tag call.
- Added syntax check and tests for the case where more than one argument
  is passed to the templatetag after the `with-default` keyword.
- Miscelaneous tests
@timmyomahony
Copy link

Came to suggest this feature - nice to see someone has done it themselves!

tangochin pushed a commit to tangochin/django-flatblocks that referenced this pull request Sep 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants