From 25f16cc07a5c1daf721103d6f1f523df26fcbbf8 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 30 Jul 2015 15:46:13 +0100 Subject: Allow body external URL to be edited in admin. --- perllib/FixMyStreet/App/Controller/Admin.pm | 4 ++-- templates/web/base/admin/bodies.html | 8 ++++---- templates/web/base/admin/body-form.html | 16 ++++++++++------ templates/web/base/admin/body.html | 6 +++--- templates/web/base/admin/category_edit.html | 8 ++++---- web/js/fixmystreet-admin.js | 2 +- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 114a2e19f..7b760d26d 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -425,7 +425,7 @@ sub update_contacts : Private { sub body_params : Private { my ( $self, $c ) = @_; - my @fields = qw/name endpoint jurisdiction api_key send_method send_comments suppress_alerts send_extended_statuses comment_user_id can_be_devolved parent deleted/; + my @fields = qw/name endpoint jurisdiction api_key send_method external_url/; my %defaults = map { $_ => '' } @fields; %defaults = ( %defaults, send_comments => 0, @@ -436,7 +436,7 @@ sub body_params : Private { parent => undef, deleted => 0, ); - my %params = map { $_ => $c->get_param($_) || $defaults{$_} } @fields; + my %params = map { $_ => $c->get_param($_) || $defaults{$_} } keys %defaults; return \%params; } diff --git a/templates/web/base/admin/bodies.html b/templates/web/base/admin/bodies.html index a039f8208..4c95423c0 100644 --- a/templates/web/base/admin/bodies.html +++ b/templates/web/base/admin/bodies.html @@ -35,13 +35,13 @@ [% IF c.cobrand.moniker == 'zurich' %] [% FILTER repeat(4*body.api_key) %] [% END %] [% IF admin_type == 'super' %] - [% body.name %] + [% body.name | html %] [% ELSE %] - [% body.name %] + [% body.name | html %] [% END %] [% ELSE %] [%# not Zurich: all bodies should be links %] - [% body.name %] - [%- ', ' _ body.parent.name IF body.parent -%] + [% body.name | html%] + [%- IF body.parent %], [% body.parent.name | html %][% END -%] [% END %] [% IF c.cobrand.moniker == 'zurich' %] diff --git a/templates/web/base/admin/body-form.html b/templates/web/base/admin/body-form.html index 608a77dc2..4122ecd3f 100644 --- a/templates/web/base/admin/body-form.html +++ b/templates/web/base/admin/body-form.html @@ -16,7 +16,7 @@

- +

@@ -72,17 +72,21 @@ [% SET body_areas = body.areas %] [% FOR area IN areas %] [% SET aid = area.id %] - + [% END %]

+

+ + +

[% loc( "You can mark a body as deleted if you do not want it to be active on the site." ) %]

- +

@@ -124,7 +128,7 @@

- +

@@ -137,7 +141,7 @@

- +

@@ -150,7 +154,7 @@

- +

diff --git a/templates/web/base/admin/body.html b/templates/web/base/admin/body.html index cd87a5af8..867c981e3 100644 --- a/templates/web/base/admin/body.html +++ b/templates/web/base/admin/body.html @@ -65,7 +65,7 @@ [% WHILE ( cat = contacts.next ) %] - [% cat.category %] + [% cat.category | html %]
[% cat.email | html %] [% loc('Confirmed') %]:  @@ -79,10 +79,10 @@
[% loc('Devolved') %]:  [%- IF body.can_be_devolved AND cat.send_method %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %] - [% cat.editor %] + [% cat.editor | html %]
[% PROCESS format_time time=cat.whenedited %] [% cat.note | html %] - + [% END %] diff --git a/templates/web/base/admin/category_edit.html b/templates/web/base/admin/category_edit.html index ef7a0a11c..fb7475e1f 100644 --- a/templates/web/base/admin/category_edit.html +++ b/templates/web/base/admin/category_edit.html @@ -48,17 +48,17 @@

- +

- +

- +

@@ -93,7 +93,7 @@ [% PROCESS highlightchanged old=prev new=contact value='email' %] [% PROCESS highlightchanged_yesno old=prev new=contact value='confirmed' %] [% PROCESS highlightchanged_yesno old=prev new=contact value='deleted' %] - [% contact.editor %] + [% contact.editor | html %] [% contact.note | html %] [%- prev = contact %] diff --git a/web/js/fixmystreet-admin.js b/web/js/fixmystreet-admin.js index e49516a5c..5e0d873c5 100644 --- a/web/js/fixmystreet-admin.js +++ b/web/js/fixmystreet-admin.js @@ -9,7 +9,7 @@ $(function(){ var show_open311 = false; if ($('#endpoint').val()) { show_open311 = true; // always show the form if there is an endpoint value - } else if (send_method && send_method.toLowerCase() != 'email') { + } else if (send_method && !send_method.match(/^(email|emptyhomes|noop|refused)$/i)) { show_open311 = true; } if (show_open311) { -- cgit v1.2.3 From 68fc33ac915bda5c5e737c037eb7854068039d29 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 30 Jul 2015 16:38:57 +0100 Subject: Add mark as sent button to admin. --- perllib/FixMyStreet/App/Controller/Admin.pm | 7 +++++++ t/app/controller/admin.t | 2 +- templates/web/base/admin/report_edit.html | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 7b760d26d..6145a6eb0 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -705,6 +705,13 @@ sub report_edit : Path('report_edit') : Args(1) { $c->forward( 'log_edit', [ $id, 'problem', 'resend' ] ); } + elsif ( $c->get_param('mark_sent') ) { + $c->forward('check_token'); + $problem->whensent(\'ms_current_timestamp()'); + $problem->update(); + $c->stash->{status_message} = '

' . _('That problem has been marked as sent.') . '

'; + $c->forward( 'log_edit', [ $id, 'problem', 'marked sent' ] ); + } elsif ( $c->get_param('flaguser') ) { $c->forward('flag_user'); $c->stash->{problem}->discard_changes; diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index f63a72117..fb3ab1917 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -568,7 +568,7 @@ foreach my $test ( $report->discard_changes; - if ( $report->state eq 'confirmed' ) { + if ($report->state eq 'confirmed' && $report->whensent) { $mech->content_contains( 'type="submit" name="resend"', 'resend button' ); } else { $mech->content_lacks( 'type="submit" name="resend"', 'no resend button' ); diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html index 12560fdf3..f14c1616a 100644 --- a/templates/web/base/admin/report_edit.html +++ b/templates/web/base/admin/report_edit.html @@ -68,7 +68,10 @@
  • [% loc('Phone:') %] [% problem.user.phone | html %]
  • [% loc('Created:') %] [% PROCESS format_time time=problem.created %]
  • [% loc('Confirmed:') %] [% PROCESS format_time time=problem.confirmed no_time='-' %]
  • -
  • [% loc('Sent:') %] [% PROCESS format_time time=problem.whensent %] [% IF problem.state == 'confirmed' %][% END %]
  • +
  • [% loc('Sent:') %] [% PROCESS format_time time=problem.whensent %] +[% IF problem.state == 'confirmed' AND problem.whensent %][% END %] +[% IF NOT problem.whensent %][% END %] +
  • [% loc('Last update:') %] [% PROCESS format_time time=problem.lastupdate %]
  • [% loc('Service:') %] [% problem.service %]
  • [% loc('Cobrand:') %] [% problem.cobrand %]
  • -- cgit v1.2.3 From 9b61f5a2294d786f97c6bf78375257ca339638bd Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 30 Jul 2015 16:39:23 +0100 Subject: Add link to comment user ID from body form if present. --- templates/web/base/admin/body-form.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/templates/web/base/admin/body-form.html b/templates/web/base/admin/body-form.html index 4122ecd3f..6b103a7cf 100644 --- a/templates/web/base/admin/body-form.html +++ b/templates/web/base/admin/body-form.html @@ -184,6 +184,9 @@

    + [% IF body.comment_user_id %] + [% loc('edit user') %] + [% END %]

    -- cgit v1.2.3 From 87f9c198c388f5defa2da72ba51541415c0fda29 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 30 Jul 2015 16:40:14 +0100 Subject: Add MapIt links to admin from body/co-ordinates. --- templates/web/base/admin/body.html | 18 +++++++++++++----- templates/web/base/admin/report_edit.html | 6 +++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/templates/web/base/admin/body.html b/templates/web/base/admin/body.html index 867c981e3..84ea6840c 100644 --- a/templates/web/base/admin/body.html +++ b/templates/web/base/admin/body.html @@ -13,14 +13,22 @@ [% IF example_pc %] [% tprintf( loc('Example postcode %s'), example_pc ) | html %] | [% END %] - [% IF c.cobrand.moniker == 'emptyhomes' %] - [% loc('List all reported problems' ) %] | - [% ELSE %] + [% loc('Area covered') %]: + [% SET body_areas = body.areas %] + [% FOR area IN areas %] + [% SET aid = area.id %] + [% IF body_areas.$aid %] + [% area.name | html %] + [% END %] + [% END %] +
    [% loc('List all reported problems' ) %] | - [% END %] - [% loc('Text only version') %] + [% loc('Text only version') %]

    + [% IF body.send_method == 'Open311' %]

    Council contacts configured via Open311 diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html index f14c1616a..a63952ec6 100644 --- a/templates/web/base/admin/report_edit.html +++ b/templates/web/base/admin/report_edit.html @@ -20,7 +20,11 @@
  • -
  • [% loc('Co-ordinates:') %] [% problem.latitude %], [% problem.longitude %] +
  • [% loc('Co-ordinates:') %] +[% problem.latitude %], [% problem.longitude %] ( [% SET postcode_safe = problem.postcode | html; tprintf( loc('originally entered: “%s”'), postcode_safe ) -- cgit v1.2.3 From 64ec1aeb3c5da3235df4fba1b765d2f831c11b49 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 30 Jul 2015 16:40:35 +0100 Subject: Show category extra data in admin. --- templates/web/base/admin/category_edit.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/templates/web/base/admin/category_edit.html b/templates/web/base/admin/category_edit.html index fb7475e1f..b827a4b6d 100644 --- a/templates/web/base/admin/category_edit.html +++ b/templates/web/base/admin/category_edit.html @@ -23,6 +23,11 @@

    [% loc('Category:') %] [% contact.category | html %] + [% IF contact.extra %] +

    [% loc('Extra data:') %] + [% USE Dumper %] + [% Dumper.dump(contact.extra) | html %]

    + [% END %]

    [% loc('Email:') %] -- cgit v1.2.3 From 26429aa50b9a915de3a9b3042420e1525f55b164 Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 30 Jul 2015 16:41:00 +0100 Subject: =?UTF-8?q?List=20a=20report=E2=80=99s=20bodies=20more=20nicely=20?= =?UTF-8?q?in=20admin.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/web/base/admin/report_edit.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/web/base/admin/report_edit.html b/templates/web/base/admin/report_edit.html index a63952ec6..d488dcadc 100644 --- a/templates/web/base/admin/report_edit.html +++ b/templates/web/base/admin/report_edit.html @@ -31,7 +31,16 @@ class="admin-offsite-link">[% problem.latitude %], [% problem.longitude %] %], [% IF problem.used_map %][% loc('used map') %][% ELSE %][% loc("didn't use map") %][% END %])

  • -
  • [% loc('For council(s):') %] [% IF problem.bodies_str %][% problem.bodies_str %][% ELSE %][% loc('None' ) %][% END %] ([% loc('other areas:') %] [% problem.areas | remove('^,') | remove( ',$' ) %])
  • +
  • [% loc('Body:') %] + [% IF problem.bodies_str %] + [% FOREACH body IN problem.bodies.values %] + [% body.name | html %] + [%- ',' IF NOT loop.last %] + [% END %] + [% ELSE %] + [% loc('None' ) %] + [% END %] + ([% loc('other areas:') %] [% problem.areas | remove('^,') | remove( ',$' ) %])
  • [% IF problem.extra.address %]
  • [% loc('Property address:') %] [% problem.extra.address | html %]
  • [% END %] -- cgit v1.2.3 From 749df1cfe907190632b09e434f9411cf08b5b2cf Mon Sep 17 00:00:00 2001 From: Matthew Somerville Date: Thu, 30 Jul 2015 16:41:18 +0100 Subject: Mark users who have moderate permission. --- t/app/controller/admin.t | 2 +- templates/web/base/admin/user-form.html | 3 ++- templates/web/base/admin/users.html | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/t/app/controller/admin.t b/t/app/controller/admin.t index fb3ab1917..498f1cedc 100644 --- a/t/app/controller/admin.t +++ b/t/app/controller/admin.t @@ -1083,7 +1083,7 @@ subtest 'report search' => sub { subtest 'search abuse' => sub { $mech->get_ok( '/admin/users?search=example' ); - $mech->content_like(qr{test4\@example.com.*\s*.*?\s*\(Email in abuse table}); + $mech->content_like(qr{test4\@example.com.*\s*.*?\s*\(Email in abuse table}s); }; subtest 'show flagged entries' => sub { diff --git a/templates/web/base/admin/user-form.html b/templates/web/base/admin/user-form.html index 4a57b05a0..3956e8533 100644 --- a/templates/web/base/admin/user-form.html +++ b/templates/web/base/admin/user-form.html @@ -34,8 +34,9 @@ [% FOR body IN bodies %] [% END %] - + [% IF user.from_body AND user.has_permission_to('moderate', user.from_body.id) %]*[% END %] + [% IF c.cobrand.moniker != 'zurich' %]
  • diff --git a/templates/web/base/admin/users.html b/templates/web/base/admin/users.html index db97c7d59..19a3de03c 100644 --- a/templates/web/base/admin/users.html +++ b/templates/web/base/admin/users.html @@ -24,7 +24,9 @@ [% PROCESS value_or_nbsp value=user.name %] [% PROCESS value_or_nbsp value=user.email %] - [% PROCESS value_or_nbsp value=user.from_body.name %] + [% PROCESS value_or_nbsp value=user.from_body.name %] + [% IF user.from_body AND user.has_permission_to('moderate', user.from_body.id) %] * [% END %] + [% IF c.cobrand.moniker != 'zurich' %] [% user.flagged == 2 ? loc('(Email in abuse table)') : user.flagged ? loc('Yes') : ' ' %] [% END %] -- cgit v1.2.3