diff options
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 45 | ||||
-rw-r--r-- | templates/web/default/admin/council_contacts.html | 2 | ||||
-rw-r--r-- | templates/web/default/admin/council_edit.html | 62 |
3 files changed, 108 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index 3fef589b4..d2ea69c94 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -278,6 +278,8 @@ sub update_contacts : Private { sub display_contacts : Private { my ( $self, $c ) = @_; + $c->forward('setup_council_details'); + my $area_id = $c->stash->{area_id}; my $contacts = $c->model('DB::Contact')->search( @@ -293,7 +295,16 @@ sub display_contacts : Private { return 1; } + return 1; +} + +sub setup_council_details : Private { + my ( $self, $c ) = @_; + + my $area_id = $c->stash->{area_id}; + my $mapit_data = mySociety::MaPit::call('area', $area_id); + $c->stash->{council_name} = $mapit_data->{name}; my $example_postcode = mySociety::MaPit::call('area/example_postcode', $area_id); @@ -301,6 +312,40 @@ sub display_contacts : Private { if ($example_postcode && ! ref $example_postcode) { $c->stash->{example_pc} = $example_postcode; } + + return 1; +} + +sub council_edit : Path('council_edit') : Args(2) { + my ( $self, $c, $area_id, $category ) = @_; + + $c->stash->{area_id} = $area_id; + + $c->forward( 'get_token' ); + $c->forward('setup_council_details'); + + my $contact = $c->model('DB::Contact')->search( + { + area_id => $area_id, + category => $category + } + )->first; + + $c->stash->{contact} = $contact; + + my $history = $c->model('DB::ContactsHistory')->search( + { + area_id => $area_id, + category => $category + }, + { + order_by => ['contacts_history_id'] + }, + ); + + $c->stash->{history} = $history; + + return 1; } # use Encode; diff --git a/templates/web/default/admin/council_contacts.html b/templates/web/default/admin/council_contacts.html index 780b11c63..42135f480 100644 --- a/templates/web/default/admin/council_contacts.html +++ b/templates/web/default/admin/council_contacts.html @@ -27,7 +27,7 @@ </tr> [% WHILE ( contact = contacts.next ) %] <tr> - <td><a href="[% c.uri_for( 'council_edit', { area_id => area_id, category => contact.category } ) %]">[% contact.category %]</a></td> + <td><a href="[% c.uri_for( 'council_edit', area_id, contact.category ) %]">[% contact.category %]</a></td> <td>[% contact.email %]</td> <td>[% IF contact.confirmed %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> <td>[% IF contact.deleted %][% loc('Yes') %][% ELSE %][% loc('No') %][% END %]</td> diff --git a/templates/web/default/admin/council_edit.html b/templates/web/default/admin/council_edit.html new file mode 100644 index 000000000..c9ce0e602 --- /dev/null +++ b/templates/web/default/admin/council_edit.html @@ -0,0 +1,62 @@ +[% INCLUDE 'admin/header.html' title=tprintf(loc('Council contacts for %s'), council_name) -%] + +[% BLOCK highlightchanged_yesno %] +[%- output = loc('No') %] +[%- IF new.$value %][% output = loc('Yes') %][% END %] +[%- IF old && old.$value != new.$value %]<strong>[% output %]</strong>[% ELSE %][% output %][% END %] +[%- END %] + +[% BLOCK highlightchanged %] +[%- IF old && old.$value != new.$value %]<strong>[% new.$value %]</strong>[% ELSE %][% new.$value %][% END %] +[%- END %] +<p> +<em>[% updated %]</em> +</p> + +<p> +[% IF example_pc %] +<a href="[% c.uri_for( '/around', { pc => example_pc } ) %]">[% tprintf( loc('Example postcode %s'), example_pc ) | html %]</a> +[% END %] +</p> + +<form method="post" action="[% c.uri_for('council_contacts', area_id ) %]" enctype="application/x-www-form-urlencoded" accept-charset="utf-8"> + <strong>Category: </strong>test + <input type="hidden" name="category" value="[% contact.category | html %]" > + <input type="hidden" name="token" value="[% token %]" >1 + <strong> Email: </strong> + <input type="text" name="email" value="[% contact.email | html %]" size="30"> + <input type="checkbox" name="confirmed" value="1" id="confirmed"[% ' checked' IF contact.confirmed %]> <label for="confirmed">Confirmed</label> + <input type="checkbox" name="deleted" value="1" id="deleted"[% ' checked' IF contact.deleted %]> <label for="deleted">Deleted</label><br> + + <strong>Note: </strong><textarea name="note" rows="3" cols="40">[% contact.note | html %]</textarea> <br> + + <input type="hidden" name="area_id" value="[% area_id %]"> + <input type="hidden" name="posted" value="new"> + <input type="submit" name="Save changes" value="Save changes"> +</form> + +<h2>History</h2> +<table border="1"> + <tr> + <th>When edited</th> + <th>Email</th> + <th>Confirmed</th> + <th>Deleted</th> + <th>Editor</th> + <th>Note</th> + </tr> + [%- prev = '' %] + [%- WHILE ( contact = history.next ) %] + <tr> + <td>[% contact.whenedited.ymd _ ' ' _ contact.whenedited.hms %]</td> + <td>[% PROCESS highlightchanged old=prev new=contact value='email' %]</td> + <td>[% PROCESS highlightchanged_yesno old=prev new=contact value='confirmed' %]</td> + <td>[% PROCESS highlightchanged_yesno old=prev new=contact value='deleted' %]</td> + <td>[% contact.editor %]</td> + <td>[% contact.note | html %]</td> + </tr> + [%- prev = contact %] + [%- END %] +</table> + +[% INCLUDE 'admin/footer.html' %] |