diff --git a/app/models/permission.rb b/app/models/permission.rb index 63b0fe0e..c370721b 100644 --- a/app/models/permission.rb +++ b/app/models/permission.rb @@ -12,7 +12,7 @@ class Permission < ActiveRecord::Base # userstamp stampable - # belongs_to :user + belongs_to :user, class_name: 'User', foreign_key: :creator_id # enumerations enumerize :level, :in => [:owner, :writer, :reader, :none], :default => :none, predicates: true diff --git a/app/models/tag.rb b/app/models/tag.rb index 17f706c1..518b8617 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -12,7 +12,7 @@ class Tag < ActiveRecord::Base # userstamp stampable - belongs_to :user, :class_name => 'User', :foreign_key => :creator_id + belongs_to :user, class_name: 'User', foreign_key: :creator_id acts_as_paranoid validates_as_paranoid diff --git a/app/models/user.rb b/app/models/user.rb index 13d25c6f..74acb6cb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,9 @@ class User < ActiveRecord::Base + + # NB: this intentionally left simple + # The bulk of the emails populated into this model will come from external authentication providers + VALID_EMAIL_REGEX = /^[^@]+@[^@]+\.[^@]+$/ + # Include devise modules. # :registerable,:rememberable, devise :confirmable, :omniauthable, :token_authenticatable, @@ -8,39 +13,47 @@ class User < ActiveRecord::Base # Setup accessible (or protected) attributes for your model attr_accessible :user_name, :display_name, :email, :password, :admin - has_many :authorizations, :dependent => :destroy + # user stamp model_stamper stampable # other associations - has_many :projects - has_many :sites - has_many :audio_recordings - has_many :audio_events - has_many :tags - has_many :audio_event_tags + has_many :authorizations, :dependent => :destroy + has_many :projects, :foreign_key => :creator_id + has_many :sites, :foreign_key => :creator_id + has_many :audio_recordings, :foreign_key => :creator_id + has_many :audio_events, :foreign_key => :creator_id + has_many :tags, :foreign_key => :creator_id + has_many :audio_event_tags, :foreign_key => :creator_id + has_many :permissions_created, :class_name => 'Permission', :foreign_key => :creator_id has_many :permissions - has_many :analysis_scripts - has_many :analysis_jobs - has_many :progresses - has_many :bookmarks - has_many :saved_searches + has_many :analysis_scripts, :foreign_key => :creator_id + has_many :analysis_jobs, :foreign_key => :creator_id + has_many :progresses, :foreign_key => :creator_id + has_many :bookmarks, :foreign_key => :creator_id + has_many :saved_searches, :foreign_key => :creator_id # validation #validates_presence_of :display_name - validates :user_name, :presence => true, :uniqueness => { :case_sensitive => false } + validates :user_name, presence: true, uniqueness: { case_sensitive: false }, + exclusion: { in: %w(admin harvester analysis_runner) }, unless: :skip_user_name_exclusion_list #:format => { :with => /\A[a-zA-Z0-9_ ]+\z/, :message => "only letters, numbers, space and underscore allowed" } - validates :display_name, :uniqueness => {:case_sensitive => false }, :presence => { :unless => Proc.new { |a| a.email.present? }, :message => "Please provide a name, email, or both." } - validates :email, :uniqueness => {:case_sensitive => false }, :presence => { :unless => Proc.new { |a| a.display_name.present? }, :message => "Please provide an email, name, or both." } - validates :user_name, :exclusion => { :in => %w(admin harvester analysis_runner) }, :unless => :skip_user_name_exclusion_list + validates :display_name, uniqueness: { case_sensitive: false }, + presence: { unless: Proc.new { |a| a.email.present? }, message: 'Please provide a display name, email, or both.' } + + # it turns out devise provdes its own validations for the email field + # providing our own (e.g.uniqueness) creates duplicated errors! #uniqueness: { case_sensitive: false }, + validates :email, format: {with:VALID_EMAIL_REGEX, message: 'Basic email validation failed. It should have at least 1 `@` and 1 `.`'} + #friendly_id :display_name, :use_slug => true, :strip_non_ascii => true - # special vanlidation skip - # TODO: does this need some protectection? + # special validation skip + # these methods allow a temporary skip of exclusion validation. this is used for seeding users into the database + # TODO: does this need some protection? def skip_user_name_exclusion_list=(value) @skip_user_name_exclusion_list = value end diff --git a/vendor/bin/install_console_audio_tools.sh b/vendor/bin/install_console_audio_tools.sh index 67904151..069c5fec 100644 --- a/vendor/bin/install_console_audio_tools.sh +++ b/vendor/bin/install_console_audio_tools.sh @@ -1,3 +1,15 @@ -sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 16126D3A3E5C1192 +sudo apt-key del 16126D3A3E5C1192 +sudo apt-get update +sudo apt-key finger +sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 16126D3A3E5C1192 +sudo apt-get update sudo apt-get install ffmpeg mp3splt sox wavpack --fix-missing -sudo apt-get update \ No newline at end of file +sudo apt-get update + +# http://askubuntu.com/a/86445 apt-get clean # Remove cached packages +cd /var/lib/apt +mv lists lists.old # Backup mirror info +mkdir -p lists/partial # Recreate directory structure +apt-get clean +apt-get update # Fetch mirror info +sudo apt-key finger \ No newline at end of file