##// END OF EJS Templates
Adds #current_version? method to wiki content....
Jean-Philippe Lang -
r7852:b8a924e4e1cb
parent child
Show More
@@ -86,7 +86,7 class WikiController < ApplicationController
86 86 end
87 87 @editable = editable?
88 88 @sections_editable = @editable && User.current.allowed_to?(:edit_wiki_pages, @page.project) &&
89 @content.version == @page.content.version &&
89 @content.current_version? &&
90 90 Redmine::WikiFormatting.supports_section_edit?
91 91
92 92 render :action => 'show'
@@ -45,6 +45,11 class WikiContent < ActiveRecord::Base
45 45 notified.collect(&:mail)
46 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 53 class Version
49 54 belongs_to :page, :class_name => '::WikiPage', :foreign_key => 'page_id'
50 55 belongs_to :author, :class_name => '::User', :foreign_key => 'author_id'
@@ -101,6 +106,11 class WikiContent < ActiveRecord::Base
101 106 page.project
102 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 114 # Returns the previous version or nil
105 115 def previous
106 116 @previous ||= WikiContent::Version.find(:first,
@@ -1,19 +1,19
1 1 <div class="contextual">
2 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.version == @page.content.version %>
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 4 <%= watcher_tag(@page, User.current) %>
5 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 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.version == @page.content.version %>
7 <%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') if @content.current_version? %>
8 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') if @content.version < @page.content.version %>
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 10 <% end %>
11 11 <%= link_to_if_authorized(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %>
12 12 </div>
13 13
14 14 <%= wiki_page_breadcrumb(@page) %>
15 15
16 <% if @content.version != @page.content.version %>
16 <% unless @content.current_version? %>
17 17 <p>
18 18 <%= link_to(("\xc2\xab " + l(:label_previous)),
19 19 :action => 'show', :id => @page.title, :project_id => @page.project,
@@ -65,6 +65,8 wiki_content_versions_005:
65 65
66 66 Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
67 67
68 Cras ipsum felis, ultrices at porttitor vel, faucibus eu nunc.
69
68 70 h2. Heading 2
69 71
70 72 Morbi facilisis accumsan orci non pharetra.
@@ -75,4 +77,26 wiki_content_versions_005:
75 77 version: 2
76 78 author_id: 1
77 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 85 page.reload
86 86 assert_equal 500.kilobyte, page.content.text.size
87 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 95 end
General Comments 0
You need to be logged in to leave comments. Login now