aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--locale/nb_NO.UTF-8/LC_MESSAGES/FixMyStreet.po41
-rw-r--r--perllib/FixMyStreet/App.pm5
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/Default.pm20
-rw-r--r--perllib/FixMyStreet/Cobrand/FixMyStreet.pm9
-rw-r--r--perllib/FixMyStreet/Cobrand/UKCouncils.pm14
-rw-r--r--perllib/FixMyStreet/Email.pm8
-rw-r--r--perllib/Open311.pm72
-rw-r--r--perllib/Open311/GetServiceRequestUpdates.pm3
-rw-r--r--perllib/Open311/GetUpdates.pm19
-rw-r--r--perllib/Open311/PopulateServiceList.pm28
-rw-r--r--t/app/controller/report_new_open311.t8
-rw-r--r--t/cobrand/bromley.t62
-rw-r--r--t/open311/getservicerequestupdates.t4
-rw-r--r--t/open311/populate-service-list.t13
-rw-r--r--templates/email/fixmystreet.com/signature.txt (renamed from templates/email/fixmystreet/signature.txt)0
-rw-r--r--templates/email/fixmystreet.com/submit-oxfordshire.txt (renamed from templates/email/fixmystreet/submit-oxfordshire.txt)0
-rw-r--r--templates/email/fixmystreet.com/submit.txt (renamed from templates/email/fixmystreet/submit.txt)0
-rw-r--r--templates/email/fixmystreet.com/update-confirm-donotsend.txt (renamed from templates/email/fixmystreet/update-confirm-donotsend.txt)0
-rw-r--r--templates/web/angus/header.html1
-rw-r--r--templates/web/angus/maps/fms.html1
-rw-r--r--templates/web/base/report/new/category_extras.html6
-rw-r--r--templates/web/fixmystreet.com/about/posters.html2
-rw-r--r--web/cobrands/fixmystreet.com/layout.scss4
-rw-r--r--web/cobrands/fixmystreet.com/posters.scss8
-rw-r--r--web/js/map-OpenLayers.js11
26 files changed, 215 insertions, 135 deletions
diff --git a/locale/nb_NO.UTF-8/LC_MESSAGES/FixMyStreet.po b/locale/nb_NO.UTF-8/LC_MESSAGES/FixMyStreet.po
index 31fd59846..66c404d3b 100644
--- a/locale/nb_NO.UTF-8/LC_MESSAGES/FixMyStreet.po
+++ b/locale/nb_NO.UTF-8/LC_MESSAGES/FixMyStreet.po
@@ -15,8 +15,8 @@ msgstr ""
"Project-Id-Version: fixmystreet\n"
"Report-Msgid-Bugs-To: matthew@mysociety.org\n"
"POT-Creation-Date: 2016-05-03 10:41+0100\n"
-"PO-Revision-Date: 2016-03-23 12:44+0000\n"
-"Last-Translator: mySociety <transifex@mysociety.org>\n"
+"PO-Revision-Date: 2016-05-28 21:04+0000\n"
+"Last-Translator: Jan Høydahl <jh@cominvent.com>\n"
"Language-Team: Norwegian Bokmål (Norway) (http://www.transifex.com/mysociety/fixmystreet/language/nb_NO/)\n"
"Language: nb_NO\n"
"MIME-Version: 1.0\n"
@@ -58,7 +58,7 @@ msgstr "%s administrator:"
#: templates/web/base/status/stats.html:26
msgid "%s bodies"
-msgstr ""
+msgstr "%s administrasjoner"
#: templates/web/base/status/stats.html:24
msgid "%s confirmed alerts, %s unconfirmed"
@@ -110,7 +110,7 @@ msgid ""
"will be sent to the district council, so will appear in both of the district\n"
"council&rsquo;s alerts, but will only appear in the \"Within the boundary\" alert\n"
"for the county council."
-msgstr ""
+msgstr "%s sender forskjellige kategorier problemer til rett administrasjon, så problemer innenfor grensene til en gitt administrasjon vil ikke alltid samsvare med problemrapporter sendt til den administrasjonen. For eksempel, en grafitti-rapport vil bli sendt til kommunen, og vil dukke opp på kommunens varsler, men vil kun vises i \"innenfor grensen\" varselet for fylket."
#: perllib/FixMyStreet/Cobrand/UK.pm:256 perllib/FixMyStreet/Cobrand/UK.pm:268
msgid "%s ward, %s"
@@ -340,7 +340,7 @@ msgstr "Er du en utvikler?"
#: templates/web/base/js/translation_strings.html:52
msgid "Are you sure you want to cancel this upload?"
-msgstr ""
+msgstr "Er du sikker på at du vil avbryte opplastingen?"
#: templates/web/base/admin/body-form.html:69
#: templates/web/base/admin/body.html:16
@@ -590,7 +590,7 @@ msgstr "Bekreft konto"
#: templates/web/base/report/new/form_user_loggedout_password.html:21
#: templates/web/base/report/update/form_user_loggedout_password.html:20
msgid "Confirm by email instead, providing a new password at that point. When you confirm, your password will be updated."
-msgstr ""
+msgstr "Bekreft via e-post isteden, ved å oppgi et nytt passord da. Når du bekrefter vil passordet ditt bli oppdatert."
#: templates/web/base/questionnaire/creator_fixed.html:1
#: templates/web/base/tokens/confirm_problem.html:1
@@ -772,7 +772,7 @@ msgstr "Arbeidshester"
#: templates/web/base/report/update-form.html:29
#: templates/web/base/report/update/form_user_loggedout.html:27
msgid "Do you have a %s password?"
-msgstr "Har du et FiksGataMi-passord?"
+msgstr "Har du et %s-passord?"
#: templates/web/base/questionnaire/index.html:55
msgid "Don&rsquo;t know"
@@ -784,7 +784,7 @@ msgstr "Liker ikke skjemaer?"
#: templates/web/base/js/translation_strings.html:51
msgid "Drag and drop photos here or <u>click to upload</u>"
-msgstr ""
+msgstr "Dra og slipp bilder hit eller <u>klikk for å laste opp</u>"
#: templates/web/base/admin/report_blocks.html:1
#: templates/web/base/admin/report_blocks.html:14
@@ -1559,7 +1559,7 @@ msgstr "Nye lokale problemer på FiksGataMi"
#: templates/web/zurich/admin/report_edit-sdm.html:117
msgid "New note to DM:"
-msgstr ""
+msgstr "Nytt notat til DM:"
#: db/alert_types.pl:38
msgid "New problems for {{COUNCIL}} within {{WARD}} ward on FixMyStreet"
@@ -1727,7 +1727,7 @@ msgstr "Note: <strong>%d</strong>"
#: templates/web/zurich/admin/list_updates.html:21
msgid "Notes from SDM to DM"
-msgstr ""
+msgstr "Notater fra SDM til DM"
#: templates/web/base/report/new/form_user_loggedout.html:2
#: templates/web/base/report/new/form_user_loggedout.html:24
@@ -1972,7 +1972,7 @@ msgstr "Vennligst legg til en melding"
#: perllib/FixMyStreet/App/Controller/Admin.pm:1079
#: perllib/FixMyStreet/App/Controller/Admin.pm:1134
msgid "Please enter a name"
-msgstr ""
+msgstr "Vennligst skriv et navn"
#: templates/web/base/auth/change_password.html:12
#: templates/web/base/auth/change_password.html:15
@@ -2081,7 +2081,7 @@ msgstr "Vær oppmerksom på at oppdateringer ikke blir videresendt til administr
#: templates/web/base/report/new/oauth_email_form.html:4
msgid "Please note your report has <strong>not yet been sent</strong>."
-msgstr ""
+msgstr "Merk at din rapport <strong>enda ikke har blitt sendt</strong>."
#: templates/web/base/report/new/fill_in_details_form.html:20
#: templates/web/zurich/report/new/fill_in_details_form.html:11
@@ -2090,7 +2090,7 @@ msgstr "Merk at din rapport <strong>ennå ikke er sendt</strong. Velg en katego
#: templates/web/base/report/display.html:26
msgid "Please note your update has <strong>not yet been posted</strong>."
-msgstr ""
+msgstr "Merk at din oppdatering <strong>enda ikke har blitt sendt</strong>."
#: templates/web/base/report/new/notes.html:1
#: templates/web/zurich/report/new/notes.html:1
@@ -2130,9 +2130,8 @@ msgstr "Vennligs oppgi om dette problemet er blitt fikset eller ikke"
#: perllib/FixMyStreet/App/Model/PhotoSet.pm:150
#: perllib/FixMyStreet/App/Model/PhotoSet.pm:152
#: templates/web/base/js/translation_strings.html:53
-#, fuzzy
msgid "Please upload an image only"
-msgstr "Vennligst last opp kun JPEG-bilder"
+msgstr "Vennligst last opp kun bilder"
#: perllib/FixMyStreet/App/Controller/Contact.pm:115
msgid "Please write a message"
@@ -2601,7 +2600,7 @@ msgstr "Velg et område"
#: templates/web/base/alert/_list.html:10
msgid "Select which type of alert you’d like and click the button for an RSS feed, or enter your email address to subscribe to an email alert."
-msgstr ""
+msgstr "Velg hvilken type varsel du ønsker og klikk på knappen for en RSS-kilde, eller skriv inn din e-postadresse for å abonnere på et e-postvarsel."
#: perllib/FixMyStreet/Cobrand/Zurich.pm:835
msgid "Sent report back"
@@ -2703,7 +2702,7 @@ msgstr "Beklager, vi kunne ikke finne det stedet."
#: templates/web/base/report/display.html:21
#: templates/web/base/report/new/fill_in_details_form.html:23
msgid "Sorry, we could not log you in. Please fill in the form below."
-msgstr ""
+msgstr "Beklager, vi kunne ikke logge deg inn. Vennligst fyll in skjemaet nedenfor."
#: perllib/FixMyStreet/Geocode/Bing.pm:35
#: perllib/FixMyStreet/Geocode/Google.pm:45
@@ -3438,7 +3437,7 @@ msgstr "Vi fant mer en ett treff for den plassen. Vi viser opp til ti treff, sÃ
#: templates/web/base/report/display.html:27
#: templates/web/base/report/new/oauth_email_form.html:5
msgid "We need your email address, please give it below."
-msgstr ""
+msgstr "Vi behøver din epost-adresse, vennligst oppgi den nedenfor."
#: templates/web/base/report/new/form_user_loggedout_email.html:2
#: templates/web/base/report/update/form_user_loggedout_email.html:2
@@ -3490,7 +3489,7 @@ msgstr "NÃ¥r sendt"
#: templates/web/base/js/translation_strings.html:50
msgid "Whoa there Testino! Three photos are enough."
-msgstr ""
+msgstr "Oj oj, brems ned! Tre bilder er nok."
#: templates/web/base/tokens/confirm_alert.html:7
msgid "Why stop there? <a href=\"/alert\">Set up more alerts</a> for free."
@@ -3612,7 +3611,7 @@ msgstr "Du har allerede lagt ved bilder til denne rapporten. Merk at du kan maks
#: templates/web/base/questionnaire/index.html:83
#: templates/web/base/report/update/form_update.html:14
msgid "You have already attached photos to this update. Note that you can attach a maximum of 3 to this update (if you try to upload more, the oldest will be removed)."
-msgstr ""
+msgstr "Du har allerede lagt ved bilder til denne rapporten. Merk at du kan maksimalt legge ved 3 til rapporten (hvis du laster opp flere blir det eldste slettet)."
#: templates/web/base/auth/sign_out.html:4
#: templates/web/zurich/auth/sign_out.html:3
@@ -3712,7 +3711,7 @@ msgstr "Ditt telefonnummer"
#: templates/web/base/questionnaire/index.html:14
msgid "Your report"
-msgstr ""
+msgstr "Din rapport"
#: templates/web/base/footer.html:29
msgid "Your reports"
diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm
index 1a651d282..be0e91101 100644
--- a/perllib/FixMyStreet/App.pm
+++ b/perllib/FixMyStreet/App.pm
@@ -310,10 +310,7 @@ sub send_email {
from => [ $sender, _($sender_name) ],
%{ $c->stash },
%$extra_stash_values,
- additional_template_paths => [
- FixMyStreet->path_to( 'templates', 'email', $c->cobrand->moniker, $c->stash->{lang_code} )->stringify,
- FixMyStreet->path_to( 'templates', 'email', $c->cobrand->moniker )->stringify,
- ]
+ additional_template_paths => $c->cobrand->path_to_email_templates($c->stash->{lang_code}),
};
return if FixMyStreet::Email::is_abuser($c->model('DB')->schema, $vars->{to});
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 696234d32..af9ca50b5 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -226,7 +226,6 @@ sub category_extras_ajax : Path('category_extras') : Args(0) {
my $category_extra = '';
my $generate;
if ( $c->stash->{category_extras}->{$category} && @{ $c->stash->{category_extras}->{$category} } >= 1 ) {
- $c->stash->{report_meta} = {};
$c->stash->{category_extras} = { $category => $c->stash->{category_extras}->{$category} };
$generate = 1;
}
@@ -641,8 +640,14 @@ sub setup_categories_and_bodies : Private {
push @category_options, $contact->category;
my $metas = $contact->get_extra_fields;
- $category_extras{ $contact->category } = $metas
- if scalar @$metas;
+ if (scalar @$metas) {
+ foreach (@$metas) {
+ if (ref $_->{values} eq 'HASH') {
+ $_->{values} = [ map { { name => $_->{name}[0], key => $_->{key}[0] } } @{$_->{values}->{value}} ];
+ }
+ }
+ $category_extras{ $contact->category } = $metas;
+ }
my $body_send_method = $bodies{$contact->body_id}->send_method || '';
$c->stash->{unresponsive}{$contact->category} = $contact->body_id
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm
index 4dc024d48..76d73d96e 100644
--- a/perllib/FixMyStreet/Cobrand/Default.pm
+++ b/perllib/FixMyStreet/Cobrand/Default.pm
@@ -27,7 +27,25 @@ Returns the path to the templates for this cobrand - by default
sub path_to_web_templates {
my $self = shift;
my $paths = [
- FixMyStreet->path_to( 'templates/web', $self->moniker )->stringify,
+ FixMyStreet->path_to( 'templates/web', $self->moniker ),
+ ];
+ return $paths;
+}
+
+=head1 path_to_email_templates
+
+ $path = $cobrand->path_to_email_templates( );
+
+Returns the path to the email templates for this cobrand - by default
+"templates/email/$moniker" (and then default in Email.pm).
+
+=cut
+
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ my $paths = [
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker, $lang_code ),
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker ),
];
return $paths;
}
diff --git a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
index c8c1eef66..61011a414 100644
--- a/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
+++ b/perllib/FixMyStreet/Cobrand/FixMyStreet.pm
@@ -7,9 +7,16 @@ use constant COUNCIL_ID_BROMLEY => 2482;
sub path_to_web_templates {
my $self = shift;
return [
- FixMyStreet->path_to( 'templates/web/fixmystreet.com' )->stringify,
+ FixMyStreet->path_to( 'templates/web/fixmystreet.com' ),
];
}
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ return [
+ FixMyStreet->path_to( 'templates', 'email', 'fixmystreet.com'),
+ ];
+}
+
# FixMyStreet should return all cobrands
sub restriction {
diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
index 0321e0297..c8512f852 100644
--- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm
+++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm
@@ -16,11 +16,21 @@ sub is_council {
sub path_to_web_templates {
my $self = shift;
return [
- FixMyStreet->path_to( 'templates/web', $self->moniker )->stringify,
- FixMyStreet->path_to( 'templates/web/fixmystreet-uk-councils' )->stringify,
+ FixMyStreet->path_to( 'templates/web', $self->moniker ),
+ FixMyStreet->path_to( 'templates/web/fixmystreet-uk-councils' ),
];
}
+sub path_to_email_templates {
+ my ( $self, $lang_code ) = @_;
+ my $paths = [
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker, $lang_code ),
+ FixMyStreet->path_to( 'templates', 'email', $self->moniker ),
+ FixMyStreet->path_to( 'templates', 'email', 'fixmystreet.com'),
+ ];
+ return $paths;
+}
+
sub site_key {
my $self = shift;
return $self->council_url;
diff --git a/perllib/FixMyStreet/Email.pm b/perllib/FixMyStreet/Email.pm
index ce7dad47a..d955f6f72 100644
--- a/perllib/FixMyStreet/Email.pm
+++ b/perllib/FixMyStreet/Email.pm
@@ -92,13 +92,11 @@ sub send_cron {
unpack('h*', random_bytes(5, 1)), FixMyStreet->config('EMAIL_DOMAIN')
);
+ my @include_path = @{ $cobrand->path_to_email_templates($lang_code) };
+ push @include_path, FixMyStreet->path_to( 'templates', 'email', 'default' );
my $tt = Template->new({
ENCODING => 'utf8',
- INCLUDE_PATH => [
- FixMyStreet->path_to( 'templates', 'email', $cobrand->moniker, $lang_code )->stringify,
- FixMyStreet->path_to( 'templates', 'email', $cobrand->moniker )->stringify,
- FixMyStreet->path_to( 'templates', 'email', 'default' )->stringify,
- ],
+ INCLUDE_PATH => \@include_path,
});
$vars->{signature} = _render_template($tt, 'signature.txt', $vars);
$vars->{site_name} = Utils::trim_text(_render_template($tt, 'site-name.txt', $vars));
diff --git a/perllib/Open311.pm b/perllib/Open311.pm
index fb793b027..6434be1fb 100644
--- a/perllib/Open311.pm
+++ b/perllib/Open311.pm
@@ -74,17 +74,10 @@ sub send_service_request {
my $obj = $self->_get_xml_object( $response );
if ( $obj ) {
- if ( $obj->{ request }->{ service_request_id } ) {
- my $request_id = $obj->{request}->{service_request_id};
-
- unless ( ref $request_id ) {
- return $request_id;
- }
- } else {
- my $token = $obj->{ request }->{ token };
- if ( $token ) {
- return $self->get_service_request_id_from_token( $token );
- }
+ if ( my $request_id = $obj->{request}->[0]->{service_request_id} ) {
+ return $request_id unless ref $request_id;
+ } elsif ( my $token = $obj->{request}->[0]->{token} ) {
+ return $self->get_service_request_id_from_token( $token );
}
}
@@ -215,8 +208,8 @@ sub get_service_request_id_from_token {
my $obj = $self->_get_xml_object( $service_token_xml );
- if ( $obj && $obj->{ request }->{ service_request_id } ) {
- return $obj->{ request }->{ service_request_id };
+ if ( $obj && $obj->{request}->[0]->{service_request_id} ) {
+ return $obj->{request}->[0]->{service_request_id};
} else {
return 0;
}
@@ -240,15 +233,7 @@ sub get_service_request_updates {
my $xml = $self->_get( $self->endpoints->{service_request_updates}, $params || undef );
my $service_requests = $self->_get_xml_object( $xml );
- my $requests;
- if ( ref $service_requests->{request_update } eq 'ARRAY' ) {
- $requests = $service_requests->{request_update};
- }
- else {
- $requests = [ $service_requests->{request_update} ];
- }
-
- return $requests;
+ return $service_requests->{request_update};
}
sub post_service_request_update {
@@ -263,16 +248,10 @@ sub post_service_request_update {
my $obj = $self->_get_xml_object( $response );
if ( $obj ) {
- if ( $obj->{ request_update }->{ update_id } ) {
- my $update_id = $obj->{request_update}->{update_id};
-
- # if there's nothing in the update_id element we get a HASHREF back
- unless ( ref $update_id ) {
- return $obj->{ request_update }->{ update_id };
- }
+ if ( my $update_id = $obj->{request_update}->[0]->{update_id} ) {
+ return $update_id unless ref $update_id;
} else {
- my $token = $obj->{ request_update }->{ token };
- if ( $token ) {
+ if ( my $token = $obj->{request_update}->[0]->{token} ) {
return $self->get_service_request_id_from_token( $token );
}
}
@@ -455,7 +434,6 @@ sub _process_error {
my $msg = '';
if ( ref $obj && exists $obj->{error} ) {
my $errors = $obj->{error};
- $errors = [ $errors ] if ref $errors ne 'ARRAY';
$msg .= sprintf( "%s: %s\n", $_->{code}, $_->{description} ) for @{ $errors };
}
@@ -463,16 +441,28 @@ sub _process_error {
}
sub _get_xml_object {
- my $self = shift;
- my $xml= shift;
-
- my $simple = XML::Simple->new();
- my $obj;
-
- eval {
- $obj = $simple ->parse_string( $xml, ForceArray => [ qr/^key$/, qr/^name$/ ] );
+ my ($self, $xml) = @_;
+
+ # Of these, services/service_requests/service_request_updates are root
+ # elements, so GroupTags has no effect, but this is used in ForceArray too.
+ my $group_tags = {
+ services => 'service',
+ attributes => 'attribute',
+ values => 'value',
+ service_requests => 'request',
+ errors => 'error',
+ service_request_updates => 'request_update',
+ };
+ my $simple = XML::Simple->new(
+ ForceArray => [ values %$group_tags ],
+ KeyAttr => {},
+ GroupTags => $group_tags,
+ SuppressEmpty => undef,
+ );
+ my $obj = eval {
+ $simple->parse_string($xml);
};
-
return $obj;
}
+
1;
diff --git a/perllib/Open311/GetServiceRequestUpdates.pm b/perllib/Open311/GetServiceRequestUpdates.pm
index daa5fb64d..921b2996d 100644
--- a/perllib/Open311/GetServiceRequestUpdates.pm
+++ b/perllib/Open311/GetServiceRequestUpdates.pm
@@ -122,8 +122,7 @@ sub update_comments {
}
);
- # ref test as XML::Simple will have returned an empty hashref for empty element
- if ($request->{media_url} && !ref $request->{media_url}) {
+ if ($request->{media_url}) {
my $ua = LWP::UserAgent->new;
my $res = $ua->get($request->{media_url});
if ( $res->is_success && $res->content_type eq 'image/jpeg' ) {
diff --git a/perllib/Open311/GetUpdates.pm b/perllib/Open311/GetUpdates.pm
index 901e78809..1b1e339e3 100644
--- a/perllib/Open311/GetUpdates.pm
+++ b/perllib/Open311/GetUpdates.pm
@@ -42,23 +42,12 @@ sub update_reports {
my ( $self, $report_ids, $open311, $body ) = @_;
my $service_requests = $open311->get_service_requests( $report_ids );
-
- my $requests;
-
- # XML::Simple is a bit inconsistent in how it structures
- # things depending on the number of children an element has :(
- if ( ref $service_requests->{request} eq 'ARRAY' ) {
- $requests = $service_requests->{request};
- }
- else {
- $requests = [ $service_requests->{request} ];
- }
+ my $requests = $service_requests->{request};
for my $request (@$requests) {
- # if it's a ref that means it's an empty element
- # however, if there's no updated date then we can't
- # tell if it's newer that what we have so we should skip it
- next if ref $request->{updated_datetime} || ! exists $request->{updated_datetime};
+ # if there's no updated date then we can't
+ # tell if it's newer than what we have so we should skip it
+ next unless $request->{updated_datetime};
my $request_id = $request->{service_request_id};
diff --git a/perllib/Open311/PopulateServiceList.pm b/perllib/Open311/PopulateServiceList.pm
index 3236f3798..f5f117fb5 100644
--- a/perllib/Open311/PopulateServiceList.pm
+++ b/perllib/Open311/PopulateServiceList.pm
@@ -71,8 +71,6 @@ sub process_services {
$self->found_contacts( [] );
my $services = $list->{service};
- # XML might only have one result and then squashed the 'array'-ness
- $services = [ $services ] unless ref $services eq 'ARRAY';
foreach my $service ( @$services ) {
$self->_current_service( $service );
$self->process_service;
@@ -83,17 +81,21 @@ sub process_services {
sub process_service {
my $self = shift;
- my $category = $self->_current_body->areas->{2218} ?
- $self->_current_service->{description} :
- $self->_current_service->{service_name};
+ my $service_name = $self->_normalize_service_name;
+
+ unless (defined $self->_current_service->{service_code}) {
+ warn "Service $service_name has no service code for body @{[$self->_current_body->id]}\n"
+ if $self->verbose >= 1;
+ return;
+ }
- print $self->_current_service->{service_code} . ': ' . $category . "\n" if $self->verbose >= 2;
+ print $self->_current_service->{service_code} . ': ' . $service_name . "\n" if $self->verbose >= 2;
my $contacts = $self->schema->resultset('Contact')->search(
{
body_id => $self->_current_body->id,
-OR => [
email => $self->_current_service->{service_code},
- category => $category,
+ category => $service_name,
]
}
);
@@ -102,7 +104,7 @@ sub process_service {
printf(
"Multiple contacts for service code %s, category %s - Skipping\n",
$self->_current_service->{service_code},
- $category,
+ $service_name,
);
# best to not mark them as deleted as we don't know what we're doing
@@ -205,13 +207,7 @@ sub _add_meta_to_contact {
print "Fetching meta data for " . $self->_current_service->{service_code} . "\n" if $self->verbose >= 2;
my $meta_data = $self->_current_open311->get_service_meta_info( $self->_current_service->{service_code} );
- if ( ref $meta_data->{ attributes }->{ attribute } eq 'HASH' ) {
- $meta_data->{ attributes }->{ attribute } = [
- $meta_data->{ attributes }->{ attribute }
- ];
- }
-
- if ( ! $meta_data->{attributes}->{attribute} ) {
+ unless ($meta_data->{attributes}) {
warn sprintf( "Empty meta data for %s at %s",
$self->_current_service->{service_code},
$self->_current_body->endpoint )
@@ -225,7 +221,7 @@ sub _add_meta_to_contact {
map { $_->{description} =~ s/:\s*//; $_ }
# there is a display order and we only want to sort once
sort { $a->{order} <=> $b->{order} }
- @{ $meta_data->{attributes}->{attribute} };
+ @{ $meta_data->{attributes} };
# Some Open311 endpoints, such as Bromley and Warwickshire send <metadata>
# for attributes which we *don't* want to display to the user (e.g. as
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index 22b37fd55..db6e07933 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -30,6 +30,14 @@ my $contact1 = $mech->create_contact_ok(
}
],
);
+my $contact1b = $mech->create_contact_ok(
+ body_id => $body->id, # Edinburgh
+ category => 'Moon lighting',
+ email => '100b',
+ extra => [ { description => 'Moon type', code => 'type', required => 'False', values =>
+ [ { name => 'Full', key => 'full' }, { name => 'New', key => 'new' } ] }
+ ],
+);
my $contact2 = $mech->create_contact_ok(
body_id => $body->id, # Edinburgh
category => 'Graffiti Removal',
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index 1f61cd3de..6066c66b6 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -7,7 +7,7 @@ my $mech = FixMyStreet::TestMech->new;
# Create test data
my $user = $mech->create_user_ok( 'bromley@example.com' );
-my $body = $mech->create_body_ok( 2482, 'Bromley', id => 2482 );
+my $body = $mech->create_body_ok( 2482, 'Bromley Council', id => 2482 );
$mech->create_contact_ok(
body_id => $body->id,
category => 'Other',
@@ -56,6 +56,66 @@ subtest 'testing special Open311 behaviour', sub {
is $report->external_id, 248, 'Report has right external ID';
};
+for my $test (
+ {
+ cobrand => 'bromley',
+ fields => {
+ submit_update => 1,
+ rznvy => 'unregistered@example.com',
+ update => 'Update from an unregistered user',
+ add_alert => undef,
+ first_name => 'Unreg',
+ last_name => 'User',
+ fms_extra_title => 'DR',
+ may_show_name => undef,
+ }
+ },
+ {
+ cobrand => 'fixmystreet',
+ fields => {
+ submit_update => 1,
+ rznvy => 'unregistered@example.com',
+ update => 'Update from an unregistered user',
+ add_alert => undef,
+ name => 'Unreg User',
+ fms_extra_title => 'DR',
+ may_show_name => undef,
+ }
+ },
+)
+{
+ subtest 'check Bromley update emails via ' . $test->{cobrand} . ' cobrand are correct' => sub {
+ $mech->log_out_ok();
+ $mech->clear_emails_ok();
+
+ my $report_id = $report->id;
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ $test->{cobrand} ],
+ }, sub {
+ $mech->get_ok("/report/$report_id");
+ $mech->submit_form_ok(
+ {
+ with_fields => $test->{fields}
+ },
+ 'submit update'
+ );
+ };
+ $mech->content_contains('Nearly done! Now check your email');
+
+ my $email = $mech->get_email;
+ ok $email, "got an email";
+ like $email->body, qr/This update will be sent to Bromley Council/i, "Email indicates problem will be sent to Bromley";
+ unlike $email->body, qr/Note that we do not send updates to/i, "Email does not say updates aren't sent to Bromley";
+
+ my $unreg_user = FixMyStreet::App->model( 'DB::User' )->find( { email => 'unregistered@example.com' } );
+
+ ok $unreg_user, 'found user';
+
+ $mech->delete_user( $unreg_user );
+ };
+}
+
# Clean up
$mech->delete_user($user);
$mech->delete_body($body);
diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t
index 134d5422e..e13a34492 100644
--- a/t/open311/getservicerequestupdates.t
+++ b/t/open311/getservicerequestupdates.t
@@ -52,13 +52,13 @@ for my $test (
desc => 'basic parsing - empty element',
updated_datetime => '<updated_datetime />',
res => { update_id => 638344, service_request_id => 1,
- status => 'open', description => 'This is a note', updated_datetime => {} } ,
+ status => 'open', description => 'This is a note', updated_datetime => undef } ,
},
{
desc => 'basic parsing - element with no content',
updated_datetime => '<updated_datetime></updated_datetime>',
res => { update_id => 638344, service_request_id => 1,
- status => 'open', description => 'This is a note', updated_datetime => {} } ,
+ status => 'open', description => 'This is a note', updated_datetime => undef } ,
},
{
desc => 'basic parsing - element with content',
diff --git a/t/open311/populate-service-list.t b/t/open311/populate-service-list.t
index f001926d2..606bcbc44 100644
--- a/t/open311/populate-service-list.t
+++ b/t/open311/populate-service-list.t
@@ -419,7 +419,6 @@ for my $test (
);
my $service_list = get_xml_simple_object( $services_xml );
- $service_list = { service => [ $service_list->{ service } ] };
$processor->_current_open311( $o );
$processor->_current_body( $body );
@@ -690,17 +689,7 @@ sub get_standard_xml {
sub get_xml_simple_object {
my $xml = shift;
-
- my $simple = XML::Simple->new();
- my $obj;
-
- eval {
- $obj = $simple->XMLin( $xml );
- };
-
- die $@ if $@;
-
- return $obj;
+ return Open311->_get_xml_object($xml);
}
done_testing();
diff --git a/templates/email/fixmystreet/signature.txt b/templates/email/fixmystreet.com/signature.txt
index 834e69b9d..834e69b9d 100644
--- a/templates/email/fixmystreet/signature.txt
+++ b/templates/email/fixmystreet.com/signature.txt
diff --git a/templates/email/fixmystreet/submit-oxfordshire.txt b/templates/email/fixmystreet.com/submit-oxfordshire.txt
index f0fc5e9b7..f0fc5e9b7 100644
--- a/templates/email/fixmystreet/submit-oxfordshire.txt
+++ b/templates/email/fixmystreet.com/submit-oxfordshire.txt
diff --git a/templates/email/fixmystreet/submit.txt b/templates/email/fixmystreet.com/submit.txt
index 17642e645..17642e645 100644
--- a/templates/email/fixmystreet/submit.txt
+++ b/templates/email/fixmystreet.com/submit.txt
diff --git a/templates/email/fixmystreet/update-confirm-donotsend.txt b/templates/email/fixmystreet.com/update-confirm-donotsend.txt
index 2e04dc0bf..2e04dc0bf 100644
--- a/templates/email/fixmystreet/update-confirm-donotsend.txt
+++ b/templates/email/fixmystreet.com/update-confirm-donotsend.txt
diff --git a/templates/web/angus/header.html b/templates/web/angus/header.html
index 8364461e6..dccbe70fb 100644
--- a/templates/web/angus/header.html
+++ b/templates/web/angus/header.html
@@ -24,7 +24,6 @@
<![endif]-->
<script src="[% version('/js/modernizr.custom.js') %]" charset="utf-8"></script>
- <script src="[% version('/cobrands/angus/position_map.js') %]" charset="utf-8"></script>
[% INCLUDE 'common_header_tags.html' %]
[% extra_js %]
diff --git a/templates/web/angus/maps/fms.html b/templates/web/angus/maps/fms.html
index 3fce8222a..ec4033041 100644
--- a/templates/web/angus/maps/fms.html
+++ b/templates/web/angus/maps/fms.html
@@ -5,6 +5,7 @@
<script type="text/javascript" src="[% version('/js/map-bing-ol.js') %]"></script>
<script type="text/javascript" src="[% version('/js/map-fms.js') %]"></script>
<script type="text/javascript" src="[% version('/js/jquery.ba-hashchange.min.js') %]"></script>
+<script src="[% version('/cobrands/angus/position_map.js') %]" charset="utf-8"></script>
[% END %]
[% map_html = INCLUDE maps/openlayers.html include_key = 1 %]
diff --git a/templates/web/base/report/new/category_extras.html b/templates/web/base/report/new/category_extras.html
index 12ef1486f..c416556e2 100644
--- a/templates/web/base/report/new/category_extras.html
+++ b/templates/web/base/report/new/category_extras.html
@@ -5,7 +5,7 @@
[% INCLUDE "report/new/unresponsive_body.html" body_id = unresponsive.$category %]
[%- END %]
- [%- IF report_meta %]
+ [%- IF category_extras.$category.size %]
<h4>[% loc('Additional Information') %]</h4>
[%- FOR meta IN category_extras.$category %]
[%- meta_name = meta.code -%]
@@ -17,8 +17,8 @@
[% IF meta.variable != 'false' %]
[% IF meta.exists('values') %]
<select name="[% meta_name %]" id="form_[% meta_name %]"[% meta.required == 'true' ? ' required' : '' %]>
- [% FOR option IN meta.values.value %]
- <option value="[% option.key.0 %]"[% IF option.key.0 == report_meta.$meta_name.value %] selected[% END %]>[% option.name.0 %]</option>
+ [% FOR option IN meta.values %]
+ <option value="[% option.key %]"[% IF option.key == report_meta.$meta_name.value %] selected[% END %]>[% option.name %]</option>
[% END %]
</select>
[% ELSE %]
diff --git a/templates/web/fixmystreet.com/about/posters.html b/templates/web/fixmystreet.com/about/posters.html
index bcf235fa4..f330b57fe 100644
--- a/templates/web/fixmystreet.com/about/posters.html
+++ b/templates/web/fixmystreet.com/about/posters.html
@@ -13,7 +13,7 @@
<script>
-$("[data-goodielink]").on(click, function(e){
+$("[data-goodielink]").on('click', function(e){
var url = $(this).attr('href')
var name = $(this).attr('data-goodielink')
var callback = function(){
diff --git a/web/cobrands/fixmystreet.com/layout.scss b/web/cobrands/fixmystreet.com/layout.scss
index 848490e7a..f8026171d 100644
--- a/web/cobrands/fixmystreet.com/layout.scss
+++ b/web/cobrands/fixmystreet.com/layout.scss
@@ -307,6 +307,10 @@ body.unresponsive-council {
.mysoc-footer {
margin-top: 3em;
+ // The below lines are so that on e.g. /about/posters the footer will move on
+ // top of the fixed sidebar in narrow height situations.
+ position: relative;
+ z-index: 1;
}
body.mappage .mysoc-footer {
display: none;
diff --git a/web/cobrands/fixmystreet.com/posters.scss b/web/cobrands/fixmystreet.com/posters.scss
index ee8da9d32..8a1061c06 100644
--- a/web/cobrands/fixmystreet.com/posters.scss
+++ b/web/cobrands/fixmystreet.com/posters.scss
@@ -16,11 +16,11 @@ body.goodies {
color: mix($primary, #000, 40%);
}
}
- }
- h2 {
- padding-top: 1em;
- border-top: 1px solid mix($primary, #eee, 20%);
+ h2 {
+ padding-top: 1em;
+ border-top: 1px solid mix($primary, #eee, 20%);
+ }
}
.pack-preview {
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index f5f5f2934..1379d0fa5 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -643,6 +643,17 @@ OpenLayers.Protocol.FixMyStreet = OpenLayers.Class(OpenLayers.Protocol.HTTP, {
/* Pan data handler */
OpenLayers.Format.FixMyStreet = OpenLayers.Class(OpenLayers.Format.JSON, {
read: function(json, filter) {
+ // Check we haven't received the data after the map has been clicked.
+ if (fixmystreet.page == 'new') {
+ // If we have, we want to do nothing, which means returning an
+ // array of the back-projected version of the current pin
+ var pin = fixmystreet.markers.features[0].clone();
+ pin.geometry.transform(
+ fixmystreet.map.getProjectionObject(),
+ new OpenLayers.Projection("EPSG:4326")
+ );
+ return [ pin ];
+ }
if (typeof json == 'string') {
obj = OpenLayers.Format.JSON.prototype.read.apply(this, [json, filter]);
} else {