Merge pull request #4252 from Raven24/diasp-feature/1283-coppa-admin
Admin: find users under the age of 13 (COPPA)
This commit is contained in:
commit
92d3bb9c69
5 changed files with 32 additions and 10 deletions
|
|
@ -6,6 +6,7 @@
|
||||||
* Don't focus comment form on 'show n more comments' [#4265](https://github.com/diaspora/diaspora/issues/4265)
|
* Don't focus comment form on 'show n more comments' [#4265](https://github.com/diaspora/diaspora/issues/4265)
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
* Admin: add option to find users under 13 (COPPA) [#4252](https://github.com/diaspora/diaspora/pull/4252)
|
||||||
|
|
||||||
# 0.1.1.0
|
# 0.1.1.0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ class AdminsController < ApplicationController
|
||||||
def user_search
|
def user_search
|
||||||
params[:user] ||= {}
|
params[:user] ||= {}
|
||||||
params[:user].delete_if {|key, value| value.blank? }
|
params[:user].delete_if {|key, value| value.blank? }
|
||||||
@users = params[:user].empty? ? [] : User.where(params[:user])
|
@users = User.joins(person: :profile).where(["profiles.birthday > ?", Date.today - 13.years]) if params[:under13]
|
||||||
|
@users = (@users || User).where(params[:user]) if params[:user].present?
|
||||||
|
@users ||= []
|
||||||
end
|
end
|
||||||
|
|
||||||
def admin_inviter
|
def admin_inviter
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@
|
||||||
= t('email')
|
= t('email')
|
||||||
= text_field_tag 'user[email]', params[:user][:email]
|
= text_field_tag 'user[email]', params[:user][:email]
|
||||||
|
|
||||||
|
= t('.under_13')
|
||||||
|
= check_box_tag 'under13', params[:under13]
|
||||||
|
|
||||||
= submit_tag t('admins.stats.go')
|
= submit_tag t('admins.stats.go')
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -38,7 +41,7 @@
|
||||||
= user.person.profile.inspect
|
= user.person.profile.inspect
|
||||||
%br
|
%br
|
||||||
= "invite token: #{invite_code_url(user.invited_by.invite_code)}" if user.invited_by.present?
|
= "invite token: #{invite_code_url(user.invited_by.invite_code)}" if user.invited_by.present?
|
||||||
= link_to "add_invites", add_invites_path(user.invitation_code)
|
= link_to t(".add_invites"), add_invites_path(user.invitation_code)
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ en:
|
||||||
you_currently: "you currently have %{user_invitation} invites left %{link}"
|
you_currently: "you currently have %{user_invitation} invites left %{link}"
|
||||||
add_invites: "add invites"
|
add_invites: "add invites"
|
||||||
email_to: "Email to Invite"
|
email_to: "Email to Invite"
|
||||||
|
under_13: "Show users that are under 13 (COPPA)"
|
||||||
users:
|
users:
|
||||||
zero: "%{count} users found"
|
zero: "%{count} users found"
|
||||||
one: "%{count} user found"
|
one: "%{count} user found"
|
||||||
|
|
|
||||||
|
|
@ -34,29 +34,44 @@ describe AdminsController do
|
||||||
assigns[:users].should == []
|
assigns[:users].should == []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should search on username' do
|
it 'searches on username' do
|
||||||
get :user_search, :user => {:username => @user.username}
|
get :user_search, :user => {:username => @user.username}
|
||||||
assigns[:users].should == [@user]
|
assigns[:users].should == [@user]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should search on email' do
|
it 'searches on email' do
|
||||||
get :user_search, :user => {:email => @user.email}
|
get :user_search, :user => {:email => @user.email}
|
||||||
assigns[:users].should == [@user]
|
assigns[:users].should == [@user]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should search on invitation_identifier' do
|
it 'searches on invitation_identifier' do
|
||||||
@user.invitation_identifier = "La@foo.com"
|
@user.invitation_identifier = "La@foo.com"
|
||||||
@user.save!
|
@user.save!
|
||||||
get :user_search, :user => {:invitation_identifier => @user.invitation_identifier}
|
get :user_search, :user => {:invitation_identifier => @user.invitation_identifier}
|
||||||
assigns[:users].should == [@user]
|
assigns[:users].should == [@user]
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should search on invitation_token' do
|
it 'searches on invitation_token' do
|
||||||
@user.invitation_token = "akjsdhflhasdf"
|
@user.invitation_token = "akjsdhflhasdf"
|
||||||
@user.save
|
@user.save
|
||||||
get :user_search, :user => {:invitation_token => @user.invitation_token}
|
get :user_search, :user => {:invitation_token => @user.invitation_token}
|
||||||
assigns[:users].should == [@user]
|
assigns[:users].should == [@user]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'searches on age < 13 (COPPA)' do
|
||||||
|
u_13 = FactoryGirl.create(:user)
|
||||||
|
u_13.profile.birthday = 10.years.ago.to_date
|
||||||
|
u_13.profile.save!
|
||||||
|
|
||||||
|
o_13 = FactoryGirl.create(:user)
|
||||||
|
o_13.profile.birthday = 20.years.ago.to_date
|
||||||
|
o_13.profile.save!
|
||||||
|
|
||||||
|
get :user_search, under13: true
|
||||||
|
|
||||||
|
assigns[:users].should include(u_13)
|
||||||
|
assigns[:users].should_not include(o_13)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue