aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2019-06-27 15:40:59 +0100
committerMatthew Somerville <matthew@mysociety.org>2019-09-30 11:12:19 +0100
commit66f879bbe6e8c58697dfd99ff8e24b1a0cbcf0fd (patch)
tree13ad5a6a6a77d489cd96ca689e7ebccf6e0f5191
parent9e2d0d842ebeeead4ee8c0c0d7011b765edc35b1 (diff)
[Zurich] Add admin label attribute for categories.
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm5
-rw-r--r--t/cobrand/zurich.t36
-rw-r--r--templates/web/zurich/admin/bodies/contact-form.html10
3 files changed, 44 insertions, 7 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 242edf991..533d1fd17 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -526,7 +526,8 @@ sub category_options {
my $c = $self->{c};
my @categories = $c->model('DB::Contact')->not_deleted->all;
$c->stash->{category_options} = [ map { {
- category => $_->category, category_display => $_->category,
+ category => $_->category,
+ category_display => $_->get_extra_metadata('admin_label') || $_->category,
abbreviation => $_->get_extra_metadata('abbreviation'),
} } @categories ];
}
@@ -1326,7 +1327,7 @@ sub singleton_bodies_str { 1 }
sub body_extra_fields { [ 'category' ] };
-sub contact_extra_fields { [ 'abbreviation' ] };
+sub contact_extra_fields { [ 'abbreviation', 'admin_label' ] };
sub default_problem_state { 'submitted' }
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index a3de931bd..a27f313f6 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -41,6 +41,7 @@ sub reset_report_state {
$report->whensent(undef);
$report->state('submitted');
$report->created($created) if $created;
+ $report->category('Other');
$report->update;
}
@@ -247,6 +248,38 @@ subtest "changing of categories" => sub {
$report->update({category => $original_category });
};
+subtest "private categories" => sub {
+ $mech->log_in_ok( 'super@example.org' );
+ $mech->get_ok('/admin/bodies');
+ $mech->follow_link_ok({ text => 'Division 1' });
+ $mech->submit_form_ok({ with_fields => {
+ category => 'Allgemein',
+ state => 'inactive',
+ email => 'allgemein@example.org',
+ 'extra[admin_label]' => 'StadtPeople',
+ 'extra[abbreviation]' => 'STA',
+ note => 'New',
+ }});
+ $mech->follow_link_ok({ text => 'Allgemein' });
+ $mech->content_contains('<option value="inactive" selected>');
+ $mech->content_like(qr/admin_label.*?StadtPeople/);
+
+ $mech->get_ok( '/around?lat=47.381817&lon=8.529156' );
+ $mech->content_lacks('StadtPeople');
+ $mech->content_contains('Allgemein');
+ $mech->get_ok( '/report/new?lat=47.381817&lon=8.529156' );
+ $mech->content_lacks('StadtPeople');
+ $mech->content_lacks('Allgemein');
+
+ $report->update({ category => 'Allgemein' });
+ $mech->get_ok('/report/' . $report->id);
+ $mech->content_lacks('StadtPeople');
+ $mech->content_contains('Allgemein');
+
+ $mech->get_ok('/admin/report_edit/' . $report->id);
+ $mech->content_contains('<option value="Allgemein">StadtPeople (STA)</option>');
+};
+
sub get_moderated_count {
# my %date_params = ( );
# my $moderated = FixMyStreet::DB->resultset('Problem')->search({
@@ -255,7 +288,7 @@ sub get_moderated_count {
# use a separate mech to avoid stomping on test state
my $mech = FixMyStreet::TestMech->new;
- my $user = $mech->log_in_ok( 'super@example.org' );
+ $mech->log_in_ok( 'super@example.org' );
$mech->get( '/admin/stats' );
if ($mech->content =~/Innerhalb eines Arbeitstages moderiert: (\d+)/) {
@@ -272,6 +305,7 @@ subtest "report_edit" => sub {
ok ( ! $report->get_extra_metadata('moderated_overdue'), 'Report currently unmoderated' );
is get_moderated_count(), 0;
+ $mech->log_in_ok( 'dm1@example.org') ;
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->content_contains( 'Unbest&auml;tigt' ); # Unconfirmed email
$mech->submit_form_ok( { with_fields => { state => 'confirmed' } } );
diff --git a/templates/web/zurich/admin/bodies/contact-form.html b/templates/web/zurich/admin/bodies/contact-form.html
index 7b59124fb..8449f2d39 100644
--- a/templates/web/zurich/admin/bodies/contact-form.html
+++ b/templates/web/zurich/admin/bodies/contact-form.html
@@ -15,6 +15,11 @@
<input type="text" class="form-control" name="extra[abbreviation]" id="abbreviation" size="30" value="[% contact.get_extra_metadata('abbreviation') | html %]">
</p>
+ <p>
+ <label for="admin_label">Admin-label</label>
+ <input type="text" class="form-control" name="extra[admin_label]" id="admin_label" size="30" value="[% contact.get_extra_metadata('admin_label') | html %]">
+ </p>
+
<p><strong>[% loc('Email:') %] </strong>
<input type="text" class="form-control" name="email" value="[% contact.email | html %]" size="30">
@@ -29,15 +34,12 @@
</div>
<p>
- [% IF contact.in_storage %]
<label for="state">[% loc('State') %]</label>
<select name="state" id="state">
<option value="confirmed"[% ' selected' IF contact.state == 'confirmed' %]>[% loc('Confirmed') %]
+ <option value="inactive"[% ' selected' IF contact.state == 'inactive' %]>[% loc('Inactive') %]
<option value="deleted"[% ' selected' IF contact.state == 'deleted' %]>[% loc('Deleted') %]
</select>
- [% ELSE %]
- <input type="hidden" name="state" value="confirmed" id="confirmed">
- [% END %]
<input type="checkbox" name="photo_required" value="1" id="photo_required"[% ' checked' IF contact.get_extra_metadata('photo_required') %]>
<label class="inline" for="photo_required">[% loc('Photo required') %]</label>
</p>