aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r--perllib/FixMyStreet/DB/Result/AdminLog.pm6
-rw-r--r--perllib/FixMyStreet/DB/Result/Comment.pm1
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Contact.pm27
3 files changed, 33 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/DB/Result/AdminLog.pm b/perllib/FixMyStreet/DB/Result/AdminLog.pm
index 5564d829a..4c89138c9 100644
--- a/perllib/FixMyStreet/DB/Result/AdminLog.pm
+++ b/perllib/FixMyStreet/DB/Result/AdminLog.pm
@@ -91,6 +91,10 @@ sub link {
my $category = $self->object;
return "/admin/body/" . $category->body_id . '/' . $category->category;
}
+ if ($type eq 'manifesttheme') {
+ my $theme = $self->object;
+ return "/admin/manifesttheme/" . $theme->cobrand;
+ }
return '';
}
@@ -114,6 +118,7 @@ sub object_summary {
role => 'name',
template => 'title',
category => 'category',
+ manifesttheme => 'cobrand',
};
my $thing = $type_to_thing->{$self->object_type} || 'id';
@@ -130,6 +135,7 @@ sub object {
template => 'ResponseTemplate',
category => 'Contact',
update => 'Comment',
+ manifesttheme => 'ManifestTheme',
};
$type = $type_to_object->{$type} || ucfirst $type;
my $object = $self->result_source->schema->resultset($type)->find($id);
diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm
index bac183271..b217bf96c 100644
--- a/perllib/FixMyStreet/DB/Result/Comment.pm
+++ b/perllib/FixMyStreet/DB/Result/Comment.pm
@@ -292,6 +292,7 @@ sub is_latest {
{ problem_id => $self->problem_id, state => 'confirmed' },
{ order_by => [ { -desc => 'confirmed' }, { -desc => 'id' } ] }
)->first;
+ return unless $latest_update;
return $latest_update->id == $self->id;
}
diff --git a/perllib/FixMyStreet/DB/ResultSet/Contact.pm b/perllib/FixMyStreet/DB/ResultSet/Contact.pm
index 1643f9931..eb502c190 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Contact.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Contact.pm
@@ -17,7 +17,7 @@ Filter down to not deleted contacts (so active or inactive).
sub not_deleted {
my $rs = shift;
- return $rs->search( { $rs->me('state') => { '!=' => 'deleted' } } );
+ return $rs->search( { $rs->me('state') => { -not_in => [ 'deleted', 'staff' ] } } );
}
sub active {
@@ -25,6 +25,31 @@ sub active {
$rs->search( { $rs->me('state') => [ 'unconfirmed', 'confirmed' ] } );
}
+sub for_new_reports {
+ my ($rs, $c, $bodies) = @_;
+ my $params = {
+ $rs->me('body_id') => [ keys %$bodies ],
+ };
+
+ if ($c->user_exists && $c->user->from_body) {
+ # Everything normal OR staff state in the user body
+ $params->{'-or'} = [
+ $rs->me('state') => [ 'unconfirmed', 'confirmed' ],
+ {
+ $rs->me('body_id') => $c->user->from_body->id,
+ $rs->me('state') => 'staff',
+ },
+ ];
+ } elsif ($c->user_exists && $c->user->is_superuser) {
+ # Everything normal OR any staff states
+ $params->{$rs->me('state')} = [ 'unconfirmed', 'confirmed', 'staff' ];
+ } else {
+ $params->{$rs->me('state')} = [ 'unconfirmed', 'confirmed' ];
+ }
+
+ $rs->search($params, { prefetch => 'body' });
+}
+
sub translated {
my $rs = shift;
my $schema = $rs->result_source->schema;