ChiliProject is not maintained anymore. Please be advised that there will be no more updates.
We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.
Wikipages don't store/show the comment correctly (Bug #415)
Description
I haven't tested this thoroughly, but as far as I can tell, the comment on wikipage update forms isn't stored in the notes
field in the new journals scheme, and hence doesn't show on the history view.
(The comment isn't lost but stored at the wrong place, getting it out of that wrong place will be difficult, so I consider this issue blocking for 2.0)
Associated revisions
Save the comments to wiki page updates correctly. #415
Change test to use the new journalized interface. #415
[#415] Fix functional tests that used the older interface
History
Updated by Felix Schäfer at 2011-05-19 08:54 pm
I think leaving the comments
field in the wiki_contents
table was an oversight as they are replaced by the notes
from acts_as_journalized
. Here's my proposed changes, the big plus being that they don't break the current interface (put comments pertaining to the current change in @wiki_content.comments
). There's a lot of cleanup that can be done in the WikiController
because of that, but I think that's for a later day.
1diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb
2index 8fe1ec5..8bdca21 100644
3--- a/app/models/wiki_content.rb
4+++ b/app/models/wiki_content.rb
5@@ -23,6 +23,10 @@ class WikiContent < ActiveRecord::Base
6 validates_presence_of :text
7 validates_length_of :comments, :maximum => 255, :allow_nil => true
8
9+ attr_accessor :comments
10+
11+ before_save :comments_to_journal_notes
12+
13 acts_as_journalized :event_type => 'wiki-page',
14 :event_title => Proc.new {|o| "#{l(:label_wiki_edit)}: #{o.page.title} (##{o.version})"},
15 :event_url => Proc.new {|o| {:controller => 'wiki', :id => o.page.wiki.project_id, :page => o.page.title, :version => o.version}
16@@ -67,6 +71,12 @@ class WikiContent < ActiveRecord::Base
17 last_journal.version
18 end
19
20+ private
21+
22+ def comments_to_journal_notes
23+ self.init_journal(author, comments)
24+ end
25+
26 # FIXME: This is for backwards compatibility only. Remove once we decide it is not needed anymore
27 WikiContentJournal.class_eval do
28 attr_protected :data
29diff --git a/db/migrate/20110519194936_remove_comments_from_wiki_content.rb b/db/migrate/20110519194936_remove_comments_from_wiki_con
30new file mode 100644
31index 0000000..461cc70
32--- /dev/null
33+++ b/db/migrate/20110519194936_remove_comments_from_wiki_content.rb
34@@ -0,0 +1,9 @@
35+class RemoveCommentsFromWikiContent < ActiveRecord::Migration
36+ def self.up
37+ remove_column :wiki_contents, :comments
38+ end
39+
40+ def self.down
41+ add_column :wiki_contents, :comments, :string
42+ end
43+end
- Status changed from Open to Ready for review
Updated by Tim Felgentreff at 2011-05-20 06:45 am
Uh, stupid oversight by me there. I like the patch. You're right, there's a lot of code that can/should be removed from the wiki code, but I guess that doing a sweep and removing duplicate functionality from the codebase should be done from a stable version.
Updated by Felix Schäfer at 2011-05-20 01:48 pm
Tim Felgentreff wrote:
I like the patch.
Great :-)
Applied in dbc10d2730952ffcd5ac82b581663d3f69cab72b.
- Status changed from Ready for review to Closed
Updated by Gregor Schmidt at 2011-05-20 03:52 pm
I think removing the comments
from wiki_contents
broke the fixture loading. The comments
lines in source:test/fixtures/wiki_contents.yml should be removed as well.
- Status changed from Closed to Open
Updated by Gregor Schmidt at 2011-05-20 03:56 pm
Attached is a patch, that removed the erroneous lines.
- File 0001-415-Removing-commments-from-wiki_contents-fixtures-s.patch added
- Assignee set to Felix Schäfer
- Status changed from Open to Ready for review
Updated by Felix Schäfer at 2011-05-20 08:17 pm
Thanks for the patch. I'll wait on the CI to confirm the tests work as expected this time ;-)
Updated by Felix Schäfer at 2011-05-21 05:30 am
The CI seems to work through, so I consider this closed (again). Thanks for your help Gregor!
- Status changed from Ready for review to Closed