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

Warn users about councils that may ignore their planning alerts sent comments. #1580 #1582

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions app/assets/javascripts/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

12 changes: 12 additions & 0 deletions app/models/authority.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,18 @@ 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
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?
Expand Down
2 changes: 1 addition & 1 deletion app/themes/standard/views/applications/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
<br>
= 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" }
26 changes: 26 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
website_url: "http://www.marrickville.nsw.gov.au",
disabled: false

authority_two = Authority.create! full_name: "Parramatta City Council",
short_name: "Parramatta",
state: "NSW",
email: "[email protected]",
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",
Expand All @@ -26,3 +35,20 @@
lng: 150.6486731
}
)

CreateOrUpdateApplicationService.call(
authority: authority_two,
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
}
)
4 changes: 4 additions & 0 deletions spec/views/applications/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down