From 21fec80bfcda1438e9fff0c663f7656446811ba9 Mon Sep 17 00:00:00 2001 From: David Black Date: Mon, 25 Apr 2022 21:32:00 +1000 Subject: [PATCH 1/3] Warn users about councils that may ignore their planning alerts sent comments. #1580 Signed-off-by: David Black --- app/assets/javascripts/applications.js | 26 +++++++++++++++++++ app/models/authority.rb | 16 ++++++++++++ .../views/applications/show.html.haml | 2 +- .../comments/_comment_form_inputs.html.haml | 11 +++++++- spec/views/applications/show_spec.rb | 4 +++ 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/applications.js b/app/assets/javascripts/applications.js index 73919fa2f..fa04f3129 100755 --- a/app/assets/javascripts/applications.js +++ b/app/assets/javascripts/applications.js @@ -14,3 +14,29 @@ $('a.hideable').click(function(e) { target = $(e.target).attr("data-target"); $(target).slideToggle('fast'); }); + +function updateLink() { + let councilRef = $("#council_ref"); + let reference = councilRef.data('reference'); + let ignoringComment = councilRef.data('ignoringcomment'); + if (ignoringComment === false) { + return; + } + let councilEmail = councilRef.data('email'); + + let comment = $("#add_comment_text").val(); + let address = $("#map_div").data('address'); + $("#council-mail-button").attr('href', 'mailto:' + councilEmail + + '?subject=' + encodeURIComponent(reference + " " + address) + + '&body=' + encodeURIComponent(comment) + ); +} + +$('#add_comment_text').change(function(e) { + updateLink(); +}); + +$(document).ready(function() { + updateLink(); +}); + diff --git a/app/models/authority.rb b/app/models/authority.rb index dde1985b3..323116b25 100644 --- a/app/models/authority.rb +++ b/app/models/authority.rb @@ -154,6 +154,22 @@ def date_last_new_application_scraped latest_application&.first_date_scraped end + # When the authority is ignoring commments from us, at least for the time being. + sig { returns(T::Boolean) } + def ignoring_planning_alert_comments? + short_name_encoded() == "parramatta" + end + + # If the council is ignoring our comments provide their email if we have it. + sig { returns(T.nilable(String)) } + def email_for_ignoring_councils + if ignoring_planning_alert_comments? + return email + end + return nil + end + + # If the latest application is over two weeks old, the scraper's probably broken sig { returns(T::Boolean) } def broken? diff --git a/app/themes/standard/views/applications/show.html.haml b/app/themes/standard/views/applications/show.html.haml index e1c5eecb0..9e9a094f2 100644 --- a/app/themes/standard/views/applications/show.html.haml +++ b/app/themes/standard/views/applications/show.html.haml @@ -47,7 +47,7 @@ %footer %p.dates= scraped_and_received_text(@application) - %p.source (Source: #{link_to @application.authority.full_name, authority_path(@application.authority.short_name_encoded)}, reference #{@application.council_reference}) + %p.source (Source: #{link_to @application.authority.full_name, authority_path(@application.authority.short_name_encoded), data: {'reference': @application.council_reference, 'ignoringComments': @application.authority.ignoring_planning_alert_comments?, 'email': @application.authority.email_for_ignoring_councils}, id: "council_ref"} reference #{@application.council_reference}) = render "comments/comments_area", comments: @comments, application: @application, add_comment: @add_comment diff --git a/app/themes/standard/views/comments/_comment_form_inputs.html.haml b/app/themes/standard/views/comments/_comment_form_inputs.html.haml index eb922b986..4bd90dd0c 100644 --- a/app/themes/standard/views/comments/_comment_form_inputs.html.haml +++ b/app/themes/standard/views/comments/_comment_form_inputs.html.haml @@ -35,5 +35,14 @@ = text_field_tag :little_sweety, "", placeholder: "Please leave this blank" -# haml-lint:enable InlineStyles = f.actions id: "comment-action-inputgroup" do - = f.action :submit, label: "Post your public comment", + - if application.authority.ignoring_planning_alert_comments? + %div{class: "flash_message"} + %p{class: "alert"} This council may or may not accept your submission via planning alerts. Instead you may need to email the council. For convience there is a button below that you can press to prompt emailing this form to the council. You may still wish to submit your comment to planning alerts to share your comments with others. + + #{ link_to 'Email Council', '#', id: 'council-mail-button', target: '_blank', class: "button button-action"} +
+ = f.action :submit, label: "Post your public comment", button_html: { class: "button button-primary" } + + - else + = f.action :submit, label: "Post your public comment", button_html: { class: "button button-action" } diff --git a/spec/views/applications/show_spec.rb b/spec/views/applications/show_spec.rb index 110d7a5c4..c3811a9a9 100644 --- a/spec/views/applications/show_spec.rb +++ b/spec/views/applications/show_spec.rb @@ -45,6 +45,8 @@ allow(application).to receive(:lat).and_return(1.0) allow(application).to receive(:lng).and_return(2.0) allow(application).to receive(:location).and_return(Location.new(lat: 1.0, lng: 2.0)) + allow(application.authority).to receive(:ignoring_planning_alert_comments?).and_return(false) + allow(application.authority).to receive(:email_for_ignoring_councils).and_return(nil) end it "displays the map" do @@ -74,6 +76,8 @@ allow(application).to receive(:location).and_return(nil) allow(application).to receive(:date_received).and_return(nil) allow(application).to receive(:first_date_scraped).and_return(Time.zone.now) + allow(application.authority).to receive(:ignoring_planning_alert_comments?).and_return(false) + allow(application.authority).to receive(:email_for_ignoring_councils).and_return(nil) assign(:application, application) render From 8e2712042e25df979c4acb1552e89001c7f1509a Mon Sep 17 00:00:00 2001 From: David Black Date: Mon, 25 Apr 2022 21:52:03 +1000 Subject: [PATCH 2/3] Seed a Parramatta City Council application for local dev purposes. Signed-off-by: David Black --- db/seeds.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/db/seeds.rb b/db/seeds.rb index 54b2b7c5b..e88ae28ce 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,6 +10,15 @@ website_url: "http://www.marrickville.nsw.gov.au", disabled: false +authorityTwo = Authority.create! full_name: "Parramatta City Council", + short_name: "Parramatta", + state: "NSW", + email: "council@cityofparramatta.nsw.gov.au", + population_2017: "243276", + morph_name: "planningalerts-scrapers/multiple_epathway_scraper", + website_url: "https://www.cityofparramatta.nsw.gov.au", + disabled: false + CreateOrUpdateApplicationService.call( authority: authority, council_reference: "DA21/0642", @@ -26,3 +35,20 @@ lng: 150.6486731 } ) + +CreateOrUpdateApplicationService.call( + authority: authorityTwo, + council_reference: "DA/321/2022", + attributes: { + address: "110 Wetherill Street North, SILVERWATER NSW 2128", + description: "Change of use to a vehicle dismantling premises and metal car part storage facility.", + date_scraped: Time.zone.now, + info_url: "https://onlineservices.cityofparramatta.nsw.gov.au/ePathway/Prod/Web/GeneralEnquiry/EnquiryDetailView.aspx?Id=725692", + # Values that would normally be the result of geocoding + suburb: "Silverwater", + state: "NSW", + postcode: "2128", + lat: -33.83568859225864, + lng: 151.04994362636435 + } +) From cf953725f7df267dc7d3b7bbabcdb878d2843cde Mon Sep 17 00:00:00 2001 From: David Black Date: Tue, 26 Apr 2022 10:23:03 +1000 Subject: [PATCH 3/3] Rubocop fix ups. Signed-off-by: David Black --- app/models/authority.rb | 8 ++------ db/seeds.rb | 18 +++++++++--------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/app/models/authority.rb b/app/models/authority.rb index 323116b25..a1334b0de 100644 --- a/app/models/authority.rb +++ b/app/models/authority.rb @@ -157,19 +157,15 @@ def date_last_new_application_scraped # When the authority is ignoring commments from us, at least for the time being. sig { returns(T::Boolean) } def ignoring_planning_alert_comments? - short_name_encoded() == "parramatta" + short_name_encoded == "parramatta" end # If the council is ignoring our comments provide their email if we have it. sig { returns(T.nilable(String)) } def email_for_ignoring_councils - if ignoring_planning_alert_comments? - return email - end - return nil + return email if ignoring_planning_alert_comments? end - # If the latest application is over two weeks old, the scraper's probably broken sig { returns(T::Boolean) } def broken? diff --git a/db/seeds.rb b/db/seeds.rb index e88ae28ce..18fdb7a8f 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -10,14 +10,14 @@ website_url: "http://www.marrickville.nsw.gov.au", disabled: false -authorityTwo = Authority.create! full_name: "Parramatta City Council", - short_name: "Parramatta", - state: "NSW", - email: "council@cityofparramatta.nsw.gov.au", - population_2017: "243276", - morph_name: "planningalerts-scrapers/multiple_epathway_scraper", - website_url: "https://www.cityofparramatta.nsw.gov.au", - disabled: false +authority_two = Authority.create! full_name: "Parramatta City Council", + short_name: "Parramatta", + state: "NSW", + email: "council@cityofparramatta.nsw.gov.au", + population_2017: "243276", + morph_name: "planningalerts-scrapers/multiple_epathway_scraper", + website_url: "https://www.cityofparramatta.nsw.gov.au", + disabled: false CreateOrUpdateApplicationService.call( authority: authority, @@ -37,7 +37,7 @@ ) CreateOrUpdateApplicationService.call( - authority: authorityTwo, + authority: authority_two, council_reference: "DA/321/2022", attributes: { address: "110 Wetherill Street North, SILVERWATER NSW 2128",