-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
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.
Cruikshanks
approved these changes
Apr 3, 2018
Oh, and just to confirm agree with not worrying about the drop in test coverage. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.