diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/FixMyStreet/Cobrand/Default.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/Cobrand/UKCouncils.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 88 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 16 |
4 files changed, 101 insertions, 5 deletions
diff --git a/perllib/FixMyStreet/Cobrand/Default.pm b/perllib/FixMyStreet/Cobrand/Default.pm index 61982c47a..aad91429a 100644 --- a/perllib/FixMyStreet/Cobrand/Default.pm +++ b/perllib/FixMyStreet/Cobrand/Default.pm @@ -713,6 +713,7 @@ sub available_permissions { planned_reports => _("Manage shortlist"), contribute_as_another_user => _("Create reports/updates on a user's behalf"), contribute_as_body => _("Create reports/updates as the council"), + view_body_contribute_details => _("See user detail for reports created as the council"), # NB this permission is special in that it can be assigned to users # without their from_body being set. It's included here for diff --git a/perllib/FixMyStreet/Cobrand/UKCouncils.pm b/perllib/FixMyStreet/Cobrand/UKCouncils.pm index 64ca7fc62..4e900e653 100644 --- a/perllib/FixMyStreet/Cobrand/UKCouncils.pm +++ b/perllib/FixMyStreet/Cobrand/UKCouncils.pm @@ -200,6 +200,7 @@ sub available_permissions { my $perms = $self->next::method(); $perms->{Problems}->{contribute_as_body} = "Create reports/updates as " . $self->council_name; + $perms->{Problems}->{view_body_contribute_details} = "See user detail for reports created as " . $self->council_name; $perms->{Users}->{user_assign_areas} = "Assign users to areas in " . $self->council_name; return $perms; diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index f5601639a..fb41bc7f0 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -6,6 +6,7 @@ package FixMyStreet::DB::Result::Comment; use strict; use warnings; +use FixMyStreet::Template; use base 'DBIx::Class::Core'; __PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn"); @@ -199,7 +200,7 @@ __PACKAGE__->has_many( "admin_log_entries", "FixMyStreet::DB::Result::AdminLog", { "foreign.object_id" => "self.id" }, - { + { cascade_copy => 0, cascade_delete => 0, where => { 'object_type' => 'update' }, } @@ -223,4 +224,89 @@ __PACKAGE__->might_have( { cascade_copy => 0, cascade_delete => 1 }, ); +=head2 meta_line + +Returns a string to be used on a report update, describing some of the metadata +about an update + +=cut + +sub meta_line { + my ( $self, $c ) = @_; + + my $meta = ''; + + $c->stash->{last_state} ||= ''; + + if ($self->anonymous or !$self->name) { + $meta = sprintf( _( 'Posted anonymously at %s' ), Utils::prettify_dt( $self->confirmed ) ) + } elsif ($self->user->from_body) { + my $user_name = FixMyStreet::Template::html_filter($self->user->name); + my $body = $self->user->body; + if ($body eq 'Bromley Council') { + $body = "$body <img src='/cobrands/bromley/favicon.png' alt=''>"; + } + if ($c->user_exists and $c->user->has_permission_to('view_body_contribute_details', $self->problem->bodies_str_ids)) { + $meta = sprintf( _( 'Posted by <strong>%s</strong> (%s) at %s' ), $body, $user_name, Utils::prettify_dt( $self->confirmed ) ); + } else { + $meta = sprintf( _( 'Posted by <strong>%s</strong> at %s' ), $body, Utils::prettify_dt( $self->confirmed ) ); + } + } else { + $meta = sprintf( _( 'Posted by %s at %s' ), FixMyStreet::Template::html_filter($self->name), Utils::prettify_dt( $self->confirmed ) ) + } + + my $update_state = ''; + + if ($self->mark_fixed) { + $update_state = _( 'marked as fixed' ); + } elsif ($self->mark_open) { + $update_state = _( 'reopened' ); + } elsif ($self->problem_state) { + my $state = $self->problem_state_display; + + if ($state eq 'confirmed') { + if ($c->stash->{last_state}) { + $update_state = _( 'reopened' ) + } + } elsif ($state eq 'investigating') { + $update_state = _( 'marked as investigating' ) + } elsif ($state eq 'planned') { + $update_state = _( 'marked as planned' ) + } elsif ($state eq 'in progress') { + $update_state = _( 'marked as in progress' ) + } elsif ($state eq 'action scheduled') { + $update_state = _( 'marked as action scheduled' ) + } elsif ($state eq 'closed') { + $update_state = _( 'marked as closed' ) + } elsif ($state eq 'fixed') { + $update_state = _( 'marked as fixed' ) + } elsif ($state eq 'unable to fix') { + $update_state = _( 'marked as unable to fix' ) + } elsif ($state eq 'not responsible') { + $update_state = _( "marked as not the council's responsibility" ) + } elsif ($state eq 'duplicate') { + $update_state = _( 'closed as a duplicate report' ) + } elsif ($state eq 'internal referral') { + $update_state = _( 'marked as an internal referral' ) + } + + if ($c->cobrand->moniker eq 'bromley' || $self->problem->bodies_str eq '2482') { + if ($state eq 'unable to fix') { + $update_state = 'marked as no further action'; + } elsif ($state eq 'not responsible') { + $update_state = 'marked as third party responsibility' + } + } + + } + + if ($update_state ne $c->stash->{last_state} and $update_state) { + $meta .= ", $update_state"; + } + + $c->stash->{last_state} = $update_state; + + return $meta; +}; + 1; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 203e72fae..92c5c160a 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -606,20 +606,28 @@ sub meta_line { $meta = sprintf( _('Reported anonymously at %s'), $date_time ); } } else { + my $problem_name = $problem->name; + + if ($c->user_exists and + $c->user->has_permission_to('view_body_contribute_details', $problem->bodies_str_ids) and + $problem->name ne $problem->user->name) { + $problem_name = sprintf( _('%s (%s)'), $problem->name, $problem->user->name ); + } + if ( $problem->service and $category && $category ne _('Other') ) { $meta = sprintf( _('Reported via %s in the %s category by %s at %s'), $problem->service, $category, - $problem->name, $date_time + $problem_name, $date_time ); } elsif ( $problem->service ) { $meta = sprintf( _('Reported via %s by %s at %s'), - $problem->service, $problem->name, $date_time ); + $problem->service, $problem_name, $date_time ); } elsif ( $category and $category ne _('Other') ) { $meta = sprintf( _('Reported in the %s category by %s at %s'), - $category, $problem->name, $date_time ); + $category, $problem_name, $date_time ); } else { - $meta = sprintf( _('Reported by %s at %s'), $problem->name, $date_time ); + $meta = sprintf( _('Reported by %s at %s'), $problem_name, $date_time ); } } |