Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit for v1.3.1 -- lots of stuff isn't working

  • Loading branch information...
commit a48d1b91ccd1ea01f39f39bb71749129221d88f5 1 parent 560053e
Harry Garrood authored
View
6 app/helpers/release_notes_helper.rb
@@ -40,12 +40,6 @@ def release_notes_overview_link_if(condition, text, version, project, opts = {})
end
end
- def release_notes_status_options_for_select
- ReleaseNote.statuses.map do |status|
- [t("release_notes.status.#{status}"), status]
- end
- end
-
def render_other_formats(formats)
str = "<p>"
str << l(:label_export_to)
View
21 app/models/release_note.rb
@@ -19,7 +19,7 @@ class ReleaseNote < ActiveRecord::Base
belongs_to :issue
def self.statuses
- %w(todo done not_required)
+ [:todo, :done, :not_required]
end
# the trackers which can have release notes
@@ -36,21 +36,18 @@ def self.enabled_project_ids
map(&:to_i)
end
- attr_accessible :text, :status
+ attr_accessible :text
validates_presence_of :issue
- validates_presence_of :text,
- :if => :done?,
- :message => I18n.t('release_notes.cant_be_blank_when_done')
+ validates_presence_of :text
- validates :status,
- :inclusion => { :in => statuses }
-
- before_validation(:on => :create) do
- self.status = 'todo' unless attribute_present?(:status)
+ def done?
+ # todo: use custom field instead
+ status == :done
end
- def done?
- status == 'done'
+ def status
+ # todo
+ :not_required
end
end
View
16 app/views/issues/_release_notes.html.erb
@@ -1,26 +1,20 @@
<div id="release-notes-display">
<p>
<strong><%= t('release_notes.title_plural') %></strong>
- <% if release_notes.status %>
- (<%= t("release_notes.status.#{release_notes.status}") %>)
- <% end %>
</p>
- <% if release_notes.text %>
+ <% if release_note.text %>
<div class="wiki">
- <p><%= h(release_notes.text).gsub(/(\r\n|\r|\n)/, "<br>").html_safe %></p>
+ <p><%= h(release_note.text).gsub(/(\r\n|\r|\n)/, "<br>").html_safe %></p>
</div>
<% end %>
</div>
-<%= form_for(release_notes,
- :as => :release_note, :remote => true,
- :url => release_note_path(release_notes, :format => :js),
- :method => :put,
+<%= form_for(release_note,
+ :remote => true,
:html => {:id => 'release-notes-form', :style => 'display: none;'}) do |f| %>
<strong><%= t('release_notes.title_plural') %></strong>
- <%= f.select 'status', release_notes_status_options_for_select %>
<div style='margin: 10px 10px 0px 10px;'>
- <%= error_messages_for release_notes %>
+ <%= error_messages_for release_note %>
<%= f.text_area 'text', :rows => 5,
:class => 'wiki-edit',
:no_label => true %>
View
20 app/views/release_notes/edit.html.erb
@@ -1,20 +0,0 @@
-<% title_str = "#{l(:button_edit)} #{l(:release_notes)}" %>
-<% html_title title_str %>
-<h2><%= title_str %></h2>
-
-<p><%= l(:edit_release_notes) %> <%= link_to_issue @issue %></p>
-<% if @issue.description and !@issue.description.empty? %>
- <h4><%= l(:field_description) %></h4>
- <p><%= @issue.description %></p>
-<% end %>
-
-<h4><%= l(:Release_notes) %></h4>
-<%= form_for @release_note do |f| %>
- <%= f.text_area :text, :size => "100x12" %><br />
- <%= f.hidden_field :issue_id, :value => @issue.id %>
- <%= check_box_tag :mark_complete, 1, @release_notes_completed %>
- <%= label(:mark, :complete, l(:mark_release_notes_complete)) %><br />
- <%= f.submit l(:button_save) %>
-<% end %>
-
-<%= button_to(l(:button_cancel), {:controller => "issues", :action => "show", :id => @issue.id}, :method => :get) %>
View
26 app/models/release_notes_query_column.rb → ...rate/004_do_everything_for_version_131.rb
@@ -14,17 +14,23 @@
# You should have received a copy of the GNU General Public License along with
# redmine_release_notes. If not, see <http://www.gnu.org/licenses/>.
-class ReleaseNotesQueryColumn < QueryColumn
- def initialize
- super(:release_notes,
- :sortable => 'rn.status',
- :groupable => 'rn.status',
- :caption => 'release_notes.title_plural')
+class DoEverythingForVersion131 < ActiveRecord::Migration
+ def up
+ # remove release_notes.status => now a custom field
+ remove_column :release_notes, :status
+
+ # don't allow nulls in release_notes.text
+ change_table :release_notes do |t|
+ t.change :text, :text, :null => false
+ end
end
- def value(object)
- object.release_note ?
- I18n.t(object.release_note.status, :scope => 'release_notes.status') :
- "-"
+ def down
+ change_table :release_notes do |t|
+ t.column :status, :string, :limit => 12
+ t.change :text, :text, :limit => nil, :null => true
+ end
+
+ add_index :release_notes, :status
end
end
View
3  init.rb
@@ -20,7 +20,6 @@
ActionDispatch::Callbacks.to_prepare do
# Patches to the Redmine core.
patched_classes = %w(issue issues_controller settings_controller version)
- patched_classes << (Redmine::VERSION::MINOR >= 3 ? 'issue_query' : 'query')
patched_classes.each do |core_class|
require_dependency core_class
"RedmineReleaseNotes::#{core_class.camelize}Patch".constantize.perform
@@ -31,7 +30,7 @@
name 'Redmine release notes plugin'
author 'Harry Garrood'
description 'A plugin for managing release notes.'
- version '1.3.0'
+ version '1.3.1-dev'
author_url 'https://github.com/hdgarrood'
requires_redmine :version_or_higher => '2.1.0'
View
15 lib/redmine_release_notes/hooks.rb
@@ -16,14 +16,17 @@
module RedmineReleaseNotes
class Hooks < Redmine::Hook::ViewListener
- def view_issues_show_description_bottom(context = {})
- if context[:issue].eligible_for_release_notes?
- context[:release_notes] = context[:issue].release_note ||
- context[:issue].create_release_note
- context[:controller].send(:render_to_string,
+ def view_issues_show_description_bottom(context)
+ issue, controller = context[:issue], context[:controller]
+
+ if issue.eligible_for_release_notes?
+ context[:release_note] = issue.release_note ||
+ issue.build_release_note
+ controller.render_to_string(
{ :partial =>
'hooks/release_notes/view_issues_show_description_bottom',
- :locals => context })
+ :locals => context }
+ )
else
""
end
View
80 lib/redmine_release_notes/issue_query_patch.rb
@@ -1,80 +0,0 @@
-# Copyright (C) 2012-2013 Harry Garrood
-# This file is a part of redmine_release_notes.
-
-# redmine_release_notes 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 3 of the License, or (at your option) any
-# later version.
-
-# redmine_release_notes 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
-# redmine_release_notes. If not, see <http://www.gnu.org/licenses/>.
-
-module RedmineReleaseNotes
- # this should only be performed on Redmine >= 2.3.0
- module IssueQueryPatch
- def self.perform
- IssueQuery.class_eval do
- # make IssueQueries aware of ReleaseNotesQueryColumns
- add_available_column(ReleaseNotesQueryColumn.new)
-
- # chain available_filters so that the release notes query filter is
- # included in the list of available filters, if the query has a project
- # which has release notes enabled
- def available_filters_with_release_notes
- filters = available_filters_without_release_notes
-
- if project && project.module_enabled?(:release_notes)
- release_note_values = ReleaseNote.statuses.map do |status|
- [I18n.t(status, :scope => 'release_notes.status'), status]
- end
- filters["release_notes"] ||= {
- :type => :list,
- :name => I18n.t('release_notes.title_plural'),
- :values => release_note_values,
- :order => filters.size + 1
- }
- end
-
- filters
- end
-
- alias_method_chain :available_filters, :release_notes
-
- # add a method to generate the part of the WHERE clause for the
- # query's SQL statement
- def sql_for_release_notes_field(field, operator, value)
- db_table_alias = 'rn'
- db_field = 'status'
- sql_for_field('release_notes', operator, value, db_table_alias, db_field)
- end
-
- # chain joins_for_order_statement so that the statement also joins
- # the release_notes table
- def joins_for_release_notes
- "LEFT OUTER JOIN #{ReleaseNote.table_name} rn on rn.issue_id = #{queried_table_name}.id"
- end
-
- def joins_for_order_statement_with_release_notes(order_options)
- joins = joins_for_order_statement_without_release_notes(order_options) || ""
- joins << " " << joins_for_release_notes
- end
-
- alias_method_chain :joins_for_order_statement, :release_notes
-
- # Override issue_count so that the join is included
- def issue_count
- Issue.visible.count(:include => [:status, :project],
- :joins => joins_for_release_notes,
- :conditions => statement)
- rescue ::ActiveRecord::StatementInvalid => e
- raise ::Query::StatementInvalid.new(e.message)
- end
- end
- end
- end
-end
View
99 lib/redmine_release_notes/query_patch.rb
@@ -1,99 +0,0 @@
-# Copyright (C) 2012-2013 Harry Garrood
-# This file is a part of redmine_release_notes.
-
-# redmine_release_notes 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 3 of the License, or (at your option) any
-# later version.
-
-# redmine_release_notes 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
-# redmine_release_notes. If not, see <http://www.gnu.org/licenses/>.
-
-module RedmineReleaseNotes
- # this should only be performed on Redmine 2.2.x or earlier
- module QueryPatch
- def self.perform
- Query.class_eval do
- # make IssueQueries aware of ReleaseNotesQueryColumns
- add_available_column(ReleaseNotesQueryColumn.new)
-
- # chain available_filters so that the release notes query filter is
- # included in the list of available filters, if the query has a project
- # which has release notes enabled
- def available_filters_with_release_notes
- filters = available_filters_without_release_notes
-
- if project && project.module_enabled?(:release_notes)
- release_note_values = ReleaseNote.statuses.map do |status|
- [I18n.t(status, :scope => 'release_notes.status'), status]
- end
- filters["release_notes"] ||= {
- :type => :list,
- :name => I18n.t('release_notes.title_plural'),
- :values => release_note_values,
- :order => filters.size + 1
- }
- end
-
- filters
- end
-
- alias_method_chain :available_filters, :release_notes
-
- # add a method to generate the part of the WHERE clause for the
- # query's SQL statement
- def sql_for_release_notes_field(field, operator, value)
- db_table_alias = 'rn'
- db_field = 'status'
- sql_for_field('release_notes', operator, value, db_table_alias, db_field)
- end
-
- # chain joins_for_order_statement so that the statement also joins
- # the release_notes table
- def joins_for_release_notes
- "LEFT OUTER JOIN #{ReleaseNote.table_name} rn on rn.issue_id = #{Issue.table_name}.id"
- end
-
- def joins_for_order_statement_with_release_notes(order_options)
- joins = joins_for_order_statement_without_release_notes(order_options) || ""
- joins << " " << joins_for_release_notes
- end
-
- alias_method_chain :joins_for_order_statement, :release_notes
-
- # Override issue_count so that the join is included
- def issue_count
- Issue.visible.count(:include => [:status, :project],
- :joins => joins_for_release_notes,
- :conditions => statement)
- rescue ::ActiveRecord::StatementInvalid => e
- raise ::Query::StatementInvalid.new(e.message)
- end
-
- # chain issue_count_by_group so that the join is included
- def issue_count_by_group_with_release_notes
- if grouped? && group_by == 'release_notes'
- begin
- # Rails3 will raise an (unexpected) RecordNotFound if there's only a nil group value
- Issue.visible.count(:group => group_by_statement,
- :include => [:status, :project],
- :joins => joins_for_release_notes,
- :conditions => statement)
- rescue ActiveRecord::RecordNotFound
- {nil => issue_count}
- end
- else
- issue_count_by_group_without_release_notes
- end
- end
-
- alias_method_chain :issue_count_by_group, :release_notes
- end
- end
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.