Remove is_default from global template.

This commit is contained in:
Akiko Takano
2014-03-31 05:49:07 +09:00
parent a265fcf8ca
commit 412f9be7c9
4 changed files with 13 additions and 24 deletions

View File

@@ -3,7 +3,6 @@ class GlobalIssueTemplate < ActiveRecord::Base
unloadable
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
belongs_to :tracker
before_save :check_default
validates :title, :presence => true
validates :tracker, :presence => true
validates_uniqueness_of :title, :scope => :tracker_id
@@ -18,7 +17,6 @@ class GlobalIssueTemplate < ActiveRecord::Base
'note',
'enabled',
'issue_title',
'is_default',
'project_ids'
def enabled?
@@ -28,14 +26,4 @@ class GlobalIssueTemplate < ActiveRecord::Base
def <=>(issue_template)
position <=> global_issue_template.position
end
#
# In case set is_default and updated, others are also updated.
#
def check_default
if is_default? && is_default_changed?
GlobalIssueTemplate.update_all({:is_default => false},
['racker_id = ?', tracker_id])
end
end
end

View File

@@ -36,12 +36,6 @@
:label => l(:issue_template_note), :style => "overflow:auto;" %>
</p>
<p><%= f.check_box :is_default, :label => l(:field_is_default) %>
<a class="icon icon-help" href="#" title="<%= l(:help_for_this_field) %>"
onclick="checkExpand('isdefault_help_content'); return false;"><%= l(:help_for_this_field) %>
</a><br/>
<span id="isdefault_help_content" class="help_content" style="display: none;"><%= l(:label_isdefault_help_message) %></span>
</p>
<p><%= f.check_box :enabled, :label => l(:label_enabled) %>
<a class="icon icon-help" href="#" title="<%= l(:help_for_this_field) %>"
onclick="checkExpand('enabled_help_content'); return false;"><%= l(:help_for_this_field) %>
@@ -52,7 +46,7 @@
</div>
<%= wikitoolbar_for 'issue_template_description' %>
<%= wikitoolbar_for 'global_issue_template_description' %>
<div id="preview" class="wiki"></div>
<%= preview_link url_for(:controller => 'global_issue_templates', :action => 'preview',

View File

@@ -1,4 +1,4 @@
<h2 class="template"><%=h "#{l(:issue_template)}" %></h2>
<h2 class="template"><%=h "#{l(:global_issue_templates)}" %></h2>
<div class="contextual">
<%= link_to(l(:label_new_templates),
@@ -22,7 +22,6 @@
<th><%= l(:field_tracker) %></th>
<th><%= l(:field_author) %></th>
<th><%= l(:field_updated_on) %></th>
<th><%= l(:field_is_default) %></th>
<th><%= l(:label_enabled) %></th>
<% if authorize_for("global_issue_templates", "edit") %>
<th><%=l(:button_sort)%></th>
@@ -33,13 +32,12 @@
<% @global_issue_templates.each do |issue_template| %>
<tr class="<%= cycle("odd", "even") %> issue_template issue">
<td><%= link_to h(issue_template.id), {:controller => 'global_issue_templates',
:id => issue_template.id, :action => 'show'}, {:title => issue_template.note } %></td>
:id => issue_template.id, :action => 'show'}, title: issue_template.title, tooltip: issue_template.note %></td>
<td><%= link_to h(issue_template.title), {:controller => 'global_issue_templates',
:id => issue_template.id, :action => 'show'}, {:title => issue_template.note } %></td>
:id => issue_template.id, :action => 'show'}, title: issue_template.note, class: "tooltip" %></td>
<td><%=h issue_template.tracker.name %></td>
<td><%=h issue_template.author %></td>
<td><%= format_time(issue_template.updated_on)%> </td>
<td class="center"><%= checked_image issue_template.is_default? %></td>
<td class="center"><%= checked_image issue_template.enabled? %></td>
<% if authorize_for("issue_templates", "edit") %>

View File

@@ -0,0 +1,9 @@
class RemoveIsDefaultFromGlobalIssueTemplates < ActiveRecord::Migration
def self.up
remove_column :global_issue_templates, :is_default
end
def self.down
raise IrreversibleMigration
end
end