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

Add form for a person to contribute suggested councillor info #1208

Conversation

hisayohorie
Copy link
Contributor

This is related to this issue openaustralia/australian_local_councillors_popolo#98 (comment)

This PR is the most basic first version of how people contribute councillor info, so that we can load the information to the site.
People can go to this page from each authorities, and put the names and emails of the councillors they want to contribute. After they submit their contribution, optionally they can give us their contact information(name and email), so that we can contact them to thank them.

screen shot 2017-08-01 at 8 45 03 am

The suggested councillors appear on admin page, and admin can copy them in the existing process of adding new councillors.

screen shot 2017-08-01 at 8 53 23 am

When this is deployed, migration needs to run to add new database tables.

equivalentideas and others added 30 commits June 15, 2017 15:52
…ustralia/planningalerts into person_contributes_councillor_info
…ncillo in authority model, and changed the create method to use build in suggested_councillor controllerr
…ontributes_councillor_info_2

Added model, controller and view for suggested councillors.
The test for Council Name is nested in the feature_flag_is_on test, so
that the feature is visible in the test environment.
to make it more readable and clear. still need some styling.
To separate the test exercise and test expectation.
…cillor_council_name

Suggested councillor council name
to add a contributor info form in the suggested councillor.
equivalentideas and others added 9 commits August 1, 2017 12:39
The user has just submitted all these councillors themselves, so I don't
think they need to be told where this list came from. This heading is
also confusing as it comes above the form to put in a new councillor.
The heading of the page explains that this is for adding councillors,
so I don't think we need to restate that here.

This commit also changes the tests to use css to target the fieldset,
rather than the text of the legend (now missing).
This makes it more the focus of the page and sets it apart from the
other details, like the labels.
This pushes the actual data you're looking at forward a bit.
There's a bug in there flexbox implementation that a fieldset
element can't be a flex container. Adding a wrapper div is the
workaround.

See https://github.com/philipwalton/flexbugs#9-some-html-elements-cant-be-flex-containers
…ontribution_basic_styles

Add basic styles to the councillor contribution form
Copy link
Contributor

@equivalentideas equivalentideas left a comment

Choose a reason for hiding this comment

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

@hisayohorie and I went through this and we found a few bits we want to improve before merging.

Looking really good though 💯 😄 looking forward to getting this deployed!

end
end

private
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be indented to the same level as the methods it covers below.

@@ -0,0 +1,4 @@
class Contributor < ActiveRecord::Base
has_many :suggested_councillors, through: :councillor_contributions
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this association necessary? If we're not using it we should remove that line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

suggested_councillor_spec.rbanduser_contributes_new_councillor_spec.rbpass without this association. Currently we don't have the controller/councillor_contribution_controller_spec.rbnor model/contributor_spec_rbso if we get to the stage to have the test, we may need the association? but for now I deleted it.

@@ -21,6 +21,9 @@ class Authority < ActiveRecord::Base
has_many :applications
has_many :councillors
has_many :comments, through: :applications
has_many :councillor_contributions
has_many :suggested_councillors, through: :councillor_contributions
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this association necessary? If we're not using it we should remove that line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test will pass without it, but the actual code won't run. It returns error because councillor_contribution#new needs authority_id. So I'm keeping this association. Also we have to create controller/councillr_contributions_controller_spec.rb.

@@ -0,0 +1,20 @@
%h1 Thank you!
%p
This data you contributed will be reviewd
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be "reviewed".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

%h1 Thank you!
%p
This data you contributed will be reviewd
by an administrator, and go live shortly.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can improve this text a bit but that's not a problem for this first pass being merged. We should open an issue for that.

fill_in "Email", with: "mgilic@casey.vic.gov.au"
end

click_button "Submit"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should use the full button text like the other tests do for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

We decided to change this so that all the times this button is hit, the full text is used "Submit 1 new councillor".

fill_in "Email", with: "mgilic@casey.vic.gov.au"
end

click_button "Add another councillor"
Copy link
Contributor

Choose a reason for hiding this comment

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

@hisayohorie and I talked about this, and we recon that this test could be more focused if the person only adds one councillor. That keeps the focus on them not adding there contributor information.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I came to realize that this test is to check it works successfully when the contributor does not provide their information, and the test is not what it's described. I changed the test to check what it described. I will make a change in the view page to pass the test in separate PR

Copy link
Contributor

Choose a reason for hiding this comment

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

@hisayohorie and I decided to try and make these tests more focused by splitting the options for the contributor to tell us their contact information into a new feature spec file 74466ea

expect(page).to have_content "Thank you"
end

it "works successfully without contributor information" do
Copy link
Contributor

Choose a reason for hiding this comment

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

To be consistent with the test above, I recon the description here should be something like "works successfully when the contributor does not provide their information"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

click_button "Submit 3 new councillors"

expect(page).to have_content "Thank you"

Copy link
Contributor

Choose a reason for hiding this comment

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

Stray empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

require 'spec_helper'

RSpec.describe Contributor, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's remove this file if we're not adding tests yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

equivalentideas and others added 6 commits August 2, 2017 12:56
This makes it clearer to the test reader which button is being pressed
here, and it also adds slightly to the test to make sure that button
text is what we intend.

Relates to discussion:
openaustralia#1208 (comment)
To give thank you for contributor who did not leave their info.
This creates a new file that covers the different options for
contribution for providing their information to us.

We split this out to make the original spec file more focused and easier
to understand.

This now means there isn't a single spec for working through the whole
contribution process from beginning to end. But we think that's ok for now,
because the contribution and the stage of providing details are quite separate.
Copy link
Contributor

@equivalentideas equivalentideas left a comment

Choose a reason for hiding this comment

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

@hisayohorie nice work making all these fixes :) I think we made the tests clearer in particular :)

I think this is ready to go. I'll merge it and deploy! 🚀 :shipit:

post "/authorities/:authority_id/councillor_contributions/new", to: "councillor_contributions#new"

resources :contributors, only:[:new, :create]
get "/contributors/no_info", to: "contributors#no_contributor_info"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should change to something a little more specific like "contributors/anonymous", but we don't need to do that before deploying.

@equivalentideas equivalentideas merged commit 2f9e80c into openaustralia:master Aug 2, 2017
The feature is globally enabled when the value of `ENV["CONTRIBUTE_COUNCILLORS_ENABLED"]` is `"true"`.
This flag is useful if you need to turn the feature _off_ globally.

We set this in the [`.env`](https://github.com/openaustralia/planningalerts/blob/master/.env) file in production. You can control setting in development by creating your own `.env.development` file which includes:
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually we set it in production in .env.production. We should update that.

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.

None yet

3 participants