mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-03-31 04:52:12 +02:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
77259d8cef
4 changed files with 18 additions and 6 deletions
|
@ -29,11 +29,11 @@ class User < ActiveRecord::Base
|
||||||
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
|
SCREEN_NAME_REGEX = /\A[a-zA-Z0-9_]{1,16}\z/
|
||||||
WEBSITE_REGEX = /https?:\/\/([A-Za-z.\-]+)\/?(?:.*)/i
|
WEBSITE_REGEX = /https?:\/\/([A-Za-z.\-]+)\/?(?:.*)/i
|
||||||
|
|
||||||
validates :screen_name, presence: true, format: { with: SCREEN_NAME_REGEX }, uniqueness: { case_sensitive: false }#,
|
before_validation do
|
||||||
#exclusion: { in: %w(justask_admin retrospring_admin admin justask retrospring support about public
|
screen_name.strip!
|
||||||
# notifications inbox sign_in sign_up sidekiq moderation moderator mod administrator
|
end
|
||||||
# siteadmin site_admin),
|
|
||||||
# message: "%{value} is reserved." }
|
validates :screen_name, presence: true, format: { with: SCREEN_NAME_REGEX }, uniqueness: { case_sensitive: false }, screen_name: true
|
||||||
|
|
||||||
validates :display_name, length: { maximum: 50 }
|
validates :display_name, length: { maximum: 50 }
|
||||||
validates :bio, length: { maximum: 200 }
|
validates :bio, length: { maximum: 200 }
|
||||||
|
|
11
app/validators/screen_name_validator.rb
Normal file
11
app/validators/screen_name_validator.rb
Normal 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
|
|
@ -107,6 +107,6 @@
|
||||||
%ul.about--moderator
|
%ul.about--moderator
|
||||||
- User.where(supporter: true).each do |sup|
|
- 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 }}
|
%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"
|
= render "shared/links"
|
||||||
|
|
|
@ -19,5 +19,6 @@ module Justask
|
||||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
# 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.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||||
# config.i18n.default_locale = :de
|
# config.i18n.default_locale = :de
|
||||||
|
config.autoload_paths += %W["#{config.root}/app/validators"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue