summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects_controller.rb15
-rw-r--r--app/models/issue.rb7
-rw-r--r--app/models/issue_category.rb1
-rw-r--r--app/models/member.rb5
-rw-r--r--app/models/user.rb1
-rw-r--r--app/views/issue_categories/_form.rhtml11
-rw-r--r--app/views/issue_categories/edit.rhtml6
-rw-r--r--app/views/projects/add_issue_category.rhtml6
-rw-r--r--app/views/projects/settings.rhtml35
9 files changed, 46 insertions, 41 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 8f7969feb..443b53a59 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -165,17 +165,12 @@ class ProjectsController < ApplicationController
# Add a new issue category to @project
def add_issue_category
- if request.post?
- @issue_category = @project.issue_categories.build(params[:issue_category])
- if @issue_category.save
- flash[:notice] = l(:notice_successful_create)
- redirect_to :action => 'settings', :tab => 'categories', :id => @project
- else
- settings
- render :action => 'settings'
- end
+ @category = @project.issue_categories.build(params[:category])
+ if request.post? and @category.save
+ flash[:notice] = l(:notice_successful_create)
+ redirect_to :action => 'settings', :tab => 'categories', :id => @project
end
- end
+ end
# Add a new version to @project
def add_version
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 52aaa0931..adc79557d 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -60,6 +60,13 @@ class Issue < ActiveRecord::Base
end
end
+ def before_create
+ # default assignment based on category
+ if assigned_to.nil? && category && category.assigned_to
+ self.assigned_to = category.assigned_to
+ end
+ end
+
def before_save
if @current_journal
# attributes changes
diff --git a/app/models/issue_category.rb b/app/models/issue_category.rb
index 1a1daffb2..fb2c099a1 100644
--- a/app/models/issue_category.rb
+++ b/app/models/issue_category.rb
@@ -18,6 +18,7 @@
class IssueCategory < ActiveRecord::Base
before_destroy :check_integrity
belongs_to :project
+ belongs_to :assigned_to, :class_name => 'User', :foreign_key => 'assigned_to_id'
validates_presence_of :name
validates_uniqueness_of :name, :scope => [:project_id]
diff --git a/app/models/member.rb b/app/models/member.rb
index 9814faa51..7b512de37 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -26,4 +26,9 @@ class Member < ActiveRecord::Base
def name
self.user.display_name
end
+
+ def before_destroy
+ # remove category based auto assignments for this member
+ project.issue_categories.update_all "assigned_to_id = NULL", ["assigned_to_id = ?", self.user.id]
+ end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index bc5d4ecf8..569233d53 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -26,6 +26,7 @@ class User < ActiveRecord::Base
has_many :memberships, :class_name => 'Member', :include => [ :project, :role ], :conditions => "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}", :order => "#{Project.table_name}.name", :dependent => :delete_all
has_many :projects, :through => :memberships
has_many :custom_values, :dependent => :delete_all, :as => :customized
+ has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'"
belongs_to :auth_source
diff --git a/app/views/issue_categories/_form.rhtml b/app/views/issue_categories/_form.rhtml
index 765b8f53d..dc62c2000 100644
--- a/app/views/issue_categories/_form.rhtml
+++ b/app/views/issue_categories/_form.rhtml
@@ -1,7 +1,6 @@
-<%= error_messages_for 'issue_category' %>
-
-<!--[form:issue_category]-->
-<p><label for="issue_category_name"><%l(:field_name)%></label>
-<%= text_field 'issue_category', 'name' %></p>
-<!--[eoform:issue_category]-->
+<%= error_messages_for 'category' %>
+<div class="box">
+<p><%= f.text_field :name, :size => 30, :required => true %></p>
+<p><%= f.select :assigned_to_id, @project.users.collect{|u| [u.name, u.id]}, :include_blank => true %></p>
+</div>
diff --git a/app/views/issue_categories/edit.rhtml b/app/views/issue_categories/edit.rhtml
index 998dfbe79..54a1f0c66 100644
--- a/app/views/issue_categories/edit.rhtml
+++ b/app/views/issue_categories/edit.rhtml
@@ -1,6 +1,6 @@
<h2><%=l(:label_issue_category)%></h2>
-<% form_tag({:action => 'edit', :id => @category}, :class => "tabular") do %>
- <%= render :partial => 'form' %>
- <%= submit_tag l(:button_save) %>
+<% 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) %>
<% end %>
diff --git a/app/views/projects/add_issue_category.rhtml b/app/views/projects/add_issue_category.rhtml
new file mode 100644
index 000000000..08bc6d0e3
--- /dev/null
+++ b/app/views/projects/add_issue_category.rhtml
@@ -0,0 +1,6 @@
+<h2><%=l(:label_issue_category_new)%></h2>
+
+<% labelled_tabular_form_for :category, @category, :url => { :action => 'add_issue_category' } do |f| %>
+<%= render :partial => 'issue_categories/form', :locals => { :f => f } %>
+<%= submit_tag l(:button_create) %>
+<% end %>
diff --git a/app/views/projects/settings.rhtml b/app/views/projects/settings.rhtml
index 73367b26a..410b72e77 100644
--- a/app/views/projects/settings.rhtml
+++ b/app/views/projects/settings.rhtml
@@ -53,36 +53,27 @@
<div id="tab-content-categories" class="tab-content" style="display:none;">
<table class="list">
- <thead><th><%= l(:label_issue_category) %></th><th style="width:15%"></th></thead>
+ <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? %>
+<% for category in @project.issue_categories %>
+ <% unless category.new_record? %>
<tr class="<%= cycle 'odd', 'even' %>">
- <td>
- <% form_tag({:controller => 'issue_categories', :action => 'edit', :id => @category}) do %>
- <%= text_field 'category', 'name', :size => 25 %>
- <% if authorize_for('issue_categories', 'edit') %>
- <%= submit_tag l(:button_save), :class => "button-small" %>
- <% end %>
- <% end %>
- </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>
+ <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;
-<% if authorize_for('projects', 'add_issue_category') %>
- <% form_tag({:action => 'add_issue_category', :tab => 'categories', :id => @project}) do %>
- <p><label for="issue_category_name"><%=l(:label_issue_category_new)%></label><br />
- <%= error_messages_for 'issue_category' %>
- <%= text_field 'issue_category', 'name', :size => 25 %>
- <%= submit_tag l(:button_add) %></p>
- <% end %>
-<% end %>
+<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;">