Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename emergency message to site message. #4450

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
- Bugfixes:
- Stop map panning breaking after long press. #4423
- Fix RSS feed subscription from alert page button.
- Admin improvements:
- Rename emergency message to site message.
- Development improvements:
- Extra data columns now stored as JSON, not RABX. #3216
- Cobrands can provide custom distances for duplicate lookup. #4456
Expand Down
16 changes: 8 additions & 8 deletions docs/_includes/admin-tasks-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -969,13 +969,13 @@ particular date range:
</div>


<div class="admin-task" markdown="1" id="emergency-message">
<div class="admin-task" markdown="1" id="site-message">

### Displaying an emergency message
### Displaying a site message

<span class="admin-task__permissions">Permissions required: User must be marked as staff and ‘Add/edit emergency message’ must be ticked.</span>
<span class="admin-task__permissions">Permissions required: User must be marked as staff and ‘Add/edit site message’ must be ticked.</span>

This feature allows you to set emergency messages which will be displayed on
This feature allows you to set site messages which will be displayed on
the homepage or reporting pages; you can have different messages for in/out of hours.

Certain HTML tags can be used for formatting purposes. These are limited to the same set as described
Expand All @@ -986,16 +986,16 @@ you want multiple paragraphs they should be separated with blank lines as in the
To clear the message simply delete any contents in the box.

<img alt="The HTML text entered in to the box will be rendered on the homepage."
src="/assets/img/pro-user-guide/emergency-message-editing.png" class="admin-screenshot" />
src="/assets/img/pro-user-guide/site-message-editing.png" class="admin-screenshot" />

<img alt="An emergency message can be shown to users on the FixMyStreet homepage."
src="/assets/img/pro-user-guide/emergency-message-example.png" class="admin-screenshot" />
<img alt="A site message can be shown to users on the FixMyStreet homepage."
src="/assets/img/pro-user-guide/site-message-example.png" class="admin-screenshot" />

You can set the time periods that will count as out of hours on the same page. For example,
if your out of hours were 6pm to 8am Monday to Friday, all day weekends and Bank Holidays,
plus Christmas Eve, you would set it up as the following screenshot:

<img alt="Saturday, Sunday, Bank Holidays, and a special Christmas Eve, 00:00-24:00; Monday to Friday 00:00-08:00 and 18:00-24:00."
src="/assets/img/pro-user-guide/emergency-message-time-periods.png" class="admin-screenshot">
src="/assets/img/pro-user-guide/site-message-time-periods.png" class="admin-screenshot">

</div>
14 changes: 7 additions & 7 deletions docs/_includes/ww-admin-tasks-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,24 +211,24 @@ Also accessible from the admin stats page is our heatmap. This can provide an ov

</div>

<div class="admin-task" markdown="1" id="emergency-message">
<div class="admin-task" markdown="1" id="site-message">

### Displaying an emergency message
### Displaying a site message

<span class="admin-task__permissions">Permissions required: User must be marked as staff and ‘Add/edit emergency message’ must be ticked.</span>
<span class="admin-task__permissions">Permissions required: User must be marked as staff and ‘Add/edit site message’ must be ticked.</span>

This feature allows you to set emergency messages which will be displayed on
This feature allows you to set site messages which will be displayed on
the homepage or reporting pages; you can have different messages for in/out of hours.

Certain HTML tags can be used for formatting purposes. These are limited to the same set as described in ["HTML content in notices"](#html-content-in-notices). You should not use block-level HTML elements (e.g. `div`,`p`, etc) in the input field, as linebreaks are automatically converted to HTML tags. If you want multiple paragraphs they should be separated with blank lines as in the below example.

To clear the message simply delete any contents in the box.

<img alt="The HTML text entered in to the box will be rendered on the homepage."
src="/assets/img/ww-user-guide/WasteWorks-emergency-message.png" class="admin-screenshot" />
src="/assets/img/ww-user-guide/WasteWorks-site-message.png" class="admin-screenshot" />

<img alt="An emergency message can be shown to users on the WasteWorkshomepage."
src="/assets/img/ww-user-guide/WasteWorks-emergency-message-frontend.png" class="admin-screenshot" />
<img alt="A site message can be shown to users on the WasteWorkshomepage."
src="/assets/img/ww-user-guide/WasteWorks-site-message-frontend.png" class="admin-screenshot" />

You can set the time periods that will count as out of hours on the same page. For example,
if your out of hours were 6pm to 8am Monday to Friday, all day weekends and Bank Holidays,
Expand Down
2 changes: 1 addition & 1 deletion docs/_layouts/pro.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<li><a href="/pro-manual/admin-tasks/#creating-editing-priorities">Creating and editing priorities</a></li>
<li><a href="/pro-manual/admin-tasks/#creating-editing-response-templates">Creating and editing response templates</a></li>
<li><a href="/pro-manual/admin-tasks/#view-statistics">Viewing statistics/heatmap</a></li>
<li><a href="/pro-manual/admin-tasks/#emergency-message">Displaying an emergency message</a></li>
<li><a href="/pro-manual/admin-tasks/#site-message">Displaying a site message</a></li>
</ul>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/_layouts/wasteworks.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<li><a href="/ww-manual/admin-tasks/#cancelling-subscriptions">Cancelling subscriptions on behalf of a resident</a>
<li><a href="/ww-manual/admin-tasks/#creating-and-editing-response-templates">Creating and editing response templates</a>
<li><a href="/ww-manual/admin-tasks/#viewing-statistics">Viewing statistics</a>
<li><a href="/ww-manual/admin-tasks/#emergency-message">Displaying an emergency message</a>
<li><a href="/ww-manual/admin-tasks/#site-message">Displaying a site message</a>
</ul>
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/running/admin_manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ them by clicking on the link at the top of any admin page:
* **Configuration** <br/> This page shows you a summary of the live
configuration information for your site.

* **Emergency message** <br/> This page allows you to set an emergency
* **Site message** <br/> This page allows you to set a site
message which will be displayed on the homepage.

<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package FixMyStreet::App::Controller::Admin::EmergencyMessage;
package FixMyStreet::App::Controller::Admin::SiteMessage;
use Moose;
use namespace::autoclean;

Expand All @@ -8,9 +8,9 @@ sub index :Path :Args(0) {
my ( $self, $c ) = @_;

# Normal users can only edit message for the current body.
$c->detach('edit_emergency_message', [$c->user->from_body]) unless $c->user->is_superuser;
$c->detach('edit_site_message', [$c->user->from_body]) unless $c->user->is_superuser;

# Superusers can see a list of all bodies with emergency messages.
# Superusers can see a list of all bodies with site messages.
my @bodies = $c->model('DB::Body')->active->search(undef, { order_by => [ 'name', 'id' ] });
$c->stash->{bodies} = \@bodies;
}
Expand All @@ -24,18 +24,18 @@ sub edit :Local :Args(1) {
my $body = $c->model('DB::Body')->find($body_id)
|| $c->detach( '/page_error_404_not_found', [] );

$c->detach('edit_emergency_message', [$body]);
$c->detach('edit_site_message', [$body]);
}

sub edit_emergency_message :Private {
sub edit_site_message :Private {
my ( $self, $c, $body ) = @_;

if ( $c->req->method eq 'POST' ) {
$c->forward('/auth/check_csrf_token');

foreach my $type ("", "_waste", "_reporting") {
foreach my $ooh ("", "_ooh") {
my $field = "emergency_message$type$ooh";
my $field = "site_message$type$ooh";
my $message = FixMyStreet::Template::sanitize($c->get_param($field), 1);
$message =~ s/^\s+|\s+$//g;

Expand All @@ -44,6 +44,7 @@ sub edit_emergency_message :Private {
} else {
$body->unset_extra_metadata($field);
}
$body->unset_extra_metadata("emergency_message$type$ooh"); # Move over as they change
}
}

Expand All @@ -59,15 +60,15 @@ sub edit_emergency_message :Private {
}

$c->forward('/auth/get_csrf_token');
foreach my $type ("", "_waste", "_reporting") {
foreach my $ooh ("", "_ooh") {
my $field = "emergency_message$type$ooh";
$c->stash->{$field} = $body->get_extra_metadata($field);
foreach my $type ("", "waste", "reporting") {
foreach my $ooh (0, 1) {
my $key = "site_message" . ($type ? "_$type" : "") . ($ooh ? "_ooh" : "");
$c->stash->{$key} = $body->site_message($type, $ooh);
}
}

$c->stash->{body} = $body;
$c->stash->{template} = 'admin/emergencymessage/edit.html';
$c->stash->{template} = 'admin/sitemessage/edit.html';

# Check cobrand for body
my $cobrand = $body->get_cobrand_handler;
Expand Down
17 changes: 7 additions & 10 deletions perllib/FixMyStreet/Cobrand/Default.pm
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ sub admin_pages {
$pages->{reportextrafields_edit} = [ undef, undef ];
}
if ( $user->has_body_permission_to('emergency_message_edit') ) {
$pages->{emergencymessage} = [ _('Emergency message'), 12 ];
$pages->{sitemessage} = [ _('Site message'), 12 ];
}
if ( $user->has_body_permission_to('wasteworks_config') ) {
$pages->{waste} = [ _('WasteWorks config'), 201];
Expand Down Expand Up @@ -820,7 +820,7 @@ sub available_permissions {
category_edit => _("Add/edit problem categories"),
template_edit => _("Add/edit response templates"),
responsepriority_edit => _("Add/edit response priorities"),
emergency_message_edit => _("Add/edit emergency message"),
emergency_message_edit => _("Add/edit site message"),
},
};
}
Expand Down Expand Up @@ -1416,22 +1416,19 @@ The URL of the privacy policy to use on the report and update submissions forms.

sub privacy_policy_url { '/about/privacy' }

=item emergency_message
=item site_message

Emergency message, if one has been set in the admin.
Site message, if one has been set in the admin.

=cut

sub emergency_message {
sub site_message {
my $self = shift;
my $type = shift;
my $body = $self->body;
return unless $body;
my $field = 'emergency_message';
$field .= "_$type" if $type;

my $msg = $body->get_extra_metadata($field);
my $ooh_msg = $body->get_extra_metadata($field . '_ooh');
my $msg = $body->site_message($type);
my $ooh_msg = $body->site_message($type, 1);
if ($ooh_msg) {
my $ooh = $self->ooh_times($body);
$msg = $ooh_msg if $ooh->active;
Expand Down
8 changes: 4 additions & 4 deletions perllib/FixMyStreet/Cobrand/FixMyStreet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ sub about_hook {
}
}

=item emergency_message
=item site_message

We want to show the reporting page emergency message from a UK cobrand if one
We want to show the reporting page site message from a UK cobrand if one
is relevant to the location we're currently at.

=cut

sub emergency_message {
sub site_message {
my $self = shift;
my ($type) = @_;

Expand All @@ -307,7 +307,7 @@ sub emergency_message {

foreach my $body (@bodies) {
my $cobrand = $body->get_cobrand_handler || next;
my $msg = $cobrand->emergency_message($type);
my $msg = $cobrand->site_message($type);
if ($msg) {
$msg = "Message from " . $body->name . ": " . $msg;
return FixMyStreet::Template::SafeString->new($msg);
Expand Down
17 changes: 17 additions & 0 deletions perllib/FixMyStreet/DB/Result/Body.pm
Original file line number Diff line number Diff line change
Expand Up @@ -307,4 +307,21 @@ sub staff_with_permission {
});
}

=head2 site_message

Returns the relevant site message.

=cut

sub site_message {
my ($self, $type, $ooh) = @_;

my $suffix = '';
$suffix .= "_$type" if $type;
$suffix .= "_ooh" if $ooh;

my $msg = $self->get_extra_metadata("site_message$suffix") || $self->get_extra_metadata("emergency_message$suffix");
return $msg;
}

1;
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Roles/CobrandSLWP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ sub available_permissions {
},
_("Bodies") => {
template_edit => _("Add/edit response templates"),
emergency_message_edit => _("Add/edit emergency message"),
emergency_message_edit => _("Add/edit site message"),
},
};
}
Expand Down
Loading