Metadata-Version: 2.5
Name: trytond_etude_maestro
Version: 8.0.0.1
Summary: Etude Form Server — Bridge to Maestro (AD prefill and write)
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: active directory,binding,form,maestro,survey,tryton
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Office/Business
Requires-Python: >=3.10
Requires-Dist: trytond-etude-bind<8.1,>=8.0
Requires-Dist: trytond-etude<8.1,>=8.0
Requires-Dist: trytond-maestro<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Requires-Dist: trytond-maestro-computers<8.1,>=8.0; extra == 'test'
Description-Content-Type: text/x-rst

Etude Maestro Module
====================

The ``etude_maestro`` module binds the questions of a form to the records the
maestro suite manages: an onboarding form reads what the deployment already
holds of the participant and writes the account it asks for, with the secondary
group, the primary group and the AD server the account is placed in.
It is a companion of the core module of the etude group and of ``etude_bind`` -
it depends on both and extends them - and the bridge of the etude group to the
AD management suite.

The chain of the AD
-------------------

The records of the suite are reached through the chain that holds them: an
account belongs to a secondary group, the secondary group is placed under a
primary group and the primary group is held by an AD server.  A form writes the
group of an account, and what the deployment holds afterwards is the whole
chain, because the primary group of an account and the server of its group are
derived by the suite from the group that was written rather than written beside
it.

Two things are read of a record: its *context* - the chain it is placed in, as
a plain dictionary, which a rule, a preset or an integration reads without
walking the chain again - and the *resolution* of a text into a record of the
chain, by the code a deployment writes a group with and the name it gives a
server.  ``maestro.user``, ``maestro.primary.group`` and
``maestro.secondary.group`` read their context with ``get_etude_context()``,
and ``maestro.computer`` reads the same of a machine where the companion
``maestro_computers`` is installed.

A reference read and written as a text
--------------------------------------

A form is answered in text where the chain is made of records, so a binding
that writes a reference of the chain writes the record the answer names rather
than the text of it: the answer is read as the *code* of the record it names -
the *name* of the server a group is held by - and the record is read through
the ORM, so the accesses, the field accesses and the record rules of the
deployment apply to the resolution exactly as they apply to the write it feeds.

An answer that names no record of the chain is refused rather than written as
no group at all, because a reference the designer asked for and the deployment
does not hold is a record the binding can not write.  The resolution runs
inside the transaction of the submit, so the whole submit is rolled back and
leaves neither a record nor an answer behind.

The two things a binding reads of the request
---------------------------------------------

A rule selects the record of the participant as often as it selects the record
an answer names, and a domain holds no answer of its own for it: ``$user``
names the login of the running user and ``$user_id`` its identifier, so a
definition reads the record of the participant without asking it a question.
What the login matches is decided by the target model the rule reads, so the
same placeholder reads the account of the participant over ``maestro.user`` and
its own record over ``res.user``.

An answer of the response overrides the placeholder, so a form which asks a
question coded ``user`` reads that answer rather than the login of the
participant, and a transaction that runs without a user - the one of a
deployment which installs a module - reads no placeholder at all.

The presets of the targets
--------------------------

The binding of an AD target is read the same way on every question of a
deployment, so what the module ships is its declaration rather than a second
copy of it: an ``etude.maestro.preset`` holds the declaration of one binding of
one target and one mode - the field, the key, the policy and the domain of its
rule - and applying it to a question writes the binding and the rule of that
question.

A preset speaks the payload the binding layer reads a definition with, so its
target is a technical model name and a field name rather than an identifier,
and it is read twice: where it is written, so that a designer reads why a
declaration is refused, and where it is applied, so that a preset whose model
this deployment does not hold is refused with the message of the binding layer
rather than written as a binding that reads nothing.  Applying a preset is a
capability of the running user, because the binding it writes is validated
where it is written - a user who may not name the target is refused with the
message of the whitelist and not with a binding written half way.

The worked example
------------------

What the module ships to prove the bridge is an onboarding example, and it is
*written* by a wizard (``etude.maestro.onboarding``) rather than shipped as
data: a binding names a model and a field of it, and the models and the fields
of a deployment are rows of ``ir.model`` and ``ir.model.field`` which a data
file can not name by a name that survives a restore.  The bindings of the
example are therefore resolved through the pool of the deployment they are
written in, by the presets the module ships, and the wizard runs as a user of
that deployment: a binding is a capability of that user, so it is written by
one who may name the target rather than loaded by the deployment as no user at
all.

What the wizard writes is one published form whose questions ask the account
name, the display name, the profile type and the disk quota of the participant
and the secondary group the account is placed in; the account of the
participant is read back into the questions that ask what the deployment
already holds, the group an answer names is checked, and the submit writes the
account and the group it is placed in, from which the primary group and the AD
server follow.

An optional dependency
----------------------

``maestro_computers`` is an optional dependency of the module
(``extras_depend``), and so is the model it holds for a deployment that
installs the bridge without it.  A deployment which installs it registers
``computer.Computer`` from a ``[register maestro_computers]`` section of
``tryton.cfg``, which the pool fills only where that dependency is activated,
and a preset that names ``maestro.computer`` is refused where it is applied in
a deployment that holds no such model.

The bridge is optional in both directions: neither the etude group nor the
maestro group depends on it, so a deployment which does not install it binds
nothing differently.

See ``doc/index.rst`` for the module documentation and ``ETUDE.md`` in
``modules-cch/`` for the architecture of the whole group.
