Feature #8979 » feature_8979_project_leader_users_activation_RM_V1.2.1_V1.1.diff
| app/helpers/application_helper.rb (copie de travail) | ||
|---|---|---|
|
# Renders flash messages
|
||
|
def render_flash_messages
|
||
|
s = ''
|
||
|
#Ennder 2011-08-05 Feature 9034 added id "flash_{notice|error}"
|
||
|
flash.each do |k,v|
|
||
|
s << content_tag('div', v, :class => "flash #{k}")
|
||
|
s << content_tag('div', v, :class => "flash #{k}", :id => "flash_#{k}")
|
||
|
end
|
||
|
s
|
||
|
end
|
||
| ... | ... | |
|
def principals_check_box_tags(name, principals)
|
||
|
s = ''
|
||
|
principals.sort.each do |principal|
|
||
|
s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n"
|
||
|
#Ennder 2011-08-05 Feature SM: #24789 RM: #8979 Project Leaders can activate users, users to activate in lightgray
|
||
|
_font_begin = '<font color="lightgrey">'
|
||
|
_font_end = '</font>'
|
||
|
_registered = (principal.status == User::STATUS_REGISTERED)
|
||
|
s << "<label>#{ (_registered ? _font_begin : '' ) }#{ check_box_tag name, principal.id, false } #{h principal}#{ (_registered ? _font_end : '' ) }</label>\n"
|
||
|
end
|
||
|
s
|
||
|
end
|
||
| app/models/principal.rb (copie de travail) | ||
|---|---|---|
|
# Groups and active users
|
||
|
named_scope :active, :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status = 1)"
|
||
|
|
||
|
# Jebat 2011-08-03 Feature SM: #24789 RM: #8979 Projects Leaders to activate users
|
||
|
# Jebat User constants can't be used here
|
||
|
named_scope :to_activate, :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status = 2"
|
||
|
named_scope :like, lambda {|q|
|
||
|
s = "%#{q.to_s.strip.downcase}%"
|
||
|
{:conditions => ["LOWER(login) LIKE :s OR LOWER(firstname) LIKE :s OR LOWER(lastname) LIKE :s OR LOWER(mail) LIKE :s", {:s => s}],
|
||
| app/controllers/members_controller.rb (copie de travail) | ||
|---|---|---|
|
def new
|
||
|
members = []
|
||
|
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, Project Leaders users activation, for flash message
|
||
|
users_to_activate = []
|
||
|
if params[:member] && request.post?
|
||
|
#a free copy of the member hash
|
||
|
attrs = params[:member].dup
|
||
|
if (user_ids = attrs.delete(:user_ids))
|
||
|
#{user_ids, roles_ids}
|
||
|
user_ids.each do |user_id|
|
||
|
#Member : belongs_to :user, has_many :roles
|
||
|
#{user_ids, roles_id, role_id}
|
||
|
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, Project Leaders users activation
|
||
|
_user = User.find_by_id(user_id)
|
||
|
if !_user.nil? && _user.registered?
|
||
|
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, will be activated later, if valid
|
||
|
users_to_activate << _user
|
||
|
end
|
||
|
members << Member.new(attrs.merge(:user_id => user_id))
|
||
|
end
|
||
|
else
|
||
|
#{roles_id}
|
||
|
members << Member.new(attrs)
|
||
|
end
|
||
|
@project.members << members
|
||
|
end
|
||
|
respond_to do |format|
|
||
|
if members.present? && members.all? {|m| m.valid? }
|
||
|
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, Project Leaders users activation
|
||
|
users_activated = ''
|
||
|
users_to_activate.each do |user_to_activate|
|
||
|
user_to_activate.activate!
|
||
|
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, activated members for flash message
|
||
|
users_activated += "<br/>#{user_to_activate.firstname} #{user_to_activate.lastname}"
|
||
|
end
|
||
|
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project }
|
||
|
format.js {
|
||
|
render(:update) {|page|
|
||
|
page.replace_html "tab-content-members", :partial => 'projects/settings/members'
|
||
|
#Ennder 2011-08-05, Feature SM: #24789 RM: #8979 add flash message for activated members
|
||
|
if ! users_activated.blank?
|
||
|
#Ennder TODO to translate: "user(s) activated"
|
||
|
flash[:notice] = "user(s) activated:#{users_activated}"
|
||
|
page.insert_html :before, 'principals', render_flash_messages
|
||
|
flash.delete(:notice)
|
||
|
page.visual_effect(:highlight, 'flash_notice')
|
||
|
else
|
||
|
page.remove :before, 'flash_notice'
|
||
|
end
|
||
|
page << 'hideOnLoad()'
|
||
|
members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") }
|
||
|
}
|
||
| ... | ... | |
|
end
|
||
|
|
||
|
def autocomplete_for_member
|
||
|
@principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals
|
||
|
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979 Activation des comptes par les CP
|
||
|
@principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals + Principal.to_activate.all
|
||
|
render :layout => false
|
||
|
end
|
||
| app/views/projects/settings/_members.rhtml (copie de travail) | ||
|---|---|---|
|
</div>
|
||
|
<% principals = Principal.active.find(:all, :limit => 100, :order => 'type, login, lastname ASC') - @project.principals %>
|
||
|
<%
|
||
|
# Jebat 2011-08-04 Feature SM: #24789 RM: #8979 Projet Leaders to activate users
|
||
|
principals = Principal.active.find(:all, :limit => 100, :order => 'type, login, lastname ASC') - @project.principals + Principal.to_activate.all
|
||
|
-%>
|
||
|
<div class="splitcontentright">
|
||
|
<% if roles.any? && principals.any? %>
|
||
- « Previous
- 1
- 2
- Next »