Merge pull request #1335 from consul/under_age_setting

Minimum age setting
This commit is contained in:
Raimond Garcia
2017-01-09 17:46:44 +01:00
committed by GitHub
14 changed files with 35 additions and 27 deletions

View File

@@ -196,6 +196,10 @@ class User < ActiveRecord::Base
@@username_max_length ||= self.columns.find { |c| c.name == 'username' }.limit || 60
end
def self.minimum_required_age
(Setting['min_age_to_participate'] || 16).to_i
end
def show_welcome_screen?
sign_in_count == 1 && unverified? && !organization && !administrator?
end

View File

@@ -23,7 +23,7 @@ class Verification::Management::Document
end
def valid_age?(response)
if under_sixteen?(response)
if under_age?(response)
errors.add(:age, true)
return false
else
@@ -31,8 +31,8 @@ class Verification::Management::Document
end
end
def under_sixteen?(response)
16.years.ago.beginning_of_day < response.date_of_birth.beginning_of_day
def under_age?(response)
User.minimum_required_age.years.ago.beginning_of_day < response.date_of_birth.beginning_of_day
end
def verified?

View File

@@ -36,7 +36,7 @@ class Verification::Residence
def allowed_age
return if errors[:date_of_birth].any?
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless self.date_of_birth <= 16.years.ago
errors.add(:date_of_birth, I18n.t('verification.residence.new.error_not_allowed_age')) unless self.date_of_birth <= User.minimum_required_age.years.ago
end
def document_number_uniqueness