Skip to content

Commit

Permalink
Merge db3ba1e into 61578ce
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Frick committed Sep 24, 2014
2 parents 61578ce + db3ba1e commit 74b9c97
Show file tree
Hide file tree
Showing 246 changed files with 1,388 additions and 1,389 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -20,7 +20,7 @@ end
if !ENV['TRAVIS'] || ENV['DB'] == 'mysql'
group :mysql do
gem 'activerecord-jdbcmysql-adapter', '>= 1.3.0.rc1', platform: :jruby
gem 'mysql2', :platform => :ruby
gem 'mysql2', platform: :ruby
end
end

Expand Down
4 changes: 2 additions & 2 deletions Rakefile
Expand Up @@ -19,6 +19,6 @@ require "refinerycms-testing"
Refinery::Testing::Railtie.load_dummy_tasks File.dirname(__FILE__)

desc "Build gem files for all projects"
task :build => "all:build"
task build: "all:build"

task :default => :spec
task default: :spec
24 changes: 12 additions & 12 deletions authentication/app/controllers/refinery/admin/users_controller.rb
Expand Up @@ -3,14 +3,14 @@ module Admin
class UsersController < Refinery::AdminController

crudify :'refinery/user',
:order => 'username ASC',
:title_attribute => 'username',
:xhr_paging => true
order: 'username ASC',
title_attribute: 'username',
xhr_paging: true

before_filter :find_available_plugins, :find_available_roles,
:only => [:new, :create, :edit, :update]
before_filter :redirect_unless_user_editable!, :only => [:edit, :update]
before_filter :exclude_password_assignment_when_blank!, :only => :update
before_action :find_available_plugins, :find_available_roles,
only: [:new, :create, :edit, :update]
before_action :redirect_unless_user_editable!, only: [:edit, :update]
before_action :exclude_password_assignment_when_blank!, only: :update

def new
@user = Refinery::User.new
Expand Down Expand Up @@ -40,7 +40,7 @@ def update
@selected_plugin_names = params[:user][:plugins]

if user_is_locking_themselves_out?
flash.now[:error] = t('lockout_prevented', :scope => 'refinery.admin.users.update')
flash.now[:error] = t('lockout_prevented', scope: 'refinery.admin.users.update')
render :edit and return
end

Expand All @@ -67,16 +67,16 @@ def create_successful
end

redirect_to refinery.admin_users_path,
:notice => t('created', :what => @user.username, :scope => 'refinery.crudify')
notice: t('created', what: @user.username, scope: 'refinery.crudify')
end

def create_failed
render :action => 'new'
render action: 'new'
end

def update_successful
redirect_to refinery.admin_users_path,
:notice => t('updated', :what => @user.username, :scope => 'refinery.crudify')
notice: t('updated', what: @user.username, scope: 'refinery.crudify')
end

def update_failed
Expand All @@ -87,7 +87,7 @@ def update_failed

def find_available_plugins
@available_plugins = Refinery::Plugins.registered.in_menu.map { |a|
{ :name => a.name, :title => a.title }
{ name: a.name, title: a.title }
}.sort_by { |a| a[:title] }
end

Expand Down
16 changes: 8 additions & 8 deletions authentication/app/controllers/refinery/passwords_controller.rb
Expand Up @@ -3,17 +3,17 @@ class PasswordsController < Devise::PasswordsController
helper Refinery::Core::Engine.helpers
layout 'refinery/layouts/login'

before_filter :store_password_reset_return_to, :only => [:update]
before_action :store_password_reset_return_to, only: [:update]
def store_password_reset_return_to
session[:'refinery_user_return_to'] = refinery.admin_root_path
end
protected :store_password_reset_return_to

# Rather than overriding devise, it seems better to just apply the notice here.
after_filter :give_notice, :only => [:update]
after_action :give_notice, only: [:update]
def give_notice
if %w(notice error alert).exclude?(flash.keys.map(&:to_s)) or @refinery_user.errors.any?
flash[:notice] = t('successful', :scope => 'refinery.users.reset', :email => @refinery_user.email)
flash[:notice] = t('successful', scope: 'refinery.users.reset', email: @refinery_user.email)
end
end
protected :give_notice
Expand All @@ -26,23 +26,23 @@ def edit
end

redirect_to refinery.new_refinery_user_password_path,
:flash => ({ :error => t('code_invalid', :scope => 'refinery.users.reset') })
flash: ({ error: t('code_invalid', scope: 'refinery.users.reset') })
end

# POST /registrations/password
def create
if params[:refinery_user].present? && (email = params[:refinery_user][:email]).present? &&
(user = User.where(:email => email).first).present?
(user = User.where(email: email).first).present?

token = user.generate_reset_password_token!
UserMailer.reset_notification(user, request, token).deliver
redirect_to refinery.login_path,
:notice => t('email_reset_sent', :scope => 'refinery.users.forgot')
notice: t('email_reset_sent', scope: 'refinery.users.forgot')
else
flash.now[:error] = if (email = params[:refinery_user][:email]).blank?
t('blank_email', :scope => 'refinery.users.forgot')
t('blank_email', scope: 'refinery.users.forgot')
else
t('email_not_associated_with_account_html', :email => ERB::Util.html_escape(email), :scope => 'refinery.users.forgot').html_safe
t('email_not_associated_with_account_html', email: ERB::Util.html_escape(email), scope: 'refinery.users.forgot').html_safe
end

@refinery_user = Refinery::User.new
Expand Down
Expand Up @@ -3,12 +3,12 @@ class SessionsController < Devise::SessionsController
helper Refinery::Core::Engine.helpers
layout 'refinery/layouts/login'

before_filter :clear_unauthenticated_flash, :only => [:new]
before_action :clear_unauthenticated_flash, only: [:new]

def create
super
rescue ::BCrypt::Errors::InvalidSalt, ::BCrypt::Errors::InvalidHash
flash[:error] = t('password_encryption', :scope => 'refinery.users.forgot')
flash[:error] = t('password_encryption', scope: 'refinery.users.forgot')
redirect_to refinery.new_refinery_user_password_path
end

Expand All @@ -17,7 +17,7 @@ def create
# We don't like this alert.
def clear_unauthenticated_flash
if flash.keys.include?(:alert) and flash.any?{|k, v|
['unauthenticated', t('unauthenticated', :scope => 'devise.failure')].include?(v)
['unauthenticated', t('unauthenticated', scope: 'devise.failure')].include?(v)
}
flash.delete(:alert)
end
Expand Down
Expand Up @@ -2,7 +2,7 @@ module Refinery
class UsersController < Devise::RegistrationsController

# Protect these actions behind an admin login
before_filter :redirect?, :only => [:new, :create]
before_action :redirect?, only: [:new, :create]

helper Refinery::Core::Engine.helpers
layout 'refinery/layouts/login'
Expand Down
10 changes: 5 additions & 5 deletions authentication/app/mailers/refinery/user_mailer.rb
Expand Up @@ -4,13 +4,13 @@ class UserMailer < ActionMailer::Base
def reset_notification(user, request, reset_password_token)
@user = user
@url = refinery.edit_refinery_user_password_url({
:host => request.host_with_port,
:reset_password_token => reset_password_token
host: request.host_with_port,
reset_password_token: reset_password_token
})

mail(:to => user.email,
:subject => t('subject', :scope => 'refinery.user_mailer.reset_notification'),
:from => "\"#{Refinery::Core.site_name}\" <#{Refinery::Authentication.email_from_name}@#{request.domain}>")
mail(to: user.email,
subject: t('subject', scope: 'refinery.user_mailer.reset_notification'),
from: "\"#{Refinery::Core.site_name}\" <#{Refinery::Authentication.email_from_name}@#{request.domain}>")
end

protected
Expand Down
6 changes: 3 additions & 3 deletions authentication/app/models/refinery/role.rb
@@ -1,17 +1,17 @@
module Refinery
class Role < Refinery::Core::BaseModel

has_and_belongs_to_many :users, :join_table => :refinery_roles_users
has_and_belongs_to_many :users, join_table: :refinery_roles_users

before_validation :camelize_title
validates :title, :uniqueness => true
validates :title, uniqueness: true

def camelize_title(role_title = self.title)
self.title = role_title.to_s.camelize
end

def self.[](title)
where(:title => title.to_s.camelize).first_or_create!
where(title: title.to_s.camelize).first_or_create!
end

end
Expand Down
6 changes: 3 additions & 3 deletions authentication/app/models/refinery/user.rb
Expand Up @@ -46,8 +46,8 @@ def find_or_initialize_with_error_by_reset_password_token(original_token)
def generate_reset_password_token!
raw, enc = Devise.token_generator.generate(self.class, :reset_password_token)
update_attributes(
:reset_password_token => enc,
:reset_password_sent_at => Time.now.utc
reset_password_token: enc,
reset_password_sent_at: Time.now.utc
)
raw
end
Expand All @@ -60,7 +60,7 @@ def plugins=(plugin_names)

if plugins.empty?
plugin_names.each_with_index do |plugin_name, index|
plugins.create(:name => plugin_name, :position => index)
plugins.create(name: plugin_name, position: index)
end
else
assigned_plugins = plugins.load
Expand Down
@@ -1,9 +1,9 @@
<ul>
<li>
<%= render '/refinery/admin/search', :url => refinery.admin_users_path %>
<%= render '/refinery/admin/search', url: refinery.admin_users_path %>
</li>
<li>
<%= link_to t('.create_new_user'),
refinery.new_admin_user_path, :class => "add_icon" %>
refinery.new_admin_user_path, class: "add_icon" %>
</li>
</ul>
42 changes: 21 additions & 21 deletions authentication/app/views/refinery/admin/users/_form.html.erb
@@ -1,8 +1,8 @@
<%= form_for [refinery, :admin, @user] do |f| %>
<%= render '/refinery/admin/error_messages',
:object => @user,
:include_object_name => true %>
object: @user,
include_object_name: true %>

<div class='field'>
<%= f.label :username %>
Expand All @@ -18,36 +18,36 @@
</div>
<div class='field'>
<%= f.label :password %>
<%= f.password_field :password, :autocomplete => 'off' %>
<%= f.password_field :password, autocomplete: 'off' %>
<% if @user.persisted? %>
<br>
<%= content_tag(:span, t('.blank_password_keeps_current')) %>
<% end %>
</div>
<div class='field'>
<%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation, :autocomplete => 'off' %>
<%= f.password_field :password_confirmation, autocomplete: 'off' %>
</div>
<div class='field plugin_access'>
<span class='label_with_help'>
<%= f.label :plugin_access, t('.plugin_access'), :class => "title_label" %>
<%= link_to "(#{t('.enable_all')})", "", :id => "user_plugins_enable_all" %>
<%= f.label :plugin_access, t('.plugin_access'), class: "title_label" %>
<%= link_to "(#{t('.enable_all')})", "", id: "user_plugins_enable_all" %>
</span>
<ul id='plugins' class='checkboxes'>
<% @available_plugins.each do |plugin| -%>
<% if Refinery::Plugins.always_allowed.names.include?(plugin[:name]) or
(plugin[:name] == 'refinery_users' && @user.id == current_refinery_user.id) %>
<%= hidden_field_tag 'user[plugins][]', plugin[:name],
:id => "plugins_#{plugin[:name]}" %>
id: "plugins_#{plugin[:name]}" %>
<% else %>
<li>
<%= check_box_tag 'user[plugins][]', plugin[:name],
@selected_plugin_names.include?(plugin[:name]),
:id => "plugins_#{plugin[:name]}" %>
id: "plugins_#{plugin[:name]}" %>
<%= f.label 'user[plugins][]',
t('title', :scope => "refinery.plugins.#{plugin[:name].downcase}", :default => plugin[:title]),
:class => "stripped",
:for => "plugins_#{plugin[:name]}" %>
t('title', scope: "refinery.plugins.#{plugin[:name].downcase}", default: plugin[:title]),
class: "stripped",
for: "plugins_#{plugin[:name]}" %>
</li>
<% end %>
<% end %>
Expand All @@ -57,29 +57,29 @@
<% if current_refinery_user.has_role?(:superuser) && Refinery::Authentication.superuser_can_assign_roles %>
<div class='field role_access'>
<span class='label_with_help'>
<%= f.label :role_access, t('.role_access'), :class => "title_label" %>
<%= f.label :role_access, t('.role_access'), class: "title_label" %>
</span>
<ul id='roles' class='checkboxes'>
<% @available_roles.each do |role|
downcased_title = (title = role[:title]).downcase -%>
<li>
<%= check_box_tag 'user[roles][]', downcased_title, @user.has_role?(title),
:id => "roles_#{downcased_title}" %>
id: "roles_#{downcased_title}" %>
<%= f.label 'user[roles][]',
t(downcased_title, :scope => 'refinery.roles', :default => title),
:class => 'stripped',
:for => "roles_#{downcased_title}" %>
t(downcased_title, scope: 'refinery.roles', default: title),
class: 'stripped',
for: "roles_#{downcased_title}" %>
</li>
<% end %>
</ul>
</div>
<% end %>
<%= render '/refinery/admin/form_actions', :f => f,
:continue_editing => false,
:hide_delete => !current_refinery_user.can_delete?(@user),
:delete_title => t('delete', :scope => 'refinery.admin.users'),
:delete_confirmation => t('message', :scope => 'refinery.admin.delete', :title => @user.username) %>
<%= render '/refinery/admin/form_actions', f: f,
continue_editing: false,
hide_delete: !current_refinery_user.can_delete?(@user),
delete_title: t('delete', scope: 'refinery.admin.users'),
delete_confirmation: t('message', scope: 'refinery.admin.delete', title: @user.username) %>
<% end %>
<% content_for :javascripts do %>
Expand Down
@@ -1,10 +1,10 @@
<%= render 'refinery/admin/search_header', :url => refinery.admin_users_path %>
<%= render 'refinery/admin/search_header', url: refinery.admin_users_path %>
<% if @users.any? %>
<div class='pagination_container'>
<%= render 'users' %>
</div>
<% else %>
<p>
<%= t('no_results', :scope => 'refinery.admin.search') %>
<%= t('no_results', scope: 'refinery.admin.search') %>
</p>
<% end %>
16 changes: 8 additions & 8 deletions authentication/app/views/refinery/admin/users/_user.html.erb
Expand Up @@ -2,22 +2,22 @@
<span class='title'>
<strong><%= user.username %></strong>
<span class="preview">
<%= t('.preview', :who => user.email, :created_at => l(user.created_at, :format => :short)) %>
<%= t('.preview', who: user.email, created_at: l(user.created_at, format: :short)) %>
</span>
</span>
<span class='actions'>
<%= mail_to user.email, refinery_icon_tag('email_go.png'),
:title => t('.email_user') %>
title: t('.email_user') %>
<%= link_to refinery_icon_tag('application_edit.png'),
refinery.edit_admin_user_path(user),
:title => t('edit', :scope => 'refinery.admin.users') if current_refinery_user.can_edit?(user) %>
title: t('edit', scope: 'refinery.admin.users') if current_refinery_user.can_edit?(user) %>
<%= link_to refinery_icon_tag('delete.png'),
refinery.admin_user_path(user),
:class => "cancel confirm-delete",
:title => t('delete', :scope => 'refinery.admin.users'),
:method => :delete,
:data => {
:confirm => t('message', :scope => 'refinery.admin.delete', :title => user.username)
class: "cancel confirm-delete",
title: t('delete', scope: 'refinery.admin.users'),
method: :delete,
data: {
confirm: t('message', scope: 'refinery.admin.delete', title: user.username)
} if current_refinery_user.can_delete?(user) %>
</span>
</li>
@@ -1,4 +1,4 @@
<%= will_paginate @users %>
<ul>
<%= render :partial => 'user', :collection => @users %>
<%= render partial: 'user', collection: @users %>
</ul>

0 comments on commit 74b9c97

Please sign in to comment.