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.pm2
-rw-r--r--perllib/FixMyStreet/DB/Result/Body.pm22
-rw-r--r--perllib/FixMyStreet/DB/Result/Problem.pm68
-rw-r--r--perllib/FixMyStreet/DB/Result/ResponseTemplate.pm49
-rw-r--r--perllib/FixMyStreet/DB/ResultSet/Problem.pm2
5 files changed, 128 insertions, 15 deletions
diff --git a/perllib/FixMyStreet/DB/Result/AdminLog.pm b/perllib/FixMyStreet/DB/Result/AdminLog.pm
index fcf909692..d60915cfc 100644
--- a/perllib/FixMyStreet/DB/Result/AdminLog.pm
+++ b/perllib/FixMyStreet/DB/Result/AdminLog.pm
@@ -37,6 +37,8 @@ __PACKAGE__->add_columns(
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"reason",
{ data_type => "text", default_value => "", is_nullable => 0 },
+ "time_spent",
+ { data_type => "integer", default_value => "0", is_nullable => 0 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to(
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm
index 0c1046cd8..a2e004c6a 100644
--- a/perllib/FixMyStreet/DB/Result/Body.pm
+++ b/perllib/FixMyStreet/DB/Result/Body.pm
@@ -18,12 +18,6 @@ __PACKAGE__->add_columns(
is_nullable => 0,
sequence => "body_id_seq",
},
- "name",
- { data_type => "text", is_nullable => 0 },
- "external_url",
- { data_type => "text", is_nullable => 1 },
- "parent",
- { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"endpoint",
{ data_type => "text", is_nullable => 1 },
"jurisdiction",
@@ -42,8 +36,14 @@ __PACKAGE__->add_columns(
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
"send_extended_statuses",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
+ "name",
+ { data_type => "text", is_nullable => 0 },
+ "parent",
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"deleted",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
+ "external_url",
+ { data_type => "text", is_nullable => 1 },
);
__PACKAGE__->set_primary_key("id");
__PACKAGE__->has_many(
@@ -87,6 +87,12 @@ __PACKAGE__->belongs_to(
},
);
__PACKAGE__->has_many(
+ "response_templates",
+ "FixMyStreet::DB::Result::ResponseTemplate",
+ { "foreign.body_id" => "self.id" },
+ { cascade_copy => 0, cascade_delete => 0 },
+);
+__PACKAGE__->has_many(
"user_body_permissions",
"FixMyStreet::DB::Result::UserBodyPermission",
{ "foreign.body_id" => "self.id" },
@@ -100,8 +106,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07035 @ 2014-07-29 13:54:07
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PhUeFDRLSQVMk7Sts5K6MQ
+# Created by DBIx::Class::Schema::Loader v0.07035 @ 2015-02-19 16:13:43
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d6GuQm8vrNmCc4NWw58srA
sub url {
my ( $self, $c, $args ) = @_;
diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm
index 9706087aa..3b7f8bcfd 100644
--- a/perllib/FixMyStreet/DB/Result/Problem.pm
+++ b/perllib/FixMyStreet/DB/Result/Problem.pm
@@ -323,10 +323,6 @@ sub visible_states_remove {
}
}
-sub visible_states_add_unconfirmed {
- $_[0]->visible_states_add('unconfirmed')
-}
-
=head2
@states = FixMyStreet::DB::Problem::council_states();
@@ -483,11 +479,17 @@ sub url {
=head2 get_photo_params
-Returns a hashref of details of any attached photo for use in templates.
+Returns a hashref of details of the attached photo, if any, for use in templates.
+
+NB: this method doesn't currently support multiple photos gracefully.
+
+Use get_photoset($c) instead to do the right thing with reports with 0, 1, or more photos.
=cut
sub get_photo_params {
+ # use Carp 'cluck';
+ # cluck "get_photo_params called"; # TEMPORARY die to make sure I've done right thing with Zurich templates
my $self = shift;
return FixMyStreet::App::get_photo_params($self, 'id');
}
@@ -637,7 +639,28 @@ sub body {
return $body;
}
-# returns true if the external id is the council's ref, i.e., useful to publish it.
+=head2 response_templates
+
+Returns all ResponseTemplates attached to this problem's bodies, in alphabetical
+order of title.
+
+=cut
+
+sub response_templates {
+ my $problem = shift;
+ return FixMyStreet::App->model('DB::ResponseTemplate')->search(
+ {
+ body_id => $problem->bodies_str_ids
+ },
+ {
+ order_by => 'title'
+ }
+ );
+}
+
+# returns true if the external id is the council's ref, i.e., useful to publish it
+# (by way of an example, the barnet send method returns a useful reference when
+# it succeeds, so that is the ref we should show on the problem report page).
# Future: this is installation-dependent so maybe should be using the contact
# data to determine if the external id is public on a council-by-council basis.
# Note: this only makes sense when called on a problem that has been sent!
@@ -828,6 +851,27 @@ sub latest_moderation_log_entry {
return $self->admin_log_entries->search({ action => 'moderation' }, { order_by => 'id desc' })->first;
}
+=head2 get_photoset
+
+Return a PhotoSet object for all photos attached to this field
+
+ my $photoset = $obj->get_photoset( $c );
+ print $photoset->num_images;
+ return $photoset->get_image_data(num => 0, size => 'full');
+
+=cut
+
+sub get_photoset {
+ my ($self, $c) = @_;
+ my $class = 'FixMyStreet::App::Model::PhotoSet';
+ eval "use $class";
+ return $class->new({
+ c => $c,
+ data => $self->photo,
+ object => $self,
+ });
+}
+
__PACKAGE__->has_many(
"admin_log_entries",
"FixMyStreet::DB::Result::AdminLog",
@@ -838,6 +882,18 @@ __PACKAGE__->has_many(
}
);
+sub get_time_spent {
+ my $self = shift;
+ my $admin_logs = $self->admin_log_entries->search({},
+ {
+ group_by => 'object_id',
+ columns => [
+ { sum_time_spent => { sum => 'time_spent' } },
+ ]
+ })->single;
+ return $admin_logs ? $admin_logs->get_column('sum_time_spent') : 0;
+}
+
# we need the inline_constructor bit as we don't inherit from Moose
__PACKAGE__->meta->make_immutable( inline_constructor => 0 );
diff --git a/perllib/FixMyStreet/DB/Result/ResponseTemplate.pm b/perllib/FixMyStreet/DB/Result/ResponseTemplate.pm
new file mode 100644
index 000000000..48a1ab3ae
--- /dev/null
+++ b/perllib/FixMyStreet/DB/Result/ResponseTemplate.pm
@@ -0,0 +1,49 @@
+use utf8;
+package FixMyStreet::DB::Result::ResponseTemplate;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+use strict;
+use warnings;
+
+use base 'DBIx::Class::Core';
+__PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn");
+__PACKAGE__->table("response_templates");
+__PACKAGE__->add_columns(
+ "id",
+ {
+ data_type => "integer",
+ is_auto_increment => 1,
+ is_nullable => 0,
+ sequence => "response_templates_id_seq",
+ },
+ "body_id",
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
+ "title",
+ { data_type => "text", is_nullable => 0 },
+ "text",
+ { data_type => "text", is_nullable => 0 },
+ "created",
+ {
+ data_type => "timestamp",
+ default_value => \"current_timestamp",
+ is_nullable => 0,
+ },
+);
+__PACKAGE__->set_primary_key("id");
+__PACKAGE__->add_unique_constraint("response_templates_body_id_title_key", ["body_id", "title"]);
+__PACKAGE__->belongs_to(
+ "body",
+ "FixMyStreet::DB::Result::Body",
+ { id => "body_id" },
+ { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07035 @ 2015-02-19 16:13:43
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xzhmxtu0taAnBMZN0HBocw
+
+
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
+1;
diff --git a/perllib/FixMyStreet/DB/ResultSet/Problem.pm b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
index f01ddfff1..40076d374 100644
--- a/perllib/FixMyStreet/DB/ResultSet/Problem.pm
+++ b/perllib/FixMyStreet/DB/ResultSet/Problem.pm
@@ -247,7 +247,7 @@ sub send_reports {
my $site = $site_override || CronFns::site($base_url);
my $states = [ 'confirmed', 'fixed' ];
- $states = [ 'unconfirmed', 'confirmed', 'in progress', 'planned', 'closed' ] if $site eq 'zurich';
+ $states = [ 'unconfirmed', 'confirmed', 'in progress', 'planned', 'closed', 'investigating' ] if $site eq 'zurich';
my $unsent = $rs->search( {
state => $states,
whensent => undef,