Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
aa6e70e
Wagtail version bump
May 23, 2021
f013253
Frontend version bumps
May 23, 2021
9fa2689
Frontend version bumps 2: package-lock update
May 23, 2021
a1c234f
Switching from wagtaildraftail to upstream wagtail's draftail
May 23, 2021
6f37cc8
Test libs bump
May 24, 2021
ab29db1
Black run
May 24, 2021
025f275
Frontend test deps bump
May 24, 2021
b9d7d44
Frontend test deps bump 2: package-lock
May 24, 2021
b2ff8ba
Eslint --fix run
May 24, 2021
5e22421
Remove flake8-colors because it's broken
May 24, 2021
b4a1211
Tox test env updates
May 24, 2021
400719d
Isort and Flake8 py fixes
May 24, 2021
f9d8836
Testapp and test fixes from wagtail bump
May 24, 2021
13a03bf
UglifyJS bump
May 24, 2021
a9573da
UglifyJS bump 2: package-lock
May 24, 2021
acead70
Remove fontawesome icon support for now
May 25, 2021
b6d73c1
Improvements to draftail option handling
May 30, 2021
aebdc94
Construct draftail DB conversion rules for models
May 31, 2021
0f3dfeb
Removing unused packages
May 31, 2021
f764ddb
Major frontend version bumps: DraftJS and React
May 31, 2021
cb0950e
first draft readme update for draftail
May 31, 2021
d6cc6e1
Add typescript and ts-ify new files
liamjohnston Jun 1, 2021
807dbd3
Replacing fstrs with .format for 3.5 compatibility
Nov 3, 2021
cda21b7
Instantiate type returned by bind_model in edit_handlers
Nov 3, 2021
d9f60ac
v0.1.3
Nov 3, 2021
db15334
Couple of fixes for wagtail 2.0.2
Nov 3, 2021
bfbee40
Fixing init for 2.0.2
Nov 7, 2021
d7908e8
TEMPORARY downgrade django-filters for older django
Nov 9, 2021
8a46a2a
Experimentally bundling static
Nov 10, 2021
f574dc7
BIG: DB convs approach
Nov 17, 2021
86124d8
className bugfix
Nov 21, 2021
9d595b0
Static refresh
Nov 21, 2021
86f171f
Append children on dom save
Nov 21, 2021
840f039
Wagtail req bump
Nov 22, 2021
0453e13
bumped django-filter down to 2.2.0
Nov 3, 2021
b971ecc
bumped wagtail version
Nov 4, 2021
3d5082b
updated deprecated code when moving to django 2.0
Nov 8, 2021
3c94d40
patch for wagtail 2.5.2
Nov 9, 2021
56b7e66
Newer injection
Nov 22, 2021
4ab5536
Only append children if the decorator didn't
Nov 29, 2021
c739679
wip
Dec 5, 2021
4dee9e3
Refactor and improve entity registration
Dec 6, 2021
48b8cb5
Rewriter bug
Dec 6, 2021
feb0eaf
Quick fix to deal with empty labels and children
Dec 7, 2021
d893191
Empty entityTypes bug fix
Dec 10, 2021
0578214
Changes to support wagtail 2.13
calvingiles Dec 7, 2021
427bc42
Support wagtail 2.15, and update version identifier
calvingiles Dec 8, 2021
595e2f6
Recompile
Dec 14, 2021
1165ac4
Hack to initialise modelchooser streamblock widget with telepath
Dec 19, 2021
321b79a
Static rebuild
Dec 19, 2021
45b1098
Added icon option
Jan 12, 2022
a0f9227
fix mistake
Jan 12, 2022
154b9ca
Merge pull request #30 from springload/upgrade/iconfix
aaronhaslett Jan 17, 2022
0eaf409
Replace <a> with <entity> and refactor
Jan 25, 2022
f3f997c
Just save children to DB
Jan 25, 2022
ff84273
Fetch initial value for modelchooser
Jan 26, 2022
61f7574
Static rebuild
Jan 26, 2022
e33df50
Give children to expander/decorator
Jan 26, 2022
664094e
Init fix for empty choice on ModelChooser
Jan 28, 2022
2e3a0dd
Rebuild
Jan 28, 2022
5056689
Alternate initialisation for field taking value
Jan 30, 2022
d7b5511
Changing display=__selection__ to a separate var
Jan 30, 2022
c203088
Rebuild
Jan 30, 2022
b166f8b
Make prefix optional in decorator
Feb 1, 2022
5ba4193
Rebuild
Feb 1, 2022
eeefc2e
Adding template initialisation for top level RTE fields
Feb 1, 2022
1ffc0fc
Rebuild
Feb 1, 2022
2f9ed12
Unescape html unnecessarily escaped by draftjs_exporter
Feb 14, 2022
37c0322
Allowing tags inside entities
Feb 14, 2022
60b7b90
add validation to RemoteModelChooserBlock
May 6, 2022
96dc245
Merge pull request #32 from springload/fix/KO-689/fix_remotemodelchoo…
aaronhaslett May 10, 2022
3b4013b
Fix to avoid setting string'd None for empty val
aaronhaslett Jun 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ build/

# Application
var
static

# Python Package
dist/
Expand All @@ -23,6 +22,7 @@ eggs
# Development & IDEs
.idea
/.venv/
/venv/

# Tests
/.tox/
Expand All @@ -43,4 +43,4 @@ $virtualenv.tar.gz
*.pot
bin

.vscode/
.vscode/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6
10
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ cache:
matrix:
# See `Which version combinations to include in Travis test matrix?` in `/docs/README.md`.
include:
- env: TOXENV=py34-dj111-wt113
python: 3.4
- env: TOXENV=py35-dj111-wt113
python: 3.5
- env: TOXENV=py36-dj111-wt112
python: 3.6
- env: TOXENV=py36-dj111-wt113
- env: TOXENV=py36-dj31-wt212
python: 3.6
- env: TOXENV=py37-dj31-wt212
python: 3.7
- env: TOXENV=py38-dj31-wt212
python: 3.8
# - env: TOXENV=py36-dj111-wt2b
# python: 3.6
# - env: TOXENV=py36-dj2-wt2b
Expand Down
32 changes: 23 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:target: https://travis-ci.org/springload/wagtailmodelchoosers
.. image:: https://img.shields.io/pypi/v/wagtailmodelchoosers.svg
:target: https://pypi.python.org/pypi/wagtailmodelchoosers

wagtailmodelchoosers
====================

Expand All @@ -29,29 +29,43 @@ Usage

from wagtail.wagtailcore import blocks
from wagtailmodelchoosers.blocks import ModelChooserBlock

class CustomBlock(blocks.StructBlock):
custom_model = ModelChooserBlock('custom_model') # `chooser` can be a positional argument, the keyword is used here for clarity.

``ModelChooserPanel`` takes the name of the field as first positional argument (like a regular Panel) and the name of the chooser configuration as second positional argument. Use other panel kwargs as usual.

.. code:: python

from django.db import models
from wagtail.core.models import Page
from wagtailmodelchoosers.edit_handlers import ModelChooserPanel

class CustomPage(Page):
custom_model = models.ForeignKey('myapp.CustomModel')

panels = [
...
ModelChooserPanel('custom_model', chooser='custom_model'), # `chooser` can be a positional argument, the keyword is used here for clarity.
]

To select a model from a remote API, respectively use ``RemoteModelChooserBlock`` and ``RemoteModelChooserPanel`` instead.

If you have `WagtailDraftail <https://github.com/springload/wagtaildraftail>`_ installed, it will automatically register the ``ModelSource`` and ``RemoteModelSource`` to the JS. Refer to ``WagtailDraftail``'s `documentation <https://github.com/springload/wagtaildraftail#configuration>`_ to hook it up properly.
If you want a chooser to be available in draftail, put a unique 'draftail_type' into its configuration dict in ``MODEL_CHOOSER_OPTIONS``, then add the chooser name to rich text features. You can do the latter either by adding it explicitly in a feature list like this:

.. code:: python

rich_text_block = RichTextBlock(features=["custom_model"])

Or adding it to the list of default features for all rich text blocks like this:

.. code:: python

@hooks.register("register_rich_text_features")
def register_rich_text_features(features):
features.default_features.append("custom_model")

Note: It's easy to confuse draftail_type with the chooser's name. See the Configuration section if you're not sure which is which. The only place you need to put the draftail_type is in settings. The value you put there gets passed into draftail as an entity type, so the blocks created by that modelchooser toolbar option have the block type equal to the draftail_type you declared. This is useful if you're doing something custom with the contentstate.

Configuration
~~~~~~~~~~~~~
Expand All @@ -63,7 +77,7 @@ The ModelChooser and RemoteModelChooser share a similar base configuration and o
.. code:: python

MODEL_CHOOSERS_OPTIONS = {
'navigation': {
'navigation': { # The chooser name
'label': 'Navigation', # The label to use for buttons or modal title
'display': 'name', # The field to display when selecting an object
'list_display': [ # The fields to display in the chooser
Expand All @@ -75,9 +89,10 @@ The ModelChooser and RemoteModelChooser share a similar base configuration and o
'fields_to_save': ['id'] + RATE_CHOOSER_DISPLAY_FIELDS, # ONLY FOR REMOTE: The remote objects fields to save to the DB. Leave empty to save the whole object.
'remote_endpoint': 'http://...' # ONLY FOR REMOTE: The remote API endpoint.
'pk_name': 'uuid', # The primary key name of the model
'draftail_type': 'NAV', # Only add this if you want the model available in draftail. Must be unique and can't clash with any default wagtail types.
}
}

In addition, you can customise the mapping of the key of the API, see the configuration key names being used for the `query <https://github.com/springload/wagtailmodelchoosers/blob/c36bb877eef4ac4af6b221f0d7ff7416354754c7/wagtailmodelchoosers/utils.py#L107-L112>`_ and the `response <https://github.com/springload/wagtailmodelchoosers/blob/c36bb877eef4ac4af6b221f0d7ff7416354754c7/wagtailmodelchoosers/utils.py#L115-L123>`_.


Expand Down Expand Up @@ -118,4 +133,3 @@ Releases
* Back on master with the PR merged, use ``make publish`` (confirm, and enter your password).
* Finally, go to GitHub and create a release and a tag for the new version.
* Done!

Loading