aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cypress/cypress/integration/category_tests.js41
-rw-r--r--CHANGELOG.md2
-rwxr-xr-xbin/browser-tests3
-rwxr-xr-xbin/fixmystreet.com/fixture9
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm11
-rw-r--r--perllib/FixMyStreet/Cobrand/Borsetshire.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Oxfordshire.pm16
-rw-r--r--perllib/FixMyStreet/DB/Factories.pm8
-rw-r--r--t/Mock/MapIt.pm1
-rw-r--r--t/cobrand/oxfordshire.t14
-rw-r--r--templates/email/bathnes/_email_color_overrides.html35
-rw-r--r--templates/email/bathnes/_email_setting_overrides.html11
-rw-r--r--templates/email/bathnes/_email_top.html77
-rw-r--r--templates/email/bathnes/_submit_footer.html1
-rw-r--r--web/cobrands/bathnes/images/email-logo.gifbin0 -> 3427 bytes
-rw-r--r--web/cobrands/fixmystreet/fixmystreet.js8
16 files changed, 230 insertions, 9 deletions
diff --git a/.cypress/cypress/integration/category_tests.js b/.cypress/cypress/integration/category_tests.js
new file mode 100644
index 000000000..5135ef842
--- /dev/null
+++ b/.cypress/cypress/integration/category_tests.js
@@ -0,0 +1,41 @@
+describe('Basic categories', function() {
+ before(function(){
+ cy.visit('/');
+ cy.contains('Go');
+ cy.get('[name=pc]').type(Cypress.env('postcode'));
+ cy.get('[name=pc]').parents('form').submit();
+ });
+
+ it('category dropdown contains the expected values', function() {
+ cy.server();
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.url().should('include', '/around');
+ cy.get('#map_box').click(210, 200);
+ cy.wait('@report-ajax');
+ cy.get('[name=category]').should('not.be.visible');
+ var categories = ['-- Pick a category --', 'Graffiti', 'Potholes', 'Street lighting', 'Other', 'Bins' ];
+ cy.get('select:eq(3) option').each(function (obj, i) {
+ expect(obj[0].value).to.equal(categories[i]);
+ });
+ cy.get('#subcategory_Bins').should('not.be.visible');
+ cy.get('select:eq(3)').select('Bins');
+ cy.get('#subcategory_Bins').should('be.visible');
+ cy.get('select:eq(3)').select('Graffiti');
+ cy.get('#subcategory_Bins').should('not.be.visible');
+ });
+
+ it('category dropdown contains works from new page', function() {
+ cy.server();
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.visit('/report/new?latitude=51.496194&longitude=-2.603482');
+ cy.get('[name=category]').should('not.be.visible');
+ var categories = ['-- Pick a category --', 'Graffiti', 'Potholes', 'Street lighting', 'Other', 'Bins' ];
+ cy.get('select:eq(1) option').each(function (obj, i) {
+ expect(obj[0].value).to.equal(categories[i]);
+ });
+ cy.get('#subcategory_Bins').should('not.be.visible');
+ cy.get('select:eq(1)').select('Bins');
+ cy.wait('@report-ajax');
+ cy.get('#subcategory_Bins').should('be.visible');
+ });
+});
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bc13c6dac..8b71e3081 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,10 +3,12 @@
* Unreleased
- New features:
- Dashboard now has update CSV export. #2249
+ - Allow cobrands to override searching by reference #2271
- Front end improvements:
- Clearer relocation options while you’re reporting a problem #2238
- Bugfixes:
- Add perl 5.26/5.28 support.
+ - Fix subcategory issues when visiting /report/new directly #2276
- Internal things:
- Move send-comments code to package for testing.
diff --git a/bin/browser-tests b/bin/browser-tests
index 00cfbc346..d77894dcc 100755
--- a/bin/browser-tests
+++ b/bin/browser-tests
@@ -94,6 +94,9 @@ sub run {
kill 'TERM', $pid if $pid;
exit $exit >> 8;
} else {
+ use Test::MockModule;
+ my $c = Test::MockModule->new('FixMyStreet::Cobrand::FixMyStreet');
+ $c->mock('enable_category_groups', sub { 1 });
# Child, run the server on port 3001
local $ENV{FIXMYSTREET_APP_DEBUG} = 0;
require Plack::Runner;
diff --git a/bin/fixmystreet.com/fixture b/bin/fixmystreet.com/fixture
index ceefbcc9d..8e943a5b5 100755
--- a/bin/fixmystreet.com/fixture
+++ b/bin/fixmystreet.com/fixture
@@ -46,6 +46,15 @@ my $body = FixMyStreet::DB::Factory::Body->find_or_create({
});
say "Created body " . $body->name . " for MapIt area ID " . $opt->area_id . ', categories ' . join(', ', @$categories);
+for my $cat (qw/Overflowing Broken Missing/) {
+ my $child_cat = FixMyStreet::DB::Factory::Contact->find_or_create({
+ body => $body,
+ category => $cat
+ });
+ $child_cat->set_extra_metadata( group => 'Bins' );
+ $child_cat->update;
+}
+
FixMyStreet::DB::Factory::ResponseTemplate->create({
body => $body, title => 'Generic',
text => 'Thank you for your report, we will be in touch with an update soon.' });
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index a1258ccaa..ec8df4450 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -399,10 +399,13 @@ sub _geocode : Private {
sub lookup_by_ref : Private {
my ( $self, $c, $ref ) = @_;
- my $problems = $c->cobrand->problems->search([
- id => $ref,
- external_id => $ref
- ]);
+ my $criteria = $c->cobrand->call_hook("lookup_by_ref", $ref) ||
+ [
+ id => $ref,
+ external_id => $ref
+ ];
+
+ my $problems = $c->cobrand->problems->search( $criteria );
my $count = try {
$problems->count;
diff --git a/perllib/FixMyStreet/Cobrand/Borsetshire.pm b/perllib/FixMyStreet/Cobrand/Borsetshire.pm
index d9b018d69..44a4a9162 100644
--- a/perllib/FixMyStreet/Cobrand/Borsetshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Borsetshire.pm
@@ -31,4 +31,6 @@ sub send_questionnaires {
sub bypass_password_checks { 1 }
+sub enable_category_groups { 1 }
+
1;
diff --git a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
index dafd6e069..4d627c756 100644
--- a/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
+++ b/perllib/FixMyStreet/Cobrand/Oxfordshire.pm
@@ -53,6 +53,22 @@ sub users_can_hide { return 1; }
sub default_show_name { 0 }
+sub lookup_by_ref_regex {
+ return qr/^\s*((?:ENQ)?\d+)\s*$/;
+}
+
+sub lookup_by_ref {
+ my ($self, $ref) = @_;
+
+ if ( $ref =~ /^ENQ/ ) {
+ my $len = length($ref);
+ my $filter = "%T18:customer_reference,T$len:$ref,%";
+ return { 'extra' => { -like => $filter } };
+ }
+
+ return 0;
+}
+
=head2 problem_response_days
Returns the number of working days that are expected to elapse
diff --git a/perllib/FixMyStreet/DB/Factories.pm b/perllib/FixMyStreet/DB/Factories.pm
index db80773e7..b66b27c5d 100644
--- a/perllib/FixMyStreet/DB/Factories.pm
+++ b/perllib/FixMyStreet/DB/Factories.pm
@@ -212,7 +212,7 @@ sub key_field { 'id' }
package FixMyStreet::DB::Factory::Contact;
-use parent "DBIx::Class::Factory";
+use parent -norequire, "FixMyStreet::DB::Factory::Base";
__PACKAGE__->resultset(FixMyStreet::DB->resultset("Contact"));
@@ -224,8 +224,8 @@ __PACKAGE__->fields({
category => 'Other',
email => __PACKAGE__->callback(sub {
my $category = shift->get('category');
- (my $email = lc $_) =~ s/ /-/g;
- lc $category . '@example.org';
+ (my $email = lc $category) =~ s/ /-/g;
+ $email . '@example.org';
}),
state => 'confirmed',
editor => 'Factory',
@@ -233,6 +233,8 @@ __PACKAGE__->fields({
note => 'Created by factory',
});
+sub key_field { 'id' }
+
#######################
package FixMyStreet::DB::Factory::ResponseTemplate;
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index ea00a7ff0..dc23b9ae2 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -26,6 +26,7 @@ my @PLACES = (
[ '?', 53.387402, -2.943997, 2527, 'Liverpool City Council', 'MTD' ],
[ 'EH1 1BB', 55.952055, -3.189579, 2651, 'Edinburgh City Council', 'UTA', 20728, 'City Centre', 'UTE' ],
[ 'BS10 5EE', 51.494885, -2.602237, 2561, 'Bristol City Council', 'UTA', 148646, 'Bedminster', 'UTW' ],
+ [ 'BS20 5EE', 51.496194, -2.603482, 2608, 'Borsetshire County Council', 'CTY', 148646, 'Bedminster', 'UTW' ],
[ 'SL9 0NX', 51.615559, -0.556903, 2217, 'Buckinghamshire County Council', 'CTY', 2257, 'Chiltern District Council', 'DIS' ],
[ 'SW1A 1AA', 51.501009, -0.141588, 2504, 'Westminster City Council', 'LBO' ],
[ 'GL50 2PR', 51.896268, -2.093063, 2226, 'Gloucestershire County Council', 'CTY', 2326, 'Cheltenham Borough Council', 'DIS', 4544, 'Lansdown', 'DIW', 143641, 'Lansdown and Park', 'CED' ],
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
index 19a82742a..cec8f53b3 100644
--- a/t/cobrand/oxfordshire.t
+++ b/t/cobrand/oxfordshire.t
@@ -186,6 +186,20 @@ subtest 'Reports are marked as inspected correctly' => sub {
};
};
+subtest 'can use customer reference to search for reports' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'oxfordshire' ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ my $problem = $problems[0];
+ $problem->set_extra_metadata( customer_reference => 'ENQ12456' );
+ $problem->update;
+
+ $mech->get_ok('/around?pc=ENQ12456');
+ is $mech->uri->path, '/report/' . $problem->id, 'redirects to report';
+ };
+};
+
END {
done_testing();
}
diff --git a/templates/email/bathnes/_email_color_overrides.html b/templates/email/bathnes/_email_color_overrides.html
new file mode 100644
index 000000000..0e7475fb0
--- /dev/null
+++ b/templates/email/bathnes/_email_color_overrides.html
@@ -0,0 +1,35 @@
+[%
+
+color_bathnes_blue = '#00AEEF'
+color_bathnes_grey_1 = '#6F777B'
+color_bathnes_grey_2 = '#BFC1C3'
+color_bathnes_grey_3 = '#DEE0E2'
+color_bathnes_grey_4 = '#F8F8F8'
+color_bathnes_link = '#00728F'
+color_bathnes_link_hover = '#009BC2'
+
+link_text_color = color_bathnes_link
+link_hover_text_color = color_bathnes_link_hover
+
+body_background_color = color_bathnes_grey_4
+body_text_color = color_bathnes_grey_1
+
+header_background_color = color_bathnes_blue
+header_text_color = color_white
+
+button_background_color = color_bathnes_blue
+button_text_color = color_white
+
+secondary_column_background_color = color_bathnes_grey_3
+secondary_column_text_color = color_black
+column_divider_color = color_bathnes_grey_2
+
+preview_photo_border = 'none'
+
+logo_width = '160'
+logo_height = '60'
+
+header_background_color = body_background_color
+header_padding = "0 0 20px 0" # a full CSS padding property (eg: top/right/bottom/left)
+
+%]
diff --git a/templates/email/bathnes/_email_setting_overrides.html b/templates/email/bathnes/_email_setting_overrides.html
new file mode 100644
index 000000000..47c438da2
--- /dev/null
+++ b/templates/email/bathnes/_email_setting_overrides.html
@@ -0,0 +1,11 @@
+[%
+
+site_name = 'Report it'
+
+header_style = "padding: $header_padding; background: $header_background_color; color: $header_text_color; border-bottom: 5px solid $color_bathnes_blue;"
+
+only_column_style = "padding: ${ column_padding }px; vertical-align: top; background-color: $primary_column_background_color; color: $primary_column_text_color; border: 1px solid $column_divider_color; border-width: 0 1px 1px 1px;"
+primary_column_style = "vertical-align: top; width: 50%; background-color: $primary_column_background_color; color: $primary_column_text_color; border: 1px solid $column_divider_color; border-width: 0 0 1px 1px;"
+secondary_column_style = "vertical-align: top; width: 50%; background-color: $secondary_column_background_color; color: $secondary_column_text_color; border: 1px solid $column_divider_color; border-width: 0 1px 1px 1px;"
+
+%]
diff --git a/templates/email/bathnes/_email_top.html b/templates/email/bathnes/_email_top.html
new file mode 100644
index 000000000..ec3c80ce2
--- /dev/null
+++ b/templates/email/bathnes/_email_top.html
@@ -0,0 +1,77 @@
+[%
+ # The cobrand might come to us a variety of ways
+ # Alert sets cobrand directly, questionnaire/submit have it in report, otherwise web
+ cobrand = cobrand.moniker OR report.cobrand OR c.cobrand.moniker;
+
+ IF cobrand == 'fixmystreet';
+ SET img_dir = 'fixmystreet.com';
+ ELSE;
+ SET img_dir = cobrand;
+ END -%]
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <style type="text/css">
+ [%~ # Styles here will be applied by everything except Gmail.com %]
+ a { [% link_style %] }
+ a:hover { [% link_hover_style %] }
+
+ body, table, td, th {
+ font-family: [% body_font_family %] !important;
+ }
+
+ @media only screen and (max-width: [% wrapper_min_width - 1 %]px) {
+ #main, .hint {
+ min-width: 0 !important;
+ }
+
+ #main table, #main tr, #main th {
+ display: block !important;
+ }
+
+ #primary_column,
+ #secondary_column {
+ width: auto !important;
+ }
+ }
+
+ @media only screen and (max-width: [% wrapper_max_width - 1 %]px) {
+ #header {
+ padding-left: 20px !important;
+ }
+ }
+
+ @media only screen and (min-width: [% wrapper_max_width %]px) {
+ .spacer-cell {
+ background-color: [% body_background_color %];
+ }
+ }
+ </style>
+</head>
+<body style="[% body_style %]">
+ <table [% wrapper_table %] style="[% wrapper_style %]">
+ <tr>
+ <th class="spacer-cell"></th>
+ <th width="[% wrapper_max_width %]" style="[% td_style %][% hint_style %]" class="hint">
+ [% email_summary %]
+ </th>
+ <th class="spacer-cell"></th>
+ </tr>
+ </table>
+ <table [% wrapper_table %] style="[% wrapper_style %]">
+ <tr>
+ <th class="spacer-cell"></th>
+ <th width="[% wrapper_max_width %]" style="[% td_style %] min-width: [% wrapper_min_width %]px;" id="main">
+ <table [% table_reset %]>
+ <tr>
+ <th id="header" colspan="[% email_columns %]" style="[% td_style %][% header_style %]">
+ [%~ IF file_exists("web/cobrands/${ img_dir }/images/email-logo.gif") ~%]
+ <img src="[% inline_image('web/cobrands/' _ img_dir _ '/images/email-logo.gif') %]" width="[% logo_width %]" height="[% logo_height %]" alt="[% site_name %]" style="[% logo_style %]"/>
+ [%~ ELSE ~%]
+ <span style="[% logo_style %]">[% site_name %]</span>
+ [%~ END %]
+ </th>
+ </tr>
+ <tr>
diff --git a/templates/email/bathnes/_submit_footer.html b/templates/email/bathnes/_submit_footer.html
new file mode 100644
index 000000000..2f280419f
--- /dev/null
+++ b/templates/email/bathnes/_submit_footer.html
@@ -0,0 +1 @@
+Thank you for using FixMyStreet Pro!
diff --git a/web/cobrands/bathnes/images/email-logo.gif b/web/cobrands/bathnes/images/email-logo.gif
new file mode 100644
index 000000000..9685c9fad
--- /dev/null
+++ b/web/cobrands/bathnes/images/email-logo.gif
Binary files differ
diff --git a/web/cobrands/fixmystreet/fixmystreet.js b/web/cobrands/fixmystreet/fixmystreet.js
index b663d37ba..8e5e40f4d 100644
--- a/web/cobrands/fixmystreet/fixmystreet.js
+++ b/web/cobrands/fixmystreet/fixmystreet.js
@@ -440,7 +440,7 @@ $.extend(fixmystreet.set_up, {
if ($category_select.length === 0) {
return;
}
- var $group_select = $("<select></select>").addClass("form-control");
+ var $group_select = $("<select></select>").addClass("form-control").attr('id', 'category_group');
var $subcategory_label = $("#form_subcategory_label");
var $empty_option = $category_select.find("option").first();
@@ -996,7 +996,8 @@ fixmystreet.update_pin = function(lonlat, savePushState) {
return;
}
$('#side-form, #site-logo').show();
- var old_category = $("select#form_category").val();
+ var category_group = $('#category_group').val(),
+ old_category = $("select#form_category").val();
fixmystreet.reporting_data = data;
@@ -1031,6 +1032,9 @@ fixmystreet.update_pin = function(lonlat, savePushState) {
category_select.change();
}
fixmystreet.run(fixmystreet.set_up.category_groups);
+ if (category_group !== '-- Pick a category --' && category_select.val() == '-- Pick a category --') {
+ $('#category_group').val(category_group).change();
+ }
if (data.contribute_as) {
var $select = $('.js-contribute-as');