aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Rees <gareth@mysociety.org>2014-10-21 17:08:48 +0100
committerGareth Rees <gareth@mysociety.org>2014-10-29 13:01:12 +0000
commit6cb4a8608f7428764dac852927ffe42c77dd4d27 (patch)
tree452b5799c3021afd9ecf2ab6a0dd9d10c583e486
parentbe8daabd9e9b23239bd359e9dd1b38553ee3503d (diff)
Group User macro methods at top of file
https://github.com/bbatsov/rails-style-guide#macro-style-methods
-rw-r--r--app/models/user.rb20
1 files changed, 8 insertions, 12 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index c6e2d2b47..e4dcf1d3f 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -28,11 +28,7 @@ require 'digest/sha1'
class User < ActiveRecord::Base
strip_attributes!
- validates_presence_of :email, :message => _("Please enter your email address")
-
- validates_presence_of :name, :message => _("Please enter your name")
-
- validates_presence_of :hashed_password, :message => _("Please enter a password")
+ attr_accessor :password_confirmation, :no_xapian_reindex
has_many :info_requests, :order => 'created_at desc'
has_many :user_info_request_sent_alerts
@@ -43,9 +39,10 @@ class User < ActiveRecord::Base
has_many :censor_rules, :order => 'created_at desc'
has_many :info_request_batches, :order => 'created_at desc'
- attr_accessor :password_confirmation, :no_xapian_reindex
+ validates_presence_of :email, :message => _("Please enter your email address")
+ validates_presence_of :name, :message => _("Please enter your name")
+ validates_presence_of :hashed_password, :message => _("Please enter a password")
validates_confirmation_of :password, :message => _("Please enter the same password twice")
-
validates_inclusion_of :admin_level, :in => [
'none',
'super',
@@ -53,6 +50,10 @@ class User < ActiveRecord::Base
validate :email_and_name_are_valid
+ after_initialize :set_defaults
+ after_save :purge_in_cache
+ after_update :reindex_referencing_models
+
acts_as_xapian :texts => [ :name, :about_me ],
:values => [
[ :created_at_numeric, 1, "created_at", :number ] # for sorting
@@ -60,11 +61,6 @@ class User < ActiveRecord::Base
:terms => [ [ :variety, 'V', "variety" ] ],
:if => :indexed_by_search?
- after_initialize :set_defaults
-
- after_save :purge_in_cache
- after_update :reindex_referencing_models
-
def created_at_numeric
# format it here as no datetime support in Xapian's value ranges
return self.created_at.strftime("%Y%m%d%H%M%S")