aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/User.pm
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2011-08-22 11:22:33 +0100
committerStruan Donald <struan@exo.org.uk>2011-08-22 11:22:33 +0100
commit44c31ab8efbd97086e17d26c819b1d5b4946ce43 (patch)
tree5a509a5006afd50f4c48f52fdf45ac9ac86ac054 /perllib/FixMyStreet/DB/Result/User.pm
parentf93ff062c986847f97aef76673c2ca7742f1f125 (diff)
parenta9a4fed583d7467c9c1f1fa56d42bcb75b4b488c (diff)
Merge branch 'master' of ssh://git.mysociety.org/data/git/public/fixmystreet into open311-consumer
Conflicts: t/app/model/problem.t templates/web/default/report/new/fill_in_details.html web/css/core.css
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/User.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm42
1 files changed, 40 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index cf4fc56d5..56d726a8d 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -26,6 +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 },
"flagged",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
);
@@ -51,8 +53,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:T2JK+KyfoE2hkCLgreq1XQ
+# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-27 10:25:21
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9IHuqRTcHZCqJeBAaiQxzw
__PACKAGE__->add_columns(
"password" => {
@@ -134,4 +136,40 @@ sub alert_for_problem {
} );
}
+sub council {
+ 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;
+}
+
+=head2 belongs_to_council
+
+ $belongs_to_council = $user->belongs_to_council( $council_list );
+
+Returns true if the user belongs to the comma seperated list of council ids passed in
+
+=cut
+
+sub belongs_to_council {
+ my $self = shift;
+ my $council = shift;
+
+ my %councils = map { $_ => 1 } split ',', $council;
+
+ return 1 if $self->from_council && $councils{ $self->from_council };
+
+ return 0;
+}
+
1;