flask plugin new output, minus the scaffold's AssetType seeding: printed parts are quantity-based consumables, not ADR-001 assets. on_install seeds the three plugin settings instead. Manifest pins core >=0.11.0, depends on employees (badge name resolution), ships disabled until a site opts in.
44 lines
2.0 KiB
Markdown
44 lines
2.0 KiB
Markdown
# Printedparts plugin
|
|
|
|
3D-printed parts inventory + kiosk checkout
|
|
|
|
This plugin was generated by `flask plugin new printedparts`. It satisfies the framework contract out of the box. Replace the example model and routes with your domain.
|
|
|
|
## What's here
|
|
|
|
- `plugin.py` - the `PrintedpartsPlugin` class extending `BasePlugin`. Edit `init_app` for custom setup, `on_install` to seed reference data.
|
|
- `models/printedparts.py` - example Asset extension table. Replace `examplefield` with your domain fields.
|
|
- `api/routes.py` - example list and detail endpoints. Add CRUD as needed.
|
|
- `schemas/__init__.py` - marshmallow schema stub for request/response validation.
|
|
- `tests/test_plugin.py` - smoke tests asserting contract compliance.
|
|
- `manifest.json` - plugin metadata. Bump `version` on changes; keep `core_version` range broad.
|
|
|
|
## Common edits
|
|
|
|
| You want to... | Do this |
|
|
|---|---|
|
|
| Add a hook (search, navigation, dashboard widget) | Override the method in `PrintedpartsPlugin`. See `docs/PLUGIN-HOOKS.md`. |
|
|
| Accept external collector data | Override `get_collector_schema()` to return a JSON Schema. See ADR-006. |
|
|
| Add another model | Create `models/<other>.py`, export it in `models/__init__.py`, return it in `get_models()`. |
|
|
| Add a CLI command | Override `get_cli_commands()` returning a list of Click commands. |
|
|
|
|
## Frontend
|
|
|
|
Vue components for this plugin live under `frontend/src/views/printedparts/` (per project convention). Backend scaffolding does not generate frontend yet; copy from an existing plugin's view files (e.g., `frontend/src/views/network/`) as a starting point.
|
|
|
|
## Install and run
|
|
|
|
```bash
|
|
flask plugin install printedparts
|
|
flask db migrate -m "Add printedparts plugin tables"
|
|
flask db upgrade
|
|
pytest plugins/printedparts/tests/
|
|
```
|
|
|
|
## References
|
|
|
|
- `docs/PLUGIN-HOOKS.md` - canonical hook reference
|
|
- `docs/PLUGIN-QUICKSTART.md` - 30-minute walkthrough
|
|
- `migrations/adr/ADR-001-asset-as-platform-contract.md` - the platform contract
|
|
- `migrations/adr/ADR-002-plugin-versioning.md` - versioning rules
|