fix typo in wiki pages controller
also rename method to prevent future mishaps test plan: * try to visit a deleted page (that is not the front page) * should not get a page error fixes #CNVS-6868 Change-Id: If0bea59d810fc0d41d3e9169fffc58fa20d74cd9 Reviewed-on: https://gerrit.instructure.com/22309 QA-Review: August Thornton <august@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Bracken Mosbacker <bracken@instructure.com> Product-Review: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
parent
35960a6431
commit
bda5b07f40
|
@ -986,7 +986,7 @@ class ApplicationController < ActionController::Base
|
|||
@page.workflow_state = 'active'
|
||||
end
|
||||
end
|
||||
if @page.front_page? && @page.new_record?
|
||||
if @page.is_front_page? && @page.new_record?
|
||||
@page.body = t "#application.wiki_front_page_default_content_course", "Welcome to your new course wiki!" if @context.is_a?(Course)
|
||||
@page.body = t "#application.wiki_front_page_default_content_group", "Welcome to your new group wiki!" if @context.is_a?(Group)
|
||||
end
|
||||
|
|
|
@ -257,7 +257,7 @@ class WikiPagesApiController < ApplicationController
|
|||
end
|
||||
|
||||
def get_front_page_params
|
||||
@was_front_page = @page.front_page?
|
||||
@was_front_page = @page.is_front_page?
|
||||
if params[:wiki_page] && params[:wiki_page].has_key?(:front_page)
|
||||
@set_front_page = true
|
||||
@set_as_front_page = value_to_boolean(params[:wiki_page].delete(:front_page))
|
||||
|
@ -289,7 +289,7 @@ class WikiPagesApiController < ApplicationController
|
|||
|
||||
def process_front_page
|
||||
if @set_front_page
|
||||
if @set_as_front_page && !@page.front_page?
|
||||
if @set_as_front_page && !@page.is_front_page?
|
||||
return @page.set_as_front_page!
|
||||
elsif !@set_as_front_page
|
||||
return @wiki.unset_front_page!
|
||||
|
@ -297,7 +297,7 @@ class WikiPagesApiController < ApplicationController
|
|||
elsif @was_front_page
|
||||
if @page.deleted?
|
||||
return @wiki.unset_front_page!
|
||||
elsif !@page.front_page?
|
||||
elsif !@page.is_front_page?
|
||||
# if url changes, keep as front page
|
||||
return @page.set_as_front_page!
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ class WikiPagesController < ApplicationController
|
|||
@editing = true if Canvas::Plugin.value_to_boolean(params[:edit])
|
||||
if @page.deleted?
|
||||
flash[:notice] = t('notices.page_deleted', 'The page "%{title}" has been deleted.', :title => @page.title)
|
||||
if @wiki.has_front_page? && !@page.front_page
|
||||
if @wiki.has_front_page? && !@page.is_front_page?
|
||||
redirect_to named_context_url(@context, :context_wiki_page_url, @wiki.get_front_page_url)
|
||||
else
|
||||
redirect_to named_context_url(@context, :context_url)
|
||||
|
@ -90,7 +90,7 @@ class WikiPagesController < ApplicationController
|
|||
|
||||
def destroy
|
||||
if authorized_action(@page, @current_user, :delete)
|
||||
if !@page.front_page?
|
||||
if !@page.is_front_page?
|
||||
flash[:notice] = t('notices.page_deleted', 'The page "%{title}" has been deleted.', :title => @page.title)
|
||||
@page.workflow_state = 'deleted'
|
||||
@page.save
|
||||
|
|
|
@ -40,7 +40,7 @@ class WikiPage < ActiveRecord::Base
|
|||
TITLE_LENGTH = WikiPage.columns_hash['title'].limit rescue 255
|
||||
|
||||
def validate_front_page_visibility
|
||||
if self.hide_from_students && self.front_page?
|
||||
if self.hide_from_students && self.is_front_page?
|
||||
self.errors.add(:hide_from_students, t(:cannot_hide_page, "cannot hide front page"))
|
||||
end
|
||||
end
|
||||
|
@ -205,7 +205,7 @@ class WikiPage < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def front_page?
|
||||
def is_front_page?
|
||||
!self.deleted? && self.wiki.has_front_page? && self.url == self.wiki.get_front_page_url
|
||||
end
|
||||
|
||||
|
@ -251,7 +251,7 @@ class WikiPage < ActiveRecord::Base
|
|||
|
||||
def editing_role?(user)
|
||||
context_roles = context.default_wiki_editing_roles rescue nil
|
||||
edit_roles = editing_roles unless self.front_page?
|
||||
edit_roles = editing_roles unless self.is_front_page?
|
||||
roles = (edit_roles || context_roles || default_roles).split(",")
|
||||
return true if roles.include?('teachers') && context.respond_to?(:teachers) && context.teachers.include?(user)
|
||||
return true if !hide_from_students && roles.include?('students') && context.respond_to?(:students) && context.includes_student?(user)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<div class="someone_else_edited" style="display: none; font-size: 0.8em;">
|
||||
<%= mt 'notices.page_edited_while_viewing', 'This page has been updated by someone else since you started viewing it. [Click here to reload the page.](%{link})', :link => request.url %>
|
||||
</div>
|
||||
<% if @page.front_page? && can_do(@page, @current_user, :update) %>
|
||||
<% if @page.is_front_page? && can_do(@page, @current_user, :update) %>
|
||||
<% if !course_home %>
|
||||
<h3><%= t :welcome_message, 'Welcome to the Course Wiki' %></h3>
|
||||
<% end %>
|
||||
|
@ -99,11 +99,11 @@ course will see this page first. You can change that from [the course home page
|
|||
<% end %>
|
||||
<div id="below_editor">
|
||||
<% if can_do(@page, @current_user, :update) %>
|
||||
<div style="text-align: left; <%= hidden if @page.front_page? %>">
|
||||
<div style="text-align: left; <%= hidden if @page.is_front_page? %>">
|
||||
<%= f.check_box :hide_from_students %>
|
||||
<%= f.label :hide_from_students, :en => "Hide this Page from Students" %>
|
||||
</div>
|
||||
<div style="text-align: left; <%= hidden if @page.front_page? %>">
|
||||
<div style="text-align: left; <%= hidden if @page.is_front_page? %>">
|
||||
<%
|
||||
select_html = if @context.is_a?(Course)
|
||||
f.select :editing_roles, [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% skip_front_page ||= false; page_link ||= nil; wiki_page = page_link; hidden ||= false %>
|
||||
<% if !wiki_page %>
|
||||
<li class="ellipsis" style="<%= 'display: none;' if hidden %>"><%= link_to t('#wiki_pages.front_page', "Front Page"), context_url(@context, :context_wiki_page_url, @context.wiki.get_front_page_url) %></li>
|
||||
<% elsif skip_front_page && wiki_page.front_page? %>
|
||||
<% elsif skip_front_page && wiki_page.is_front_page? %>
|
||||
<% else %>
|
||||
<% if !wiki_page.hide_from_students || can_do(@context, @current_user, :manage_content) %>
|
||||
<li class="ellipsis" style="<%= 'display: none;' if hidden %><%= 'font-weight: bold;' if @page && wiki_page == @page %><%= 'font-style: italic;' if wiki_page.hide_from_students %>" title="<%= t(:link_hidden_from_students_warning, "Students won't see this link") if wiki_page.hide_from_students %>"><%= link_to wiki_page.title, context_url(
|
||||
|
|
|
@ -63,13 +63,13 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<% if can_do(@page, @current_user, :update_content) || (can_do(@page, @current_user, :delete) && !@page.front_page?) || can_do(@wiki, @current_user, :create_page) %>
|
||||
<% if can_do(@page, @current_user, :update_content) || (can_do(@page, @current_user, :delete) && !@page.is_front_page?) || can_do(@wiki, @current_user, :create_page) %>
|
||||
<div class="rs-margin-lr <%= "rs-margin-bottom" if course_home %>">
|
||||
<hr />
|
||||
<% if can_do(@page, @current_user, :update_content)%>
|
||||
<%= link_to ('<i class="icon-edit"></i>').html_safe + " " + t('links.edit_page', "Edit this Page"), "#edit", :class => "edit_link btn button-sidebar-wide" %>
|
||||
<% end %>
|
||||
<% if can_do(@page, @current_user, :delete) && !@page.front_page? && !@page.deleted? %>
|
||||
<% if can_do(@page, @current_user, :delete) && !@page.is_front_page? && !@page.deleted? %>
|
||||
<%= link_to ('<i class="icon-trash"></i>').html_safe + " " + t('links.delete_page', "Delete this Page"), context_url(@context, :context_wiki_page_url, @page.url), :method => :delete, :confirm => t('delete_page_confirmation', 'Are you sure you want to delete this page? This cannot be undone!'), :class => "btn button-sidebar-wide" %>
|
||||
<% end %>
|
||||
<a href="<%= context_url(@context, :context_wiki_page_url, @page) %>" class="wiki_page_url" style="display: none;"> </a>
|
||||
|
@ -93,7 +93,7 @@
|
|||
<div>
|
||||
<h2><%= t 'headers.page_tools', 'Page Tools' %></h2>
|
||||
<ul class="item_list">
|
||||
<% unless @page.front_page? || @page.new_record? %>
|
||||
<% unless @page.is_front_page? || @page.new_record? %>
|
||||
<li>
|
||||
<a id="wiki_page_rename_link" class="icon-note-dark element_toggler" aria-controls="wiki_page_rename_section" href="#"><%= t 'links.rename_page', 'Rename this page' %></a>
|
||||
<div id="wiki_page_rename_section" style="display:none;">
|
||||
|
|
|
@ -29,7 +29,7 @@ module Api::V1::WikiPage
|
|||
hash['body'] = api_user_content(wiki_page.body) if include_body
|
||||
hash['last_edited_by'] = user_display_json(wiki_page.user, wiki_page.context) if wiki_page.user
|
||||
hash['published'] = wiki_page.active?
|
||||
hash['front_page'] = wiki_page.front_page?
|
||||
hash['front_page'] = wiki_page.is_front_page?
|
||||
if @domain_root_account && @domain_root_account.enable_draft?
|
||||
hash['html_url'] = polymorphic_url([wiki_page.context, :named_page], :wiki_page_id => wiki_page)
|
||||
else
|
||||
|
|
|
@ -227,7 +227,7 @@ describe "Pages API", :type => :integration do
|
|||
{ :wiki_page => { :title => 'New Wiki Page!', :body => 'hello new page', :front_page => true}})
|
||||
|
||||
page = @course.wiki.wiki_pages.find_by_url!(json['url'])
|
||||
page.front_page?.should be_true
|
||||
page.is_front_page?.should be_true
|
||||
|
||||
wiki = @course.wiki
|
||||
wiki.reload
|
||||
|
@ -307,7 +307,7 @@ describe "Pages API", :type => :integration do
|
|||
:body => 'Information wants to be free', :front_page => true }})
|
||||
no_longer_hidden_page = @hidden_page
|
||||
no_longer_hidden_page.reload
|
||||
no_longer_hidden_page.front_page?.should be_true
|
||||
no_longer_hidden_page.is_front_page?.should be_true
|
||||
|
||||
wiki.reload
|
||||
wiki.front_page.should == no_longer_hidden_page
|
||||
|
@ -326,7 +326,7 @@ describe "Pages API", :type => :integration do
|
|||
:body => 'Information wants to be free', :front_page => false }})
|
||||
|
||||
front_page.reload
|
||||
front_page.front_page?.should be_false
|
||||
front_page.is_front_page?.should be_false
|
||||
|
||||
wiki.reload
|
||||
wiki.front_page.should be_nil
|
||||
|
@ -344,7 +344,7 @@ describe "Pages API", :type => :integration do
|
|||
{ :wiki_page => { :url => 'noooo' }})
|
||||
|
||||
page.reload
|
||||
page.front_page?.should be_true
|
||||
page.is_front_page?.should be_true
|
||||
|
||||
wiki = @course.wiki
|
||||
wiki.reload
|
||||
|
@ -360,7 +360,7 @@ describe "Pages API", :type => :integration do
|
|||
{:expected_status => 400})
|
||||
|
||||
@hidden_page.reload
|
||||
@hidden_page.front_page?.should_not be_true
|
||||
@hidden_page.is_front_page?.should_not be_true
|
||||
end
|
||||
|
||||
context "with unpublished page" do
|
||||
|
|
Loading…
Reference in New Issue