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

Eligibility Start: Show Veteran-flow specific bullet copy #1459

Merged
merged 7 commits into from Jun 30, 2023

Conversation

machikoyasuda
Copy link
Member

@machikoyasuda machikoyasuda commented Jun 27, 2023

closes #1441

This PR does not change any CSS. It looks like some indentation has changed on this screen.

What this PR does

  • Add English and Spanish copy for bullets
  • Adds bullets an optional JSONField to the EligibilityVerifer model and migrations
  • Adds bullets data with the strings of the msgids for the Eligibility Start page MediaItem's bullets, for VA, Login.gov (MST, SacRT)

This PR makes model changes

How to run this PR locally

bin/makemigrations.sh
bin/init.sh

How to test

  • Test all the combinations of Eligibility Start pages: MST/Login.gov, MST/VA.gov, MST/CC - for correct bullet information in English and Spanish, SacRT/Login.gov (for no regressions)

Screenshots

image image image

@github-actions github-actions bot added i18n Copy: Language files or Django i18n framework deployment-dev [auto] Changes that will trigger a deploy if merged to dev back-end Django views, sessions, middleware, models, migrations etc. and removed i18n Copy: Language files or Django i18n framework labels Jun 27, 2023
@machikoyasuda machikoyasuda marked this pull request as ready for review June 27, 2023 21:23
@machikoyasuda machikoyasuda requested a review from a team as a code owner June 27, 2023 21:23
benefits/eligibility/views.py Outdated Show resolved Hide resolved
@machikoyasuda
Copy link
Member Author

@thekaveman @angela-tran Posting this question here for posterity:

In this latest commit, f548b4b, I'm trying to do the following:

  • Add bullets field, of type JSONField, to EligibilityVerifier model
  • Add bullets field, of type JSONField, to the initial EligibilityVerifier model migration

When I do just these two things, and run bin/makemigrations.sh; bin/init.sh - the app starts up fine. I'm able to run the django shell and manually add and save a dict to a specific EligibilityVerifier object.

When, however, I try to add a bullets with a non-empty dict to mst_veteran_verifier in 0002_data.py field, and then run bin/makemigrations.sh; bin/init.sh, the command fails at init.sh's python manage.py migrate command - returning TypeError: Object of type __proxy__ is not JSON serializable which causes a db transaction error: TransactionManagementError( django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.

Any ideas? I was thinking maybe I have... some sort of syntax error or declaring the bullets={...} incorrectly, or the way the db isn't compatible with JSONFields or something (??)

Full stacktrace:

calitp@cdbe8faf8c05:~/app$ bin/makemigrations.sh
+ mkdir -p benefits/core/old_migrations
+ mv benefits/core/migrations/0001_initial.py benefits/core/migrations/0002_data.py benefits/core/migrations/__init__.py benefits/core/migrations/sample_agency.json benefits/core/old_migrations
+ cp benefits/core/old_migrations/__init__.py benefits/core/migrations
+ python manage.py makemigrations
Migrations for 'core':
  benefits/core/migrations/0001_initial.py
    - Create model AuthProvider
    - Create model EligibilityType
    - Create model EligibilityVerifier
    - Create model PaymentProcessor
    - Create model PemData
    - Create model TransitAgency
    - Add field client_cert to paymentprocessor
    - Add field client_cert_private_key to paymentprocessor
    - Add field client_cert_root_ca to paymentprocessor
    - Add field public_key to eligibilityverifier
+ cp benefits/core/old_migrations/0001_initial.py benefits/core/old_migrations/0002_data.py benefits/core/old_migrations/__init__.py benefits/core/old_migrations/sample_agency.json benefits/core/migrations --no-clobber --recursive
+ rm -rf benefits/core/old_migrations
+ python -m black benefits/core/migrations/0001_initial.py benefits/core/migrations/0002_data.py benefits/core/migrations/__init__.py
All done! ✨ 🍰 ✨
3 files left unchanged.
calitp@cdbe8faf8c05:~/app$ bin/init.sh 
+ rm -f django.db
+ python manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, core, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying auth.0010_alter_group_name_max_length... OK
  Applying auth.0011_update_proxy_permissions... OK
  Applying auth.0012_alter_user_first_name_max_length... OK
  Applying core.0001_initial... OK
  Applying core.0002_data...Traceback (most recent call last):
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/migrations/migration.py", line 132, in apply
    operation.database_forwards(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
    self.code(from_state.apps, schema_editor)
  File "/home/calitp/app/benefits/core/migrations/0002_data.py", line 180, in load_data
    mst_veteran_verifier = EligibilityVerifier.objects.create(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/query.py", line 658, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/base.py", line 814, in save
    self.save_base(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/base.py", line 877, in save_base
    updated = self._save_table(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/base.py", line 1020, in _save_table
    results = self._do_insert(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/base.py", line 1061, in _do_insert
    return manager._insert(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/manager.py", line 87, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/query.py", line 1805, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1819, in execute_sql
    for sql, params in self.as_sql():
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1743, in as_sql
    value_rows = [
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1744, in <listcomp>
    [
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1745, in <listcomp>
    self.prepare_value(field, self.pre_save_val(field, obj))
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1684, in prepare_value
    return field.get_db_prep_save(value, connection=self.connection)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/fields/json.py", line 134, in get_db_prep_save
    return self.get_db_prep_value(value, connection)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/models/fields/json.py", line 129, in get_db_prep_value
    return connection.ops.adapt_json_value(value, self.encoder)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/backends/base/operations.py", line 584, in adapt_json_value
    return json.dumps(value, cls=encoder)
  File "/usr/local/lib/python3.10/json/__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
  File "/usr/local/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/local/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/usr/local/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type __proxy__ is not JSON serializable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/calitp/app/manage.py", line 21, in <module>
    main()
  File "/home/calitp/app/manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "/home/calitp/.local/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
    output = self.handle(*args, **options)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/core/management/base.py", line 106, in wrapper
    res = handle_func(*args, **kwargs)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 356, in handle
    post_migrate_state = executor.migrate(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
    state = self._migrate_all_forwards(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
    state = self.apply_migration(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/migrations/executor.py", line 249, in apply_migration
    with self.connection.schema_editor(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/backends/sqlite3/schema.py", line 38, in __exit__
    self.connection.check_constraints()
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 244, in check_constraints
    violations = cursor.execute("PRAGMA foreign_key_check").fetchall()
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/backends/utils.py", line 83, in _execute
    self.db.validate_no_broken_transaction()
  File "/home/calitp/.local/lib/python3.10/site-packages/django/db/backends/base/base.py", line 531, in validate_no_broken_transaction
    raise TransactionManagementError(
django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.

@machikoyasuda
Copy link
Member Author

@thekaveman @angela-tran ready for review

While pairing with @angela-tran, we changed the following:

  • bullets are now a list of msgid strings
  • apply the _ translation method to each item in verifier.bullets in the view method

angela-tran
angela-tran previously approved these changes Jun 29, 2023
Copy link
Member

@angela-tran angela-tran left a comment

Choose a reason for hiding this comment

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

👍

thekaveman
thekaveman previously approved these changes Jun 29, 2023
Copy link
Member

@thekaveman thekaveman left a comment

Choose a reason for hiding this comment

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

This looks great!

@machikoyasuda machikoyasuda force-pushed the feat/1441-veterans--elig-start-bullet-copy branch from e2dbfaf to 2db41b0 Compare June 30, 2023 00:04
@machikoyasuda machikoyasuda merged commit 8a555fd into dev Jun 30, 2023
13 checks passed
@machikoyasuda machikoyasuda deleted the feat/1441-veterans--elig-start-bullet-copy branch June 30, 2023 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eligibility Start: Bullet copy for each EligibilityVerifier
3 participants