You need to join this project to post message / question. See Help for details.
join_action.patch
| app/controllers/my_controller.rb (working copy) | ||
|---|---|---|
| 157 | 157 |
session[:page_layout] = nil |
| 158 | 158 |
redirect_to :action => 'page' |
| 159 | 159 |
end |
| 160 |
|
|
| 161 |
# (dis)Join to a project |
|
| 162 |
# params[:id] : the project's id |
|
| 163 |
# params[:confirm] = 1 : ok, confirm the change |
|
| 164 |
def join |
|
| 165 |
@user = User.current |
|
| 166 |
@project = Project.find(params[:id]) |
|
| 167 |
@confirm = params[:confirm].to_i |
|
| 168 |
@memberships = @user.memberships |
|
| 169 | ||
| 170 |
if @confirm == 1 |
|
| 171 |
if @user.member_of?(@project) |
|
| 172 |
membership = Member.find :first, :conditions => ['user_id = ? and project_id =? ', @user.id, @project.id] |
|
| 173 |
membership_id = membership.id |
|
| 174 |
membership.destroy unless membership.nil? |
|
| 175 |
@memberships.delete_if {|m| m.id == membership_id }
|
|
| 176 |
else |
|
| 177 |
@role = Role.find :first, :conditions => ['name = ?', 'User'] |
|
| 178 |
membership = Member.new :user_id => @user.id, |
|
| 179 |
:project_id => @project.id, :mail_notification => true, |
|
| 180 |
:role_id => @role.id, :created_on => Time.now |
|
| 181 |
if membership.save |
|
| 182 |
@memberships << membership |
|
| 183 |
end |
|
| 184 |
end |
|
| 185 |
end |
|
| 186 |
end |
|
| 160 | 187 |
end |
| app/controllers/projects_controller.rb (working copy) | ||
|---|---|---|
| 22 | 22 |
menu_item :files, :only => [:list_files, :add_file] |
| 23 | 23 |
menu_item :settings, :only => :settings |
| 24 | 24 |
menu_item :issues, :only => [:changelog] |
| 25 |
|
|
| 25 |
|
|
| 26 | 26 |
before_filter :find_project, :except => [ :index, :list, :add, :activity ] |
| 27 | 27 |
before_filter :find_optional_project, :only => :activity |
| 28 | 28 |
before_filter :authorize, :except => [ :index, :list, :add, :archive, :unarchive, :destroy, :activity ] |
| ... | ... | |
| 220 | 220 |
retrieve_selected_tracker_ids(@trackers) |
| 221 | 221 |
@versions = @project.versions.sort |
| 222 | 222 |
end |
| 223 | ||
| 223 |
|
|
| 224 | 224 |
def roadmap |
| 225 | 225 |
@trackers = @project.trackers.find(:all, :conditions => ["is_in_roadmap=?", true]) |
| 226 | 226 |
retrieve_selected_tracker_ids(@trackers) |
| app/views/projects/index.rhtml (working copy) | ||
|---|---|---|
| 7 | 7 |
<h2><%=l(:label_project_plural)%></h2> |
| 8 | 8 | |
| 9 | 9 |
<% @project_tree.keys.sort.each do |project| %> |
| 10 |
<h3><%= link_to h(project.name), {:action => 'show', :id => project}, :class => (User.current.member_of?(project) ? "icon icon-fav" : "") %></h3>
|
|
| 10 |
<h3> |
|
| 11 |
<%= link_to h(project.name), {:action => 'show', :id => project}, :class => (User.current.member_of?(project) ? "icon icon-fav" : "") %>
|
|
| 12 |
<sup>(<%= link_to (User.current.member_of?(project) ? "disjoin" : "join"), {:controller => 'my', :action => 'join', :id => project} %>)</sup>
|
|
| 13 |
</h3> |
|
| 11 | 14 |
<%= textilizable(project.short_description, :project => project) %> |
| 12 | 15 | |
| 13 | 16 |
<% if @project_tree[project].any? %> |
| 14 | 17 |
<p><%= l(:label_subproject_plural) %>: |
| 15 | 18 |
<%= @project_tree[project].sort.collect {|subproject|
|
| 16 |
link_to(h(subproject.name), {:action => 'show', :id => subproject}, :class => (User.current.member_of?(subproject) ? "icon icon-fav" : ""))}.join(', ') %></p>
|
|
| 19 |
link_to(h(subproject.name), {:action => 'show', :id => subproject}, :class => (User.current.member_of?(subproject) ? "icon icon-fav" : "")) +
|
|
| 20 |
' <sup>(' + link_to( (User.current.member_of?(subproject) ? "disjoin" : "join"), {:controller => 'my', :action => 'join', :id => subproject} ) + ')</sup>'
|
|
| 21 |
}.join(', ')
|
|
| 22 |
%> |
|
| 23 |
</p> |
|
| 17 | 24 |
<% end %> |
| 18 | 25 |
<% end %> |
| 19 | 26 | |
| app/views/projects/show.rhtml (working copy) | ||
|---|---|---|
| 44 | 44 |
<%= users[0,25].collect(&:user).collect{|u| link_to_user u}.join(", ") %>
|
| 45 | 45 |
<%= "... (#{users.size} total)" if users.size > 25 -%>
|
| 46 | 46 |
<br /> |
| 47 |
<% end %></p> |
|
| 47 |
<% end %> |
|
| 48 |
Your membership: <%= link_to User.current.member_of?(@project) ? "DisJoin" : "Join", :controller => 'my', :action => 'join', :id => @project %> |
|
| 49 |
</p> |
|
| 48 | 50 |
</div> |
| 49 | 51 |
<% end %> |
| 50 | 52 | |