Merge remote-tracking branch 'origin/master'

This commit is contained in:
Andreas N 2015-01-09 21:54:18 +01:00
commit 77259d8cef
4 changed files with 18 additions and 6 deletions

View File

@ -29,11 +29,11 @@ class User < ActiveRecord::Base
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
WEBSITE_REGEX = /https?:\/\/([A-Za-z.\-]+)\/?(?:.*)/i
validates :screen_name, presence: true, format: { with: SCREEN_NAME_REGEX }, uniqueness: { case_sensitive: false }#,
#exclusion: { in: %w(justask_admin retrospring_admin admin justask retrospring support about public
# notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
# siteadmin site_admin),
# message: "%{value} is reserved." }
before_validation do
screen_name.strip!
end
validates :screen_name, presence: true, format: { with: SCREEN_NAME_REGEX }, uniqueness: { case_sensitive: false }, screen_name: true
validates :display_name, length: { maximum: 50 }
validates :bio, length: { maximum: 200 }

View File

@ -0,0 +1,11 @@
class ScreenNameValidator < ActiveModel::EachValidator
FORBIDDEN_SCREEN_NAMES = %w(justask_admin retrospring_admin admin justask retrospring support about public
notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
siteadmin site_admin help retro_spring retroospring retrosprlng niisding nllsding)
def validate_each(record, attribute, value)
if FORBIDDEN_SCREEN_NAMES.include? value.downcase
record.errors[attribute] << "Thou shalt not use this username! Please choose another one."
end
end
end

View File

@ -107,6 +107,6 @@
%ul.about--moderator
- User.where(supporter: true).each do |sup|
%a{href: show_user_profile_path(sup.screen_name), title: sup.screen_name, data: { toggle: :tooltip, placement: :top }}
%img.img-rounded.answerbox--img-small{src: sup.profile_picture_url(:medium)}
%img.img-rounded.answerbox--img-small{src: sup.profile_picture.url(:medium)}
= render "shared/links"

View File

@ -19,5 +19,6 @@ module Justask
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
config.autoload_paths += %W["#{config.root}/app/validators"]
end
end