aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-07-16 22:05:52 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-08-10 11:30:41 +0100
commitcc3e99fa9878bfb722e61d4a09d94839b152c5b7 (patch)
treeaa273efab59cb60c6c0edc37de9b7665aa49b27d
parentfe4153e367bcbb74eebed9c8ac0126d94709506c (diff)
Set up translatable category columns.
As category is used both for display and as a link between Problem and Contact tables, add `category_display` for use whenever a category is displayed.
-rw-r--r--perllib/FixMyStreet/App/Controller/Admin.pm4
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/My.pm2
-rw-r--r--perllib/FixMyStreet/App/Controller/Report/New.pm11
-rw-r--r--perllib/FixMyStreet/App/Controller/Reports.pm2
-rw-r--r--perllib/FixMyStreet/Cobrand/Zurich.pm4
-rw-r--r--perllib/FixMyStreet/DB/Result/Contact.pm8
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm14
-rw-r--r--perllib/FixMyStreet/Roles/Translatable.pm13
-rw-r--r--t/app/model/problem.t9
-rw-r--r--t/roles/translatable.t39
-rw-r--r--templates/web/base/admin/body.html2
-rw-r--r--templates/web/base/admin/category-checkboxes.html2
-rw-r--r--templates/web/base/admin/category-multiselect.html2
-rw-r--r--templates/web/base/admin/contact-form.html2
-rw-r--r--templates/web/base/admin/council_contacts.txt2
-rw-r--r--templates/web/base/admin/defecttypes/list.html2
-rw-r--r--templates/web/base/admin/problem_row.html2
-rw-r--r--templates/web/base/admin/report-category.html8
-rw-r--r--templates/web/base/admin/responsepriorities/list.html2
-rw-r--r--templates/web/base/dashboard/index.html2
-rw-r--r--templates/web/base/report/_inspect.html25
-rw-r--r--templates/web/base/report/_item.html2
-rw-r--r--templates/web/base/report/new/category.html6
-rw-r--r--templates/web/base/reports/_list-filters.html4
-rw-r--r--templates/web/zurich/admin/body.html2
-rw-r--r--templates/web/zurich/admin/contact-form.html2
-rw-r--r--templates/web/zurich/admin/problem_row.html2
-rw-r--r--templates/web/zurich/admin/report_edit-sdm.html2
-rw-r--r--templates/web/zurich/admin/report_edit.html6
-rw-r--r--templates/web/zurich/report/_main.html2
31 files changed, 120 insertions, 67 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm
index d1ac5e76b..acbc62fb8 100644
--- a/perllib/FixMyStreet/App/Controller/Admin.pm
+++ b/perllib/FixMyStreet/App/Controller/Admin.pm
@@ -925,8 +925,8 @@ sub categories_for_point : Private {
# Remove the "Pick a category" option
shift @{$c->stash->{category_options}} if @{$c->stash->{category_options}};
- $c->stash->{categories} = $c->stash->{category_options};
- $c->stash->{categories_hash} = { map { $_ => 1 } @{$c->stash->{category_options}} };
+ $c->stash->{category_options_copy} = $c->stash->{category_options};
+ $c->stash->{categories_hash} = { map { $_->{name} => 1 } @{$c->stash->{category_options}} };
}
sub templates : Path('templates') : Args(0) {
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 561a6c2e3..a8782eba2 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -259,7 +259,7 @@ sub check_and_stash_category : Private {
distinct => 1
}
)->all;
- my @categories = map { $_->category } @contacts;
+ my @categories = map { { name => $_->category, value => $_->category_display } } @contacts;
$c->stash->{filter_categories} = \@categories;
my %categories_mapped = map { $_ => 1 } @categories;
diff --git a/perllib/FixMyStreet/App/Controller/My.pm b/perllib/FixMyStreet/App/Controller/My.pm
index 6fee25ec5..ea7aee016 100644
--- a/perllib/FixMyStreet/App/Controller/My.pm
+++ b/perllib/FixMyStreet/App/Controller/My.pm
@@ -162,7 +162,7 @@ sub setup_page_data : Private {
distinct => 1,
order_by => [ 'category' ],
} )->all;
- @categories = map { $_->category } @categories;
+ @categories = map { { name => $_->category, value => $_->category_display } } @categories;
$c->stash->{filter_categories} = \@categories;
$c->stash->{page} = 'my';
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm
index 6b02bd80d..ab4c616fb 100644
--- a/perllib/FixMyStreet/App/Controller/Report/New.pm
+++ b/perllib/FixMyStreet/App/Controller/Report/New.pm
@@ -213,7 +213,6 @@ sub report_form_ajax : Path('ajax') : Args(0) {
category => $category,
extra_name_info => $extra_name_info,
titles_list => $extra_titles_list,
- categories => $c->stash->{category_options},
%$contribute_as ? (contribute_as => $contribute_as) : (),
$top_message ? (top_message => $top_message) : (),
}
@@ -645,7 +644,7 @@ sub setup_categories_and_bodies : Private {
$bodies_to_list{ $contact->body_id } = $contact->body;
unless ( $seen{$contact->category} ) {
- push @category_options, $contact->category;
+ push @category_options, { name => $contact->category, value => $contact->category_display };
my $metas = $contact->get_metadata_for_input;
$category_extras{$contact->category} = $metas if @$metas;
@@ -657,13 +656,15 @@ sub setup_categories_and_bodies : Private {
$non_public_categories{ $contact->category } = 1 if $contact->non_public;
}
- $seen{$contact->category} = 1;
+ $seen{$contact->category} = $contact->category_display;
}
if (@category_options) {
# If there's an Other category present, put it at the bottom
- @category_options = ( _('-- Pick a category --'), grep { $_ ne _('Other') } @category_options );
- push @category_options, _('Other') if $seen{_('Other')};
+ @category_options = (
+ { name => _('-- Pick a category --'), value => _('-- Pick a category --') },
+ grep { $_->{name} ne _('Other') } @category_options );
+ push @category_options, { name => _('Other'), value => $seen{_('Other')} } if $seen{_('Other')};
}
$c->cobrand->call_hook(munge_category_list => \@category_options, \@contacts, \%category_extras);
diff --git a/perllib/FixMyStreet/App/Controller/Reports.pm b/perllib/FixMyStreet/App/Controller/Reports.pm
index c3616eed0..33a1ac5b9 100644
--- a/perllib/FixMyStreet/App/Controller/Reports.pm
+++ b/perllib/FixMyStreet/App/Controller/Reports.pm
@@ -150,7 +150,7 @@ sub ward : Path : Args(2) {
distinct => 1,
order_by => [ 'category' ],
} )->all;
- @categories = map { $_->category } @categories;
+ @categories = map { { name => $_->category, value => $_->category_display } } @categories;
$c->stash->{filter_categories} = \@categories;
$c->stash->{filter_category} = { map { $_ => 1 } $c->get_param_list('filter_category', 1) };
diff --git a/perllib/FixMyStreet/Cobrand/Zurich.pm b/perllib/FixMyStreet/Cobrand/Zurich.pm
index 776350b25..c56f595ca 100644
--- a/perllib/FixMyStreet/Cobrand/Zurich.pm
+++ b/perllib/FixMyStreet/Cobrand/Zurich.pm
@@ -519,7 +519,7 @@ sub admin_report_edit {
# Can change category to any other
my @categories = $c->model('DB::Contact')->not_deleted->all;
- $c->stash->{categories} = [ map { $_->category } @categories ];
+ $c->stash->{category_options} = [ map { { name => $_->category, value => $_->category } } @categories ];
} elsif ($type eq 'dm') {
@@ -534,7 +534,7 @@ sub admin_report_edit {
# Can change category to any other
my @categories = $c->model('DB::Contact')->not_deleted->all;
- $c->stash->{categories} = [ map { $_->category } @categories ];
+ $c->stash->{category_options} = [ map { { name => $_->category, value => $_->category } } @categories ];
}
diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm
index 3454c5806..fb731b9a3 100644
--- a/perllib/FixMyStreet/DB/Result/Contact.pm
+++ b/perllib/FixMyStreet/DB/Result/Contact.pm
@@ -82,12 +82,18 @@ __PACKAGE__->rabx_column('extra');
use Moo;
use namespace::clean -except => [ 'meta' ];
-with 'FixMyStreet::Roles::Extra';
+with 'FixMyStreet::Roles::Extra',
+ 'FixMyStreet::Roles::Translatable';
__PACKAGE__->many_to_many( response_templates => 'contact_response_templates', 'response_template' );
__PACKAGE__->many_to_many( response_priorities => 'contact_response_priorities', 'response_priority' );
__PACKAGE__->many_to_many( defect_types => 'contact_defect_types', 'defect_type' );
+sub category_display {
+ my $self = shift;
+ $self->translate('category');
+}
+
sub get_metadata_for_input {
my $self = shift;
my $id_field = $self->id_field;
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index f353c02ee..afa117e4c 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -206,6 +206,7 @@ my $IM = eval {
with 'FixMyStreet::Roles::Abuser',
'FixMyStreet::Roles::Extra',
+ 'FixMyStreet::Roles::Translatable',
'FixMyStreet::Roles::PhotoSet';
=head2
@@ -456,12 +457,6 @@ sub check_for_errors {
$errors{category} = _('Please choose a category');
$self->category(undef);
}
- elsif ($self->category
- && $self->category eq _('-- Pick a property type --') )
- {
- $errors{category} = _('Please choose a property type');
- $self->category(undef);
- }
return \%errors;
}
@@ -489,6 +484,11 @@ sub confirm {
return 1;
}
+sub category_display {
+ my $self = shift;
+ $self->translate('category');
+}
+
sub bodies_str_ids {
my $self = shift;
return [] unless $self->bodies_str;
@@ -635,7 +635,7 @@ sub meta_line {
my $date_time = Utils::prettify_dt( $problem->confirmed );
my $meta = '';
- my $category = $problem->category;
+ my $category = $problem->category_display;
$category = $c->cobrand->call_hook(change_category_text => $category) || $category;
if ( $problem->anonymous ) {
diff --git a/perllib/FixMyStreet/Roles/Translatable.pm b/perllib/FixMyStreet/Roles/Translatable.pm
index 43cb063d1..cc66f9621 100644
--- a/perllib/FixMyStreet/Roles/Translatable.pm
+++ b/perllib/FixMyStreet/Roles/Translatable.pm
@@ -22,6 +22,19 @@ sub _translate {
my $table = lc $self->result_source->source_name;
my $id = $self->id;
+ # Deal with the fact problem table has denormalized copy of category string
+ if ($table eq 'problem' && $col eq 'category') {
+ my $body_id = $self->bodies_str_ids->[0];
+ return $fallback unless $body_id && $body_id =~ /^[0-9]+$/;
+ my $contact = $schema->resultset("Contact")->find( {
+ body_id => $body_id,
+ category => $fallback,
+ } );
+ return $fallback unless $contact; # Shouldn't happen, but some tests
+ $table = 'contact';
+ $id = $contact->id;
+ }
+
if (ref $schema) {
my $translation = $schema->resultset('Translation')->find({
lang => $schema->lang,
diff --git a/t/app/model/problem.t b/t/app/model/problem.t
index 76b7c476a..718b980b0 100644
--- a/t/app/model/problem.t
+++ b/t/app/model/problem.t
@@ -117,15 +117,6 @@ for my $test (
}
},
{
- desc => 'bad category',
- changed => {
- category => '-- Pick a property type --',
- },
- errors => {
- category => 'Please choose a property type',
- }
- },
- {
desc => 'correct category',
changed => {
category => 'Horse!',
diff --git a/t/roles/translatable.t b/t/roles/translatable.t
index a33b2d9d0..bbe05ce9f 100644
--- a/t/roles/translatable.t
+++ b/t/roles/translatable.t
@@ -2,6 +2,11 @@ use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
my $body = FixMyStreet::DB->resultset("Body")->create({ name => 'Dunkirk' });
+my $contact = $mech->create_contact_ok(
+ body => $body,
+ email => 'potholes@dunkirk',
+ category => 'Potholes'
+);
FixMyStreet::DB->resultset("Translation")->create({
lang => "fr",
@@ -11,12 +16,46 @@ FixMyStreet::DB->resultset("Translation")->create({
msgstr => "Dunkerque",
});
+FixMyStreet::DB->resultset("Translation")->create({
+ lang => "de",
+ tbl => "contact",
+ object_id => $contact->id,
+ col => "category",
+ msgstr => "Schlaglöcher",
+});
+
+FixMyStreet::DB->resultset("Translation")->create({
+ lang => "nb",
+ tbl => "contact",
+ object_id => $contact->id,
+ col => "category",
+ msgstr => "Hull i veien",
+});
+
+my ($problem) = $mech->create_problems_for_body(1, $body->id, "Title", {
+ whensent => \'current_timestamp',
+ category => 'Potholes',
+});
+
is $body->name, "Dunkirk";
+is $contact->category_display, "Potholes";
+is $problem->category_display, "Potholes";
FixMyStreet::DB->schema->lang("fr");
is $body->name, "Dunkerque";
+is $contact->category_display, "Potholes";
+is $problem->category_display, "Potholes";
FixMyStreet::DB->schema->lang("de");
is $body->name, "Dunkirk";
+is $contact->category_display, "Schlaglöcher";
+is $problem->category_display, "Schlaglöcher";
+
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fiksgatami' ],
+}, sub {
+ $mech->get_ok($problem->url);
+ $mech->content_contains('Hull i veien');
+};
done_testing;
diff --git a/templates/web/base/admin/body.html b/templates/web/base/admin/body.html
index 82032c0c3..47dce4a9c 100644
--- a/templates/web/base/admin/body.html
+++ b/templates/web/base/admin/body.html
@@ -79,7 +79,7 @@
</tr>
[% WHILE ( cat = contacts.next ) %]
<tr [% IF cat.state == 'deleted' %]class="is-deleted"[% END %]>
- <td class="contact-category"><a href="[% c.uri_for( 'body', body_id, cat.category ) %]">[% cat.category | html %]</a>
+ <td class="contact-category"><a href="[% c.uri_for( 'body', body_id, cat.category ) %]">[% cat.category_display | html %]</a>
<br>[% cat.email | html %]</td>
<td>
[% cat.state %]
diff --git a/templates/web/base/admin/category-checkboxes.html b/templates/web/base/admin/category-checkboxes.html
index 63acd4112..9d5ab17ea 100644
--- a/templates/web/base/admin/category-checkboxes.html
+++ b/templates/web/base/admin/category-checkboxes.html
@@ -11,7 +11,7 @@
<li>
<label>
<input type="checkbox" name="contacts[[% contact.id %]]" [% 'checked' IF contact.active %]/>
- [% contact.category %]
+ [% contact.category_display %]
</label>
</li>
[% END %]
diff --git a/templates/web/base/admin/category-multiselect.html b/templates/web/base/admin/category-multiselect.html
index 98416204f..4e4eceeed 100644
--- a/templates/web/base/admin/category-multiselect.html
+++ b/templates/web/base/admin/category-multiselect.html
@@ -4,7 +4,7 @@
<p>
<select class="form-control js-multiple" name="categories" id="categories" multiple data-all="[% loc('All categories') %]">
[% FOR contact IN contacts %]
- <option value="[% contact.id %]" [% 'selected' IF contact.active %]>[% contact.category | html %]</option>
+ <option value="[% contact.id %]" [% 'selected' IF contact.active %]>[% contact.category_display | html %]</option>
[% END %]
</select>
</p>
diff --git a/templates/web/base/admin/contact-form.html b/templates/web/base/admin/contact-form.html
index 0694459cb..c074605ef 100644
--- a/templates/web/base/admin/contact-form.html
+++ b/templates/web/base/admin/contact-form.html
@@ -2,7 +2,7 @@
[% IF contact.in_storage %]
<p>
- <h1>[% contact.category | html %]</h2>
+ <h1>[% contact.category_display | html %]</h2>
<input type="hidden" name="category" value="[% contact.category | html %]" >
</p>
[% ELSE %]
diff --git a/templates/web/base/admin/council_contacts.txt b/templates/web/base/admin/council_contacts.txt
index ffab83ab6..f11615789 100644
--- a/templates/web/base/admin/council_contacts.txt
+++ b/templates/web/base/admin/council_contacts.txt
@@ -1,4 +1,4 @@
[% WHILE ( contact = contacts.next ) -%]
[%- NEXT IF contact.state != 'confirmed' %]
-[% contact.category %] [% contact.email %]
+[% contact.category_display %] [% contact.email %]
[%- END %]
diff --git a/templates/web/base/admin/defecttypes/list.html b/templates/web/base/admin/defecttypes/list.html
index 783bd085c..ffff89eff 100644
--- a/templates/web/base/admin/defecttypes/list.html
+++ b/templates/web/base/admin/defecttypes/list.html
@@ -20,7 +20,7 @@
<em>[% ('All categories') %]</em>
[% ELSE %]
[% FOR contact IN d.contacts %]
- [% contact.category %][% ',' UNLESS loop.last %]
+ [% contact.category_display %][% ',' UNLESS loop.last %]
[% END %]
[% END %]
</td>
diff --git a/templates/web/base/admin/problem_row.html b/templates/web/base/admin/problem_row.html
index e7e18dee9..def6ce60f 100644
--- a/templates/web/base/admin/problem_row.html
+++ b/templates/web/base/admin/problem_row.html
@@ -20,7 +20,7 @@
<br>[% loc('Anonymous') %]: [% IF problem.anonymous %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]
</td>
<td>
- [% PROCESS value_or_nbsp value=problem.category %]
+ [% PROCESS value_or_nbsp value=problem.category_display %]
<br>[%- IF edit_body_contacts -%]
[% FOR body IN problem.bodies.values %]
<a href="[% c.uri_for('body', body.id ) %]">[% PROCESS value_or_nbsp value=body.name %]</a>
diff --git a/templates/web/base/admin/report-category.html b/templates/web/base/admin/report-category.html
index 1e39236d7..a2290089b 100644
--- a/templates/web/base/admin/report-category.html
+++ b/templates/web/base/admin/report-category.html
@@ -1,13 +1,13 @@
<select class="form-control" name="category" id="category">
[% IF NOT problem.category OR NOT categories_hash.${problem.category} %]
<optgroup label="[% loc('Existing category') %]">
- <option selected value="[% problem.category | html %]">[% (problem.category OR '-') | html %]</option>
+ <option selected value="[% problem.category | html %]">[% (problem.category_display OR '-') | html %]</option>
</optgroup>
[% END %]
- [% IF categories.size %]
+ [% IF category_options_copy.size %]
<optgroup label="[% loc('Available categories') %]">
- [% FOREACH cat IN categories %]
- <option[% ' selected' IF problem.category == cat %]>[% cat | html %]</option>
+ [% FOREACH cat IN category_options_copy %]
+ <option value="[% cat.name | html %]"[% ' selected' IF problem.category == cat.name %]>[% cat.value | html %]</option>
[% END %]
</optgroup>
[% END %]
diff --git a/templates/web/base/admin/responsepriorities/list.html b/templates/web/base/admin/responsepriorities/list.html
index 4c05ca14d..80d4e2cee 100644
--- a/templates/web/base/admin/responsepriorities/list.html
+++ b/templates/web/base/admin/responsepriorities/list.html
@@ -19,7 +19,7 @@
<em>[% loc('All categories') %]</em>
[% ELSE %]
[% FOR contact IN p.contacts %]
- [% contact.category %][% ',' UNLESS loop.last %]
+ [% contact.category_display %][% ',' UNLESS loop.last %]
[% END %]
[% END %]
</td>
diff --git a/templates/web/base/dashboard/index.html b/templates/web/base/dashboard/index.html
index 2a9a2ef42..6033ef36b 100644
--- a/templates/web/base/dashboard/index.html
+++ b/templates/web/base/dashboard/index.html
@@ -29,7 +29,7 @@
<label for="category">[% loc('Category:') %]</label>
<select class="form-control" name="category"><option value=''>[% loc('All') %]</option>
[% FOR cat_op IN category_options %]
- <option value='[% cat_op | html %]'[% ' selected' IF category == cat_op %]>[% cat_op | html %]</option>
+ <option value='[% cat_op.name | html %]'[% ' selected' IF category == cat_op.name %]>[% cat_op.value | html %]</option>
[% END %]
</select>
</p>
diff --git a/templates/web/base/report/_inspect.html b/templates/web/base/report/_inspect.html
index bf57cb858..922cc480b 100644
--- a/templates/web/base/report/_inspect.html
+++ b/templates/web/base/report/_inspect.html
@@ -50,18 +50,21 @@
[% INCLUDE 'admin/report-category.html' %]
</p>
- [% FOREACH category IN categories %]
- [% cat_prefix = category | lower | replace('[^a-z]', '') %]
- [% cat_prefix = "category_" _ cat_prefix _ "_" %]
- [% IF category == problem.category %]
- <p data-category="[% category | html %]" data-priorities='[% priorities_by_category.$category %]' data-defect-types='[% category_defect_types.$category %]' data-templates='[% templates_by_category.$category %]'>
- [% INCLUDE 'report/new/category_extras_fields.html' %]
- </p>
- [% ELSE %]
- <p data-category="[% category | html %]" class="hidden" data-priorities='[% priorities_by_category.$category %]' data-defect-types='[% category_defect_types.$category %]' data-templates='[% templates_by_category.$category %]'>
- [% INCLUDE 'report/new/category_extras_fields.html' report_meta='' %]
+ [% FOREACH category IN category_options_copy %]
+ [% cat_name = category.name;
+ cat_prefix = cat_name | lower | replace('[^a-z]', '');
+ cat_prefix = "category_" _ cat_prefix _ "_" %]
+ <p data-category="[% cat_name | html %]"
+ [%~ IF cat_name != problem.category %] class="hidden"[% END %]
+ data-priorities='[% priorities_by_category.$cat_name %]'
+ data-defect-types='[% category_defect_types.$cat_name %]'
+ ata-templates='[% templates_by_category.$cat_name %]'>
+ [% IF cat_name == problem.category %]
+ [% INCLUDE 'report/new/category_extras_fields.html' %]
+ [% ELSE %]
+ [% INCLUDE 'report/new/category_extras_fields.html' report_meta='' %]
+ [% END %]
</p>
- [% END %]
[% END %]
[% IF permissions.report_inspect %]
diff --git a/templates/web/base/report/_item.html b/templates/web/base/report/_item.html
index 7a3530b1f..a892086ca 100644
--- a/templates/web/base/report/_item.html
+++ b/templates/web/base/report/_item.html
@@ -90,7 +90,7 @@
</div>
<div>
<h4>[% loc('Category') %]</h4>
- <p>[% (problem.category OR '-') | html %]</p>
+ <p>[% (problem.category_display OR '-') | html %]</p>
</div>
<div>
<h4>[% loc('State') %]</h4>
diff --git a/templates/web/base/report/new/category.html b/templates/web/base/report/new/category.html
index 4c66f00fb..b8ebf1653 100644
--- a/templates/web/base/report/new/category.html
+++ b/templates/web/base/report/new/category.html
@@ -7,9 +7,9 @@
</label>[% =%]
<select class="form-control" name='category' id='form_category' data-role='[% c.user.has_body_permission_to('planned_reports') ? 'inspector' : 'user' %]' data-body='[% c.user.from_body.name %]'>
[%~ FOREACH cat_op IN category_options ~%]
- [% cat_op_lc = cat_op | lower =%]
- <option value='[% cat_op | html %]'[% ' selected' IF report.category == cat_op || category_lc == cat_op_lc || (category_options.size == 2 AND loop.last) ~%]
- >[% IF loop.first %][% cat_op %][% ELSE %][% cat_op | html %][% END %]</option>
+ [% cat_op_lc = cat_op.name | lower =%]
+ <option value='[% cat_op.name | html %]'[% ' selected' IF report.category == cat_op.name || category_lc == cat_op_lc || (category_options.size == 2 AND loop.last) ~%]
+ >[% IF loop.first %][% cat_op.value %][% ELSE %][% cat_op.value | html %][% END %]</option>
[%~ END =%]
</select>
[%~ END ~%]
diff --git a/templates/web/base/reports/_list-filters.html b/templates/web/base/reports/_list-filters.html
index efb917c16..73afe64f4 100644
--- a/templates/web/base/reports/_list-filters.html
+++ b/templates/web/base/reports/_list-filters.html
@@ -19,8 +19,8 @@
[% IF filter_categories.size %]
<select class="form-control js-multiple" name="filter_category" id="filter_categories" multiple data-all="[% loc('Everything') %]">
[% FOR cat IN filter_categories %]
- <option value="[% cat | html %]"[% ' selected' IF filter_category.$cat %]>
- [% cat | html %]
+ <option value="[% cat.name | html %]"[% ' selected' IF filter_category.${cat.name} %]>
+ [% cat.value | html %]
</option>
[% END %]
</select>
diff --git a/templates/web/zurich/admin/body.html b/templates/web/zurich/admin/body.html
index cf860990d..468f7adff 100644
--- a/templates/web/zurich/admin/body.html
+++ b/templates/web/zurich/admin/body.html
@@ -19,7 +19,7 @@
</tr>
[% WHILE ( cat = contacts.next ) %]
<tr[% IF cat.deleted %] class="is-deleted"[% END %]>
- <td><a href="[% c.uri_for( 'body', body_id, cat.category ) %]">[% cat.category %]</a></td>
+ <td><a href="[% c.uri_for( 'body', body_id, cat.category ) %]">[% cat.category_display %]</a></td>
<td>[% cat.email | html %]</td>
<td>[% cat.editor %]</td>
<td>[% cat.note | html %]</td>
diff --git a/templates/web/zurich/admin/contact-form.html b/templates/web/zurich/admin/contact-form.html
index aaf7a1797..236b169d0 100644
--- a/templates/web/zurich/admin/contact-form.html
+++ b/templates/web/zurich/admin/contact-form.html
@@ -1,5 +1,5 @@
<form method="post" action="[% c.uri_for('body', body_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8" id="category_edit">
- <p><strong>[% loc('Category:') %] </strong>[% contact.category | html %]
+ <p><strong>[% loc('Category:') %] </strong>[% contact.category_display | html %]
<input type="hidden" name="category" value="[% contact.category | html %]" >
<input type="hidden" name="token" value="[% csrf_token %]" >
diff --git a/templates/web/zurich/admin/problem_row.html b/templates/web/zurich/admin/problem_row.html
index acbf17017..a83e22b27 100644
--- a/templates/web/zurich/admin/problem_row.html
+++ b/templates/web/zurich/admin/problem_row.html
@@ -15,7 +15,7 @@
[% END %]
</td>
<td>[% PROCESS value_or_nbsp value=problem.title %]</td>
- <td>[% PROCESS value_or_nbsp value=problem.category %]</td>
+ <td>[% PROCESS value_or_nbsp value=problem.category_display %]</td>
<td>[% PROCESS format_date this_date=problem.created %]</td>
<td>[% PROCESS format_date this_date=problem.lastupdate %]</td>
<td> [% states.${problem.state} %][% IF problem.state == 'planned';
diff --git a/templates/web/zurich/admin/report_edit-sdm.html b/templates/web/zurich/admin/report_edit-sdm.html
index 3df9459f9..07f0332d5 100644
--- a/templates/web/zurich/admin/report_edit-sdm.html
+++ b/templates/web/zurich/admin/report_edit-sdm.html
@@ -70,7 +70,7 @@
</dd>
<dt>[% loc('Category:') %] <!-- Kategorie --></dt>
- <dd>[% problem.category | html %]</dd>
+ <dd>[% problem.category_display | html %]</dd>
<dt class="print-only">[% loc('State:') %] <!-- Status --></dt>
<dd class="print-only">[% states.${problem.state} %]</dd>
diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html
index f87dcb5cf..35075a9f0 100644
--- a/templates/web/zurich/admin/report_edit.html
+++ b/templates/web/zurich/admin/report_edit.html
@@ -98,7 +98,7 @@
</dd>
<dt>[% loc('Category:') %] <!-- Kategorie --></dt>
- <dd>[% problem.category | html %]</dd>
+ <dd>[% problem.category_display | html %]</dd>
<dt class="print-only">[% loc('State:') %] <!-- Status --></dt>
<dd class="print-only">[% states_trans.${problem.state} %]</dd>
@@ -169,8 +169,8 @@
<label for="category">[% loc('Assign to different category:') %]</label>
<select class="form-control" name="category" id="category">
<option value="">--</option>
- [% FOREACH cat IN categories %]
- <option value="[% cat %]">[% cat %]</option>
+ [% FOREACH cat IN category_options %]
+ <option value="[% cat.name %]">[% cat.value %]</option>
[% END %]
</select>
</div>
diff --git a/templates/web/zurich/report/_main.html b/templates/web/zurich/report/_main.html
index c1e4d15e6..b868c03e2 100644
--- a/templates/web/zurich/report/_main.html
+++ b/templates/web/zurich/report/_main.html
@@ -1,5 +1,5 @@
<div class="problem-header clearfix">
- <h1>[% tprintf( loc('Reported in the %s category'), problem.category ) %]</h1>
+ <h1>[% tprintf( loc('Reported in the %s category'), problem.category_display ) %]</h1>
<p class="sub">
[% prettify_dt( problem.created, 'zurich' ) %]
[%- IF !problem.used_map %]<br>[% loc('there is no pin shown as the user did not use the map') %][% END %]