Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rename current_user to current_cms_user #752

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 52 additions & 36 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ PATH
ancestry (~> 2.0.0)
bootstrap-sass
ckeditor_rails (~> 4.3.0)
compass-rails (~> 1.1.3)
compass-rails (~> 2.0.4)
devise (~> 3.0)
jquery-rails (~> 3.1)
jquery-ui-rails (~> 4.1)
panoramic
paperclip (~> 3.4)
paperclip (~> 4.3)
rails (~> 4.0.0)
sass-rails
simple_form (>= 3.0.0.rc, < 3.1)
Expand Down Expand Up @@ -57,10 +57,14 @@ GEM
childprocess (>= 0.3.6)
cucumber (>= 1.1.1)
rspec-expectations (>= 2.7.0)
bcrypt (3.1.7)
autoprefixer-rails (6.1.0.1)
execjs
json
bcrypt (3.1.10)
bluecloth (2.2.0)
bootstrap-sass (3.2.0.2)
sass (~> 3.2)
bootstrap-sass (3.3.5.1)
autoprefixer-rails (>= 5.0.0.1)
sass (>= 3.3.0)
builder (3.1.4)
capybara (2.1.0)
mime-types (>= 1.16)
Expand All @@ -70,28 +74,29 @@ GEM
xpath (~> 2.0)
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
chunky_png (1.3.1)
chunky_png (1.3.5)
ckeditor_rails (4.3.4)
railties (>= 3.0)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.4)
cocaine (0.5.7)
climate_control (>= 0.0.3, < 1.0)
compass (1.0.1)
compass (1.0.3)
chunky_png (~> 1.2)
compass-core (~> 1.0.1)
compass-core (~> 1.0.2)
compass-import-once (~> 1.0.5)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
sass (>= 3.3.13, < 3.5)
compass-core (1.0.1)
compass-core (1.0.3)
multi_json (~> 1.0)
sass (>= 3.3.0, < 3.5)
compass-import-once (1.0.5)
sass (>= 3.2, < 3.5)
compass-rails (1.1.7)
compass (>= 0.12.2)
sprockets (<= 2.11.0)
compass-rails (2.0.5)
compass (~> 1.0.0)
sass-rails (< 5.1)
sprockets (< 2.13)
cucumber (1.3.6)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
Expand All @@ -104,10 +109,11 @@ GEM
nokogiri (>= 1.5.0)
daemons (1.1.9)
database_cleaner (1.2.0)
devise (3.3.0)
devise (3.5.2)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.4)
Expand All @@ -122,18 +128,19 @@ GEM
railties (>= 3.0.0)
faye-websocket (0.4.7)
eventmachine (>= 0.12.0)
ffi (1.9.0)
ffi (1.9.10)
gherkin (2.12.1)
multi_json (~> 1.3)
hashie (2.0.5)
hike (1.2.3)
http_parser.rb (0.5.3)
i18n (0.6.11)
jquery-rails (3.1.2)
i18n (0.7.0)
jquery-rails (3.1.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1)
railties (>= 3.2.16)
json (1.8.3)
launchy (2.3.0)
addressable (~> 2.3)
m (1.3.2)
Expand All @@ -145,6 +152,7 @@ GEM
metaclass (0.0.1)
method_source (0.8.2)
mime-types (1.25.1)
mimemagic (0.3.0)
mini_portile (0.5.1)
minitest (4.7.5)
minitest-rails (0.9.2)
Expand All @@ -165,11 +173,12 @@ GEM
orm_adapter (0.5.0)
panoramic (0.0.4)
rails (>= 3.0.7)
paperclip (3.5.4)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
paperclip (4.3.1)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
cocaine (~> 0.5.5)
mime-types
mimemagic (= 0.3.0)
poltergeist (1.3.0)
capybara (~> 2.1.0)
faye-websocket (>= 0.4.4, < 0.5.0)
Expand All @@ -180,8 +189,8 @@ GEM
hashie (>= 1.1.0)
quiet_assets (1.0.2)
railties (>= 3.1, < 5.0)
rack (1.5.2)
rack-test (0.6.2)
rack (1.5.5)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.0.2)
actionmailer (= 4.0.2)
Expand All @@ -196,24 +205,28 @@ GEM
activesupport (= 4.0.2)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.1)
rb-fsevent (0.9.4)
rake (10.4.2)
rb-fsevent (0.9.6)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
responders (1.1.2)
railties (>= 3.2, < 4.2)
rspec-expectations (2.14.1)
diff-lcs (>= 1.1.3, < 2.0)
ruby-prof (0.13.0)
sass (3.4.5)
sass-rails (4.0.1)
sass (3.4.19)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
sass (>= 3.1.10)
sprockets-rails (~> 2.0.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
simple_form (3.1.0.rc2)
actionpack (~> 4.0)
activemodel (~> 4.0)
single_test (0.6.0)
rake
sprockets (2.10.1)
sprockets (2.12.4)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
Expand All @@ -225,24 +238,24 @@ GEM
sqlite3 (1.3.7)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
term-ansicolor (1.3.0)
term-ansicolor (1.3.2)
tins (~> 1.0)
thin (1.5.1)
daemons (>= 1.0.9)
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
thor (0.18.1)
thread_safe (0.3.4)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
tins (1.3.3)
tins (1.7.0)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.41)
tzinfo (0.3.45)
uglifier (2.1.2)
execjs (>= 0.3.0)
multi_json (~> 1.0, >= 1.0.2)
underscore-rails (1.7.0)
underscore-rails (1.8.3)
warden (1.2.3)
rack (>= 1.0)
will_paginate (3.0.7)
Expand Down Expand Up @@ -278,3 +291,6 @@ DEPENDENCIES
thin
uglifier
yard

BUNDLED WITH
1.10.6
18 changes: 11 additions & 7 deletions app/assets/javascripts/bcms/ckeditor_load.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,29 @@
// Note: Uses noConflict version of jquery to avoid possible issues with loading ckeditor.
jQuery(function ($) {
$('textarea.editor').each(function (e) {
if (editorEnabled()) {
if (editorEnabled(this.id)) {
loadEditor(this.id);
}
});
});

function editorEnabled() {
return $.cookie('editorEnabled') ? $.cookie('editorEnabled') == "true" : true;
function editorEnabled(id) {
return $.cookie(cookieName(id)) ? $.cookie(cookieName(id)) == "true" : false;
}

function disableEditor(id) {
if (typeof(CKEDITOR) != "undefined" && CKEDITOR.instances[id] != null) {
$('#' + id).val(CKEDITOR.instances[id].getData()).show();
CKEDITOR.instances[id].destroy();
$.cookie('editorEnabled', false, { expires:90, path:'/' });
$.cookie(cookieName(id), false, { expires:90, path:'/' });
}
}

function enableEditor(id) {
if (typeof(CKEDITOR) != "undefined" && CKEDITOR.instances[id] != null) {
CKEDITOR.instances[id].setData($('#' + id).val());
$('#' + id).hide();
$.cookie('editorEnabled', true, { expires:90, path:'/' });
$.cookie(cookieName(id), true, { expires:90, path:'/' });
}
}

Expand All @@ -46,9 +46,13 @@ function loadEditor(id) {
editor.config.width = '100%';
editor.config.height = 400;
}
$.cookie('editorEnabled', true, { expires:90, path:'/' });
$.cookie(cookieName(id), true, { expires:90, path:'/' });
return true;
} else {
return false;
}
}
}

function cookieName(id) {
return 'editorEnabled_' + id + '_' + $('#' + id).data('path')
}
1 change: 1 addition & 0 deletions app/assets/javascripts/cms/form_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ FormBuilder.prototype.confirmDeleteFormField = function() {
FormBuilder.prototype.editFormField = function() {
// This is the overall container for the entire field.
formBuilder.field_being_editted = $(this).parents('.control-group');
$('#modal-edit-field').find('.modal-content').load($(this).attr('data-edit-path'));
$('#modal-edit-field').modal({
show: true,
remote: $(this).attr('data-edit-path')
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/cms/content_block_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ def check_permissions
when "index", "show", "new", "create", "version", "versions"
# Allow
when "edit", "update", "inline"
raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@block)
raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@block)
when "destroy", "publish", "revert_to"
raise Cms::Errors::AccessDenied unless current_user.able_to_publish?(@block)
raise Cms::Errors::AccessDenied unless current_cms_user.able_to_publish?(@block)
else
raise Cms::Errors::AccessDenied
end
Expand All @@ -330,7 +330,7 @@ def check_permissions
private

def render_block_in_main_container
ensure_current_user_can_view(@block)
ensure_current_cms_user_can_view(@block)
show_content_as_page(@block)
render 'render_block_in_main_container', layout: @block.class.layout
end
Expand All @@ -341,7 +341,7 @@ def render_block_in_content_library

def render_editing_frame_or_block_in_main_container
if @block.class.addressable?
if current_user.able_to_edit?(@block)
if current_cms_user.able_to_edit?(@block)
render_toolbar_and_iframe
else
render_block_in_main_container
Expand Down
10 changes: 5 additions & 5 deletions app/controllers/cms/content_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def edit
def preview
@mode = "view"
@page = Page.find_draft(params[:id].to_i)
ensure_current_user_can_view(@page)
ensure_current_cms_user_can_view(@page)
render_page
end

Expand Down Expand Up @@ -114,7 +114,7 @@ def redirect_non_cms_users_to_public_site
logger.debug "Using cms subdomain is enabled"
if request_is_for_cms_subdomain?
logger.debug "User has required a page on the cms subdomain."
if current_user.able_to?(:edit_content, :publish_content, :administrate)
if current_cms_user.able_to?(:edit_content, :publish_content, :administrate)
logger.debug "User has access to cms"
@show_toolbar = true
else
Expand All @@ -126,7 +126,7 @@ def redirect_non_cms_users_to_public_site
end
else
logger.debug "Using cms subdomain is disabled"
if current_user.able_to?(:edit_content, :publish_content, :administrate)
if current_cms_user.able_to?(:edit_content, :publish_content, :administrate)
@show_toolbar = true
end
end
Expand Down Expand Up @@ -157,7 +157,7 @@ def try_to_stream_file
end

def load_page
if current_user.able_to?(:edit_content, :publish_content, :administrate)
if current_cms_user.able_to?(:edit_content, :publish_content, :administrate)
logger.debug "Displaying draft version of page"
@page = Page.find_draft(@path)
else
Expand All @@ -167,7 +167,7 @@ def load_page
end

def check_access_to_page
ensure_current_user_can_view(@page)
ensure_current_cms_user_can_view(@page)
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/cms/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ class DashboardController < Cms::BaseController

def index
@unpublished_pages = Page.unpublished.order("updated_at desc")
@unpublished_pages = @unpublished_pages.select { |page| current_user.able_to_publish?(page) }
@incomplete_tasks = current_user.tasks.incomplete.
@unpublished_pages = @unpublished_pages.select { |page| current_cms_user.able_to_publish?(page) }
@incomplete_tasks = current_cms_user.tasks.incomplete.
includes(:page).
order("#{Task.table_name}.due_date desc, #{Page.table_name}.name").
references(:page)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/cms/links_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def link_params

def load_section
@section = Section.find(params[:section_id])
raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@section)
raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@section)
end

def load_link
@link = Link.find(params[:id])
raise Cms::Errors::AccessDenied unless current_user.able_to_edit?(@link)
raise Cms::Errors::AccessDenied unless current_cms_user.able_to_edit?(@link)
end

def load_draft_link
Expand Down
Loading