Metadata-Version: 2.1
Name: hope-flex-fields
Version: 0.1.0rc0
Author-Email: sax <s.apostolico@gmail.com>
License: MIT
Requires-Python: >=3.11
Requires-Dist: django-strategy-field>=3.1.0
Requires-Dist: django-regex>=0.5.0
Requires-Dist: django-regex-field>=3.1.0
Requires-Dist: django-admin-extra-buttons>=1.6.0
Requires-Dist: django-jsoneditor>=0.2.4
Requires-Dist: djangorestframework>=3.15.1
Requires-Dist: mini-racer>=0.12.4
Requires-Dist: jsonpickle>=3.2.2
Requires-Dist: xlsxwriter>=3.2.0
Requires-Dist: django-adminactions>=2.3.0
Requires-Dist: duckdb>=1.0.0
Requires-Dist: python-calamine>=0.2.0
Requires-Dist: requests>=2.32.3
Requires-Dist: responses>=0.25.3
Requires-Dist: jmespath>=1.0.1
Requires-Dist: deepdiff>=8.0.1
Provides-Extra: docs
Requires-Dist: mkdocs>=1.6.1; extra == "docs"
Requires-Dist: mkdocs-material>=9.5.36; extra == "docs"
Requires-Dist: mkdocs-awesome-pages-plugin>=2.9.3; extra == "docs"
Requires-Dist: mkdocstrings-python; extra == "docs"
Description-Content-Type: text/markdown

# HOPE FlexFields

[![Test](https://github.com/unicef/hope-flex-fields/actions/workflows/test.yml/badge.svg)](https://github.com/unicef/hope-flex-fields/actions/workflows/test.yml)
[![codecov](https://codecov.io/gh/unicef/hope-flex-fields/graph/badge.svg?token=GSYAH4IEUK)](https://codecov.io/gh/unicef/hope-flex-fields)

This library provides the ability to define a set of fields and related validation rules dynamically. It has been designed as part of the [HOPE](https://github.com/unicef/hct-mis) project to manage user-customizable fields (FlexField). The idea is to have a central business logic repository for data import validation.


It provides four classes:

- FieldDefinition: This represents a collection of reusable pre-configured fields
- FlexField: Instance like representation of `FieldDefinition` inside a `Fieldset`
- Fieldset: Group of FlexField
- DataChecker: Compound of fieldset

From the design point of view a high level comparison with Django components could be:

- `FieldDefinition` = `class forms.Field`
- `Fieldset` = `forms.Form`
- `FlexField` = `forms.Field()`
- `DataChecker` = `[forms.Form(),...]`

... and some utilities

- Automatic creation of FieldSets inspecting [exiting models](http://localhost:8000/hope_flex_fields/fieldset/create_from_content_type/?)
- Automatic creation of XLS file matching an existing [Datachecker](http://localhost:8000/hope_flex_fields/datachecker/)
- Validate XLS against an existing [Datachecker](http://localhost:8000/hope_flex_fields/datachecker/)


```mermaid 

classDiagram
    class AbstractField
    class FieldDefinition
    class FlexField
    class Fieldset
    class DataChecker
    AbstractField <|-- FlexField
    AbstractField <|-- FieldDefinition
    Fieldset *-- FlexField 
    FlexField --> FieldDefinition
    DataChecker o-- Fieldset

```


## Install
    CSP_SCRIPT_SRC = [
        ...
        "cdnjs.cloudflare.com",
    ]

    INSTALLED_APPS = [
        ...
        'admin_extra_buttons',
        'jsoneditor',
        'hope_flex_fields',
    
    ]

## Demo Application

    python manage.py migrate
    python manage.py demo
    python manage.py runserver

Navigate to http://localhost:8000/admin/ and login using any username/password
