| |   |
| 328 | 328 | out = %Q{<table class='right_default_table'>} |
| 329 | 329 | out << %Q{<tr><th>Actions</th></tr>} |
| 330 | 330 | # |
| 331 | | #FIXME finish this, also it must must only be true if logged_in? |
| 332 | | logged_in? ? is_member = true : is_member = false |
| 333 | 331 | acts = "" |
| 334 | 332 | acts << %Q{<li>#{link_to("List Wiki Pages", project_wikis_path(@project.slug))}</li>} if flags[:list_project_wikis] |
| 335 | | acts << %Q{<li>#{link_to("Edit Wiki Page", edit_project_wiki_path(@project.slug, @wiki.slug))}</li>} if flags[:edit_project_wiki] && is_member |
| 336 | | acts << %Q{<li>#{link_to("New Wiki Page", new_project_wiki_path(@project.slug))}</li>} if flags[:new_project_wiki] && is_member |
| 337 | | acts << %Q{<li>#{link_to("Edit Article", edit_project_article_path(@project.slug, @article.slug))}</li>} if flags[:edit_article] && is_member |
| 338 | | acts << %Q{<li>#{link_to("New Article", new_project_article_path(@project.slug))}</li>} if flags[:new_article] && is_member |
| 333 | acts << %Q{<li>#{link_to("Edit Wiki Page", edit_project_wiki_path(@project.slug, @wiki.slug))}</li>} if flags[:edit_project_wiki] && @is_member |
| 334 | acts << %Q{<li>#{link_to("New Wiki Page", new_project_wiki_path(@project.slug))}</li>} if flags[:new_project_wiki] && @is_member |
| 335 | acts << %Q{<li>#{link_to("Edit Article", edit_project_article_path(@project.slug, @article.slug))}</li>} if flags[:edit_article] && @is_member |
| 336 | acts << %Q{<li>#{link_to("New Article", new_project_article_path(@project.slug))}</li>} if flags[:new_article] && @is_member |
| 339 | 337 | acts << %Q{<li>#{link_to("New Ticket", new_project_ticket_path(@project.slug))}</li>} if flags[:new_ticket] |
| 340 | 338 | acts << %Q{<li>#{link_to("Edit Ticket", edit_project_ticket_path(@project.slug))}</li>} if flags[:edit_ticket] |
| 341 | 339 | acts << %Q{<li>#{link_to("Close Ticket", root_path)}</li>} if flags[:close_ticket] |
| 342 | 340 | acts << %Q{<li>#{link_to("List Tickets", project_tickets_path(@project.slug))}</li>} if flags[:list_tickets] |
| 343 | | acts << %Q{<li>#{link_to("New Milestone", new_project_milestone_path(@project.slug))}</li>} if flags[:new_milestone] && is_member |
| 341 | acts << %Q{<li>#{link_to("New Milestone", new_project_milestone_path(@project.slug))}</li>} if flags[:new_milestone] && @is_member |
| 344 | 342 | acts << %Q{<li>#{link_to("List Active Milestones", root_path)}</li>} if flags[:list_active_milestones] |
| 345 | 343 | acts << %Q{<li>#{link_to("List Completed Milestones", root_path)}</li>} if flags[:list_completed_milestones] |
| 346 | | acts << %Q{<li>#{link_to("Edit Milestones", root_path)}</li>} if flags[:edit_milestones] && is_member |
| 347 | | acts << %Q{<li>#{link_to("Edit Components", root_path)}</li>} if flags[:edit_components] && is_member |
| 344 | acts << %Q{<li>#{link_to("Edit Milestones", root_path)}</li>} if flags[:edit_milestones] && @is_member |
| 345 | acts << %Q{<li>#{link_to("Edit Components", root_path)}</li>} if flags[:edit_components] && @is_member |
| 346 | acts << %Q{<li>#{link_to("New Member", root_path)}</li>} if flags[:new_member] && @is_member |
| 347 | acts << %Q{<li>#{link_to("List Members", root_path)}</li>} if flags[:list_members] |
| 348 | 348 | acts << %Q{<li>#{link_to("Clone Mainline", new_project_repository_path(@project.slug, @repository))}</li>} if flags[:clone_mainline] && logged_in? |
| 349 | 349 | out << %Q{<tr><td><ul>#{acts}</ul></td></tr>} if acts != "" |
| 350 | 350 | out << %Q{<tr><td>#{actionbox_default(flags)}</td></tr>} |
| toggle raw diff |
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -328,23 +328,23 @@ module ApplicationHelper
out = %Q{<table class='right_default_table'>}
out << %Q{<tr><th>Actions</th></tr>}
#
- #FIXME finish this, also it must must only be true if logged_in?
- logged_in? ? is_member = true : is_member = false
acts = ""
acts << %Q{<li>#{link_to("List Wiki Pages", project_wikis_path(@project.slug))}</li>} if flags[:list_project_wikis]
- acts << %Q{<li>#{link_to("Edit Wiki Page", edit_project_wiki_path(@project.slug, @wiki.slug))}</li>} if flags[:edit_project_wiki] && is_member
- acts << %Q{<li>#{link_to("New Wiki Page", new_project_wiki_path(@project.slug))}</li>} if flags[:new_project_wiki] && is_member
- acts << %Q{<li>#{link_to("Edit Article", edit_project_article_path(@project.slug, @article.slug))}</li>} if flags[:edit_article] && is_member
- acts << %Q{<li>#{link_to("New Article", new_project_article_path(@project.slug))}</li>} if flags[:new_article] && is_member
+ acts << %Q{<li>#{link_to("Edit Wiki Page", edit_project_wiki_path(@project.slug, @wiki.slug))}</li>} if flags[:edit_project_wiki] && @is_member
+ acts << %Q{<li>#{link_to("New Wiki Page", new_project_wiki_path(@project.slug))}</li>} if flags[:new_project_wiki] && @is_member
+ acts << %Q{<li>#{link_to("Edit Article", edit_project_article_path(@project.slug, @article.slug))}</li>} if flags[:edit_article] && @is_member
+ acts << %Q{<li>#{link_to("New Article", new_project_article_path(@project.slug))}</li>} if flags[:new_article] && @is_member
acts << %Q{<li>#{link_to("New Ticket", new_project_ticket_path(@project.slug))}</li>} if flags[:new_ticket]
acts << %Q{<li>#{link_to("Edit Ticket", edit_project_ticket_path(@project.slug))}</li>} if flags[:edit_ticket]
acts << %Q{<li>#{link_to("Close Ticket", root_path)}</li>} if flags[:close_ticket]
acts << %Q{<li>#{link_to("List Tickets", project_tickets_path(@project.slug))}</li>} if flags[:list_tickets]
- acts << %Q{<li>#{link_to("New Milestone", new_project_milestone_path(@project.slug))}</li>} if flags[:new_milestone] && is_member
+ acts << %Q{<li>#{link_to("New Milestone", new_project_milestone_path(@project.slug))}</li>} if flags[:new_milestone] && @is_member
acts << %Q{<li>#{link_to("List Active Milestones", root_path)}</li>} if flags[:list_active_milestones]
acts << %Q{<li>#{link_to("List Completed Milestones", root_path)}</li>} if flags[:list_completed_milestones]
- acts << %Q{<li>#{link_to("Edit Milestones", root_path)}</li>} if flags[:edit_milestones] && is_member
- acts << %Q{<li>#{link_to("Edit Components", root_path)}</li>} if flags[:edit_components] && is_member
+ acts << %Q{<li>#{link_to("Edit Milestones", root_path)}</li>} if flags[:edit_milestones] && @is_member
+ acts << %Q{<li>#{link_to("Edit Components", root_path)}</li>} if flags[:edit_components] && @is_member
+ acts << %Q{<li>#{link_to("New Member", root_path)}</li>} if flags[:new_member] && @is_member
+ acts << %Q{<li>#{link_to("List Members", root_path)}</li>} if flags[:list_members]
acts << %Q{<li>#{link_to("Clone Mainline", new_project_repository_path(@project.slug, @repository))}</li>} if flags[:clone_mainline] && logged_in?
out << %Q{<tr><td><ul>#{acts}</ul></td></tr>} if acts != ""
out << %Q{<tr><td>#{actionbox_default(flags)}</td></tr>} |
| |   |
| 64 | 64 | out << "<ul id='tabmenu'>" |
| 65 | 65 | out << project_tab(active_tab, PRJ_TAB_SUMMARY) |
| 66 | 66 | out << project_tab(active_tab, PRJ_TAB_GIT) |
| 67 | | out << project_tab(active_tab, PRJ_TAB_MEMBERS) |
| 67 | out << project_tab(active_tab, PRJ_TAB_TEAM) |
| 68 | 68 | out << project_tab(active_tab, PRJ_TAB_TICKETS) |
| 69 | 69 | out << project_tab(active_tab, PRJ_TAB_WIKI) |
| 70 | 70 | out << project_tab(active_tab, PRJ_TAB_ARTICLES) |
| … | … | |
| 120 | 120 | when PRJ_TAB_GIT_MERGEREQUESTS |
| 121 | 121 | out << actionbox_basic(:allow_shortcuts => true) |
| 122 | 122 | end |
| 123 | | when PRJ_TAB_MEMBERS |
| 124 | | out << actionbox_basic(:allow_shortcuts => true) |
| 125 | | out << render(:partial => "ac_right_actionbox_post_message") if @is_member |
| 126 | | out << render_right_project_members |
| 123 | when PRJ_TAB_TEAM |
| 124 | case subtab |
| 125 | when PRJ_TAB_SUBTAB_NONE |
| 126 | out << actionbox_complex(:allow_shortcuts => true, :new_member => true, :list_members => true) |
| 127 | out << render(:partial => "messages/ac_right_actionbox_post_message") if @is_member |
| 128 | out << render_right_project_members |
| 129 | when PRJ_TAB_TEAM_NEW |
| 130 | when PRJ_TAB_TEAM_LIST |
| 131 | end |
| 127 | 132 | when PRJ_TAB_TICKETS |
| 128 | 133 | case subtab |
| 129 | 134 | when PRJ_TAB_SUBTAB_NONE |
| toggle raw diff |
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -64,7 +64,7 @@ module ProjectsHelper
out << "<ul id='tabmenu'>"
out << project_tab(active_tab, PRJ_TAB_SUMMARY)
out << project_tab(active_tab, PRJ_TAB_GIT)
- out << project_tab(active_tab, PRJ_TAB_MEMBERS)
+ out << project_tab(active_tab, PRJ_TAB_TEAM)
out << project_tab(active_tab, PRJ_TAB_TICKETS)
out << project_tab(active_tab, PRJ_TAB_WIKI)
out << project_tab(active_tab, PRJ_TAB_ARTICLES)
@@ -120,10 +120,15 @@ module ProjectsHelper
when PRJ_TAB_GIT_MERGEREQUESTS
out << actionbox_basic(:allow_shortcuts => true)
end
- when PRJ_TAB_MEMBERS
- out << actionbox_basic(:allow_shortcuts => true)
- out << render(:partial => "ac_right_actionbox_post_message") if @is_member
- out << render_right_project_members
+ when PRJ_TAB_TEAM
+ case subtab
+ when PRJ_TAB_SUBTAB_NONE
+ out << actionbox_complex(:allow_shortcuts => true, :new_member => true, :list_members => true)
+ out << render(:partial => "messages/ac_right_actionbox_post_message") if @is_member
+ out << render_right_project_members
+ when PRJ_TAB_TEAM_NEW
+ when PRJ_TAB_TEAM_LIST
+ end
when PRJ_TAB_TICKETS
case subtab
when PRJ_TAB_SUBTAB_NONE |
| |   |
| 55 | 55 | |
| 56 | 56 | #public version of .count to filter articles you are not authorised to see |
| 57 | 57 | def self.public_count (curruser) |
| 58 | | @projects = Project.list_for_user(curruser) |
| 58 | @projects = Project.list_for_user(curruser.id) |
| 59 | 59 | #FIXME is there a faster way of doing this? |
| 60 | 60 | @articles = find(:all, :conditions => ["status = '#{:published}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC") |
| 61 | 61 | return @articles.size |
| … | … | |
| 66 | 66 | # |
| 67 | 67 | def self.find_by_date (curruser, year, month = nil, day = nil) |
| 68 | 68 | from, to = self.time_delta(year, month, day) |
| 69 | | @projects = Project.list_for_user(curruser) |
| 69 | @projects = Project.list_for_user(curruser.id) |
| 70 | 70 | find(:all, :conditions => [ "status = '#{:published}' AND (created_at BETWEEN ? AND ?) AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )", from, to ]) |
| 71 | 71 | end |
| 72 | 72 | |
| 73 | 73 | # |
| 74 | 74 | def self.find_all_articles (curruser) |
| 75 | | @projects = Project.list_for_user(curruser) |
| 75 | @projects = Project.list_for_user(curruser.id) |
| 76 | 76 | find(:all, :conditions => ["status = '#{:published}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC") |
| 77 | 77 | end |
| 78 | 78 | |
| 79 | 79 | # |
| 80 | 80 | def self.find_home (curruser) |
| 81 | | @projects = Project.list_for_user(curruser) |
| 81 | @projects = Project.list_for_user(curruser.id) |
| 82 | 82 | find(:all, :conditions => ["status = '#{:published}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC", :limit => 3) |
| 83 | 83 | end |
| 84 | 84 | |
| 85 | 85 | # finds articles for a user based on the user slug e.g. /profiles/test-user/articles |
| 86 | 86 | def self.find_by_id (id, curruser) |
| 87 | | @projects = Project.list_for_user(curruser) |
| 87 | @projects = Project.list_for_user(curruser.id) |
| 88 | 88 | find(:first, :conditions => ["status = '#{:published}' AND id = '#{id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"]) |
| 89 | 89 | end |
| 90 | 90 | |
| … | … | |
| 95 | 95 | |
| 96 | 96 | # finds articles for a user based on the user slug e.g. /profiles/test-user/articles |
| 97 | 97 | def self.find_by_user (user_id, curruser) |
| 98 | | @projects = Project.list_for_user(curruser) |
| 98 | @projects = Project.list_for_user(curruser.id) |
| 99 | 99 | find(:all, :conditions => ["status = '#{:published}' AND user_id = '#{user_id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC") |
| 100 | 100 | end |
| 101 | 101 | |
| 102 | 102 | # finds articles for a user/project based on the user slug e.g. /profiles/test-user/project/project_id/articles |
| 103 | 103 | def self.find_by_user_project (user_id, project_id, curruser) |
| 104 | | @projects = Project.list_for_user(curruser) |
| 104 | @projects = Project.list_for_user(curruser.id) |
| 105 | 105 | find(:all, :conditions => ["status = '#{:published}' AND user_id = '#{user_id}' AND project_id = '#{project_id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC") |
| 106 | 106 | end |
| 107 | 107 | |
| 108 | 108 | # |
| 109 | 109 | def self.find_by_permalink (permalink, curruser) |
| 110 | | @projects = Project.list_for_user(curruser) |
| 110 | @projects = Project.list_for_user(curruser.id) |
| 111 | 111 | find(:first, :conditions => ["status = '#{:published}' AND permalink = '#{permalink}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"]) |
| 112 | 112 | end |
| 113 | 113 | |
| 114 | 114 | # |
| 115 | 115 | def self.find_by_type (article_type, curruser) |
| 116 | | @projects = Project.list_for_user(curruser) |
| 116 | @projects = Project.list_for_user(curruser.id) |
| 117 | 117 | find(:all, :conditions => ["status = '#{:published}' AND article_type = '#{article_type}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC") |
| 118 | 118 | end |
| 119 | 119 | |
| 120 | 120 | # |
| 121 | 121 | def self.find_by_category (category_id, curruser) |
| 122 | | @projects = Project.list_for_user(curruser) |
| 122 | @projects = Project.list_for_user(curruser.id) |
| 123 | 123 | find(:all, :conditions => ["status = '#{:published}' AND category_id = '#{category_id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC") |
| 124 | 124 | end |
| 125 | 125 | |
| … | … | |
| 130 | 130 | |
| 131 | 131 | # |
| 132 | 132 | def self.find_by_project (project_id, curruser) |
| 133 | | projects_allowed = Project.list_for_user(curruser) |
| 133 | projects_allowed = Project.list_for_user(curruser.id) |
| 134 | 134 | find(:all, :conditions => ["status = '#{:published}' AND project_id = '#{project_id}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC") |
| 135 | 135 | end |
| 136 | 136 | |
| … | … | |
| 146 | 146 | |
| 147 | 147 | # |
| 148 | 148 | def self.find_by_project_and_type (article_type, project_id, curruser) |
| 149 | | projects_allowed = Project.list_for_user(curruser) |
| 149 | projects_allowed = Project.list_for_user(curruser.id) |
| 150 | 150 | find(:all, :conditions => ["status = '#{:published}' AND project_id = '#{project_id}' AND article_type = '#{article_type}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC") |
| 151 | 151 | end |
| 152 | 152 | |
| toggle raw diff |
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -55,7 +55,7 @@ protected
#public version of .count to filter articles you are not authorised to see
def self.public_count (curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
#FIXME is there a faster way of doing this?
@articles = find(:all, :conditions => ["status = '#{:published}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC")
return @articles.size
@@ -66,25 +66,25 @@ protected
#
def self.find_by_date (curruser, year, month = nil, day = nil)
from, to = self.time_delta(year, month, day)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:all, :conditions => [ "status = '#{:published}' AND (created_at BETWEEN ? AND ?) AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )", from, to ])
end
#
def self.find_all_articles (curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:published}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC")
end
#
def self.find_home (curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:published}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC", :limit => 3)
end
# finds articles for a user based on the user slug e.g. /profiles/test-user/articles
def self.find_by_id (id, curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:first, :conditions => ["status = '#{:published}' AND id = '#{id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"])
end
@@ -95,31 +95,31 @@ protected
# finds articles for a user based on the user slug e.g. /profiles/test-user/articles
def self.find_by_user (user_id, curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:published}' AND user_id = '#{user_id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC")
end
# finds articles for a user/project based on the user slug e.g. /profiles/test-user/project/project_id/articles
def self.find_by_user_project (user_id, project_id, curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:published}' AND user_id = '#{user_id}' AND project_id = '#{project_id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC")
end
#
def self.find_by_permalink (permalink, curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:first, :conditions => ["status = '#{:published}' AND permalink = '#{permalink}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"])
end
#
def self.find_by_type (article_type, curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:published}' AND article_type = '#{article_type}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC")
end
#
def self.find_by_category (category_id, curruser)
- @projects = Project.list_for_user(curruser)
+ @projects = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:published}' AND category_id = '#{category_id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC")
end
@@ -130,7 +130,7 @@ protected
#
def self.find_by_project (project_id, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:published}' AND project_id = '#{project_id}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC")
end
@@ -146,7 +146,7 @@ protected
#
def self.find_by_project_and_type (article_type, project_id, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:published}' AND project_id = '#{project_id}' AND article_type = '#{article_type}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC")
end
|
| |   |
| 6 | 6 | protected |
| 7 | 7 | |
| 8 | 8 | def self.find_by_project(project_id, curruser) |
| 9 | | projects_allowed = Project.list_for_user(curruser) |
| 9 | projects_allowed = Project.list_for_user(curruser.id) |
| 10 | 10 | find(:all, :conditions => ["project_id = '#{project_id}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC") |
| 11 | 11 | end |
| 12 | 12 | |
| 13 | 13 | #FIXME maybe expand this to return all tasks so it doesn't need to revisit table so many times |
| 14 | 14 | #to display roadmap, except it's now also used by the project summary tab |
| 15 | 15 | def self.roadmap(project_id, curruser) |
| 16 | | projects_allowed = Project.list_for_user(curruser) |
| 16 | projects_allowed = Project.list_for_user(curruser.id) |
| 17 | 17 | find(:all, :conditions => ["project_id = '#{project_id}' AND NOT status = 'complete' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "due_date ASC") |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | 20 | def self.find_by_project_excl_proposed(project_id, curruser) |
| 21 | | projects_allowed = Project.list_for_user(curruser) |
| 21 | projects_allowed = Project.list_for_user(curruser.id) |
| 22 | 22 | find(:all, :conditions => ["project_id = '#{project_id}' AND status <> '#{:proposed}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC") |
| 23 | 23 | end |
| 24 | 24 | |
| 25 | 25 | def self.find_by_id(milestone_id, curruser) |
| 26 | | projects_allowed = Project.list_for_user(curruser) |
| 26 | projects_allowed = Project.list_for_user(curruser.id) |
| 27 | 27 | #FIXME don't need the ORDER BY as it only returns one result, should probably check for other cases of this |
| 28 | 28 | find(:first, :conditions => ["id = '#{milestone_id}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC") |
| 29 | 29 | end |
| toggle raw diff |
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -6,24 +6,24 @@ class Milestone < ActiveRecord::Base
protected
def self.find_by_project(project_id, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["project_id = '#{project_id}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC")
end
#FIXME maybe expand this to return all tasks so it doesn't need to revisit table so many times
#to display roadmap, except it's now also used by the project summary tab
def self.roadmap(project_id, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["project_id = '#{project_id}' AND NOT status = 'complete' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "due_date ASC")
end
def self.find_by_project_excl_proposed(project_id, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["project_id = '#{project_id}' AND status <> '#{:proposed}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC")
end
def self.find_by_id(milestone_id, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
#FIXME don't need the ORDER BY as it only returns one result, should probably check for other cases of this
find(:first, :conditions => ["id = '#{milestone_id}' AND ( audience = '#{:public}' OR project_id IN (" << projects_allowed << ") )"], :order => "created_at DESC")
end |
| |   |
| 1 | 1 | class Project < ActiveRecord::Base |
| 2 | |
| 2 | 3 | belongs_to :user |
| 3 | 4 | has_many :comments, :dependent => :destroy |
| 5 | has_many :tickets |
| 4 | 6 | has_many :repositories, :order => "repositories.mainline desc, repositories.created_at asc", |
| 5 | 7 | :dependent => :destroy |
| 6 | 8 | has_one :mainline_repository, :conditions => ["mainline = ?", true], |
| … | … | |
| 58 | 58 | end |
| 59 | 59 | |
| 60 | 60 | def self.find_by_slug(slug, curruser) |
| 61 | | projects_allowed = Project.list_for_user(curruser) |
| 61 | projects_allowed = Project.list_for_user(curruser.id) |
| 62 | 62 | find(:first, :conditions => ["status = '#{:active}' AND projects.slug = '#{slug}' AND ( audience = '#{:public}' OR projects.id IN (#{projects_allowed}) )"]) |
| 63 | 63 | end |
| 64 | 64 | |
| … | … | |
| 148 | 148 | |
| 149 | 149 | # |
| 150 | 150 | def self.allowed_access (project_id, curruser) |
| 151 | | projects_allowed = Project.list_for_user(curruser) |
| 151 | projects_allowed = Project.list_for_user(curruser.id) |
| 152 | 152 | find(:first, :conditions => ["status = '#{:active}' AND projects.id = '" << project_id.to_s << "' AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"]) |
| 153 | 153 | end |
| 154 | 154 | |
| 155 | 155 | # |
| 156 | 156 | #FIXME this should maybe show inactive too |
| 157 | 157 | def self.find_by_user(user, curruser) |
| 158 | | projects_allowed = Project.list_for_user(curruser) |
| 158 | projects_allowed = Project.list_for_user(curruser.id) |
| 159 | 159 | projects_available = Project.list_for_user(user) |
| 160 | 160 | find(:all, :conditions => ["status = '#{:active}' AND projects.id IN (" << projects_available << ") AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"]) |
| 161 | 161 | end |
| 162 | 162 | |
| 163 | 163 | # returns all allowed projects |
| 164 | 164 | def self.find_all_projects (curruser) |
| 165 | | projects_allowed = Project.list_for_user(curruser) |
| 165 | projects_allowed = Project.list_for_user(curruser.id) |
| 166 | 166 | find(:all, :conditions => ["status = '#{:active}' AND ( audience = '#{:public}' OR id IN (" << projects_allowed << ") )"]) |
| 167 | 167 | end |
| 168 | 168 | |
| 169 | 169 | def self.find_popular_projects (curruser) |
| 170 | | projects_allowed = Project.list_for_user(curruser) |
| 170 | projects_allowed = Project.list_for_user(curruser.id) |
| 171 | 171 | find(:all, :conditions => ["status = '#{:active}' AND ( audience = '#{:public}' OR id IN (" << projects_allowed << ") )"], :limit => 10, :order => "views DESC") |
| 172 | 172 | end |
| 173 | 173 | |
| 174 | 174 | # returns all public projects (no private regardless of allowed) |
| 175 | 175 | def self.find_all_active_public_projects (curruser) |
| 176 | | projects_allowed = Project.list_for_user(curruser) |
| 176 | projects_allowed = Project.list_for_user(curruser.id) |
| 177 | 177 | find(:all, :conditions => ["status = '#{:active}' AND ( audience = '#{:public}' AND NOT id IN (" << projects_allowed << ") )"]) |
| 178 | 178 | end |
| 179 | 179 | |
| … | … | |
| 187 | 187 | |
| 188 | 188 | # takes a list of project_ids e.g. '1','2','3' |
| 189 | 189 | def self.find_by_list (list, curruser) |
| 190 | | projects_allowed = Project.list_for_user(curruser) |
| 190 | projects_allowed = Project.list_for_user(curruser.id) |
| 191 | 191 | find(:all, :conditions => ["status = '#{:active}' AND id IN (" << list << ") AND ( audience = '#{:public}' AND id IN (" << projects_allowed << ") )"]) |
| 192 | 192 | end |
| 193 | 193 | |
| 194 | 194 | # |
| 195 | 195 | # Get a list of project_ids of a user is a members of in the format '1','2','3' |
| 196 | 196 | # |
| 197 | | def self.list_for_user(user) |
| 198 | | if user |
| 197 | def self.list_for_user(user_id) |
| 198 | if user_id |
| 199 | 199 | list = "" |
| 200 | | projects = Member.find_by_user(user.id) |
| 200 | projects = Member.find_by_user(user_id) |
| 201 | 201 | unless projects.empty? |
| 202 | 202 | start = true |
| 203 | 203 | for project in projects |
| … | … | |
| 221 | 221 | when PRJ_TAB_GIT |
| 222 | 222 | title = "Git" |
| 223 | 223 | url_suffix = "/git/" |
| 224 | | when PRJ_TAB_MEMBERS |
| 225 | | title = "Members" |
| 226 | | url_suffix = "/members/" |
| 224 | when PRJ_TAB_TEAM |
| 225 | title = "Team" |
| 226 | url_suffix = "/team/" |
| 227 | 227 | when PRJ_TAB_WIKI |
| 228 | 228 | title = "Wiki" |
| 229 | 229 | url_suffix = "/wikis/" + wiki_slug |
| toggle raw diff |
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1,6 +1,8 @@
class Project < ActiveRecord::Base
+
belongs_to :user
has_many :comments, :dependent => :destroy
+ has_many :tickets
has_many :repositories, :order => "repositories.mainline desc, repositories.created_at asc",
:dependent => :destroy
has_one :mainline_repository, :conditions => ["mainline = ?", true],
@@ -56,7 +58,7 @@ class Project < ActiveRecord::Base
end
def self.find_by_slug(slug, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:first, :conditions => ["status = '#{:active}' AND projects.slug = '#{slug}' AND ( audience = '#{:public}' OR projects.id IN (#{projects_allowed}) )"])
end
@@ -146,32 +148,32 @@ class Project < ActiveRecord::Base
#
def self.allowed_access (project_id, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:first, :conditions => ["status = '#{:active}' AND projects.id = '" << project_id.to_s << "' AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"])
end
#
#FIXME this should maybe show inactive too
def self.find_by_user(user, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
projects_available = Project.list_for_user(user)
find(:all, :conditions => ["status = '#{:active}' AND projects.id IN (" << projects_available << ") AND ( audience = '#{:public}' OR projects.id IN (" << projects_allowed << ") )"])
end
# returns all allowed projects
def self.find_all_projects (curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:active}' AND ( audience = '#{:public}' OR id IN (" << projects_allowed << ") )"])
end
def self.find_popular_projects (curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:active}' AND ( audience = '#{:public}' OR id IN (" << projects_allowed << ") )"], :limit => 10, :order => "views DESC")
end
# returns all public projects (no private regardless of allowed)
def self.find_all_active_public_projects (curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:active}' AND ( audience = '#{:public}' AND NOT id IN (" << projects_allowed << ") )"])
end
@@ -185,17 +187,17 @@ class Project < ActiveRecord::Base
# takes a list of project_ids e.g. '1','2','3'
def self.find_by_list (list, curruser)
- projects_allowed = Project.list_for_user(curruser)
+ projects_allowed = Project.list_for_user(curruser.id)
find(:all, :conditions => ["status = '#{:active}' AND id IN (" << list << ") AND ( audience = '#{:public}' AND id IN (" << projects_allowed << ") )"])
end
#
# Get a list of project_ids of a user is a members of in the format '1','2','3'
#
- def self.list_for_user(user)
- if user
+ def self.list_for_user(user_id)
+ if user_id
list = ""
- projects = Member.find_by_user(user.id)
+ projects = Member.find_by_user(user_id)
unless projects.empty?
start = true
for project in projects
@@ -219,9 +221,9 @@ class Project < ActiveRecord::Base
when PRJ_TAB_GIT
title = "Git"
url_suffix = "/git/"
- when PRJ_TAB_MEMBERS
- title = "Members"
- url_suffix = "/members/"
+ when PRJ_TAB_TEAM
+ title = "Team"
+ url_suffix = "/team/"
when PRJ_TAB_WIKI
title = "Wiki"
url_suffix = "/wikis/" + wiki_slug |