* Splits documentation over multiple folders * Editor guide documentation intro * Adds segment dashboard documentation * Adds editor documenation regarding segment creation * Adds logo with padding for the documentation * Updates usage guide documentation * Splits sandbox and custom rules documentation * Improves ‘Create a variant’ documentation * Adds documentation regarding streamfield and template tags * Consistent StreamField references * Feedback from M. Dingjan * Remove ‘coming soon’ section * Enable sandbox debug toolbar * Updated documentation
18 lines
575 B
ReStructuredText
18 lines
575 B
ReStructuredText
Creating custom rules
|
|
=====================
|
|
|
|
Rules consist of two important elements, the model fields and the
|
|
``test_user`` function. They should inherit the ``AbstractBaseRule`` class from
|
|
``wagtail_personalisation.rules``.
|
|
|
|
A simple example of a rule could look something like this:
|
|
|
|
.. literalinclude:: ../../src/wagtail_personalisation/rules.py
|
|
:pyobject: UserIsLoggedInRule
|
|
|
|
As you can see, the only real requirement is the ``test_user`` function that
|
|
will either return ``True`` or ``False`` based on the model fields and
|
|
optionally the request object.
|
|
|
|
That's it!
|