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 new ExtendedChoiceField and map ai_is_trustworthy "Yes"/"No" values to "CD" #12979

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

danielfmiranda
Copy link
Collaborator

@danielfmiranda danielfmiranda commented Oct 8, 2024

Description

Link to Review App: https://foundation-s-pni-trustw-eoreu3.herokuapp.com/en/privacynotincluded/newspaper-present-man-recent/

This PR introduces a new ExtendedChoiceField model, offering users the following selection of options:

  • Good
  • Average
  • Needs Improvement
  • Bad
  • Not Applicable
  • Can’t Determine

The ai_is_untrustworthy field in the GeneralProductPage model has been updated to use this new set of choices.

Additionally, this PR includes a migration operation that iterates through all GeneralProductPage instances where ai_is_untrustworthy is currently set to Yes or No, and updates those values to Can’t Determine (CD) to align with the new choices.

Some front-end templates have also been updated to accommodate for this change to the ai_is_untrustworthy field.

Screenshots

CMS:
Screenshot 2024-10-08 at 12 40 35 PM

CMS (Choices):
Screenshot 2024-10-08 at 12 40 47 PM

Template:
Screenshot 2024-10-08 at 12-40-58 RA Newspaper present man recent  Privacy   security guide Mozilla Foundation

Methodology Template:
Screenshot 2024-10-08 at 12-43-12 RA Our methodology Privacy Not Included Mozilla Foundation

How-to-use Template:
Screenshot 2024-10-08 at 12-44-20 RA How to use Privacy Not Included Mozilla Foundation

┆Issue is synchronized with this Jira Story

@danielfmiranda danielfmiranda changed the title Pni trustworthy ai field update Add new ExtendedChoiceField and map ai_is_trustworthy "Yes"/"No" values to "CD" Oct 8, 2024
@MozillaFoundation MozillaFoundation deleted a comment from mergify bot Oct 8, 2024
Comment on lines +6 to +7
<p class="pni-product-smaller-body mb-0">{% trans "Device:" %} <span class="font-italic">{{ device|extended_choice }}</span></p>
<p class="pni-product-smaller-body mb-0">{% trans "App:" %} <span class="font-italic">{{ app|extended_choice }}</span></p>
Copy link
Collaborator Author

@danielfmiranda danielfmiranda Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not directly related to the field ai_is_untrustworthy, these have been updated to use the updated template tag mentioned here

@@ -3,6 +3,6 @@
<div class="signup-requirement d-flex flex-column">
<h4 class="pni-product-smaller-body-bold">{{ title }}</h4>
<div class="explanation">
<p class="pni-product-smaller-body mb-0">{{ value | extended_yes_no }}</p>
<p class="pni-product-smaller-body mb-0">{{ value | extended_choice }}</p>
Copy link
Collaborator Author

@danielfmiranda danielfmiranda Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While not directly related to the field ai_is_untrustworthy, this line has been updated to use the updated template tag mentioned here

Comment on lines +18 to +27
def extended_choice(value):
"""Converts key from ExtendedChoiceField/ExtendedYesNoField to human readable string"""
if value == "Good":
return gettext("Good")
if value == "AVG":
return gettext("Average")
if value == "NI":
return gettext("Needs Improvement")
if value == "Bad":
return gettext("Bad")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this existing tag instead of creating a new one, because almost all of the GeneralProductPage's fields use the template "product_criterion_primary_info.html", which uses this tag, to render its selection.

@@ -15,7 +15,7 @@ <h3 class="tw-mb-8 tw-font-zilla tw-text-2xl tw-leading-7 tw-flex tw-items-cente
</div>
{% else %}
<p class="rating pni-product-smaller-body mb-0">
{% trans value|extended_yes_no context value|extended_yes_no %}
{% trans value|extended_choice context value|extended_choice %}
Copy link
Collaborator Author

@danielfmiranda danielfmiranda Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the template used to render the "How trustworthy is the AI?" section, as well as every other field that uses the ExtendedYesNoField/ExtendedChoiceField.

It has been updated to use the updated template tag mentioned here

import networkapi.wagtailpages.fields


def map_yes_no_to_cant_determine(apps, schema_editor):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos! Good job on this! 🙌

Copy link
Collaborator

@dlopezvsr dlopezvsr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielfmiranda thank you for working on this. Everything looks good to me, I just left a minor suggestion for the ai_help title. Amazing work! 🚀

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielfmiranda amzing job! A minor observation I just saw on the ai_helptext title, it would be nice to standardize the word of "Ai" to "AI" - maybe we can add verbose_name="AI helptext" 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants