Commit fe66613953dbb943829fdff0a8cb54d2a675b389

Added summary tab
Refactored other tabs
Project now uses a wiki slug not id
Changed project.description to project.summary
Browser title fixes

Commit diff

app/controllers/activities_controller.rb

 
0class ActivitiesController < ApplicationController
1
2 before_filter :find_project
3
4 def index
5 @title, @url_suffix = Project.tab_settings(PRJ_TAB_ACTIVITIES)
6 @members = Member.find_by_project_alpha(@project.id)
7 if @is_member
8 @messages = Message.find_by_project_user(@project.id, current_user.id, 40)
9 else
10 @messages = Message.find_by_project(@project.id, 40)
11 end
12 render :action => "ac_project_index"
13 end
14
15 def create
16 @message = Message.new(params[:message])
17 @message.user_id = current_user.id
18 @message.project_id = @project.id
19 if @message.save
20 Journal.create(@message, request.env["REMOTE_ADDR"], @project.id, current_user.id).to_s
21 redirect_to project_activities_path(@project.slug)
22 else
23 #FIXME this is wrong I think
24 flash[:error] = 'Error.'
25 render :action => 'ac_project_new'
26 end
27 end
28
29end
toggle raw diff

app/controllers/articles_controller.rb

 
5959 original_article = @article.deep_clone
6060 if @article.update_attributes(params[:article])
6161 @article.save
62 Journal.update(original_article, @article, request.env["REMOTE_ADDR"], @project.id, current_user.id)
62 Journal.update(original_article, @article, request.env["REMOTE_ADDR"], @project.id, current_user.id, "Edited article: \'" + @article.title + "\'.")
6363 flash[:notice] = "Article was successfully updated."
6464 redirect_to project_articles_path(@project)
6565 else
7777
7878 def destroy
7979 if @is_member
80 flash[:notice] = 'Article deleted.'
8180 @article = Article.find(params[:id])
82 @article.status = :deleted
83 @article.save
84 redirect_to project_articles_path(@project)
81 if @article
82 original_article = Article.new
83 original_article = @article.deep_clone
84 @article.status = :deleted
85 if @article.save
86 Journal.update(original_article, @article, request.env["REMOTE_ADDR"], @project.id, current_user.id, "Deleted article: \'" + @article.title + "\'.")
87 flash[:notice] = 'Article deleted.'
88 else
89 #TODO add error report
90 flash[:error] = 'An error occurred.'
91 end
92 redirect_to project_articles_path(@project)
93 else
94 flash[:error] = 'Article ' + params[:id] + ' does not exist.'
95 redirect_to project_articles_path(@project)
96 end
8597 end
86 rescue ActiveRecord::RecordNotFound
87 flash[:error] = 'Article ' + params[:id] + ' does not exist.'
88 redirect_to project_articles_path(@project)
8998 end
9099
91100 # Show all articles /2008 or /2008/11 or /2008/11/1 and render grouped by date
toggle raw diff

app/controllers/members_controller.rb

 
11class MembersController < ApplicationController
22
33 before_filter :find_project
4
5 def index
6 @title, @url_suffix = Project.tab_settings(PRJ_TAB_MEMBERS)
7 @members = Member.find_by_project_alpha(@project.id)
8 if @is_member
9 @messages = Message.find_by_project_user(@project.id, current_user.id, 40)
10 else
11 @messages = Message.find_by_project(@project.id, 40)
12 end
13 render :action => "ac_project_index"
14 end
415
516end
toggle raw diff

app/controllers/messages_controller.rb

 
1class MessagesController < ApplicationController
2
3 #before_filter :find_project
4
5 def create
6 @message = Message.new(params[:message])
7 @message.user_id = current_user.id
8 @message.project_id = @project.id
9 if @message.save
10 Journal.create(@message, request.env["REMOTE_ADDR"], @project.id, current_user.id).to_s
11 redirect_to project_members_path(@project.slug)
12 else
13 #FIXME this is wrong I think
14 flash[:error] = 'Error.'
15 render :action => 'ac_project_new'
16 end
17 end
18
19end
toggle raw diff

app/controllers/projects_controller.rb

 
3131 end
3232
3333 def show
34 @wiki = @project.wiki
35 @title = @wiki.title
34# @wiki = @project.wiki
35 @title = "Summary"
3636 @url_suffix = ""
3737 render :action => "ac_show"
3838 end
8484 end
8585
8686 def roadmap
87 @title, @url_suffix = Project.tab_settings(PRJ_TAB_ROADMAP)
87 @title, @url_suffix = Project.tab_settings(PRJ_TAB_SUMMARY)
8888 render :action => "ac_roadmap"
8989 end
9090
9292 # Project events index page, shows list of all wikis for that project
9393 @events = Event.find_by_project(@project.id)
9494 if @events.size > 0
95 @title = "Events"
95 @title = "Log"
9696 @url_suffix = ""
9797 render :action => "ac_log_index"
9898 else
99 flash[:error] = "No events for this project."
99 flash[:error] = "No log for this project."
100100 redirect_to project_path(@project.slug)
101101 end
102102 end
toggle raw diff

app/controllers/repositories_controller.rb

 
99 def index
1010 if @project
1111 @repositories = @project.repositories.find(:all)
12 @title, @url_suffix = Project.tab_settings(PRJ_TAB_REPOS)
12 @title, @url_suffix = Project.tab_settings(PRJ_TAB_GIT)
1313 render :action => "ac_index"
1414 else
1515 flash[:error] = "Project not found."
toggle raw diff

app/controllers/tickets_controller.rb

 
44
55 def index
66 @title, @url_suffix = Project.tab_settings(PRJ_TAB_TICKETS)
7 @tickets = Ticket.filtered(params[:ticket] ? params[:ticket] : "")
78 render :action => "ac_project_index"
89 end
910
toggle raw diff

app/controllers/wikis_controller.rb

 
99 # Project Wiki index page, shows list of all wikis for that project
1010 @wikis = Wiki.find_by_project(@project.id)
1111 if @wikis.size > 0
12 @title = "List Wikis"
12 @title = "Wiki"
1313 @url_suffix = ""
1414 render :action => "ac_project_index"
1515 else
117117 original_wiki = @wiki.deep_clone
118118 if @wiki.update_attributes(params[:wiki])
119119 @wiki.save
120 Journal.update(original_wiki, @wiki, request.env["REMOTE_ADDR"], @project.id, current_user.id)
120 Journal.update(original_wiki, @wiki, request.env["REMOTE_ADDR"], @project.id, current_user.id, "Edited wiki: \'" + @wiki.title + "\'.")
121121 flash[:notice] = "Wiki was successfully updated."
122122 @title = @wiki.title
123123 render :action => "ac_project_show"
143143
144144 def destroy
145145 if @is_member
146 flash[:notice] = 'Wiki deleted.'
147146 @wiki = Wiki.find(params[:id])
148 @wiki.status = :deleted
149 @wiki.save
150 redirect_to project_wikis_path(@project)
147 if @wiki
148 original_wiki = Wiki.new
149 original_wiki = @wiki.deep_clone
150 @wiki.status = :deleted
151 if @wiki.save
152 Journal.update(original_wiki, @wiki, request.env["REMOTE_ADDR"], @project.id, current_user.id, "Deleted wiki: \'" + @wiki.title + "\'.")
153 flash[:notice] = 'Wiki deleted.'
154 else
155 #TODO add error report
156 flash[:error] = 'An error occurred.'
157 end
158 redirect_to project_wikis_path(@project)
159 else
160 flash[:error] = 'Wiki ' + params[:id] + ' does not exist.'
161 redirect_to project_wikis_path(@project)
162 end
163
164# else
165# flash[:error] = 'xxxxxxxxxx'
166# redirect_to root_path
151167 end
152 rescue ActiveRecord::RecordNotFound
153 flash[:error] = 'Wiki ' + params[:id] + ' does not exist.'
154 redirect_to project_wikis_path(@project)
155168 end
156169
157
158170 #FIXME
159171 def to_slug(s)
160172 s.gsub(/\W+/, ' ').strip.downcase.gsub(/\ +/, '-')
161173 end
162174
163
164175protected
165176
166177 # Increase view count for a wiki page
toggle raw diff

app/helpers/activities_helper.rb

 
0module ActivitiesHelper
1
2 include ProjectsHelper
3
4end
toggle raw diff

app/helpers/application_helper.rb

 
150150 end
151151
152152 def breadcrumb_repositories
153 %Q{<li>#{link_to("Repos", project_repositories_path(@project))}<span> / </span></li>}
153 %Q{<li>#{link_to("Git", project_repositories_path(@project))}<span> / </span></li>}
154154 end
155155
156156 def breadcrumb_repository
334334 acts << %Q{<li>#{link_to("New Article", new_project_article_path(@project.slug))}</li>} if flags[:new_article] && is_member
335335 acts << %Q{<li>#{link_to("New Ticket", new_project_ticket_path(@project.slug))}</li>} if flags[:new_ticket]
336336 acts << %Q{<li>#{link_to("New Milestone", new_project_milestone_path(@project.slug))}</li>} if flags[:new_milestone] && is_member
337 acts << %Q{<li>#{link_to("Current Milestones", root_path)}</li>} if flags[:current_milestones]
337338 acts << %Q{<li>#{link_to("Completed Milestones", root_path)}</li>} if flags[:completed_milestones]
338339 acts << %Q{<li>#{link_to("Clone Mainline", new_project_repository_path(@project.slug, @repository))}</li>} if flags[:clone_mainline] && logged_in?
339340 out << %Q{<tr><td><ul>#{acts}</ul></td></tr>} if acts != ""
toggle raw diff

app/helpers/projects_helper.rb

 
2323 out
2424 end
2525
26 def render_right_project_contributors
26 def render_right_project_members
2727 out = ""
2828 members = Member.find_by_project(@project.id)
2929 if members.size > 0 then
3030 out << "<table class='right_default_table'>"
31 out << "<tr><th>Contributors</th></tr>"
31 out << "<tr><th>Members</th></tr>"
3232 for member in members
3333 #TODO only display admin/modify members
3434 out << %Q{<tr><td>#{link_to_profile(member.user)} <small><span style='color: #888'>(#{format_member_accesslevel(member.accesslevel)})</span></small></td></tr>} if member.accesslevel != :user
6262 def render_project_tabs (active_tab)
6363 out = ""
6464 out << "<ul id='tabmenu'>"
65 out << project_tab(active_tab, PRJ_TAB_WIKI)
66 out << project_tab(active_tab, PRJ_TAB_REPOS)
67 out << project_tab(active_tab, PRJ_TAB_ACTIVITIES)
68 out << project_tab(active_tab, PRJ_TAB_ROADMAP)
65 out << project_tab(active_tab, PRJ_TAB_SUMMARY)
66 out << project_tab(active_tab, PRJ_TAB_GIT)
67 out << project_tab(active_tab, PRJ_TAB_MEMBERS)
6968 out << project_tab(active_tab, PRJ_TAB_TICKETS)
69 out << project_tab(active_tab, PRJ_TAB_WIKI)
7070 out << project_tab(active_tab, PRJ_TAB_ARTICLES)
7171 out << project_tab(active_tab, PRJ_TAB_FORUM)
7272 out << project_tab(active_tab, PRJ_TAB_LOG)
7878 def breadcrumb_repos_tab(subtab)
7979 subtab == PRJ_TAB_SUBTAB_NONE ? out = "" : out = breadcrumb_repositories
8080 case subtab
81 when PRJ_TAB_REPOS_LOGS
81 when PRJ_TAB_GIT_LOGS
8282 out << breadcrumb_repository
83 when PRJ_TAB_REPOS_COMMIT
83 when PRJ_TAB_GIT_COMMIT
8484 out << breadcrumb_repository
8585 out << breadcrumb_repos_logs
86 when PRJ_TAB_REPOS_TREE
86 when PRJ_TAB_GIT_TREE
8787 out << breadcrumb_repository
88 when PRJ_TAB_REPOS_MERGEREQUESTS
88 when PRJ_TAB_GIT_MERGEREQUESTS
8989 end
9090 out
9191 end
100100 def render_right_column_project (tab, subtab)
101101 out = ""
102102 case tab
103 when PRJ_TAB_WIKI
104 case subtab
105 when PRJ_TAB_WIKI_EDIT, PRJ_TAB_WIKI_NEW
106 out << actionbox_basic(:allow_shortcuts => true)
107 when PRJ_TAB_WIKI_LIST
108 out << actionbox_complex(:allow_shortcuts => true, :new_project_wiki => true)
109 else
110 out << actionbox_complex(:allow_shortcuts => true, :edit_project_wiki => true, :new_project_wiki => true, :list_project_wikis => true)
111 out << render_right_project_extrainfo
112 out << render_right_project_contributors
113 end
114 when PRJ_TAB_ACTIVITIES
115 out << actionbox_basic(:allow_shortcuts => true)
116 out << render(:partial => "ac_right_actionbox_post_message") if @is_member
117 when PRJ_TAB_REPOS
103 when PRJ_TAB_SUMMARY
104 out << actionbox_complex(:allow_shortcuts => true)
105 out << render_right_project_extrainfo
106 out << render_right_project_members
107 when PRJ_TAB_GIT
118108 case subtab
119109 when PRJ_TAB_SUBTAB_NONE
120110 out << actionbox_complex(:allow_shortcuts => true, :clone_mainline => true)
121 when PRJ_TAB_REPOS_SUMMARY
111 when PRJ_TAB_GIT_SUMMARY
122112 out << render(:partial => "repositories/ac_right_actionbox_repos_summary")
123 when PRJ_TAB_REPOS_LOGS
113 when PRJ_TAB_GIT_LOGS
124114 out << actionbox_basic(:allow_shortcuts => true)
125115 out << render(:partial => "repositories/ac_right_branches")
126 when PRJ_TAB_REPOS_COMMIT
116 when PRJ_TAB_GIT_COMMIT
127117 out << actionbox_basic(:allow_shortcuts => true)
128118 out << render(:partial => "commits/ac_right_diff_mode_selector")
129 when PRJ_TAB_REPOS_TREE
119 when PRJ_TAB_GIT_TREE
130120 out << actionbox_basic(:allow_shortcuts => true)
131121 out << render(:partial => "trees/ac_right_branches")
132 when PRJ_TAB_REPOS_MERGEREQUESTS
122 when PRJ_TAB_GIT_MERGEREQUESTS
133123 out << actionbox_basic(:allow_shortcuts => true)
134124 end
135 when PRJ_TAB_ROADMAP
136 out << actionbox_complex(:allow_shortcuts => true, :new_milestone => true, :completed_milestones => true)
125 when PRJ_TAB_MEMBERS
126 out << actionbox_basic(:allow_shortcuts => true)
127 out << render(:partial => "ac_right_actionbox_post_message") if @is_member
128 out << render_right_project_members
137129 when PRJ_TAB_TICKETS
138 out << actionbox_complex(:allow_shortcuts => true, :new_ticket => true)
130 out << actionbox_complex(:allow_shortcuts => true, :new_ticket => true, :new_milestone => true, :completed_milestones => true, :current_milestones => true)
139131 out << render(:partial => "ac_right_ticket_filter")
132 when PRJ_TAB_WIKI
133 case subtab
134 when PRJ_TAB_WIKI_EDIT, PRJ_TAB_WIKI_NEW
135 out << actionbox_basic(:allow_shortcuts => true)
136 when PRJ_TAB_WIKI_LIST
137 out << actionbox_complex(:allow_shortcuts => true, :new_project_wiki => true)
138 else
139 out << actionbox_complex(:allow_shortcuts => true, :edit_project_wiki => true, :new_project_wiki => true, :list_project_wikis => true)
140 end
140141 when PRJ_TAB_ARTICLES
141142 case subtab
142143 when PRJ_TAB_ARTICLES_EDIT, PRJ_TAB_ARTICLES_NEW
toggle raw diff

app/helpers/tickets_helper.rb

 
11module TicketsHelper
22
33 include ProjectsHelper
4
5 def render_project_tickets
6 out = ""
7 @tickets = Ticket.filtered(params[:ticket] ? params[:ticket] : "")
8 if @tickets.size > 0 then
9 # tasks list
10 out << "<table class='public' width='100%'>"
11 out << "<tr>"
12 out << "<th></th>"
13 out << "<th>Task</th>"
14 out << "<th>Assignee</th>"
15 out << "<th>Type</th>"
16 out << "<th>Status</th>"
17 out << "<th>Impact</th>"
18 out << "<th>Priority</th>"
19 out << "</tr>"
20 #
21 for ticket in @tickets
22 out << "<tr>"
23 out << "<td>" << ticket.name << "</td>"
24 out << "<td>" << ticket.title << "</td>"
25 out << "<td>" << ticket.fullname << "</td>"
26 out << "<td>" << ticket.ttype.to_s.capitalize << "</td>"
27 out << "<td>" << ticket.status.to_s.capitalize << "</td>"
28 out << "<td>" << ticket.impact.to_s.capitalize << "</td>"
29 out << "<td>" << ticket.priority.to_s.capitalize << "</td>"
30 out << "</tr>"
31 end
32 out << "</table>"
33 out << "<br />"
34 end
35 out
36 end
374
385 def ticket_value_checked? (v)
396 params[:ticket][v] == "1" ? "checked" : "" if params[:ticket]
toggle raw diff

app/models/journal.rb

 
8080 # ip: IP address
8181 # user_id: user id of changer
8282 #
83 def self.update (original_model, updated_model, ip, project_id, user_id)
83 def self.update (original_model, updated_model, ip, project_id, user_id, summary)
8484
8585 # record that something has happened
8686 journal = Journal.new
8989 journal.row_id = updated_model.id
9090 journal.ip = ip
9191 journal.user_id = user_id
92 journal.summary = "Updated " << updated_model.class.to_s
92 journal.summary = summary
9393 #TODO check saves okay
9494 journal.save
9595 #
toggle raw diff

app/models/project.rb

 
228228
229229 def self.tab_settings (tab)
230230 case tab
231 when PRJ_TAB_SUMMARY
232 title = "Summary"
233 url_suffix = "/"
234 when PRJ_TAB_GIT
235 title = "Git"
236 url_suffix = "/git/"
237 when PRJ_TAB_MEMBERS
238 title = "Members"
239 url_suffix = "/members/"
231240 when PRJ_TAB_WIKI
232241 title = "Wiki"
233 url_suffix = ""
234 when PRJ_TAB_ACTIVITIES
235 title = "Activity"
236 url_suffix = "/activities"
237 when PRJ_TAB_REPOS
238 title = "Repositories"
239 url_suffix = "/repos"
240 when PRJ_TAB_ROADMAP
241 title = "Roadmap"
242 url_suffix = "/roadmap"
242 url_suffix = "/wikis/"
243243 when PRJ_TAB_TICKETS
244244 title = "Tickets"
245 url_suffix = "/tickets"
245 url_suffix = "/tickets/"
246246 when PRJ_TAB_ARTICLES
247247 title = "Articles"
248 url_suffix = "/articles"
248 url_suffix = "/articles/"
249249 when PRJ_TAB_FORUM
250250 title = "Forum"
251 url_suffix = "/forum"
251 url_suffix = "/forum/"
252252 when PRJ_TAB_LOG
253253 title = "Log"
254 url_suffix = "/log"
254 url_suffix = "/log/"
255255 when PRJ_TAB_CONFIG
256256 title = "Config"
257 url_suffix = "/config"
257 url_suffix = "/config/"
258258 end
259259 return title, url_suffix
260260 end
toggle raw diff

app/models/ticket.rb

 
55
66 belongs_to :assignee, :class_name => 'User', :foreign_key => 'assignee_id'
77 belongs_to :submitter, :class_name => 'User', :foreign_key => 'submitter_id'
8
9 def formatted_ttype
10 case self.ttype
11 when :enhancement
12 "Enh."
13 when :task
14 "Task"
15 when :defect
16 "Def."
17 end
18 end
819
920 protected
1021
6767 JOIN users ON tickets.assignee_id = users.id
6868 LEFT JOIN milestones ON tickets.milestone_id = milestones.id
6969 #{w}
70 ORDER BY milestones.due_date DESC, priority")
70 ORDER BY milestones.due_date ASC, priority DESC")
7171 end
7272
7373 def self.generate_key(length = 6)
toggle raw diff

app/views/activities/_ac_right_actionbox_post_message.html.erb

 
0
1<% form_for :message, :url => project_activities_path(@project.slug), :method => :post, :html => {:name => 'postmessage', :id => 'input'} do |f| -%>
2
3 <h2>Post Message</h2>
4
5 <p>Add your current activity:</p>
6
7 <%= f.text_area(:activity, :rows => 4) -%>
8
9 <p>
10 <a href="javascript:document.postmessage.submit();">Update</a>
11 </p>
12
13<% end -%>
toggle raw diff

app/views/activities/ac_project_index.html.erb

 
0<%= render :partial => "projects/ac_project_header", :locals => { :tab => PRJ_TAB_ACTIVITIES,
1 :subtab => PRJ_TAB_SUBTAB_NONE,
2 :project => @project,
3 :pagetitle => @title } %>
4
5<% if @is_member && @members.size > 1 %>
6<div id='projectmembers'>
7<ul>
8<% @members.each do |m| %>
9 <% if m.user != current_user %>
10 <li><%= m.user.fullname %></li>
11 <% end %>
12<% end %>
13</ul>
14</div>
15<% end %>
16
17<%= div_formattedtext_open %>
18
19<ul>
20<% @messages.each do |m| %>
21 <li>
22 <% unless @is_member %>
23 <strong><%= m.user.fullname %></strong>
24 <% end %>
25 <%= m.activity %>
26 <small>(<%= time_ago_in_words(m.created_at) %> ago)</small>
27 </li>
28<% end %>
29</ul>
30
31<%= div_formattedtext_close %>
32
33<%= render :partial => "projects/ac_project_footer" %>
toggle raw diff