diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/Result')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Body.pm | 108 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/BodyArea.pm | 33 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Comment.pm | 5 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Contact.pm | 17 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/ContactsHistory.pm | 6 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Open311conf.pm | 61 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Problem.pm | 136 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Token.pm | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 60 |
9 files changed, 282 insertions, 145 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm new file mode 100644 index 000000000..83704563a --- /dev/null +++ b/perllib/FixMyStreet/DB/Result/Body.pm @@ -0,0 +1,108 @@ +use utf8; +package FixMyStreet::DB::Result::Body; + +# 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("body"); +__PACKAGE__->add_columns( + "id", + { + data_type => "integer", + is_auto_increment => 1, + is_nullable => 0, + sequence => "body_id_seq", + }, + "name", + { data_type => "text", is_nullable => 0 }, + "endpoint", + { data_type => "text", is_nullable => 1 }, + "jurisdiction", + { data_type => "text", is_nullable => 1 }, + "api_key", + { data_type => "text", is_nullable => 1 }, + "send_method", + { data_type => "text", is_nullable => 1 }, + "send_comments", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, + "comment_user_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "suppress_alerts", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, + "can_be_devolved", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, + "send_extended_statuses", + { data_type => "boolean", default_value => \"false", is_nullable => 0 }, + "parent", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, +); +__PACKAGE__->set_primary_key("id"); +__PACKAGE__->has_many( + "bodies", + "FixMyStreet::DB::Result::Body", + { "foreign.parent" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); +__PACKAGE__->has_many( + "body_areas", + "FixMyStreet::DB::Result::BodyArea", + { "foreign.body_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); +__PACKAGE__->belongs_to( + "comment_user", + "FixMyStreet::DB::Result::User", + { id => "comment_user_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); +__PACKAGE__->has_many( + "contacts", + "FixMyStreet::DB::Result::Contact", + { "foreign.body_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); +__PACKAGE__->belongs_to( + "parent", + "FixMyStreet::DB::Result::Body", + { id => "parent" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); +__PACKAGE__->has_many( + "users", + "FixMyStreet::DB::Result::User", + { "foreign.from_body" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-19 12:47:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DdtXjMWRpz20ZHjtY3oP2w + +sub url { + my ( $self, $c ) = @_; + # XXX $areas_info was used here for Norway parent - needs body parents, I guess + return $c->uri_for( '/reports/' . $c->cobrand->short_name( $self ) ); +} + +sub areas { + my $self = shift; + my %ids = map { $_->area_id => 1 } $self->body_areas->all; + return \%ids; +} + +1; diff --git a/perllib/FixMyStreet/DB/Result/BodyArea.pm b/perllib/FixMyStreet/DB/Result/BodyArea.pm new file mode 100644 index 000000000..844a3277d --- /dev/null +++ b/perllib/FixMyStreet/DB/Result/BodyArea.pm @@ -0,0 +1,33 @@ +use utf8; +package FixMyStreet::DB::Result::BodyArea; + +# 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("body_areas"); +__PACKAGE__->add_columns( + "body_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "area_id", + { data_type => "integer", is_nullable => 0 }, +); +__PACKAGE__->add_unique_constraint("body_areas_body_id_area_id_idx", ["body_id", "area_id"]); +__PACKAGE__->belongs_to( + "body", + "FixMyStreet::DB::Result::Body", + { id => "body_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-19 12:47:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aAr+Nadyu8IckZlK6+PTNg + + __PACKAGE__->set_primary_key(__PACKAGE__->columns); + +1; diff --git a/perllib/FixMyStreet/DB/Result/Comment.pm b/perllib/FixMyStreet/DB/Result/Comment.pm index b551be9ef..33fbb9356 100644 --- a/perllib/FixMyStreet/DB/Result/Comment.pm +++ b/perllib/FixMyStreet/DB/Result/Comment.pm @@ -91,6 +91,7 @@ __PACKAGE__->filter_column( my $self = shift; my $ser = shift; return undef unless defined $ser; + utf8::encode($ser) if utf8::is_utf8($ser); my $h = new IO::String($ser); return RABX::wire_rd($h); }, @@ -146,8 +147,8 @@ sub check_for_errors { $errors{update} = _('Please enter a message') unless $self->text =~ m/\S/; - if ( $self->text && $self->problem && $self->problem->council - && $self->problem->council eq '2482' && length($self->text) > 2000 ) { + if ( $self->text && $self->problem && $self->problem->bodies_str + && $self->problem->bodies_str eq '2482' && length($self->text) > 2000 ) { $errors{update} = _('Updates are limited to 2000 characters in length. Please shorten your update'); } diff --git a/perllib/FixMyStreet/DB/Result/Contact.pm b/perllib/FixMyStreet/DB/Result/Contact.pm index 993e3524b..551bcd019 100644 --- a/perllib/FixMyStreet/DB/Result/Contact.pm +++ b/perllib/FixMyStreet/DB/Result/Contact.pm @@ -18,8 +18,8 @@ __PACKAGE__->add_columns( is_nullable => 0, sequence => "contacts_id_seq", }, - "area_id", - { data_type => "integer", is_nullable => 0 }, + "body_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "category", { data_type => "text", default_value => "Other", is_nullable => 0 }, "email", @@ -48,11 +48,17 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); -__PACKAGE__->add_unique_constraint("contacts_area_id_category_idx", ["area_id", "category"]); +__PACKAGE__->add_unique_constraint("contacts_body_id_category_idx", ["body_id", "category"]); +__PACKAGE__->belongs_to( + "body", + "FixMyStreet::DB::Result::Body", + { id => "body_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-08-31 10:29:17 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:t6yOPhZmedV/eH6AUvHI6w +# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-13 12:34:33 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:imXq3EtrC0FrQwj+E2xfBw __PACKAGE__->filter_column( extra => { @@ -60,6 +66,7 @@ __PACKAGE__->filter_column( my $self = shift; my $ser = shift; return undef unless defined $ser; + utf8::encode($ser) if utf8::is_utf8($ser); my $h = new IO::String($ser); return RABX::wire_rd($h); }, diff --git a/perllib/FixMyStreet/DB/Result/ContactsHistory.pm b/perllib/FixMyStreet/DB/Result/ContactsHistory.pm index deb00fb95..7126d91c9 100644 --- a/perllib/FixMyStreet/DB/Result/ContactsHistory.pm +++ b/perllib/FixMyStreet/DB/Result/ContactsHistory.pm @@ -20,7 +20,7 @@ __PACKAGE__->add_columns( }, "contact_id", { data_type => "integer", is_nullable => 0 }, - "area_id", + "body_id", { data_type => "integer", is_nullable => 0 }, "category", { data_type => "text", default_value => "Other", is_nullable => 0 }, @@ -40,8 +40,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("contacts_history_id"); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-03-08 17:19:55 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dN2ueIDoP3d/+Mg1UDqsMw +# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-12 16:37:16 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sxflEBBn0Mn0s3MroWnWFA # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/perllib/FixMyStreet/DB/Result/Open311conf.pm b/perllib/FixMyStreet/DB/Result/Open311conf.pm deleted file mode 100644 index f01a20dec..000000000 --- a/perllib/FixMyStreet/DB/Result/Open311conf.pm +++ /dev/null @@ -1,61 +0,0 @@ -use utf8; -package FixMyStreet::DB::Result::Open311conf; - -# 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("open311conf"); -__PACKAGE__->add_columns( - "id", - { - data_type => "integer", - is_auto_increment => 1, - is_nullable => 0, - sequence => "open311conf_id_seq", - }, - "area_id", - { data_type => "integer", is_nullable => 0 }, - "endpoint", - { data_type => "text", is_nullable => 0 }, - "jurisdiction", - { data_type => "text", is_nullable => 1 }, - "api_key", - { data_type => "text", is_nullable => 1 }, - "send_method", - { data_type => "text", is_nullable => 1 }, - "send_comments", - { data_type => "boolean", default_value => \"false", is_nullable => 0 }, - "comment_user_id", - { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, - "suppress_alerts", - { data_type => "boolean", default_value => \"false", is_nullable => 0 }, - "can_be_devolved", - { data_type => "boolean", default_value => \"false", is_nullable => 0 }, - "send_extended_statuses", - { data_type => "boolean", default_value => \"false", is_nullable => 0 }, -); -__PACKAGE__->set_primary_key("id"); -__PACKAGE__->add_unique_constraint("open311conf_area_id_key", ["area_id"]); -__PACKAGE__->belongs_to( - "comment_user", - "FixMyStreet::DB::Result::User", - { id => "comment_user_id" }, - { - is_deferrable => 1, - join_type => "LEFT", - on_delete => "CASCADE", - on_update => "CASCADE", - }, -); - - -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-08-29 14:04:20 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Yoult8K/ldH6DMAKURtr3Q - -# 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 0238e3b09..d9a2a0273 100644 --- a/perllib/FixMyStreet/DB/Result/Problem.pm +++ b/perllib/FixMyStreet/DB/Result/Problem.pm @@ -24,7 +24,7 @@ __PACKAGE__->add_columns( { data_type => "double precision", is_nullable => 0 }, "longitude", { data_type => "double precision", is_nullable => 0 }, - "council", + "bodies_str", { data_type => "text", is_nullable => 1 }, "areas", { data_type => "text", is_nullable => 0 }, @@ -99,7 +99,7 @@ __PACKAGE__->add_columns( "external_source_id", { data_type => "text", is_nullable => 1 }, "interest_count", - { data_type => "integer", is_nullable => 1 }, + { data_type => "integer", default_value => 0, is_nullable => 1 }, "subcategory", { data_type => "text", is_nullable => 1 }, ); @@ -124,8 +124,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-03 17:48:10 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xN/RB8Vx50CwyOeBjvJezQ +# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-13 15:13:48 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:H2P3Og37G569nQdQA1IWaA # Add fake relationship to stored procedure table __PACKAGE__->has_one( @@ -141,6 +141,7 @@ __PACKAGE__->filter_column( my $self = shift; my $ser = shift; return undef unless defined $ser; + utf8::encode($ser) if utf8::is_utf8($ser); my $h = new IO::String($ser); return RABX::wire_rd($h); }, @@ -161,6 +162,7 @@ __PACKAGE__->filter_column( my $self = shift; my $ser = shift; return undef unless defined $ser; + utf8::encode($ser) if utf8::is_utf8($ser); my $h = new IO::String($ser); return RABX::wire_rd($h); }, @@ -259,24 +261,26 @@ HASHREF. =cut +my $visible_states = { + 'confirmed' => 1, + 'investigating' => 1, + 'in progress' => 1, + 'planned' => 1, + 'action scheduled' => 1, + 'fixed' => 1, + 'fixed - council' => 1, + 'fixed - user' => 1, + 'unable to fix' => 1, + 'not responsible' => 1, + 'duplicate' => 1, + 'closed' => 1, + 'internal referral' => 1, +}; sub visible_states { - my $states = { - 'confirmed' => 1, - 'investigating' => 1, - 'in progress' => 1, - 'planned' => 1, - 'action scheduled' => 1, - 'fixed' => 1, - 'fixed - council' => 1, - 'fixed - user' => 1, - 'unable to fix' => 1, - 'not responsible' => 1, - 'duplicate' => 1, - 'closed' => 1, - 'internal referral' => 1, - }; - - return wantarray ? keys %{$states} : $states; + return wantarray ? keys %{$visible_states} : $visible_states; +} +sub visible_states_add_unconfirmed { + $visible_states->{unconfirmed} = 1; } =head2 @@ -336,7 +340,6 @@ sub council_states { return wantarray ? keys %{$states} : $states; } - my $tz = DateTime::TimeZone->new( name => "local" ); sub confirmed_local { @@ -378,6 +381,12 @@ around service => sub { return $s; }; +sub title_safe { + my $self = shift; + return _('Awaiting moderation') if $self->cobrand eq 'zurich' && $self->state eq 'unconfirmed'; + return $self->title; +} + =head2 check_for_errors $error_hashref = $problem->check_for_errors(); @@ -402,9 +411,9 @@ sub check_for_errors { $errors{detail} = _('Please enter some details') unless $self->detail =~ m/\S/; - $errors{council} = _('No council selected') - unless $self->council - && $self->council =~ m/^(?:-1|[\d,]+(?:\|[\d,]+)?)$/; + $errors{bodies} = _('No council selected') + unless $self->bodies_str + && $self->bodies_str =~ m/^(?:-1|[\d,]+(?:\|[\d,]+)?)$/; if ( !$self->name || $self->name !~ m/\S/ ) { $errors{name} = _('Please enter your name'); @@ -431,8 +440,8 @@ sub check_for_errors { $self->category(undef); } - if ( $self->council && $self->detail && - $self->council eq '2482' && length($self->detail) > 2000 ) { + if ( $self->bodies_str && $self->detail && + $self->bodies_str eq '2482' && length($self->detail) > 2000 ) { $errors{detail} = _('Reports are limited to 2000 characters in length. Please shorten your report'); } @@ -462,18 +471,26 @@ sub confirm { return 1; } -=head2 councils +sub bodies_str_ids { + my $self = shift; + return unless $self->bodies_str; + (my $bodies = $self->bodies_str) =~ s/\|.*$//; + my @bodies = split( /,/, $bodies ); + return \@bodies; +} + +=head2 bodies -Returns an arrayref of councils to which a report was sent. +Returns an arrayref of bodies to which a report was sent. =cut -sub councils { +sub bodies($) { my $self = shift; - return [] unless $self->council; - (my $council = $self->council) =~ s/\|.*$//; - my @council = split( /,/, $council ); - return \@council; + return {} unless $self->bodies_str; + my $bodies = $self->bodies_str_ids; + my @bodies = FixMyStreet::App->model('DB::Body')->search({ id => $bodies })->all; + return { map { $_->id => $_ } @bodies }; } =head2 url @@ -557,8 +574,7 @@ meta data about the report. sub meta_line { my ( $problem, $c ) = @_; - my $date_time = - Utils::prettify_epoch( $problem->confirmed_local->epoch ); + my $date_time = Utils::prettify_dt( $problem->confirmed_local ); my $meta = ''; # FIXME Should be in cobrand @@ -623,21 +639,22 @@ sub body { my ( $problem, $c ) = @_; my $body; if ($problem->external_body) { - $body = $problem->external_body; + if ($problem->cobrand eq 'zurich') { + $body = $c->model('DB::Body')->find({ id => $problem->external_body }); + } else { + $body = $problem->external_body; + } } else { - my $councils = $problem->councils; - my $areas_info = mySociety::MaPit::call('areas', $councils); + my $bodies = $problem->bodies; $body = join( _(' and '), map { - my $name = $areas_info->{$_}->{name}; + my $name = $_->name; if (mySociety::Config::get('AREA_LINKS_FROM_PROBLEMS')) { - '<a href="' - . $c->uri_for( '/reports/' . $c->cobrand->short_name( $areas_info->{$_} ) ) - . '">' . $name . '</a>'; + '<a href="' . $_->url($c) . '">' . $name . '</a>'; } else { $name; } - } @$councils + } values %$bodies ); } return $body; @@ -696,6 +713,14 @@ sub duration_string { ); } +sub local_coords { + my $self = shift; + if ($self->cobrand eq 'zurich') { + my ($x, $y) = Geo::Coordinates::CH1903::from_latlon($self->latitude, $self->longitude); + return ( int($x+0.5), int($y+0.5) ); + } +} + =head2 update_from_open311_service_request $p->update_from_open311_service_request( $request, $council_details, $system_user ); @@ -789,6 +814,29 @@ sub update_send_failed { } ); } +sub as_hashref { + my $self = shift; + my $c = shift; + + return { + id => $self->id, + title => $self->title, + category => $self->category, + detail => $self->detail, + latitude => $self->latitude, + longitude => $self->longitude, + postcode => $self->postcode, + state => $self->state, + state_t => _( $self->state ), + used_map => $self->used_map, + is_fixed => $self->fixed_states->{ $self->state } ? 1 : 0, + photo => $self->get_photo_params, + meta => $self->confirmed ? $self->meta_line( $c ) : '', + confirmed_pp => $self->confirmed ? Utils::prettify_dt( $self->confirmed_local, 1 ): '', + created_pp => Utils::prettify_dt( $self->created_local, 1 ), + }; +} + # 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/Token.pm b/perllib/FixMyStreet/DB/Result/Token.pm index b223ada3a..028300842 100644 --- a/perllib/FixMyStreet/DB/Result/Token.pm +++ b/perllib/FixMyStreet/DB/Result/Token.pm @@ -60,6 +60,7 @@ __PACKAGE__->filter_column( my $self = shift; my $ser = shift; return undef unless defined $ser; + utf8::encode($ser) if utf8::is_utf8($ser); my $h = new IO::String($ser); return RABX::wire_rd($h); }, diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index 7f43d1a52..481b654c9 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -26,8 +26,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "password", { data_type => "text", default_value => "", is_nullable => 0 }, - "from_council", - { data_type => "integer", is_nullable => 1 }, + "from_body", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, "flagged", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "title", @@ -42,16 +42,27 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); __PACKAGE__->has_many( + "bodies", + "FixMyStreet::DB::Result::Body", + { "foreign.comment_user_id" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); +__PACKAGE__->has_many( "comments", "FixMyStreet::DB::Result::Comment", { "foreign.user_id" => "self.id" }, { cascade_copy => 0, cascade_delete => 0 }, ); -__PACKAGE__->has_many( - "open311confs", - "FixMyStreet::DB::Result::Open311conf", - { "foreign.comment_user_id" => "self.id" }, - { cascade_copy => 0, cascade_delete => 0 }, +__PACKAGE__->belongs_to( + "from_body", + "FixMyStreet::DB::Result::Body", + { id => "from_body" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, ); __PACKAGE__->has_many( "problems", @@ -61,8 +72,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-05-01 16:20:29 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:LKi8u5IYnHW1+Mez64nvGg +# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-14 09:23:59 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aw374WQraL5ysOvUmUIU3w __PACKAGE__->add_columns( "password" => { @@ -144,38 +155,27 @@ sub alert_for_problem { } ); } -sub council { +sub body { my $self = shift; - - return '' unless $self->from_council; - - my $key = 'council_name:' . $self->from_council; - my $result = Memcached::get($key); - - unless ($result) { - my $area_info = mySociety::MaPit::call('area', $self->from_council); - $result = $area_info->{name}; - Memcached::set($key, $result, 86400); - } - - return $result; + return '' unless $self->from_body; + return $self->from_body->name; } -=head2 belongs_to_council +=head2 belongs_to_body - $belongs_to_council = $user->belongs_to_council( $council_list ); + $belongs_to_body = $user->belongs_to_body( $bodies ); -Returns true if the user belongs to the comma seperated list of council ids passed in +Returns true if the user belongs to the comma seperated list of body ids passed in =cut -sub belongs_to_council { +sub belongs_to_body { my $self = shift; - my $council = shift; + my $bodies = shift; - my %councils = map { $_ => 1 } split ',', $council; + my %bodies = map { $_ => 1 } split ',', $bodies; - return 1 if $self->from_council && $councils{ $self->from_council }; + return 1 if $self->from_body && $bodies{ $self->from_body->id }; return 0; } |