Metadata-Version: 2.5
Name: ocyan.plugin.demo_data
Version: 1.2.5rc1
Summary: Provides basic sample content and fixture registration for Ocyan sites.
Author: MandelBlogStack
License: Proprietary
Classifier: Environment :: Plugins
Classifier: Framework :: Django
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: <3.14,>=3.12
Requires-Dist: ocyan-core<2,>=1.2.14
Provides-Extra: test
Requires-Dist: coverage<8,>=7; extra == 'test'
Requires-Dist: ruff<1,>=0.6; extra == 'test'
Description-Content-Type: text/markdown

Ocyan plugin demo data
======================

Installation
------------
Add `ocyan.plugin.demo_data` to your projects dependencies.

Description
-----------
This plugin installs basic content into the website.
Each plugin contains their own demo data, which will be aggregated and installed
in the project.

Demodata fixtures will only be installed *ONCE* a record is kept in the database
of the installed demodata fixtures. This is needed, because if we would install
the fixtures each time, it would overwrite any modifications done in the database.

The demodata fixture record can be found here:

http://127.0.0.1:8000/manage/ocyan_plugin_demo_data/demodatafixture/

By deleting a record, you can force the fixture to be installed again. This
can be useful, when installing a new plugin that overrides fixtures of a
plugin allready installed.

Usage
-----

Demo data consists of a `name`, a `fixture` and optionally a `priority`. Plugins can
register fixtures under a certain key and override the fixtures registered by
other plugins by speififying a priority.

An example of a plugin registering demodata by using fixtures:

    def contribute_to_fixtures(self, fixtures):
        fixtures.add("data", "plugin/data")
        fixtures.add("wagtailhome", "superhome/home", 7) # with high priority 7
        return fixtures

Signals
-------

The demodata plugin sends 2 signals, to which plugins can respond to perform
additional actions, like copying images or creating data that is more dynamic
than can be stored in a fixture.

1. `django.core.signals.pre_loaddemodata` providing_args=["has_unloaded_fixtures"]
2. `django.core.signals.post_loaddemodata` providing_args=["has_unloaded_fixtures"]

The `has_unloaded_fixtures` argument designates if there are any fixtures that
will be loaded this run. Use that argument for tasks that shpuld not run
every time the demodata is loaded, only when actual loading is being performed.


Install the demodata
--------------------

While the demodata will usually be installed into the project automatically,
you can run it manually also.
To manually run the demo data installation, run

```
manage.py loaddemodata
```
