Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

'flatblock' with default content feature #9

Open
wants to merge 10 commits into
from

Conversation

Projects
None yet
2 participants

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 some commits Jun 15, 2011

Armando Pérez Marqués Added 'flatblock_default' template tag
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.
a1273dd
Armando Pérez Marqués Revert "Added 'flatblock_default' template tag"
This reverts commit a1273dd.
ef6b5aa
Armando Pérez Marqués Rework of the default block content feature
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.
b233a39
Armando Pérez Marqués Changes and tests:
- 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
8848e6b
Armando Pérez Marqués Removed comment 06b4325
Armando Pérez Marqués Fixed DebugNodeList reference 0fe5b01

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

@tangochin tangochin pushed a commit to tangochin/django-flatblocks that referenced this pull request Sep 15, 2016

@funkybob funkybob [Fixes #9] Fix README [thanks olivermarchand] f6dae2b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment