@@ -86,7 +86,7 class WikiController < ApplicationController | |||||
86 | end |
|
86 | end | |
87 | @editable = editable? |
|
87 | @editable = editable? | |
88 | @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) && |
|
88 | @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) && | |
89 | @content.version == @page.content.version && |
|
89 | @content.current_version? && | |
90 | Redmine::WikiFormatting.supports_section_edit? |
|
90 | Redmine::WikiFormatting.supports_section_edit? | |
91 |
|
91 | |||
92 | render :action => 'show' |
|
92 | render :action => 'show' |
@@ -45,6 +45,11 class WikiContent < ActiveRecord::Base | |||||
45 | notified.collect(&:mail) |
|
45 | notified.collect(&:mail) | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
|
48 | # Return true if the content is the current page content | |||
|
49 | def current_version? | |||
|
50 | true | |||
|
51 | end | |||
|
52 | ||||
48 | class Version |
|
53 | class Version | |
49 | belongs_to :page, :class_name => '::WikiPage', :foreign_key => 'page_id' |
|
54 | belongs_to :page, :class_name => '::WikiPage', :foreign_key => 'page_id' | |
50 | belongs_to :author, :class_name => '::User', :foreign_key => 'author_id' |
|
55 | belongs_to :author, :class_name => '::User', :foreign_key => 'author_id' | |
@@ -101,6 +106,11 class WikiContent < ActiveRecord::Base | |||||
101 | page.project |
|
106 | page.project | |
102 | end |
|
107 | end | |
103 |
|
108 | |||
|
109 | # Return true if the content is the current page content | |||
|
110 | def current_version? | |||
|
111 | page.content.version == self.version | |||
|
112 | end | |||
|
113 | ||||
104 | # Returns the previous version or nil |
|
114 | # Returns the previous version or nil | |
105 | def previous |
|
115 | def previous | |
106 | @previous ||= WikiContent::Version.find(:first, |
|
116 | @previous ||= WikiContent::Version.find(:first, |
@@ -1,19 +1,19 | |||||
1 | <div class="contextual"> |
|
1 | <div class="contextual"> | |
2 | <% if @editable %> |
|
2 | <% if @editable %> | |
3 |
<%= link_to_if_authorized(l(:button_edit), {:action => 'edit', :id => @page.title}, :class => 'icon icon-edit', :accesskey => accesskey(:edit)) if @content. |
|
3 | <%= link_to_if_authorized(l(:button_edit), {:action => 'edit', :id => @page.title}, :class => 'icon icon-edit', :accesskey => accesskey(:edit)) if @content.current_version? %> | |
4 | <%= watcher_tag(@page, User.current) %> |
|
4 | <%= watcher_tag(@page, User.current) %> | |
5 | <%= link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected? %> |
|
5 | <%= link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected? %> | |
6 | <%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %> |
|
6 | <%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %> | |
7 |
<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') if @content. |
|
7 | <%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') if @content.current_version? %> | |
8 | <%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %> |
|
8 | <%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %> | |
9 |
<%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version }, :class => 'icon icon-cancel') |
|
9 | <%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version }, :class => 'icon icon-cancel') unless @content.current_version? %> | |
10 | <% end %> |
|
10 | <% end %> | |
11 | <%= link_to_if_authorized(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %> |
|
11 | <%= link_to_if_authorized(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %> | |
12 | </div> |
|
12 | </div> | |
13 |
|
13 | |||
14 | <%= wiki_page_breadcrumb(@page) %> |
|
14 | <%= wiki_page_breadcrumb(@page) %> | |
15 |
|
15 | |||
16 | <% if @content.version != @page.content.version %> |
|
16 | <% unless @content.current_version? %> | |
17 | <p> |
|
17 | <p> | |
18 | <%= link_to(("\xc2\xab " + l(:label_previous)), |
|
18 | <%= link_to(("\xc2\xab " + l(:label_previous)), | |
19 | :action => 'show', :id => @page.title, :project_id => @page.project, |
|
19 | :action => 'show', :id => @page.title, :project_id => @page.project, |
@@ -64,6 +64,8 wiki_content_versions_005: | |||||
64 | @WHATEVER@ |
|
64 | @WHATEVER@ | |
65 |
|
65 | |||
66 | Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in. |
|
66 | Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in. | |
|
67 | ||||
|
68 | Cras ipsum felis, ultrices at porttitor vel, faucibus eu nunc. | |||
67 |
|
69 | |||
68 | h2. Heading 2 |
|
70 | h2. Heading 2 | |
69 |
|
71 | |||
@@ -75,4 +77,26 wiki_content_versions_005: | |||||
75 | version: 2 |
|
77 | version: 2 | |
76 | author_id: 1 |
|
78 | author_id: 1 | |
77 | comments: |
|
79 | comments: | |
|
80 | wiki_content_versions_006: | |||
|
81 | data: |- | |||
|
82 | h1. Title | |||
|
83 | ||||
|
84 | Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero. | |||
|
85 | ||||
|
86 | h2. Heading 1 | |||
|
87 | ||||
|
88 | @WHATEVER@ | |||
|
89 | ||||
|
90 | Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in. | |||
|
91 | ||||
|
92 | h2. Heading 2 | |||
|
93 | ||||
|
94 | Morbi facilisis accumsan orci non pharetra. | |||
|
95 | updated_on: 2007-03-08 00:18:07 +01:00 | |||
|
96 | page_id: 11 | |||
|
97 | wiki_content_id: 11 | |||
|
98 | id: 6 | |||
|
99 | version: 3 | |||
|
100 | author_id: 1 | |||
|
101 | comments: | |||
78 |
|
102 |
@@ -85,4 +85,11 class WikiContentTest < ActiveSupport::TestCase | |||||
85 | page.reload |
|
85 | page.reload | |
86 | assert_equal 500.kilobyte, page.content.text.size |
|
86 | assert_equal 500.kilobyte, page.content.text.size | |
87 | end |
|
87 | end | |
|
88 | ||||
|
89 | def test_current_version | |||
|
90 | content = WikiContent.find(11) | |||
|
91 | assert_equal true, content.current_version? | |||
|
92 | assert_equal true, content.versions.first(:order => 'version DESC').current_version? | |||
|
93 | assert_equal false, content.versions.first(:order => 'version ASC').current_version? | |||
|
94 | end | |||
88 | end |
|
95 | end |
General Comments 0
You need to be logged in to leave comments.
Login now