From a0a855c3ec66303a46e20013528112c16ea36611 Mon Sep 17 00:00:00 2001 From: Daniel Miranda Date: Sun, 26 Sep 2021 15:15:56 -0700 Subject: [PATCH 1/2] added new fields, however, need to ask whether or not we want the helptext fields to go along or if they are static: --- .../migrations/0039_auto_20210926_2156.py | 39 +++++++++++++++++ .../wagtailpages/pagemodels/products.py | 43 ++++++++++++++++--- 2 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 network-api/networkapi/wagtailpages/migrations/0039_auto_20210926_2156.py diff --git a/network-api/networkapi/wagtailpages/migrations/0039_auto_20210926_2156.py b/network-api/networkapi/wagtailpages/migrations/0039_auto_20210926_2156.py new file mode 100644 index 00000000000..e355cdb7653 --- /dev/null +++ b/network-api/networkapi/wagtailpages/migrations/0039_auto_20210926_2156.py @@ -0,0 +1,39 @@ +# Generated by Django 3.1.11 on 2021-09-26 21:56 + +from django.db import migrations, models +import networkapi.wagtailpages.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailpages', '0038_auto_20210924_2002'), + ] + + operations = [ + migrations.AddField( + model_name='generalproductpage', + name='ai_can_user_control', + field=networkapi.wagtailpages.fields.ExtendedYesNoField(help_text='Does the user have control over the AI features?'), + ), + migrations.AddField( + model_name='generalproductpage', + name='ai_can_user_control_helptext', + field=models.TextField(blank=True, help_text='Helptext that will appear in the can user control section.', max_length=5000), + ), + migrations.AddField( + model_name='generalproductpage', + name='ai_is_transparent_helptext', + field=models.TextField(blank=True, help_text='Helptext that will appear in the AI is transparent section.', max_length=5000), + ), + migrations.AddField( + model_name='generalproductpage', + name='ai_is_untrustworthy_helptext', + field=models.TextField(blank=True, help_text='Helptext that will appear in the AI is untrustworthy section.', max_length=5000), + ), + migrations.AlterField( + model_name='generalproductpage', + name='ai_is_untrustworthy', + field=networkapi.wagtailpages.fields.ExtendedYesNoField(help_text='Is the AI untrustworthy?'), + ), + ] diff --git a/network-api/networkapi/wagtailpages/pagemodels/products.py b/network-api/networkapi/wagtailpages/pagemodels/products.py index 8525b10dc13..f70d339b93b 100644 --- a/network-api/networkapi/wagtailpages/pagemodels/products.py +++ b/network-api/networkapi/wagtailpages/pagemodels/products.py @@ -1116,16 +1116,23 @@ class GeneralProductPage(ProductPage): ai_is_transparent = ExtendedYesNoField( help_text='Does the company allow users to see how the AI works?' ) - + ai_is_transparent_helptext = models.TextField( + max_length=5000, + blank=True, + help_text='Helptext that will appear in the AI is transparent section.', + ) ai_helptext = models.TextField( max_length=5000, blank=True, help_text='Helpful text around AI to show on the product page', ) - ai_is_untrustworthy = models.BooleanField( - null=True, + ai_is_untrustworthy = ExtendedYesNoField( + help_text='Is the AI untrustworthy?' + ) + ai_is_untrustworthy_helptext = models.TextField( + max_length=5000, blank=True, - help_text='Is the AI untrustworthy?', + help_text='Helptext that will appear in the AI is untrustworthy section.', ) ai_is_untrustworthy_ding = models.BooleanField( help_text='Tick this box if the AI invades privacy or behaves unethically.', @@ -1135,6 +1142,14 @@ class GeneralProductPage(ProductPage): blank=True, help_text='What kind of decisions does this AI make about you or for you?' ) + ai_can_user_control = ExtendedYesNoField( + help_text='Does the user have control over the AI features?' + ) + ai_can_user_control_helptext = models.TextField( + max_length=5000, + blank=True, + help_text='Helptext that will appear in the can user control section.', + ) @classmethod def map_import_fields(cls): @@ -1158,9 +1173,13 @@ def map_import_fields(cls): "AI uses personal data": "ai_uses_personal_data", "AI help text": "ai_helptext", "AI is transparent": "ai_is_transparent", + "AI is transparent help text": "ai_is_transparent_helptext", "AI is untrustworthy": "ai_is_untrustworthy", + "AI is untrustworthy help text": "ai_is_untrustworthy_helptext", "AI is untrustworthy ding": "ai_is_untrustworthy_ding", "AI What can it do": "ai_what_can_it_do", + "AI can user control": "ai_can_user_control", + "AI can user control help text": "ai_can_user_control_helptext", } # Return the merged fields return {**generic_product_import_fields, **general_product_mappings} @@ -1188,11 +1207,15 @@ def get_export_fields(self): "Offline use": self.offline_use_description, "Uses AI": self.uses_ai, "AI uses personal data": self.ai_uses_personal_data, - "AI is transparent": self.ai_uses_personal_data, + "AI is transparent": self.ai_is_transparent, + "AI is transparent help text": self.ai_is_transparent_helptext, "AI help text": self.ai_helptext, "AI is untrustworthy": self.ai_is_untrustworthy, + "AI is untrustworthy help text": self.ai_is_untrustworthy_helptext, "AI is untrustworthy ding": self.ai_is_untrustworthy_ding, "AI What can it do": self.ai_what_can_it_do, + "AI can user control": self.ai_can_user_control, + "AI can user control help text": self.ai_can_user_control_helptext, } # Merge the two dicts together. data = {**generic_product_data, **general_product_data} @@ -1274,12 +1297,16 @@ def get_export_fields(self): MultiFieldPanel( [ FieldPanel('uses_ai'), + FieldPanel('ai_helptext'), FieldPanel('ai_uses_personal_data'), FieldPanel('ai_is_transparent'), - FieldPanel('ai_helptext'), + FieldPanel('ai_is_transparent_helptext'), FieldPanel('ai_is_untrustworthy'), + FieldPanel('ai_is_untrustworthy_helptext'), FieldPanel('ai_is_untrustworthy_ding'), FieldPanel('ai_what_can_it_do'), + FieldPanel('ai_can_user_control'), + FieldPanel('ai_can_user_control_helptext'), ], heading='Artificial Intelligence', classname='collapsible' @@ -1301,10 +1328,14 @@ def get_export_fields(self): SynchronizedField('uses_ai'), SynchronizedField('ai_uses_personal_data'), SynchronizedField('ai_is_transparent'), + TranslatableField('ai_is_transparent_helptext'), TranslatableField('ai_helptext'), SynchronizedField('ai_is_untrustworthy'), + TranslatableField('ai_is_untrustworthy_helptext'), SynchronizedField('ai_is_untrustworthy_ding'), TranslatableField('ai_what_can_it_do'), + SynchronizedField('ai_can_user_control'), + TranslatableField('ai_can_user_control_helptext'), ] @property From 6a580aeb33afb628267b0b71c365b7a21855d18b Mon Sep 17 00:00:00 2001 From: Daniel Miranda Date: Mon, 27 Sep 2021 17:58:18 -0700 Subject: [PATCH 2/2] updated AI fields, as well as reordered them in the code and CMS to match new PNI product page template --- .../wagtailpages/pagemodels/products.py | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/network-api/networkapi/wagtailpages/pagemodels/products.py b/network-api/networkapi/wagtailpages/pagemodels/products.py index f70d339b93b..29c3ef22d73 100644 --- a/network-api/networkapi/wagtailpages/pagemodels/products.py +++ b/network-api/networkapi/wagtailpages/pagemodels/products.py @@ -1108,19 +1108,6 @@ class GeneralProductPage(ProductPage): uses_ai = ExtendedYesNoField( help_text='Does the product use AI?' ) - - ai_uses_personal_data = ExtendedYesNoField( - help_text='Does the AI use your personal data to make decisions about you?' - ) - - ai_is_transparent = ExtendedYesNoField( - help_text='Does the company allow users to see how the AI works?' - ) - ai_is_transparent_helptext = models.TextField( - max_length=5000, - blank=True, - help_text='Helptext that will appear in the AI is transparent section.', - ) ai_helptext = models.TextField( max_length=5000, blank=True, @@ -1142,6 +1129,14 @@ class GeneralProductPage(ProductPage): blank=True, help_text='What kind of decisions does this AI make about you or for you?' ) + ai_is_transparent = ExtendedYesNoField( + help_text='Does the company allow users to see how the AI works?' + ) + ai_is_transparent_helptext = models.TextField( + max_length=5000, + blank=True, + help_text='Helptext that will appear in the AI is transparent section.', + ) ai_can_user_control = ExtendedYesNoField( help_text='Does the user have control over the AI features?' ) @@ -1150,6 +1145,9 @@ class GeneralProductPage(ProductPage): blank=True, help_text='Helptext that will appear in the can user control section.', ) + ai_uses_personal_data = ExtendedYesNoField( + help_text='Does the AI use your personal data to make decisions about you?' + ) @classmethod def map_import_fields(cls): @@ -1298,15 +1296,16 @@ def get_export_fields(self): [ FieldPanel('uses_ai'), FieldPanel('ai_helptext'), - FieldPanel('ai_uses_personal_data'), - FieldPanel('ai_is_transparent'), - FieldPanel('ai_is_transparent_helptext'), FieldPanel('ai_is_untrustworthy'), FieldPanel('ai_is_untrustworthy_helptext'), FieldPanel('ai_is_untrustworthy_ding'), FieldPanel('ai_what_can_it_do'), + FieldPanel('ai_is_transparent'), + FieldPanel('ai_is_transparent_helptext'), FieldPanel('ai_can_user_control'), FieldPanel('ai_can_user_control_helptext'), + FieldPanel('ai_uses_personal_data'), + ], heading='Artificial Intelligence', classname='collapsible'