aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/update-schema1
-rw-r--r--db/schema.sql3
-rw-r--r--db/schema_0029-add_deleted_flag_to_body.sql6
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm3
-rw-r--r--perllib/FixMyStreet/DB/Result/Body.pm6
-rw-r--r--t/cobrand/zurich.t14
-rw-r--r--templates/web/default/admin/bodies.html4
-rw-r--r--templates/web/zurich/admin/body-form.html7
-rw-r--r--templates/web/zurich/admin/report_edit.html2
-rw-r--r--web/cobrands/zurich/_zurich.scss4
10 files changed, 42 insertions, 8 deletions
diff --git a/bin/update-schema b/bin/update-schema
index f728f8c56..81c9ff4ab 100644
--- a/bin/update-schema
+++ b/bin/update-schema
@@ -84,6 +84,7 @@ print "Nothing to do\n" if $nothing;
# By querying the database schema, we can see where we're currently at
# (assuming schema change files are never half-applied, which should be the case)
sub get_db_version {
+ return '0029' if column_exists('body', 'deleted');
return '0028' if table_exists('body');
return '0027' if column_exists('problem', 'subcategory');
return '0026' if column_exists('open311conf', 'send_extended_statuses');
diff --git a/db/schema.sql b/db/schema.sql
index 5e4bc4a3e..5c54e2d88 100644
--- a/db/schema.sql
+++ b/db/schema.sql
@@ -64,7 +64,8 @@ create table body (
comment_user_id int references users(id),
suppress_alerts boolean not null default 'f',
can_be_devolved boolean not null default 'f',
- send_extended_statuses boolean not null default 'f'
+ send_extended_statuses boolean not null default 'f',
+ deleted boolean not null default 'f'
);
create table body_areas (
diff --git a/db/schema_0029-add_deleted_flag_to_body.sql b/db/schema_0029-add_deleted_flag_to_body.sql
new file mode 100644
index 000000000..3a8be7890
--- /dev/null
+++ b/db/schema_0029-add_deleted_flag_to_body.sql
@@ -0,0 +1,6 @@
+BEGIN;
+
+ALTER table body
+ ADD column deleted BOOL NOT NULL DEFAULT 'f';
+
+COMMIT;
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index ba8f22a05..4973b7c4e 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -413,7 +413,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/;
+ 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 %defaults = map { $_ => '' } @fields;
%defaults = ( %defaults,
send_comments => 0,
@@ -422,6 +422,7 @@ sub body_params : Private {
send_extended_statuses => 0,
can_be_devolved => 0,
parent => undef,
+ deleted => 0,
);
my %params = map { $_ => $c->req->param($_) || $defaults{$_} } @fields;
return \%params;
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm
index b6a044b04..c2b0555fb 100644
--- a/perllib/FixMyStreet/DB/Result/Body.pm
+++ b/perllib/FixMyStreet/DB/Result/Body.pm
@@ -40,6 +40,8 @@ __PACKAGE__->add_columns(
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
"send_extended_statuses",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
+ "deleted",
+ { data_type => "boolean", default_value => \"false", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->has_many(
@@ -90,8 +92,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 17:11:54
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:JT0w76BWaDpjAV61WVSYHg
+# Created by DBIx::Class::Schema::Loader v0.07035 @ 2013-09-10 18:11:23
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hTOxxiiHmC8nmQK/p8dXhQ
sub url {
my ( $self, $c ) = @_;
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 7a060ae2b..869e5d460 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -311,6 +311,20 @@ $mech->submit_form( with_fields => { phone => "" } );
$mech->content_contains( 'Diese Information wird benötigt' );
$mech->log_out_ok;
+# Test problems can't be assigned to deleted bodies
+$user = $mech->log_in_ok( 'dm1@example.org' );
+$user->from_body( 1 );
+$user->update;
+$report->state( 'confirmed' );
+$report->update;
+$mech->get_ok( '/admin/body/' . $external_body->id );
+$mech->submit_form_ok( { with_fields => { deleted => 1 } } );
+$mech->get_ok( '/admin/report_edit/' . $report->id );
+$mech->content_lacks( $external_body->name );
+$user->from_body( 2 );
+$user->update;
+$mech->log_out_ok;
+
$mech->delete_problems_for_body( 2 );
$mech->delete_user( 'dm1@example.org' );
$mech->delete_user( 'sdm1@example.org' );
diff --git a/templates/web/default/admin/bodies.html b/templates/web/default/admin/bodies.html
index fabaf8923..c0824521e 100644
--- a/templates/web/default/admin/bodies.html
+++ b/templates/web/default/admin/bodies.html
@@ -16,6 +16,7 @@
<th>[% loc('Name') %]</th>
[% IF c.cobrand.moniker == 'zurich' %]
<th>[% loc('Email') %]</th>
+ <th>[% loc('Deleted') %]</th>
[% ELSE %]
<th>[% loc('Category') %]</th>
[% END %]
@@ -23,7 +24,7 @@
[%- FOREACH body IN bodies %]
[%- SET id = body.id %]
[% NEXT IF c.cobrand.moniker == 'zurich' AND admin_type == 'dm' AND (body.parent OR body.bodies) %]
- <tr>
+ <tr[% IF c.cobrand.moniker == 'zurich' AND body.deleted %] class="muted"[% END %]>
<td>
[% IF c.cobrand.moniker == 'zurich' %]
[% FILTER repeat(4*body.api_key) %]&nbsp;[% END %]
@@ -39,6 +40,7 @@
</td>
[% IF c.cobrand.moniker == 'zurich' %]
<td>[% body.endpoint %]</td>
+ <td>[% IF body.deleted %]Yes[% END %]</td>
[% ELSE %]
<td>
[% IF counts.$id %]
diff --git a/templates/web/zurich/admin/body-form.html b/templates/web/zurich/admin/body-form.html
index 5ae8eb8a6..4e570a058 100644
--- a/templates/web/zurich/admin/body-form.html
+++ b/templates/web/zurich/admin/body-form.html
@@ -10,7 +10,6 @@
<input type="text" name="endpoint" id="email" value="[% body.endpoint %]" size="50">
</p>
-[% IF admin_type == 'super' %]
<p>
<label for="parent">[% loc('Parent') %]</label>
<select name="parent" id="parent">
@@ -31,7 +30,11 @@
[% END %]
</select>
</p>
-[% END %]
+
+ <p>
+ <label for="deleted">[% loc('Flag as deleted') %]</label>
+ <input type="checkbox" name="deleted" id="deleted" value="1"[% ' checked' IF body.deleted %] />
+ </p>
<input type="hidden" name="send_method" value="Email">
<input type="hidden" name="jurisdiction" id="jurisdiction" value="[% body.jurisdiction %]">
diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html
index 128e74766..723086c46 100644
--- a/templates/web/zurich/admin/report_edit.html
+++ b/templates/web/zurich/admin/report_edit.html
@@ -136,7 +136,7 @@
<select name="body_external" id="body_external">
<option value="">--</option>
[% FOR body IN bodies %]
- [% NEXT IF body.parent OR body.bodies %]
+ [% NEXT IF body.parent OR body.bodies OR body.deleted %]
<option value="[% body.id %]"[% IF body.id == problem.bodies_str %] selected[% END %]>[% body.name %]</option>
[% END %]
</select>
diff --git a/web/cobrands/zurich/_zurich.scss b/web/cobrands/zurich/_zurich.scss
index c9eb7a080..f9ea29d9a 100644
--- a/web/cobrands/zurich/_zurich.scss
+++ b/web/cobrands/zurich/_zurich.scss
@@ -35,3 +35,7 @@ body.frontpage #zurich-footer-wrapper {
#zurich-footer a:hover {
color: #3c3c3c;
}
+
+.muted, .muted a {
+ color: #aaa;
+}