Patch #9041 » feature_8979_project_leader_users_activation_RM_V1.2.1_V1.1.diff
app/helpers/application_helper.rb (copie de travail) | ||
---|---|---|
206 | 206 |
# Renders flash messages |
207 | 207 |
def render_flash_messages |
208 | 208 |
s = '' |
209 |
#Ennder 2011-08-05 Feature 9034 added id "flash_{notice|error}" |
|
209 | 210 |
flash.each do |k,v| |
210 |
s << content_tag('div', v, :class => "flash #{k}") |
|
211 |
s << content_tag('div', v, :class => "flash #{k}", :id => "flash_#{k}")
|
|
211 | 212 |
end |
212 | 213 |
s |
213 | 214 |
end |
... | ... | |
287 | 288 |
def principals_check_box_tags(name, principals) |
288 | 289 |
s = '' |
289 | 290 |
principals.sort.each do |principal| |
290 |
s << "<label>#{ check_box_tag name, principal.id, false } #{h principal}</label>\n" |
|
291 |
#Ennder 2011-08-05 Feature SM: #24789 RM: #8979 Project Leaders can activate users, users to activate in lightgray |
|
292 |
_font_begin = '<font color="lightgrey">' |
|
293 |
_font_end = '</font>' |
|
294 |
_registered = (principal.status == User::STATUS_REGISTERED) |
|
295 |
s << "<label>#{ (_registered ? _font_begin : '' ) }#{ check_box_tag name, principal.id, false } #{h principal}#{ (_registered ? _font_end : '' ) }</label>\n" |
|
291 | 296 |
end |
292 | 297 |
s |
293 | 298 |
end |
app/models/principal.rb (copie de travail) | ||
---|---|---|
25 | 25 |
# Groups and active users |
26 | 26 |
named_scope :active, :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status = 1)" |
27 | 27 |
|
28 |
# Jebat 2011-08-03 Feature SM: #24789 RM: #8979 Projects Leaders to activate users |
|
29 |
# Jebat User constants can't be used here |
|
30 |
named_scope :to_activate, :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status = 2" |
|
31 | ||
28 | 32 |
named_scope :like, lambda {|q| |
29 | 33 |
s = "%#{q.to_s.strip.downcase}%" |
30 | 34 |
{: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) | ||
---|---|---|
24 | 24 | |
25 | 25 |
def new |
26 | 26 |
members = [] |
27 |
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, Project Leaders users activation, for flash message |
|
28 |
users_to_activate = [] |
|
29 | ||
27 | 30 |
if params[:member] && request.post? |
31 |
#a free copy of the member hash |
|
28 | 32 |
attrs = params[:member].dup |
29 | 33 |
if (user_ids = attrs.delete(:user_ids)) |
34 |
#{user_ids, roles_ids} |
|
30 | 35 |
user_ids.each do |user_id| |
36 |
#Member : belongs_to :user, has_many :roles |
|
37 |
#{user_ids, roles_id, role_id} |
|
38 | ||
39 |
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, Project Leaders users activation |
|
40 |
_user = User.find_by_id(user_id) |
|
41 |
if !_user.nil? && _user.registered? |
|
42 |
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, will be activated later, if valid |
|
43 |
users_to_activate << _user |
|
44 |
end |
|
45 | ||
31 | 46 |
members << Member.new(attrs.merge(:user_id => user_id)) |
32 | 47 |
end |
33 | 48 |
else |
49 |
#{roles_id} |
|
34 | 50 |
members << Member.new(attrs) |
35 | 51 |
end |
36 | 52 |
@project.members << members |
37 | 53 |
end |
54 | ||
38 | 55 |
respond_to do |format| |
39 | 56 |
if members.present? && members.all? {|m| m.valid? } |
57 |
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, Project Leaders users activation |
|
58 |
users_activated = '' |
|
59 |
users_to_activate.each do |user_to_activate| |
|
60 |
user_to_activate.activate! |
|
40 | 61 | |
62 |
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979, activated members for flash message |
|
63 |
users_activated += "<br/>#{user_to_activate.firstname} #{user_to_activate.lastname}" |
|
64 |
end |
|
65 | ||
66 | ||
41 | 67 |
format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'members', :id => @project } |
42 | 68 | |
43 | 69 |
format.js { |
44 | 70 |
render(:update) {|page| |
45 | 71 |
page.replace_html "tab-content-members", :partial => 'projects/settings/members' |
72 | ||
73 |
#Ennder 2011-08-05, Feature SM: #24789 RM: #8979 add flash message for activated members |
|
74 |
if ! users_activated.blank? |
|
75 |
#Ennder TODO to translate: "user(s) activated" |
|
76 |
flash[:notice] = "user(s) activated:#{users_activated}" |
|
77 |
page.insert_html :before, 'principals', render_flash_messages |
|
78 |
flash.delete(:notice) |
|
79 | ||
80 |
page.visual_effect(:highlight, 'flash_notice') |
|
81 |
else |
|
82 |
page.remove :before, 'flash_notice' |
|
83 |
end |
|
84 | ||
46 | 85 |
page << 'hideOnLoad()' |
47 | 86 |
members.each {|member| page.visual_effect(:highlight, "member-#{member.id}") } |
48 | 87 |
} |
... | ... | |
93 | 132 |
end |
94 | 133 |
|
95 | 134 |
def autocomplete_for_member |
96 |
@principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals |
|
135 |
#Ennder 2011-08-04 Feature SM: #24789 RM: #8979 Activation des comptes par les CP |
|
136 |
@principals = Principal.active.like(params[:q]).find(:all, :limit => 100) - @project.principals + Principal.to_activate.all |
|
97 | 137 |
render :layout => false |
98 | 138 |
end |
99 | 139 |
app/views/projects/settings/_members.rhtml (copie de travail) | ||
---|---|---|
51 | 51 |
</div> |
52 | 52 | |
53 | 53 | |
54 |
<% principals = Principal.active.find(:all, :limit => 100, :order => 'type, login, lastname ASC') - @project.principals %> |
|
54 |
<% |
|
55 |
# Jebat 2011-08-04 Feature SM: #24789 RM: #8979 Projet Leaders to activate users |
|
56 |
principals = Principal.active.find(:all, :limit => 100, :order => 'type, login, lastname ASC') - @project.principals + Principal.to_activate.all |
|
57 |
-%> |
|
55 | 58 | |
56 | 59 |
<div class="splitcontentright"> |
57 | 60 |
<% if roles.any? && principals.any? %> |
- « Previous
- 1
- 2
- Next »