compliance-trestle icon indicating copy to clipboard operation
compliance-trestle copied to clipboard

feat: Allow jinja to pull prose by name from sub-parts of a control

Open fsuits opened this issue 2 years ago • 1 comments

Issue description / feature objectives

Recent new features in trestle allow injection of guidance prose into a control at arbitrarily deep sub-parts of the control, instead of simply named "sections" that are parts added to the list of the control's parts. As a result, @aerwin has need to query a control for its guidance by name, and as a response get a list of all the found prose along with the associated label or section in which the prose was found. Here are examples:

# Editable Content

## Control Implementation Guidance

Implementation prose as new part added to the control's parts.

## Control Extra Guidance

Extra prose as new part added to the control's parts

## Part a.

### Implementation Guidance

Implementation prose attached as sub-part to item with label a. in the statement part of the control.

### Extra Guidance

Extra prose attached as sub-part to item with label a. in the statement part of the control.

There is a need for a query like get_control_prose(control_id, guidance_name) that returns a list of prose and corresponding label:

get_control_prose('ac-2', 'implementation_guidance')  returns:
'', 'Implementation prose as new part added to the control's parts.'
'a.', 'Implementation prose attached as sub-part to item with label a. in the statement part of the control.'

The first return has an empty associated label ('') indicating it is a top level "section" as its own part in the control. The second return indicates the prose was found in the a. item of the control's statement.

Caveats / Assumptions

The user writing jinja to make the query must know the "short names" of the guidance that is being queried. The default conversion from "long version title": "Implementation Guidance" is to make it snake-case as implementation_guidance, and that is the actual name of the part being queried. But the user may specify a special short name by using the "sections" argument in trestle commands. Either way, the actual name of the part must be known.

Completion Criteria

  • Make sure all needed use cases are handled
  • Add the needed query that can be accessed by jinja
  • Provide a jinja example showing that it works

fsuits avatar Sep 16 '22 00:09 fsuits