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

TP2000-1130 Move current workbasket from Session to custom User model #1123

Merged
merged 34 commits into from
Jan 29, 2024

Conversation

mattjamc
Copy link
Collaborator

@mattjamc mattjamc commented Jan 11, 2024

TP2000-1130 Move current workbasket from Session to custom User model

Why

TMs have reported losing their current workbasket and having it switch to an entirely different one after a short period of inactivity, which has led on occasion to tariff changes being applied to the wrong workbasket. Saving the users' current workbasket in the database rather than in the session would prevent this from happening following session expiration.

What

  • Updates User model referencing to use get_user_model()

  • Substitutes Django's default User model for a custom user model (see #Note)

  • Adds current_workbasket field to User model to store the user's current workbasket in the DB

  • Add User model to admin

  • Updates require_current_workbasket view decorator to redirect users without an active current workbasket to select a new workbasket

  • Removes now unused ValidateSessionWorkBasketMiddleware

  • Adds a new view, template and route, NoActiveWorkBasket, to be used as a redirect endpoint for users without an active current workbasket

  • Updates WorkBasket model methods and test fixtures to account for the workbasket now being stored in the user model rather than session data

    New model methods:

    • assign_to_user sets the workbasket to be the user's current workbasket
    • remove_users_current_workbasket removes user's current workbasket

    Removed model methods:

    • save_to_session previously saved workbasket to the session of request
    • load_from_session previously queried session workbasket from database
    • remove_current_from_session previously deleted the workbasket from the session data

    New fixtures:

    • client_with_current_workbasket returns a valid user client with a workbasket associated to the user
    • api_client_with_current_workbasket returns a valid user api client with a workbasket associated to the user
    • session_request_with_workbasket returns a request object with a valid user with a current workbasket and session
    • user_workbasket returns a workbasket which has been assigned to a valid logged-in user
    • user_empty_workbasket - returns an empty workbasket which bas been assigned to a valid logged-in user
    • client_with_current_workbasket_no_permissions - returns a client with a logged in user who has a current workbasket but no permissions

    Removed fixtures:

    • session_workbasket previously returned a workbasket in the session
    • session_empty_workbasket previously returned an empty workbasket in the session
  • Adds new unit tests for the new changes

Note

This PR followed the guide set out in https://code.djangoproject.com/ticket/25313#comment:24 to change to a custom user model mid project.

It's possible to place the custom User model in its own app, say users, however that requires either truncating the django_migrations table or manually inserting the initial migration for the user model (using raw SQL) into the table making it as if it had already been applied. This would need doing only once for production but need doing every time a new DB snapshot was imported for local dev environments if the snapshot preceded the manual intervention to the migrations table on prod.

Screenshot

Screenshot 2024-01-12 at 09 45 30 Screenshot 2024-01-24 at 15 50 20 Screenshot 2024-01-24 at 15 50 33

Checklist

  • Requires migrations? Yes

dalecannon and others added 3 commits January 3, 2024 10:44
* Update middleware to check for workbasket changing state

* Update to use decorator rather than middleware, add pytest fixtures

* Update tests that require a session workbasket to run

* Move views and urls to workbasket app and update template

* Add tests for when workbasket status changes

* Tidy up following Pauls comments

* Update models and templates to find workbasket in user model

* Update test fixtures for workbasket being in user model

* Tidy up and test updates
@dalecannon dalecannon changed the title TP2000-1152-handling-invalid-workbaskets TP2000-1130 Move current workbasket from Session to custom User model Jan 11, 2024
@codecov-commenter
Copy link

codecov-commenter commented Jan 12, 2024

Codecov Report

Attention: 109 lines in your changes are missing coverage. Please review.

Comparison is base (e1e87cd) 93.33% compared to head (a296289) 93.17%.
Report is 4 commits behind head on master.

Files Patch % Lines
measures/tests/test_migrations.py 10.66% 67 Missing ⚠️
settings/common.py 23.07% 8 Missing and 2 partials ⚠️
workbaskets/models.py 65.21% 8 Missing ⚠️
reports/views.py 78.12% 6 Missing and 1 partial ⚠️
workbaskets/views/ui.py 50.00% 5 Missing ⚠️
commodities/tests/test_migrations.py 0.00% 4 Missing ⚠️
common/middleware.py 72.72% 2 Missing and 1 partial ⚠️
common/tests/test_migrations.py 0.00% 1 Missing ⚠️
publishing/tests/test_migrations.py 0.00% 1 Missing ⚠️
urls.py 50.00% 0 Missing and 1 partial ⚠️
... and 2 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1123      +/-   ##
==========================================
- Coverage   93.33%   93.17%   -0.16%     
==========================================
  Files         571      572       +1     
  Lines       42631    42888     +257     
  Branches     3069     3077       +8     
==========================================
+ Hits        39788    39961     +173     
- Misses       2249     2327      +78     
- Partials      594      600       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mattjamc mattjamc marked this pull request as ready for review January 16, 2024 11:01
@dougmills-DIT dougmills-DIT requested a review from a team January 18, 2024 10:07
workbaskets/models.py Outdated Show resolved Hide resolved
commodities/tests/test_migrations.py Outdated Show resolved Hide resolved
commodities/tests/test_migrations.py Show resolved Hide resolved
workbaskets/models.py Outdated Show resolved Hide resolved
workbaskets/models.py Outdated Show resolved Hide resolved
workbaskets/models.py Outdated Show resolved Hide resolved
common/models/utils.py Outdated Show resolved Hide resolved
geo_areas/tests/test_views.py Show resolved Hide resolved
workbaskets/models.py Outdated Show resolved Hide resolved
workbaskets/admin.py Outdated Show resolved Hide resolved
workbaskets/models.py Outdated Show resolved Hide resolved
@mattjamc mattjamc merged commit d20d2af into master Jan 29, 2024
3 checks passed
@mattjamc mattjamc deleted the TP2000-1130--extend-user-model branch January 29, 2024 16:39
dougmills-DIT pushed a commit that referenced this pull request Feb 20, 2024
…#1123)

* Update User model references

* Use custom User model

* TP2000-1152-handling-invalid-workbaskets (#1113)

* Update middleware to check for workbasket changing state

* Update to use decorator rather than middleware, add pytest fixtures

* Update tests that require a session workbasket to run

* Move views and urls to workbasket app and update template

* Add tests for when workbasket status changes

* Tidy up following Pauls comments

* Update models and templates to find workbasket in user model

* Update test fixtures for workbasket being in user model

* Tidy up and test updates

* Update referencing to User model

* Updating bdd tests for new user model

* Add and update view and model unit tests

* Update require_current_workbasket decorator docstring

* Add docstring, move template for NoActiveWorkBasket view

* Amend current workbasket id retrieval in template

* Amend custom User model migration

* Remake migration adding current_workbasket field to User model

* Remove unused ValidateSessionWorkBasketMiddleware

* Make current_workbasket optional

* Add User model to admin

* Use historical models to fix migration tests

* Move ContentType data migration so it may be applied

* Rename function to remove a users current workbasket

* Amend docstrings

* Remove reference to session middleware that is no longer used

* Update workbaskets models following Pauls review

* Bring back user workbasket middleware as extra security

* Move User model from workbaskets app to common app

* Add forgotten content type data migration

* Remove setup_content_type fixture following patch to migrator fixture

* Amend middleware util method name

* Remove uneeded DoesNotExist try except block

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>
dougmills-DIT added a commit that referenced this pull request Feb 23, 2024
* TP2000-1168 Add sub-quota, blocking period & suspension period nested review tabs (#1133)

* Add sub-quotas nested review tab

* Add quota blocking periods nested review tab

* Add quota suspension periods nested review tab

* Use tab title instead of model verbose name

* Add blocking period and suspension period SID to table

* Feat: expand expiring quotas report to include tabs (#1131)

* feat: invoke UI changes to reports and create new URL path to handle reports with multiple tabs (#1134)

* feat: Add both CSV and excel types for charts exporting (#1136)

* TP2000-1185  Add maintenance mode (#1137)

* Add MAINTENANCE_MODE setting and middleware

* Fix middleware removal and recursive redirect

* Add template view and url

* Add tests

* Update contact us form link for other pages

* Update text wording

* Remove database route during maintenance

* Update maintenance page template/url name

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Increment message id & record sequence number correctly (#1083)

* record seq number & message id fix

* fix taricXMLRenderer, pass in value of counter

* feat: implement URLs for quota reports to ease navigation (#1135)

* Update readme with maintenance mode instructions. (#1140)

* TP2000-1130 Move current workbasket from Session to custom User model (#1123)

* Update User model references

* Use custom User model

* TP2000-1152-handling-invalid-workbaskets (#1113)

* Update middleware to check for workbasket changing state

* Update to use decorator rather than middleware, add pytest fixtures

* Update tests that require a session workbasket to run

* Move views and urls to workbasket app and update template

* Add tests for when workbasket status changes

* Tidy up following Pauls comments

* Update models and templates to find workbasket in user model

* Update test fixtures for workbasket being in user model

* Tidy up and test updates

* Update referencing to User model

* Updating bdd tests for new user model

* Add and update view and model unit tests

* Update require_current_workbasket decorator docstring

* Add docstring, move template for NoActiveWorkBasket view

* Amend current workbasket id retrieval in template

* Amend custom User model migration

* Remake migration adding current_workbasket field to User model

* Remove unused ValidateSessionWorkBasketMiddleware

* Make current_workbasket optional

* Add User model to admin

* Use historical models to fix migration tests

* Move ContentType data migration so it may be applied

* Rename function to remove a users current workbasket

* Amend docstrings

* Remove reference to session middleware that is no longer used

* Update workbaskets models following Pauls review

* Bring back user workbasket middleware as extra security

* Move User model from workbaskets app to common app

* Add forgotten content type data migration

* Remove setup_content_type fixture following patch to migrator fixture

* Amend middleware util method name

* Remove uneeded DoesNotExist try except block

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Bump aiohttp from 3.9.1 to 3.9.2 (#1142)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](aio-libs/aiohttp@v3.9.1...v3.9.2)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* initial commit - ref doc data model

* update importer model matching to account for end dated objects. (#1146)

* update importer model matching to account for end dated objects.

* update importer model matching to account for end dated objects.

* Tp2000 1211 (#1148)

* update govuk dependency since its been deleted at source

* update govuk dependency since its been deleted at source

* initial commit - ref doc data model

* wip commit

* Bump django from 3.2.23 to 3.2.24 (#1150)

Bumps [django](https://github.com/django/django) from 3.2.23 to 3.2.24.
- [Commits](django/django@3.2.23...3.2.24)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Tp2000 652  force rule check after real edit (#1130)

* added a check that if tracked models have been updated since the last checks business rules need run again
* data migration to add timestamps to tracked models and transaction checks
* tests for real edits
* tests for data migrations

* TP2000-1219  Prevent maintenance mode errors (#1152)

* Remove authbroker middleware when in maintenance mode

* Skip applying migrations in init script

* Prevent maintenance mode template attempts to access user attribute on request object

* Update privacy policy link

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* wip commit

* wip commit

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* TP2000-1168 Add sub-quota, blocking period & suspension period nested review tabs (#1133)

* Add sub-quotas nested review tab

* Add quota blocking periods nested review tab

* Add quota suspension periods nested review tab

* Use tab title instead of model verbose name

* Add blocking period and suspension period SID to table

* Feat: expand expiring quotas report to include tabs (#1131)

* feat: invoke UI changes to reports and create new URL path to handle reports with multiple tabs (#1134)

* feat: Add both CSV and excel types for charts exporting (#1136)

* TP2000-1185  Add maintenance mode (#1137)

* Add MAINTENANCE_MODE setting and middleware

* Fix middleware removal and recursive redirect

* Add template view and url

* Add tests

* Update contact us form link for other pages

* Update text wording

* Remove database route during maintenance

* Update maintenance page template/url name

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Increment message id & record sequence number correctly (#1083)

* record seq number & message id fix

* fix taricXMLRenderer, pass in value of counter

* feat: implement URLs for quota reports to ease navigation (#1135)

* Update readme with maintenance mode instructions. (#1140)

* TP2000-1130 Move current workbasket from Session to custom User model (#1123)

* Update User model references

* Use custom User model

* TP2000-1152-handling-invalid-workbaskets (#1113)

* Update middleware to check for workbasket changing state

* Update to use decorator rather than middleware, add pytest fixtures

* Update tests that require a session workbasket to run

* Move views and urls to workbasket app and update template

* Add tests for when workbasket status changes

* Tidy up following Pauls comments

* Update models and templates to find workbasket in user model

* Update test fixtures for workbasket being in user model

* Tidy up and test updates

* Update referencing to User model

* Updating bdd tests for new user model

* Add and update view and model unit tests

* Update require_current_workbasket decorator docstring

* Add docstring, move template for NoActiveWorkBasket view

* Amend current workbasket id retrieval in template

* Amend custom User model migration

* Remake migration adding current_workbasket field to User model

* Remove unused ValidateSessionWorkBasketMiddleware

* Make current_workbasket optional

* Add User model to admin

* Use historical models to fix migration tests

* Move ContentType data migration so it may be applied

* Rename function to remove a users current workbasket

* Amend docstrings

* Remove reference to session middleware that is no longer used

* Update workbaskets models following Pauls review

* Bring back user workbasket middleware as extra security

* Move User model from workbaskets app to common app

* Add forgotten content type data migration

* Remove setup_content_type fixture following patch to migrator fixture

* Amend middleware util method name

* Remove uneeded DoesNotExist try except block

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Bump aiohttp from 3.9.1 to 3.9.2 (#1142)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](aio-libs/aiohttp@v3.9.1...v3.9.2)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update importer model matching to account for end dated objects. (#1146)

* update importer model matching to account for end dated objects.

* update importer model matching to account for end dated objects.

* Tp2000 1211 (#1148)

* update govuk dependency since its been deleted at source

* update govuk dependency since its been deleted at source

* Bump django from 3.2.23 to 3.2.24 (#1150)

Bumps [django](https://github.com/django/django) from 3.2.23 to 3.2.24.
- [Commits](django/django@3.2.23...3.2.24)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Tp2000 652  force rule check after real edit (#1130)

* added a check that if tracked models have been updated since the last checks business rules need run again
* data migration to add timestamps to tracked models and transaction checks
* tests for real edits
* tests for data migrations

* TP2000-1219  Prevent maintenance mode errors (#1152)

* Remove authbroker middleware when in maintenance mode

* Skip applying migrations in init script

* Prevent maintenance mode template attempts to access user attribute on request object

* Update privacy policy link

* Formatting updates and adding end date field to footnote create (#1154)

* TP2000-1114: React enhanced forms proof of concept (#1091)

* Add react

* Start to build origins form in react

* Build quota origin form with initial data

* Enable adding/removing of origins

* Repopulate form initial in case of error on submit

* Pass errors from django to react

* Create origins

* Add aria attribute

* Reinstate geo area descriptions in form

* Organise JS, code comments

* Add key for react list

* Simplify if statement

* Add exclusions formset

* Add jest for react testing

* Amend gitignore

* Fix error re-rendering component after submit fail

* Move state management into top level component

* Pass origin index to exclusions formset

* Submit origin pk

* Update constants.py

* Test form cleaned_data

* Update quota origins to use with_latest_description

* Use description from annotated query

* Update origins and add test

* Update origin exclusions

* Don't remove empty data

* Fix exclusions not pre-populating

* Add jest snapshot tests

* Add react tests

* Add jest tests to github actions

* Fix query not returning origin exclusions

* Fix disabled widget error

* Fix origins no longer being linked to quota when order number updated

* Update tests for workbasket change

* Add tests for add_extra_error form method

* Fix incorrect exclusion being removed

* Clean up babel config

* Remove unused field

* Create exclusions for updated and new origins

* Make sure exclusions are updated/deleted

* Move current() queryset into init

* Fix geographical area invalid choice error in test

* Move babel packages out of dev deps (#1155)

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* wip commit

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* prep for merge to mega branch

* prep for merge to mega branch

* prep for merge to mega branch

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Dale Cannon <118175145+dalecannon@users.noreply.github.com>
Co-authored-by: Tash Boyse <57753415+nboyse@users.noreply.github.com>
Co-authored-by: Matthew McKenzie <97194636+mattjamc@users.noreply.github.com>
Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>
Co-authored-by: A Gleeson <anthoni.gleeson@digital.trade.gov.uk>
Co-authored-by: Paul Pepper <85895113+paulpepper-trade@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Edie Pearce <edie.pearce@digital.trade.gov.uk>
dougmills-DIT added a commit that referenced this pull request May 8, 2024
* Add reference_documents app

* WIP - Templates >:(

* Get a template of some sort working

* Add reference document detail path and templates

* add date filters to the get_context_data function

* WiP

* Rough commit - working tabs - need cleaning up

* Add button to home form

* Add comm code links to table

* initial commit - ref doc data model

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* wip commit

* wip commit

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* TP2000-1168 Add sub-quota, blocking period & suspension period nested review tabs (#1133)

* Add sub-quotas nested review tab

* Add quota blocking periods nested review tab

* Add quota suspension periods nested review tab

* Use tab title instead of model verbose name

* Add blocking period and suspension period SID to table

* Feat: expand expiring quotas report to include tabs (#1131)

* feat: invoke UI changes to reports and create new URL path to handle reports with multiple tabs (#1134)

* feat: Add both CSV and excel types for charts exporting (#1136)

* TP2000-1185  Add maintenance mode (#1137)

* Add MAINTENANCE_MODE setting and middleware

* Fix middleware removal and recursive redirect

* Add template view and url

* Add tests

* Update contact us form link for other pages

* Update text wording

* Remove database route during maintenance

* Update maintenance page template/url name

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Increment message id & record sequence number correctly (#1083)

* record seq number & message id fix

* fix taricXMLRenderer, pass in value of counter

* feat: implement URLs for quota reports to ease navigation (#1135)

* Update readme with maintenance mode instructions. (#1140)

* TP2000-1130 Move current workbasket from Session to custom User model (#1123)

* Update User model references

* Use custom User model

* TP2000-1152-handling-invalid-workbaskets (#1113)

* Update middleware to check for workbasket changing state

* Update to use decorator rather than middleware, add pytest fixtures

* Update tests that require a session workbasket to run

* Move views and urls to workbasket app and update template

* Add tests for when workbasket status changes

* Tidy up following Pauls comments

* Update models and templates to find workbasket in user model

* Update test fixtures for workbasket being in user model

* Tidy up and test updates

* Update referencing to User model

* Updating bdd tests for new user model

* Add and update view and model unit tests

* Update require_current_workbasket decorator docstring

* Add docstring, move template for NoActiveWorkBasket view

* Amend current workbasket id retrieval in template

* Amend custom User model migration

* Remake migration adding current_workbasket field to User model

* Remove unused ValidateSessionWorkBasketMiddleware

* Make current_workbasket optional

* Add User model to admin

* Use historical models to fix migration tests

* Move ContentType data migration so it may be applied

* Rename function to remove a users current workbasket

* Amend docstrings

* Remove reference to session middleware that is no longer used

* Update workbaskets models following Pauls review

* Bring back user workbasket middleware as extra security

* Move User model from workbaskets app to common app

* Add forgotten content type data migration

* Remove setup_content_type fixture following patch to migrator fixture

* Amend middleware util method name

* Remove uneeded DoesNotExist try except block

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Bump aiohttp from 3.9.1 to 3.9.2 (#1142)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](aio-libs/aiohttp@v3.9.1...v3.9.2)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update importer model matching to account for end dated objects. (#1146)

* update importer model matching to account for end dated objects.

* update importer model matching to account for end dated objects.

* Tp2000 1211 (#1148)

* update govuk dependency since its been deleted at source

* update govuk dependency since its been deleted at source

* Bump django from 3.2.23 to 3.2.24 (#1150)

Bumps [django](https://github.com/django/django) from 3.2.23 to 3.2.24.
- [Commits](django/django@3.2.23...3.2.24)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Tp2000 652  force rule check after real edit (#1130)

* added a check that if tracked models have been updated since the last checks business rules need run again
* data migration to add timestamps to tracked models and transaction checks
* tests for real edits
* tests for data migrations

* TP2000-1219  Prevent maintenance mode errors (#1152)

* Remove authbroker middleware when in maintenance mode

* Skip applying migrations in init script

* Prevent maintenance mode template attempts to access user attribute on request object

* Update privacy policy link

* Formatting updates and adding end date field to footnote create (#1154)

* TP2000-1114: React enhanced forms proof of concept (#1091)

* Add react

* Start to build origins form in react

* Build quota origin form with initial data

* Enable adding/removing of origins

* Repopulate form initial in case of error on submit

* Pass errors from django to react

* Create origins

* Add aria attribute

* Reinstate geo area descriptions in form

* Organise JS, code comments

* Add key for react list

* Simplify if statement

* Add exclusions formset

* Add jest for react testing

* Amend gitignore

* Fix error re-rendering component after submit fail

* Move state management into top level component

* Pass origin index to exclusions formset

* Submit origin pk

* Update constants.py

* Test form cleaned_data

* Update quota origins to use with_latest_description

* Use description from annotated query

* Update origins and add test

* Update origin exclusions

* Don't remove empty data

* Fix exclusions not pre-populating

* Add jest snapshot tests

* Add react tests

* Add jest tests to github actions

* Fix query not returning origin exclusions

* Fix disabled widget error

* Fix origins no longer being linked to quota when order number updated

* Update tests for workbasket change

* Add tests for add_extra_error form method

* Fix incorrect exclusion being removed

* Clean up babel config

* Remove unused field

* Create exclusions for updated and new origins

* Make sure exclusions are updated/deleted

* Move current() queryset into init

* Fix geographical area invalid choice error in test

* Move babel packages out of dev deps (#1155)

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* wip commit

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* prep for merge to mega branch

* prep for merge to mega branch

* prep for merge to mega branch

* Tp2000 1186 ref doc data model (#1164)

* TP2000-1168 Add sub-quota, blocking period & suspension period nested review tabs (#1133)

* Add sub-quotas nested review tab

* Add quota blocking periods nested review tab

* Add quota suspension periods nested review tab

* Use tab title instead of model verbose name

* Add blocking period and suspension period SID to table

* Feat: expand expiring quotas report to include tabs (#1131)

* feat: invoke UI changes to reports and create new URL path to handle reports with multiple tabs (#1134)

* feat: Add both CSV and excel types for charts exporting (#1136)

* TP2000-1185  Add maintenance mode (#1137)

* Add MAINTENANCE_MODE setting and middleware

* Fix middleware removal and recursive redirect

* Add template view and url

* Add tests

* Update contact us form link for other pages

* Update text wording

* Remove database route during maintenance

* Update maintenance page template/url name

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Increment message id & record sequence number correctly (#1083)

* record seq number & message id fix

* fix taricXMLRenderer, pass in value of counter

* feat: implement URLs for quota reports to ease navigation (#1135)

* Update readme with maintenance mode instructions. (#1140)

* TP2000-1130 Move current workbasket from Session to custom User model (#1123)

* Update User model references

* Use custom User model

* TP2000-1152-handling-invalid-workbaskets (#1113)

* Update middleware to check for workbasket changing state

* Update to use decorator rather than middleware, add pytest fixtures

* Update tests that require a session workbasket to run

* Move views and urls to workbasket app and update template

* Add tests for when workbasket status changes

* Tidy up following Pauls comments

* Update models and templates to find workbasket in user model

* Update test fixtures for workbasket being in user model

* Tidy up and test updates

* Update referencing to User model

* Updating bdd tests for new user model

* Add and update view and model unit tests

* Update require_current_workbasket decorator docstring

* Add docstring, move template for NoActiveWorkBasket view

* Amend current workbasket id retrieval in template

* Amend custom User model migration

* Remake migration adding current_workbasket field to User model

* Remove unused ValidateSessionWorkBasketMiddleware

* Make current_workbasket optional

* Add User model to admin

* Use historical models to fix migration tests

* Move ContentType data migration so it may be applied

* Rename function to remove a users current workbasket

* Amend docstrings

* Remove reference to session middleware that is no longer used

* Update workbaskets models following Pauls review

* Bring back user workbasket middleware as extra security

* Move User model from workbaskets app to common app

* Add forgotten content type data migration

* Remove setup_content_type fixture following patch to migrator fixture

* Amend middleware util method name

* Remove uneeded DoesNotExist try except block

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Bump aiohttp from 3.9.1 to 3.9.2 (#1142)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](aio-libs/aiohttp@v3.9.1...v3.9.2)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* initial commit - ref doc data model

* update importer model matching to account for end dated objects. (#1146)

* update importer model matching to account for end dated objects.

* update importer model matching to account for end dated objects.

* Tp2000 1211 (#1148)

* update govuk dependency since its been deleted at source

* update govuk dependency since its been deleted at source

* initial commit - ref doc data model

* wip commit

* Bump django from 3.2.23 to 3.2.24 (#1150)

Bumps [django](https://github.com/django/django) from 3.2.23 to 3.2.24.
- [Commits](django/django@3.2.23...3.2.24)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Tp2000 652  force rule check after real edit (#1130)

* added a check that if tracked models have been updated since the last checks business rules need run again
* data migration to add timestamps to tracked models and transaction checks
* tests for real edits
* tests for data migrations

* TP2000-1219  Prevent maintenance mode errors (#1152)

* Remove authbroker middleware when in maintenance mode

* Skip applying migrations in init script

* Prevent maintenance mode template attempts to access user attribute on request object

* Update privacy policy link

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* wip commit

* wip commit

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* TP2000-1168 Add sub-quota, blocking period & suspension period nested review tabs (#1133)

* Add sub-quotas nested review tab

* Add quota blocking periods nested review tab

* Add quota suspension periods nested review tab

* Use tab title instead of model verbose name

* Add blocking period and suspension period SID to table

* Feat: expand expiring quotas report to include tabs (#1131)

* feat: invoke UI changes to reports and create new URL path to handle reports with multiple tabs (#1134)

* feat: Add both CSV and excel types for charts exporting (#1136)

* TP2000-1185  Add maintenance mode (#1137)

* Add MAINTENANCE_MODE setting and middleware

* Fix middleware removal and recursive redirect

* Add template view and url

* Add tests

* Update contact us form link for other pages

* Update text wording

* Remove database route during maintenance

* Update maintenance page template/url name

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Increment message id & record sequence number correctly (#1083)

* record seq number & message id fix

* fix taricXMLRenderer, pass in value of counter

* feat: implement URLs for quota reports to ease navigation (#1135)

* Update readme with maintenance mode instructions. (#1140)

* TP2000-1130 Move current workbasket from Session to custom User model (#1123)

* Update User model references

* Use custom User model

* TP2000-1152-handling-invalid-workbaskets (#1113)

* Update middleware to check for workbasket changing state

* Update to use decorator rather than middleware, add pytest fixtures

* Update tests that require a session workbasket to run

* Move views and urls to workbasket app and update template

* Add tests for when workbasket status changes

* Tidy up following Pauls comments

* Update models and templates to find workbasket in user model

* Update test fixtures for workbasket being in user model

* Tidy up and test updates

* Update referencing to User model

* Updating bdd tests for new user model

* Add and update view and model unit tests

* Update require_current_workbasket decorator docstring

* Add docstring, move template for NoActiveWorkBasket view

* Amend current workbasket id retrieval in template

* Amend custom User model migration

* Remake migration adding current_workbasket field to User model

* Remove unused ValidateSessionWorkBasketMiddleware

* Make current_workbasket optional

* Add User model to admin

* Use historical models to fix migration tests

* Move ContentType data migration so it may be applied

* Rename function to remove a users current workbasket

* Amend docstrings

* Remove reference to session middleware that is no longer used

* Update workbaskets models following Pauls review

* Bring back user workbasket middleware as extra security

* Move User model from workbaskets app to common app

* Add forgotten content type data migration

* Remove setup_content_type fixture following patch to migrator fixture

* Amend middleware util method name

* Remove uneeded DoesNotExist try except block

---------

Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>

* Bump aiohttp from 3.9.1 to 3.9.2 (#1142)

Bumps [aiohttp](https://github.com/aio-libs/aiohttp) from 3.9.1 to 3.9.2.
- [Release notes](https://github.com/aio-libs/aiohttp/releases)
- [Changelog](https://github.com/aio-libs/aiohttp/blob/master/CHANGES.rst)
- [Commits](aio-libs/aiohttp@v3.9.1...v3.9.2)

---
updated-dependencies:
- dependency-name: aiohttp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update importer model matching to account for end dated objects. (#1146)

* update importer model matching to account for end dated objects.

* update importer model matching to account for end dated objects.

* Tp2000 1211 (#1148)

* update govuk dependency since its been deleted at source

* update govuk dependency since its been deleted at source

* Bump django from 3.2.23 to 3.2.24 (#1150)

Bumps [django](https://github.com/django/django) from 3.2.23 to 3.2.24.
- [Commits](django/django@3.2.23...3.2.24)

---
updated-dependencies:
- dependency-name: django
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Tp2000 652  force rule check after real edit (#1130)

* added a check that if tracked models have been updated since the last checks business rules need run again
* data migration to add timestamps to tracked models and transaction checks
* tests for real edits
* tests for data migrations

* TP2000-1219  Prevent maintenance mode errors (#1152)

* Remove authbroker middleware when in maintenance mode

* Skip applying migrations in init script

* Prevent maintenance mode template attempts to access user attribute on request object

* Update privacy policy link

* Formatting updates and adding end date field to footnote create (#1154)

* TP2000-1114: React enhanced forms proof of concept (#1091)

* Add react

* Start to build origins form in react

* Build quota origin form with initial data

* Enable adding/removing of origins

* Repopulate form initial in case of error on submit

* Pass errors from django to react

* Create origins

* Add aria attribute

* Reinstate geo area descriptions in form

* Organise JS, code comments

* Add key for react list

* Simplify if statement

* Add exclusions formset

* Add jest for react testing

* Amend gitignore

* Fix error re-rendering component after submit fail

* Move state management into top level component

* Pass origin index to exclusions formset

* Submit origin pk

* Update constants.py

* Test form cleaned_data

* Update quota origins to use with_latest_description

* Use description from annotated query

* Update origins and add test

* Update origin exclusions

* Don't remove empty data

* Fix exclusions not pre-populating

* Add jest snapshot tests

* Add react tests

* Add jest tests to github actions

* Fix query not returning origin exclusions

* Fix disabled widget error

* Fix origins no longer being linked to quota when order number updated

* Update tests for workbasket change

* Add tests for add_extra_error form method

* Fix incorrect exclusion being removed

* Clean up babel config

* Remove unused field

* Create exclusions for updated and new origins

* Make sure exclusions are updated/deleted

* Move current() queryset into init

* Fix geographical area invalid choice error in test

* Move babel packages out of dev deps (#1155)

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* wip commit

* initial commit - ref doc data model

* wip commit

* initial commit - ref doc data model

* wip commit

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* added alignment report, reference document and reference document version views, refactored the checks and ran the checks several times against reference document versions.

* prep for merge to mega branch

* prep for merge to mega branch

* prep for merge to mega branch

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Dale Cannon <118175145+dalecannon@users.noreply.github.com>
Co-authored-by: Tash Boyse <57753415+nboyse@users.noreply.github.com>
Co-authored-by: Matthew McKenzie <97194636+mattjamc@users.noreply.github.com>
Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>
Co-authored-by: A Gleeson <anthoni.gleeson@digital.trade.gov.uk>
Co-authored-by: Paul Pepper <85895113+paulpepper-trade@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Edie Pearce <edie.pearce@digital.trade.gov.uk>

* prep for merge to mega branch

* Add command to import duties and quotas

* Add command to import duties and quotas

* Functionality to edit reference documents

* CRUD templates

* Reference Doc CRUD

* Add factories, add editing for rates - still WIP but working

* Add factories, add editing for rates - still WIP but working

* Add factories, add editing for rates - still WIP but working

* TP2000-1232 Reference doc UI management (#1165)

* Functionality to edit reference documents

* CRUD templates

* Reference Doc CRUD

* fixed time zone issue with factories.py

* Create update form tests

* fixed time zone issue with factories.py

* add basic tests for models

* add basic tests for models

* Add test init files

* View and form tests for ref doc crud

* Remove init files

* Add reference doc form and view tests

* Move get_area_name_by_id to model

* add basic tests for models

* add basic tests for models

* add basic tests for models

* update edit quota view

* fix views

* Ref doc versions create and edit urls/templates

* Ref doc formatting tidy up

* Ref doc versions create and edit views/form

* fix views

* fix views

* Update ref doc create breadcrumbs

* Ref doc version delete

* Delete ref doc version and confirmation pages

* Area ID and version form validation

* update data

* Ref doc versions form and view tests

* Add model test for get_area_name_by_id

* Update data model

* Preferential rate style and consistency tidy

* separate out the context from reference document version details

* separate out the context from reference document version details

* separate out the context from reference document version details

* separate out the context from reference document version details

* separate out the context from reference document version details

* Pref quota bulk create base

* add / edit order number

* Bulk add preferential quotas for a commodity code list

* add / edit order number

* Bulk create quotas for multiple validity period volume combos

* WIP commit - quota and order number updates

* WIP commit - quota and order number updates

* quota and order number views + test fixes

* quota and order number views + test fixes

* Bulk create quotas redo without validityperiodform

* test fixes

* Add js remove button to additional quota definition forms

* tested quota order number and quota forms

* Preferential quota bulk create tests

* Content standardisations

* Add preferential quota bulk create for specific order numbers

* models 100% tested, forms 100% tested

* models 100% tested, forms 100% tested

* Ref doc and versions view tests

* added more tests

* added more tests

* tidy up for PR

* tidy up for PR

* Stop add new button submitting form when js is disabled

* tidy up for PR

* tidy up for PR

* tidy up for PR

* tidy up for PR

* tidy up for PR

* tidy up for PR

* tidy up for PR

* tidy up for PR

* tidy up for PR

* content corrections

* content corrections

* fixes for breadcrumbs

* fixes for breadcrumbs

* minor fix

* minor text changes

* updates to ref doc data import management command

* Test fixes after content change

* Updates from Dale's review

* updated based on PR comments

* updated based on PR comments

* updated js based on linting issues

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Lauren Qurashi <lauren.qurashi@digital.trade.gov.uk>
Co-authored-by: Anthoni Gleeson <anthoni.gleeson@digital.trade.gov.uk>
Co-authored-by: Dale Cannon <118175145+dalecannon@users.noreply.github.com>
Co-authored-by: Tash Boyse <57753415+nboyse@users.noreply.github.com>
Co-authored-by: Matthew McKenzie <97194636+mattjamc@users.noreply.github.com>
Co-authored-by: Dale Cannon <dale.cannon@digital.trade.gov.uk>
Co-authored-by: Paul Pepper <85895113+paulpepper-trade@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Edie Pearce <edie.pearce@digital.trade.gov.uk>
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.

5 participants