This repository has been archived by the owner on Dec 9, 2019. It is now read-only.
forked from howiworkdaily/django-freetext
-
Notifications
You must be signed in to change notification settings - Fork 47
'flatblock' with default content feature #9
Open
mandx
wants to merge
10
commits into
zerok:master
Choose a base branch
from
mandx:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This reverts commit a1273dd.
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This references my previous issue.
See the commit message for changes, I used the syntax specified by @zerok
mandx/django-flatblocks@b233a39