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

[docs] Update B5 migration guide #34825

Merged
merged 8 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def handle(self, app_name, **options):
if not confirm:
return

if not is_app_in_progress(app_name) and not is_app_migration_complete:
self.no_split = options.get('no_split')
if not is_app_in_progress(app_name) and not is_app_migration_complete and not self.no_split:
self.stdout.write(self.style.WARNING(
f"\n\n'{app_name}' is not marked as 'in progress'.\n"
))
Expand All @@ -129,7 +130,6 @@ def handle(self, app_name, **options):
show_apply_commit=not has_changes
)

self.no_split = options.get('no_split')
self.skip_all = options.get('skip_all')
if self.skip_all and self.no_split:
self.stderr.write(
Expand Down
6 changes: 2 additions & 4 deletions corehq/apps/hqwebapp/tests/utils/test_bootstrap_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,8 @@ def test_flag_inline_styles():
def test_flag_crispy_forms_in_template():
line = """ {% crispy form %}\n"""
flags = flag_crispy_forms_in_template(line)
eq(flags, [["check crispy",
"This template uses crispy forms. "
"Please ensure the form looks good after migration, and refer to "
"the updated Style Guide for current best practices, especially with checkbox fields."]])
eq(flags[0][0], "check crispy")
eq(flags[0][1].startswith("This template uses crispy forms."), True)


def test_flag_changed_javascript_plugins_bootstrap5():
Expand Down
4 changes: 1 addition & 3 deletions corehq/apps/hqwebapp/utils/bootstrap/changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,7 @@ def flag_crispy_forms_in_template(line):
if re.search(regex, line):
flags.append([
"check crispy",
"This template uses crispy forms. "
"Please ensure the form looks good after migration, and refer to "
"the updated Style Guide for current best practices, especially with checkbox fields."
_get_change_guide("crispy")
])
return flags

Expand Down
19 changes: 19 additions & 0 deletions corehq/apps/hqwebapp/utils/bootstrap/changes_guide/crispy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
This template uses crispy forms.

Please ensure the form looks good after migration, and refer to the
<a href="https://www.commcarehq.org/styleguide/b5/organisms/forms/#crispy-forms" target="_blank">crispy forms
section</a> of the style guide.

A few useful things to know about crispy forms in Bootstrap 5:

* Checkboxes, typically based on a `BooleanField`, need to be updated to use the `BootstrapCheckboxInput` as their
`widget`, as shown in <a href="https://www.commcarehq.org/styleguide/b5/organisms/forms/#crispy-forms-simple"
target="_blank">this style guide example</a>.
* As described in <a href="https://www.commcarehq.org/styleguide/b5/organisms/forms/#crispy-forms-simple"
target="_blank">this section of the style guide</a>, best practice is to use one of HQ's standard helper classes
for layout. Doing so means you can delete <code>form_class</code>, <code>label_class</code>,
<code>field_class</code>, and <code>offset_class</code> from the form itself. This allows us to change the layout
of crispy forms across HQ without needing to update each individual form.
* If you do need to troubleshoot Bootstrap issues with crispy forms, be aware that Dimagi maintains a <a
href="https://github.com/dimagi/crispy-bootstrap3to5" target="_blank">crispy-bootstrap3to5 </a> repo with
transitional templates. You may also need to troubleshoot in the crispy templates.
Loading
Loading