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

Users can add people with relevant convictions #104

Merged
merged 8 commits into from
Apr 3, 2018

Conversation

irisfaraway
Copy link
Member

@irisfaraway irisfaraway commented Mar 16, 2018

https://eaflood.atlassian.net/browse/WC-108

If a user answers yes to "Has anyone involved in managing your organisation been convicted of an environmental offence in the past 12 months?" they should be prompted to provide the details of the person with the offence (but not the details of the offence).

This should be a blank form as any data from the previous registration is out of date.

https://eaflood.atlassian.net/browse/WC-108

If a user answers yes to "Has anyone involved in managing your organisation been convicted of an environmental offence in the past 12 months?" they should be prompted to provide the details of the person with the offence (but not the details of the offence).

This should be a blank form as any data from the previous registration is out of date.
@irisfaraway irisfaraway self-assigned this Mar 16, 2018
The KeyPeople class actually covers two types of people:

- people with the 'key' person_type, added on the key people form
- people with the 'relevant' person_type, added on the relevant conviction details form

For what I assume are historical reasons in the existing database, all of a registration's people are stored together as KeyPeople embedded objects, with the only distinguishing factor being the 'person_type' attribute. However, as far as the frontend is concerned, these are two separate lists. We need to make sure we don't modify key people when changing relevant people, and the reverse. For example, checking the number of key people which a registration has (eg, a sole trader can only have one) should not also count 'relevant' people.

This change adds some methods to registration-y objects to get lists of 'key people' or 'relevant people' only. It also makes some modifications to the existing key people form to make sure we leave relevant people alone when adding, listing or deleting key people.

And, of course, we really needed some tests for all this.
The forms for key people and conviction details are very similar - the only difference is the additional "position" field for the conviction details form. So to start out with, we're mostly duplicating key people and making sure the tests pass.

Once we have the form and test suite in place, we can start reducing duplication between the two (and improving some of the naming).
These both now inherit from a PersonFormController class, which inherits from the FormController.

This allows them to share behaviour to add another person or delete a person.
There was also a lot of duplication between KeyPeopleForm and ConvictionDetailsForm. This change adds a PersonForm which both classes inherit from.

Where the PersonForm calls methods which are only defined in the subclasses, we raise a NotImplementedError. This is so that in the event we ever implement a third subclass, these errors will notify us to add those methods to the new subclass. They should never be triggered now as we don't create any instances of PersonForm itself.
Create some shared partials for the name and date fields.

Also fix a validation issue for the 'position' field.
@irisfaraway
Copy link
Member Author

The drop in test coverage is because we're not testing PersonForm on its own, and so never call the NotImplementedErrors. I don't see much point in testing this but happy to add some if you disagree @Cruikshanks

Updated the minimum age for a person with relevant convictions after consulting with the product owner.
@irisfaraway irisfaraway merged commit 6c71e35 into master Apr 3, 2018
@irisfaraway irisfaraway deleted the feature/conviction-details branch April 3, 2018 14:34
@Cruikshanks
Copy link
Member

Oh, and just to confirm agree with not worrying about the drop in test coverage.

@irisfaraway irisfaraway added the enhancement New feature or request label Oct 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants