Commit dd59a484 authored by jplang's avatar jplang

Added project module concept.

A project module (eg. issue tracking, news, wiki,...) is a set of permissions that can enabled/disabled at project level.
For each project, modules can be enabled on the project settings view ('Modules' tab).
This requires a specific permission: 'Select project modules' (if this permission is turned off, only Redmine administrators can choose which modules a project uses).

When applying this migration, all modules are enabled for all existing projects.

git-svn-id: https://svn.redmine.org/redmine/trunk@725 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 718c184c
......@@ -17,13 +17,23 @@
class MembersController < ApplicationController
layout 'base'
before_filter :find_project, :authorize
before_filter :find_member, :except => :new
before_filter :find_project, :only => :new
before_filter :authorize
def new
@project.members << Member.new(params[:member]) if request.post?
respond_to do |format|
format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project }
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} }
end
end
def edit
if request.post? and @member.update_attributes(params[:member])
respond_to do |format|
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/members'} }
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} }
end
end
end
......@@ -32,12 +42,18 @@ class MembersController < ApplicationController
@member.destroy
respond_to do |format|
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/members'} }
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'projects/settings/members'} }
end
end
private
def find_project
@project = Project.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
def find_member
@member = Member.find(params[:id])
@project = @member.project
rescue ActiveRecord::RecordNotFound
......
......@@ -73,16 +73,9 @@ class ProjectsController < ApplicationController
else
@project.custom_fields = CustomField.find(params[:custom_field_ids]) if params[:custom_field_ids]
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => (params[:custom_fields] ? params["custom_fields"][x.id.to_s] : nil)) }
@project.custom_values = @custom_values
if params[:repository_enabled] && params[:repository_enabled] == "1"
@project.repository = Repository.factory(params[:repository_scm])
@project.repository.attributes = params[:repository]
end
if "1" == params[:wiki_enabled]
@project.wiki = Wiki.new
@project.wiki.attributes = params[:wiki]
end
@project.custom_values = @custom_values
if @project.save
@project.enabled_module_names = params[:enabled_modules]
flash[:notice] = l(:notice_successful_create)
redirect_to :controller => 'admin', :action => 'projects'
end
......@@ -107,6 +100,8 @@ class ProjectsController < ApplicationController
@issue_category ||= IssueCategory.new
@member ||= @project.members.new
@custom_values ||= ProjectCustomField.find(:all).collect { |x| @project.custom_values.find_by_custom_field_id(x.id) || CustomValue.new(:custom_field => x) }
@repository ||= @project.repository
@wiki ||= @project.wiki
end
# Edit @project
......@@ -117,24 +112,6 @@ class ProjectsController < ApplicationController
@custom_values = ProjectCustomField.find(:all).collect { |x| CustomValue.new(:custom_field => x, :customized => @project, :value => params["custom_fields"][x.id.to_s]) }
@project.custom_values = @custom_values
end
if params[:repository_enabled]
case params[:repository_enabled]
when "0"
@project.repository = nil
when "1"
@project.repository ||= Repository.factory(params[:repository_scm])
@project.repository.update_attributes params[:repository] if @project.repository
end
end
if params[:wiki_enabled]
case params[:wiki_enabled]
when "0"
@project.wiki.destroy if @project.wiki
when "1"
@project.wiki ||= Wiki.new
@project.wiki.update_attributes params[:wiki]
end
end
@project.attributes = params[:project]
if @project.save
flash[:notice] = l(:notice_successful_update)
......@@ -145,6 +122,11 @@ class ProjectsController < ApplicationController
end
end
end
def modules
@project.enabled_module_names = params[:enabled_modules]
redirect_to :action => 'settings', :id => @project, :tab => 'modules'
end
def archive
@project.archive if request.post? && @project.active?
......@@ -195,25 +177,6 @@ class ProjectsController < ApplicationController
end
end
# Add a new member to @project
def add_member
@member = @project.members.build(params[:member])
if request.post? && @member.save
respond_to do |format|
format.html { redirect_to :action => 'settings', :tab => 'members', :id => @project }
format.js { render(:update) {|page| page.replace_html "tab-content-members", :partial => 'members'} }
end
else
settings
render :action => 'settings'
end
end
# Show members list of @project
def list_members
@members = @project.members.find(:all)
end
# Add a new document to @project
def add_document
@categories = Enumeration::get_values('DCAT')
......
......@@ -21,10 +21,29 @@ require 'digest/sha1'
class RepositoriesController < ApplicationController
layout 'base'
before_filter :find_project, :except => [:update_form]
before_filter :authorize, :except => [:update_form]
before_filter :find_repository, :except => :edit
before_filter :find_project, :only => :edit
before_filter :authorize
accept_key_auth :revisions
def edit
@repository = @project.repository
if !@repository
@repository = Repository.factory(params[:repository_scm])
@repository.project = @project
end
if request.post?
@repository.attributes = params[:repository]
@repository.save
end
render(:update) {|page| page.replace_html "tab-content-repository", :partial => 'projects/settings/repository'}
end
def destroy
@repository.destroy
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'repository'
end
def show
# check if new revisions have been committed in the repository
@repository.fetch_changesets if Setting.autofetch_changesets?
......@@ -113,14 +132,15 @@ class RepositoriesController < ApplicationController
end
end
def update_form
@repository = Repository.factory(params[:repository_scm])
render :partial => 'projects/repository', :locals => {:repository => @repository}
end
private
def find_project
@project = Project.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
def find_repository
@project = Project.find(params[:id])
@repository = @project.repository
render_404 and return false unless @repository
@path = params[:path].squeeze('/') if params[:path]
......
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class WikisController < ApplicationController
layout 'base'
before_filter :find_project, :authorize
# Create or update a project's wiki
def edit
@wiki = @project.wiki || Wiki.new(:project => @project)
@wiki.attributes = params[:wiki]
@wiki.save if @request.post?
render(:update) {|page| page.replace_html "tab-content-wiki", :partial => 'projects/settings/wiki'}
end
# Delete a project's wiki
def destroy
if request.post? && params[:confirm] && @project.wiki
@project.wiki.destroy
redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'wiki'
end
end
private
def find_project
@project = Project.find(params[:id])
rescue ActiveRecord::RecordNotFound
render_404
end
end
......@@ -26,6 +26,19 @@ module ProjectsHelper
}, options
end
def project_settings_tabs
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
{:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository},
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}
]
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
end
# Generates a gantt image
# Only defined if RMagick is avalaible
def gantt_image(events, date_from, months, zoom)
......
......@@ -29,13 +29,13 @@ module RepositoriesHelper
send(method, form, repository) if repository.is_a?(Repository) && respond_to?(method)
end
def scm_select_tag
def scm_select_tag(repository)
container = [[]]
REDMINE_SUPPORTED_SCM.each {|scm| container << ["Repository::#{scm}".constantize.scm_name, scm]}
select_tag('repository_scm',
options_for_select(container, @project.repository.class.name.demodulize),
:disabled => (@project.repository && !@project.repository.new_record?),
:onchange => remote_function(:update => "repository_fields", :url => { :controller => 'repositories', :action => 'update_form', :id => @project }, :with => "Form.serialize(this.form)")
options_for_select(container, repository.class.name.demodulize),
:disabled => (repository && !repository.new_record?),
:onchange => remote_function(:url => { :controller => 'repositories', :action => 'edit', :id => @project }, :method => :get, :with => "Form.serialize(this.form)")
)
end
......
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class EnabledModule < ActiveRecord::Base
belongs_to :project
validates_presence_of :name
validates_uniqueness_of :name, :scope => :project_id
end
......@@ -23,6 +23,7 @@ class Project < ActiveRecord::Base
has_many :members, :dependent => :delete_all, :include => :user, :conditions => "#{User.table_name}.status=#{User::STATUS_ACTIVE}"
has_many :users, :through => :members
has_many :custom_values, :dependent => :delete_all, :as => :customized
has_many :enabled_modules, :dependent => :delete_all
has_many :issues, :dependent => :destroy, :order => "#{Issue.table_name}.created_on DESC", :include => [:status, :tracker]
has_many :issue_changes, :through => :issues, :source => :journals
has_many :versions, :dependent => :destroy, :order => "#{Version.table_name}.effective_date DESC, #{Version.table_name}.name DESC"
......@@ -38,7 +39,7 @@ class Project < ActiveRecord::Base
has_and_belongs_to_many :custom_fields, :class_name => 'IssueCustomField', :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", :association_foreign_key => 'custom_field_id'
acts_as_tree :order => "name", :counter_cache => true
attr_protected :status
attr_protected :status, :enabled_module_names
validates_presence_of :name, :description, :identifier
validates_uniqueness_of :name, :identifier
......@@ -121,10 +122,43 @@ class Project < ActiveRecord::Base
def <=>(project)
name <=> project.name
end
def allows_to?(action)
if action.is_a? Hash
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
else
allowed_permissions.include? action
end
end
def module_enabled?(module_name)
module_name = module_name.to_s
enabled_modules.detect {|m| m.name == module_name}
end
def enabled_module_names=(module_names)
enabled_modules.clear
module_names = [] unless module_names && module_names.is_a?(Array)
module_names.each do |name|
enabled_modules << EnabledModule.new(:name => name.to_s)
end
end
protected
def validate
errors.add(parent_id, " must be a root project") if parent and parent.parent
errors.add_to_base("A project with subprojects can't be a subproject") if parent and children.size > 0
end
private
def allowed_permissions
@allowed_permissions ||= begin
module_names = enabled_modules.collect {|m| m.name}
Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name}
end
end
def allowed_actions
@actions_allowed ||= allowed_permissions.inject([]) { |actions, permission| actions += Redmine::AccessControl.allowed_actions(permission) }.flatten
end
end
......@@ -178,8 +178,13 @@ class User < ActiveRecord::Base
# * a parameter-like Hash (eg. :controller => 'projects', :action => 'edit')
# * a permission Symbol (eg. :edit_project)
def allowed_to?(action, project)
# No action allowed on archived projects
return false unless project.active?
# No action allowed on disabled modules
return false unless project.allows_to?(action)
# Admin users are authorized for anything else
return true if admin?
role = role_for_project(project)
return false unless role
role.allowed_to?(action) && (project.is_public? || role.member?)
......
......@@ -2,5 +2,5 @@
<% labelled_tabular_form_for :category, @category, :url => { :action => 'edit', :id => @category } do |f| %>
<%= render :partial => 'issue_categories/form', :locals => { :f => f } %>
<%= submit_tag l(:button_create) %>
<%= submit_tag l(:button_save) %>
<% end %>
......@@ -71,7 +71,7 @@
<% if @project && !@project.new_record? %>
<h2><%= @project.name %></h2>
<ul class="menublock">
<% Redmine::MenuManager.allowed_items(:project_menu, current_role).each do |item| %>
<% Redmine::MenuManager.allowed_items(:project_menu, User.current, @project).each do |item| %>
<% unless item.condition && !item.condition.call(@project) %>
<li><%= link_to l(item.name), {item.param => @project}.merge(item.url) %></li>
<% end %>
......
<% labelled_tabular_form_for :project, @project, :url => { :action => "edit", :id => @project } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>
......@@ -28,32 +28,6 @@
<!--[eoform:project]-->
</div>
<div class="box">
<h3><%= check_box_tag "repository_enabled", 1, !@project.repository.nil?, :onclick => "Element.toggle('repository');" %> <%= l(:label_repository) %></h3>
<%= hidden_field_tag "repository_enabled", 0 %>
<div id="repository">
<p class="tabular"><label>SCM</label><%= scm_select_tag %></p>
<div id="repository_fields">
<%= render :partial => 'projects/repository', :locals => {:repository => @project.repository} if @project.repository %>
</div>
</div>
</div>
<%= javascript_tag "Element.hide('repository');" if @project.repository.nil? %>
<div class="box">
<h3><%= check_box_tag "wiki_enabled", 1, !@project.wiki.nil?, :onclick => "Element.toggle('wiki');" %> <%= l(:label_wiki) %></h3>
<%= hidden_field_tag "wiki_enabled", 0 %>
<div id="wiki">
<% fields_for :wiki, @project.wiki, { :builder => TabularFormBuilder, :lang => current_language} do |wiki| %>
<p><%= wiki.text_field :start_page, :size => 60, :required => true %><br /><em><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em></p>
<% # content_tag("div", "", :id => "wiki_start_page_auto_complete", :class => "auto_complete") +
# auto_complete_field("wiki_start_page", { :url => { :controller => 'wiki', :action => 'auto_complete_for_wiki_page', :id => @project } })
%>
<% end %>
</div>
<%= javascript_tag "Element.hide('wiki');" if @project.wiki.nil? %>
</div>
<% content_for :header_tags do %>
<%= javascript_include_tag 'calendar/calendar' %>
<%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
......
<% fields_for :repository, repository, { :builder => TabularFormBuilder, :lang => current_language} do |f| %>
<%= repository_field_tags(f, repository) %>
<% end %>
......@@ -2,5 +2,14 @@
<% labelled_tabular_form_for :project, @project, :url => { :action => "add" } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<div class="box">
<p><label><%= l(:label_module_plural) %></label>
<% Redmine::AccessControl.available_project_modules.each do |m| %>
<%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) %> <%= m.to_s.humanize %>
<% end %></p>
</div>
<%= submit_tag l(:button_save) %>
<% end %>
\ No newline at end of file
<% end %>
......@@ -2,83 +2,15 @@
<div class="tabs">
<ul>
<li><%= link_to l(:label_information_plural), {}, :id=> "tab-info", :onclick => "showTab('info'); this.blur(); return false;" %></li>
<li><%= link_to l(:label_member_plural), {}, :id=> "tab-members", :onclick => "showTab('members'); this.blur(); return false;" %></li>
<li><%= link_to l(:label_version_plural), {}, :id=> "tab-versions", :onclick => "showTab('versions'); this.blur(); return false;" %></li>
<li><%= link_to l(:label_issue_category_plural), {}, :id=> "tab-categories", :onclick => "showTab('categories'); this.blur(); return false;" %></li>
<li><%= link_to l(:label_board_plural), {}, :id=> "tab-boards", :onclick => "showTab('boards'); this.blur(); return false;" %></li>
</ul>
</div>
<div id="tab-content-info" class="tab-content">
<% if authorize_for('projects', 'edit') %>
<% labelled_tabular_form_for :project, @project, :url => { :action => "edit", :id => @project } do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<%= submit_tag l(:button_save) %>
<% end %>
<% project_settings_tabs.each do |tab| %>
<li><%= link_to l(tab[:label]), {}, :id => "tab-#{tab[:name]}", :onclick => "showTab('#{tab[:name]}'); this.blur(); return false;" %></li>
<% end %>
</ul>
</div>
<div id="tab-content-members" class="tab-content" style="display:none;">
<%= render :partial => 'members' %>
</div>
<div id="tab-content-versions" class="tab-content" style="display:none;">
<table class="list">
<thead>
<th><%= l(:label_version) %></th>
<th><%= l(:field_effective_date) %></th>
<th><%= l(:field_description) %></th>
<th><%= l(:label_wiki_page) unless @project.wiki.nil? %></th>
<th style="width:15%"></th>
<th style="width:15%"></th>
</thead>
<tbody>
<% for version in @project.versions.sort %>
<tr class="<%= cycle 'odd', 'even' %>">
<td><%=h version.name %></td>
<td align="center"><%= format_date(version.effective_date) %></td>
<td><%=h version.description %></td>
<td><%= link_to(version.wiki_page_title, :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td>
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %></small></td>
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td>
</td>
</tr>
<% end; reset_cycle %>
</tbody>
</table>
&nbsp;
<p><%= link_to_if_authorized l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %></p>
</div>
<div id="tab-content-categories" class="tab-content" style="display:none;">
<table class="list">
<thead>
<th><%= l(:label_issue_category) %></th>
<th><%= l(:field_assigned_to) %></th>
<th style="width:15%"></th>
<th style="width:15%"></th>
</thead>
<tbody>
<% for category in @project.issue_categories %>
<% unless category.new_record? %>
<tr class="<%= cycle 'odd', 'even' %>">
<td><%=h(category.name) %></td>
<td><%=h(category.assigned_to.name) if category.assigned_to %></td>
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'issue_categories', :action => 'edit', :id => category }, :class => 'icon icon-edit' %></small></td>
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'issue_categories', :action => 'destroy', :id => category}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td>
</tr>
<% end %>
<% project_settings_tabs.each do |tab| %>
<%= content_tag('div', render(:partial => tab[:partial]), :id => "tab-content-#{tab[:name]}", :class => 'tab-content') %>
<% end %>
</tbody>
</table>
&nbsp;
<p><%= link_to_if_authorized l(:label_issue_category_new), :controller => 'projects', :action => 'add_issue_category', :id => @project %></p>
</div>
<div id="tab-content-boards" class="tab-content" style="display:none;">
<%= render :partial => 'boards' %>
</div>
<%= tab = params[:tab] ? h(params[:tab]) : 'info'
javascript_tag "showTab('#{tab}');" %>
\ No newline at end of file
<%= tab = params[:tab] ? h(params[:tab]) : project_settings_tabs.first[:name]
javascript_tag "showTab('#{tab}');" %>
<table class="list">
<thead>
<th><%= l(:label_issue_category) %></th>
<th><%= l(:field_assigned_to) %></th>
<th style="width:15%"></th>
<th style="width:15%"></th>
</thead>
<tbody>
<% for category in @project.issue_categories %>
<% unless category.new_record? %>
<tr class="<%= cycle 'odd', 'even' %>">
<td><%=h(category.name) %></td>
<td><%=h(category.assigned_to.name) if category.assigned_to %></td>
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'issue_categories', :action => 'edit', :id => category }, :class => 'icon icon-edit' %></small></td>
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'issue_categories', :action => 'destroy', :id => category}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
&nbsp;
<p><%= link_to_if_authorized l(:label_issue_category_new), :controller => 'projects', :action => 'add_issue_category', :id => @project %></p>
......@@ -33,8 +33,8 @@
</table>
&nbsp;
<% if authorize_for('projects', 'add_member') && !users.empty? %>
<% remote_form_for(:member, @member, :url => {:controller => 'projects', :action => 'add_member', :tab => 'members', :id => @project}, :method => :post) do |f| %>
<% if authorize_for('members', 'new') && !users.empty? %>
<% remote_form_for(:member, @member, :url => {:controller => 'members', :action => 'new', :id => @project}, :method => :post) do |f| %>
<p><label for="member_user_id"><%=l(:label_member_new)%></label><br />
<%= f.select :user_id, users.collect{|user| [user.name, user.id]} %>
<%= l(:label_role) %>: <%= f.select :role_id, roles.collect{|role| [role.name, role.id]}, :selected => nil %>
......
<% form_for :project, @project,
:url => { :action => 'modules', :id => @project },
:html => {:id => 'modules-form'} do |f| %>
<div class=box>
<% Redmine::AccessControl.available_project_modules.each do |m| %>
<p><label><%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) %> <%= m.to_s.humanize %></label></p>
<% end %>
</div>
<p><%= check_all_links 'modules-form' %></p>
<p><%= submit_tag l(:button_save) %></p>
<% end %>
<% remote_form_for :repository, @repository,
:url => { :controller => 'repositories', :action => 'edit', :id => @project },
:builder => TabularFormBuilder do |f| %>
<%= error_messages_for 'repository' %>
<div class="box tabular">
<p><label>SCM</label><%= scm_select_tag(@repository) %></p>
<%= repository_field_tags(f, @repository) if @repository %>
</div>
<div class="contextual">
<%= link_to(l(:button_delete), {:controller => 'repositories', :action => 'destroy', :id => @project},
:confirm => l(:text_are_you_sure),
:method => :post,
:class => 'icon icon-del') if @repository && !@repository.new_record? %>
</div>
<%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save)) %>
<% end %>
<table class="list">
<thead>
<th><%= l(:label_version) %></th>
<th><%= l(:field_effective_date) %></th>
<th><%= l(:field_description) %></th>
<th><%= l(:label_wiki_page) unless @project.wiki.nil? %></th>
<th style="width:15%"></th>
<th style="width:15%"></th>
</thead>
<tbody>
<% for version in @project.versions.sort %>
<tr class="<%= cycle 'odd', 'even' %>">
<td><%=h version.name %></td>
<td align="center"><%= format_date(version.effective_date) %></td>
<td><%=h version.description %></td>
<td><%= link_to(version.wiki_page_title, :controller => 'wiki', :page => Wiki.titleize(version.wiki_page_title)) unless version.wiki_page_title.blank? || @project.wiki.nil? %></td>
<td align="center"><small><%= link_to_if_authorized l(:button_edit), { :controller => 'versions', :action => 'edit', :id => version }, :class => 'icon icon-edit' %></small></td>
<td align="center"><small><%= link_to_if_authorized l(:button_delete), {:controller => 'versions', :action => 'destroy', :id => version}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %></small></td>
</td>
</tr>
<% end; reset_cycle %>
</tbody>
</table>
&nbsp;
<p><%= link_to_if_authorized l(:label_version_new), :controller => 'projects', :action => 'add_version', :id => @project %></p>
<% remote_form_for :wiki, @wiki,
:url => { :controller => 'wikis', :action => 'edit', :id => @project },
:builder => TabularFormBuilder do |f| %>
<%= error_messages_for 'wiki' %>
<div class="box tabular">
<p><%= f.text_field :start_page, :size => 60, :required => true %><br />
<em><%= l(:text_unallowed_characters) %>: , . / ? ; : |</em></p>
</div>
<div class="contextual">
<%= link_to(l(:button_delete), {:controller => 'wikis', :action => 'destroy', :id => @project},
:class => 'icon icon-del') if @wiki && !@wiki.new_record? %>
</div>
<%= submit_tag((@wiki.nil? || @wiki.new_record?) ? l(:button_create) : l(:button_save)) %>
<% end %>