Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata fields to the output of the Weaver to help with publishing to courtformsonline.org #925

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions docassemble/ALWeaver/data/questions/assembly_line.yml
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ fields:
required: False
validate: |
lambda y: (not y or is_url(y)) or validation_error("Write a valid URL, like: https://masslegalhelp.org/my_form")
- Date original form was last published (optional): interview.original_form_published_on
datatype: date
required: False
- Web page with related resources (optional): interview.help_page_url
help: |
Include a link to a resource that explains the topic of this form. For example,
Expand Down Expand Up @@ -498,7 +501,10 @@ fields:
states_list(country_code=interview.default_country_code) if pycountry.subdivisions.get(country_code=interview.default_country_code) else ()
default: ${ "MA" if interview.default_country_code == 'US' else '' }
required: False

- Jurisdiction: interview.jurisdiction
default: NAM-US-US+MA
help: |
Use the [LMSS](https://www.sali.org/) standard for jurisdiction codes. For example, "NAM-US-US+MA" for Massachusetts.
- note: |
---
<h2 class="h5">Optional packages to include</h2>
Expand Down Expand Up @@ -602,6 +608,13 @@ fields:
- Custom filename: interview_label_draft
show if: interview.customize_file_name
default: ${ varname(interview.short_filename_with_spaces[:35]) }
- Court-assigned form number (optional): interview.form_number
required: False
help: |
For example, "CJ-P 1234"
- Filing fee (optional): interview.filing_fee
datatype: currency
required: False
- Description of the form for metadata: interview.description
default: |
This interview helps someone in ${ state_name(interview.state, country_code=interview.default_country_code) } ${ interview.intro_prompt[0:1].lower() }${ interview.intro_prompt[1:] }.
Expand All @@ -610,6 +623,14 @@ fields:
help: |
This description can help people find your form. It is not
displayed inside the interview.
- "Answer this question: you can use this form if": interview.can_I_use_this_form
datatype: area
rows: 2
default: |
If you are a _____________, you can use this interview to ____________.
help: |
It's important to explain to the user when they can and cannot use
your form. Write any conditions, such as age, status of their case, etc.
- label: |
What does your user need to know before they start this interview?
field: interview.getting_started
Expand All @@ -625,17 +646,27 @@ fields:
When you are finished, you will need to:

1.
1.

Most people take about _______ minutes to finish this interview.
1.
datatype: area
rows: 17
rows: 14
help: |
Tell your user what they need to know before they start the form.
This helps your user feel prepared and
prevents frustration later in your interview, especially for longer
forms. You can use Markdown lists (1. ) and bullets (*) at the beginning
of a line to add formatting.
- To complete this form, most people take about: interview.estimated_completion_minutes
grid: 2
datatype: integer
under text: |
minutes
default: 10
- plus or minus: interview.estimated_completion_delta
grid: 2
datatype: integer
default: 5
under text: |
minutes
---
code: |
interview_label_draft = interview.title[:35]
Expand Down
46 changes: 44 additions & 2 deletions docassemble/ALWeaver/data/templates/output.mako
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,27 @@ metadata:
${ interview.short_title }
description: |-
${ indent(interview.description, by=4) }
can_I_use_this_form: |
% if interview.can_I_use_this_form:
${ indent(interview.can_I_use_this_form, by=4) }
% endif
before_you_start: |
% if interview.getting_started:
${ indent(interview.getting_started, by=4) }
% endif
maturity: production
estimated_completion_minutes: 60
estimated_completion_delta: 30
% if interview.categories.any_true():
LIST_topics:
% for category in sorted(set(interview.categories.true_values())):
- "${ escape_double_quoted_yaml(oneline(category)).strip() }"
% endfor
% if interview.has_other_categories:
% for category in interview.other_categories.split(','):
- "${ escape_double_quoted_yaml(oneline(category)).strip() }"
% endfor
% endif
tags:
% for category in sorted(set(interview.categories.true_values())):
- "${ escape_double_quoted_yaml(oneline(category)).strip() }"
Expand All @@ -35,7 +55,10 @@ ${ indent(interview.description, by=4) }
% if interview.original_form:
original_form:
- ${ interview.original_form }
% else:
original_form: []
% endif
original_form_published_on: ${ interview.original_form_published_on.format("yyyy-MM-dd") or '""'}
% if interview.help_page_url:
help_page_url: >-
${ indent(interview.help_page_url, by=4) }
Expand All @@ -55,6 +78,23 @@ ${ indent(interview.help_page_title, by=4) }
% endif
al_weaver_version: "${ package_version_number }"
generated_on: "${ today().format("yyyy-MM-dd") }"
languages:
- en
jurisdiction: ${ interview.jurisdiction }
review_date: ${ today().format("yyyy-MM-dd")}
form_titles:
- ${ interview.title }
% if interview.form_number:
form_numbers:
- ${ interview.form_number }
% else:
form_numbers: []
% endif
% if interview.filing_fee:
fees:
- Filing fee: ${ currency(interview.filing_fee) }
% endif
update_notes: |
---
code: |
# This controls the default country and list of states in address field questions
Expand Down Expand Up @@ -154,14 +194,16 @@ code: |
- just use interview_label instead of varname(interview.title)
</%doc>\
---
comment: |
This question is used to introduce your interview. Please customize
id: ${ varname(interview.title) }
continue button field: ${ interview.interview_label }_intro
question: |
${ interview.title }
subquestion: |
${ indent(interview.getting_started, 2) }

${ indent(interview.can_I_use_this_form, by=2)}

Most people take about ${ interview.estimated_completion_minutes or "_______________"} minutes to complete this interview.
<%doc>
Main question loop
</%doc>\
Expand Down
1 change: 1 addition & 0 deletions docassemble/ALWeaver/generator_constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Constants for interview_generator.py
"""

from typing import Dict, List


Expand Down
24 changes: 13 additions & 11 deletions docassemble/ALWeaver/interview_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ def user_ask_about_field(self):
"label above field": True,
"grid": 3,
"code": "field_type_options()",
"default": self.field_type_guess
if hasattr(self, "field_type_guess")
else None,
"default": (
self.field_type_guess if hasattr(self, "field_type_guess") else None
),
}
)
field_questions.append(
Expand Down Expand Up @@ -517,14 +517,16 @@ def user_ask_about_field(self):
"field": self.attr_name("choices"),
"datatype": "area",
"js show if": f"['multiple choice dropdown','multiple choice combobox','multiselect', 'multiple choice radio', 'multiple choice checkboxes'].includes(val('{ self.attr_name('field_type') }'))",
"default": "\n".join(
[
f"{opt.capitalize().replace('_', ' ')}: {opt}"
for opt in self.choice_options
]
)
if hasattr(self, "choice_options")
else None,
"default": (
"\n".join(
[
f"{opt.capitalize().replace('_', ' ')}: {opt}"
for opt in self.choice_options
]
)
if hasattr(self, "choice_options")
else None
),
"help": "Like `Descriptive name: key_name`, or just `Descriptive name`",
"hint": "Descriptive name: key_name",
}
Expand Down
Loading