diff options
Diffstat (limited to 'perllib/FixMyStreet/DB')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Body.pm | 10 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Contact.pm | 37 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/ContactResponsePriority.pm | 46 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 112 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/ResponsePriority.pm | 57 |
5 files changed, 206 insertions, 56 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm index a2e004c6a..037b69352 100644 --- a/perllib/FixMyStreet/DB/Result/Body.pm +++ b/perllib/FixMyStreet/DB/Result/Body.pm @@ -87,6 +87,12 @@ __PACKAGE__->belongs_to( }, ); __PACKAGE__->has_many( + "response_priorities", + "FixMyStreet::DB::Result::ResponsePriority", + { "foreign.body_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); +__PACKAGE__->has_many( "response_templates", "FixMyStreet::DB::Result::ResponseTemplate", { "foreign.body_id" => "self.id" }, @@ -106,8 +112,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2015-02-19 16:13:43 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d6GuQm8vrNmCc4NWw58srA +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-09-06 15:33:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZuzscnLqcx0k512cTZ/kdg sub url { my ( $self, $c, $args ) = @_; diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm index ea9b656aa..b37734e7a 100644 --- a/perllib/FixMyStreet/DB/Result/Contact.pm +++ b/perllib/FixMyStreet/DB/Result/Contact.pm @@ -11,29 +11,29 @@ use base 'DBIx::Class::Core'; __PACKAGE__->load_components("FilterColumn", "InflateColumn::DateTime", "EncodedColumn"); __PACKAGE__->table("contacts"); __PACKAGE__->add_columns( - "id", - { - data_type => "integer", - is_auto_increment => 1, - is_nullable => 0, - sequence => "contacts_id_seq", - }, "body_id", { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, - "category", - { data_type => "text", default_value => "Other", is_nullable => 0 }, "email", { data_type => "text", is_nullable => 0 }, - "confirmed", - { data_type => "boolean", is_nullable => 0 }, - "deleted", - { data_type => "boolean", is_nullable => 0 }, "editor", { data_type => "text", is_nullable => 0 }, "whenedited", { data_type => "timestamp", is_nullable => 0 }, "note", { data_type => "text", is_nullable => 0 }, + "confirmed", + { data_type => "boolean", is_nullable => 0 }, + "category", + { data_type => "text", default_value => "Other", is_nullable => 0 }, + "deleted", + { data_type => "boolean", is_nullable => 0 }, + "id", + { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, + sequence => "contacts_id_seq", + }, "extra", { data_type => "text", is_nullable => 1 }, "non_public", @@ -56,6 +56,12 @@ __PACKAGE__->belongs_to( { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, ); __PACKAGE__->has_many( + "contact_response_priorities", + "FixMyStreet::DB::Result::ContactResponsePriority", + { "foreign.contact_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); +__PACKAGE__->has_many( "contact_response_templates", "FixMyStreet::DB::Result::ContactResponseTemplate", { "foreign.contact_id" => "self.id" }, @@ -63,8 +69,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-08-24 11:29:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CXUabm3Yd11OoIYJceSPag +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-09-06 15:33:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ocmQGeFJtO3wmvyx6W+EKQ __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn"); __PACKAGE__->rabx_column('extra'); @@ -75,6 +81,7 @@ use namespace::clean -except => [ 'meta' ]; with 'FixMyStreet::Roles::Extra'; __PACKAGE__->many_to_many( response_templates => 'contact_response_templates', 'response_template' ); +__PACKAGE__->many_to_many( response_priorities => 'contact_response_priorities', 'response_priority' ); sub get_metadata_for_input { my $self = shift; diff --git a/perllib/FixMyStreet/DB/Result/ContactResponsePriority.pm b/perllib/FixMyStreet/DB/Result/ContactResponsePriority.pm new file mode 100644 index 000000000..d5afd75a7 --- /dev/null +++ b/perllib/FixMyStreet/DB/Result/ContactResponsePriority.pm @@ -0,0 +1,46 @@ +use utf8; +package FixMyStreet::DB::Result::ContactResponsePriority; + +# 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("contact_response_priorities"); +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, + sequence => "contact_response_priorities_id_seq", + }, + "contact_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "response_priority_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->belongs_to( + "contact", + "FixMyStreet::DB::Result::Contact", + { id => "contact_id" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, +); +__PACKAGE__->belongs_to( + "response_priority", + "FixMyStreet::DB::Result::ResponsePriority", + { id => "response_priority_id" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-09-06 15:33:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kM/9jY1QSgakyPTvutS+hw + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/perllib/FixMyStreet/DB/Result/Problem.pm b/perllib/FixMyStreet/DB/Result/Problem.pm index 8236524d6..27648ddad 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -20,36 +20,14 @@ __PACKAGE__->add_columns( }, "postcode", { data_type => "text", is_nullable => 0 }, - "latitude", - { data_type => "double precision", is_nullable => 0 }, - "longitude", - { data_type => "double precision", is_nullable => 0 }, - "bodies_str", - { data_type => "text", is_nullable => 1 }, - "areas", - { data_type => "text", is_nullable => 0 }, - "category", - { data_type => "text", default_value => "Other", is_nullable => 0 }, "title", { data_type => "text", is_nullable => 0 }, "detail", { data_type => "text", is_nullable => 0 }, "photo", { data_type => "bytea", is_nullable => 1 }, - "used_map", - { data_type => "boolean", is_nullable => 0 }, - "user_id", - { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "name", { data_type => "text", is_nullable => 0 }, - "anonymous", - { data_type => "boolean", is_nullable => 0 }, - "external_id", - { data_type => "text", is_nullable => 1 }, - "external_body", - { data_type => "text", is_nullable => 1 }, - "external_team", - { data_type => "text", is_nullable => 1 }, "created", { data_type => "timestamp", @@ -57,18 +35,22 @@ __PACKAGE__->add_columns( is_nullable => 0, original => { default_value => \"now()" }, }, - "confirmed", - { data_type => "timestamp", is_nullable => 1 }, "state", { data_type => "text", is_nullable => 0 }, - "lang", - { data_type => "text", default_value => "en-gb", is_nullable => 0 }, - "service", - { data_type => "text", default_value => "", is_nullable => 0 }, - "cobrand", - { data_type => "text", default_value => "", is_nullable => 0 }, - "cobrand_data", - { data_type => "text", default_value => "", is_nullable => 0 }, + "whensent", + { data_type => "timestamp", is_nullable => 1 }, + "used_map", + { data_type => "boolean", is_nullable => 0 }, + "bodies_str", + { data_type => "text", is_nullable => 1 }, + "anonymous", + { data_type => "boolean", is_nullable => 0 }, + "category", + { data_type => "text", default_value => "Other", is_nullable => 0 }, + "confirmed", + { data_type => "timestamp", is_nullable => 1 }, + "send_questionnaire", + { data_type => "boolean", default_value => \"true", is_nullable => 0 }, "lastupdate", { data_type => "timestamp", @@ -76,14 +58,32 @@ __PACKAGE__->add_columns( is_nullable => 0, original => { default_value => \"now()" }, }, - "whensent", - { data_type => "timestamp", is_nullable => 1 }, - "send_questionnaire", - { data_type => "boolean", default_value => \"true", is_nullable => 0 }, - "extra", + "areas", + { data_type => "text", is_nullable => 0 }, + "service", + { data_type => "text", default_value => "", is_nullable => 0 }, + "lang", + { data_type => "text", default_value => "en-gb", is_nullable => 0 }, + "cobrand", + { data_type => "text", default_value => "", is_nullable => 0 }, + "cobrand_data", + { data_type => "text", default_value => "", is_nullable => 0 }, + "latitude", + { data_type => "double precision", is_nullable => 0 }, + "longitude", + { data_type => "double precision", is_nullable => 0 }, + "external_id", + { data_type => "text", is_nullable => 1 }, + "external_body", { data_type => "text", is_nullable => 1 }, + "external_team", + { data_type => "text", is_nullable => 1 }, + "user_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "flagged", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, + "extra", + { data_type => "text", is_nullable => 1 }, "geocode", { data_type => "bytea", is_nullable => 1 }, "send_fail_count", @@ -106,6 +106,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "bodies_missing", { data_type => "text", is_nullable => 1 }, + "response_priority_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->has_many( @@ -127,6 +129,17 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); __PACKAGE__->belongs_to( + "response_priority", + "FixMyStreet::DB::Result::ResponsePriority", + { id => "response_priority_id" }, + { + is_deferrable => 0, + join_type => "LEFT", + on_delete => "NO ACTION", + on_update => "NO ACTION", + }, +); +__PACKAGE__->belongs_to( "user", "FixMyStreet::DB::Result::User", { id => "user_id" }, @@ -140,8 +153,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-07-20 15:00:41 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PMOhd1uloLTAYovW/fxgSg +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-09-07 11:01:40 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:iH9c4VZZN/ONnhN6g89DFw # Add fake relationship to stored procedure table __PACKAGE__->has_one( @@ -656,6 +669,27 @@ sub response_templates { ); } +=head2 response_priorities + +Returns all ResponsePriorities attached to this problem's category/contact, in +alphabetical order of name. + +=cut + +sub response_priorities { + my $self = shift; + return $self->result_source->schema->resultset('ResponsePriority')->search( + { + 'me.body_id' => $self->bodies_str_ids, + 'contact.category' => $self->category, + }, + { + order_by => 'name', + join => { 'contact_response_priorities' => 'contact' }, + } + ); +} + # returns true if the external id is the council's ref, i.e., useful to publish it # (by way of an example, the Oxfordshire send method returns a useful reference when # it succeeds, so that is the ref we should show on the problem report page). diff --git a/perllib/FixMyStreet/DB/Result/ResponsePriority.pm b/perllib/FixMyStreet/DB/Result/ResponsePriority.pm new file mode 100644 index 000000000..d312fbcea --- /dev/null +++ b/perllib/FixMyStreet/DB/Result/ResponsePriority.pm @@ -0,0 +1,57 @@ +use utf8; +package FixMyStreet::DB::Result::ResponsePriority; + +# 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_priorities"); +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, + sequence => "response_priorities_id_seq", + }, + "body_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "name", + { data_type => "text", is_nullable => 0 }, + "deleted", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->add_unique_constraint("response_priorities_body_id_name_key", ["body_id", "name"]); +__PACKAGE__->belongs_to( + "body", + "FixMyStreet::DB::Result::Body", + { id => "body_id" }, + { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, +); +__PACKAGE__->has_many( + "contact_response_priorities", + "FixMyStreet::DB::Result::ContactResponsePriority", + { "foreign.response_priority_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); +__PACKAGE__->has_many( + "problems", + "FixMyStreet::DB::Result::Problem", + { "foreign.response_priority_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07035 @ 2016-09-07 11:01:40 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:B1swGtQzC3qRa0LUM4IyzA + +__PACKAGE__->many_to_many( contacts => 'contact_response_priorities', 'contact' ); + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; |