Fix syntax (w/Rubocop) in (Rails) controllers

Signed-off-by: Alex Coles <alex@alexbcoles.com>
This commit is contained in:
Alex Coles
2015-06-27 12:36:20 +02:00
parent 16720d2d7c
commit ec1bb39f9b
31 changed files with 118 additions and 121 deletions
+2 -1
View File
@@ -71,7 +71,8 @@ class AccountController < ApplicationController
redirect_to(home_url) && return unless @token and !@token.expired?
@user = @token.user
if request.post?
@user.password, @user.password_confirmation = params[:new_password], params[:new_password_confirmation]
@user.password = params[:new_password]
@user.password_confirmation = params[:new_password_confirmation]
@user.force_password_change = false
if @user.save
@token.destroy
+2 -2
View File
@@ -55,10 +55,10 @@ class ActivitiesController < ApplicationController
if events.empty? || stale?(etag: [@activity.scope, @date_to, @date_from, @with_subprojects, @author, events.first, User.current, current_language])
respond_to do |format|
format.html {
format.html do
@events_by_day = events.group_by { |e| e.event_datetime.to_date }
render layout: false if request.xhr?
}
end
format.atom {
title = l(:label_activity)
if @author
@@ -109,10 +109,10 @@ module Api::Experimental::Concerns::ColumnData
existing_cf_ids = existing_custom_field_ids(custom_field_ids)
valid_cf_column_names = columns.select do |name|
valid_cf_column_names = columns.select { |name|
id = custom_field_id_in(name)
existing_cf_ids.include?(id)
end
}
# keep order of provided columns
columns & (valid_column_names + valid_cf_column_names)
@@ -171,9 +171,9 @@ module Api::Experimental::Concerns::ColumnData
work_packages.map { |wp| yield wp }
.uniq
.inject({}) do |group_sums, current_group|
work_packages_in_current_group = work_packages.select do |wp|
work_packages_in_current_group = work_packages.select { |wp|
(yield wp) == current_group
end
}
group_sums.merge current_group => column_sum(column_name, work_packages_in_current_group)
end
@@ -194,13 +194,13 @@ module Api::Experimental::Concerns::ColumnData
def fetch_columns_data(column_names, work_packages)
column_names, custom_field_column_ids = separate_columns_by_custom_fields(column_names)
columns = column_names.map do |column_name|
columns = column_names.map { |column_name|
fetch_non_custom_field_column_data(column_name, work_packages)
end
}
columns += custom_field_column_ids.map do |cf_id|
columns += custom_field_column_ids.map { |cf_id|
fetch_custom_field_column_data(cf_id, work_packages)
end
}
columns
end
@@ -214,9 +214,9 @@ module Api::Experimental::Concerns::ColumnData
end
def fetch_custom_field_column_data(custom_field_id, work_packages, display = true)
custom_field_data = work_packages.map do |wp|
custom_field_data = work_packages.map { |wp|
wp.custom_values_display_data(custom_field_id)
end
}
if display
custom_field_data.flatten
@@ -257,8 +257,6 @@ module Api::Experimental::Concerns::ColumnData
if groups
groups[0]
else
nil
end
end
@@ -42,10 +42,10 @@ module Api::V2::Concerns::MultipleProjects
# authorize
# Ignoring projects, where user has no view_work_packages permission.
permission = params[:controller].sub api_version, ''
@projects = @projects.select do |project|
@projects = @projects.select { |project|
User.current.allowed_to?({ controller: permission,
action: params[:action] },
project)
end
}
end
end
@@ -292,12 +292,12 @@ module Api
def render_errors(errors)
options = { status: :bad_request, layout: false }
options.merge!(case params[:format]
when 'xml'; { xml: errors }
when 'json'; { json: { 'errors' => errors } }
else
raise "Unknown format #{params[:format]} in #render_validation_errors"
when 'xml'; { xml: errors }
when 'json'; { json: { 'errors' => errors } }
else
raise "Unknown format #{params[:format]} in #render_validation_errors"
end
)
)
render options
end
@@ -316,7 +316,6 @@ module Api
filtered_ids = @planning_elements.map(&:id)
@planning_elements.each do |pe|
# re-wire the parent of this pe to the first ancestor found in the filtered set
# re-wiring is only needed, when there is actually a parent, and the parent has been filtered out
if pe.parent_id && !filtered_ids.include?(pe.parent_id)
@@ -106,7 +106,6 @@ module Api
@associations_by_id[a.project_b_id] ||= []
@associations_by_id[a.project_b_id] << a
end
end
@@ -98,7 +98,7 @@ module Api
condition += ' AND ' unless condition.empty?
project_parents = params[:project_parents].split(/,/).map(&:to_i)
nested_set_selection = Project.find(project_parents).map { |p| p.lft..p.rgt }.inject([]) { |r, e| e.each { |i| r << i }; r }
nested_set_selection = Project.find(project_parents).map { |p| p.lft..p.rgt }.inject([]) { |r, e| e.each do |i| r << i end; r }
temp_condition += "#{Project.quoted_table_name}.lft IN (?)"
condition_params << nested_set_selection
@@ -123,12 +123,12 @@ module Api
@reportings = @project.reportings_via_source.find(:all,
include: :project,
conditions: conditions
)
)
when 'via_target'
@reportings = @project.reportings_via_target.find(:all,
include: :project,
conditions: conditions
)
)
else
@reportings = @project.reportings.all
end
@@ -154,12 +154,12 @@ module Api
@ancestor_reportings = @project.reportings_via_source.find(:all,
include: :project,
conditions: conditions
)
)
when 'via_target'
@ancestor_reportings = @project.reportings_via_target.find(:all,
include: :project,
conditions: conditions
)
)
else
@ancestor_reportings = @project.reportings.all
end
+4 -4
View File
@@ -246,7 +246,7 @@ class ApplicationController < ActionController::Base
project_id: params[:project_id])
end
respond_to do |format|
format.any(:html, :atom) { redirect_to signin_path(back_url: url) }
format.any(:html, :atom) do redirect_to signin_path(back_url: url) end
authentication_scheme = if request.headers['X-Authentication-Scheme'] == 'Session'
'Session'
@@ -566,7 +566,7 @@ class ApplicationController < ActionController::Base
def render_feed(items, options = {})
@items = items || []
@items.sort! { |x, y| y.event_datetime <=> x.event_datetime }
@items.sort! do |x, y| y.event_datetime <=> x.event_datetime end
@items = @items.slice(0, Setting.feeds_limit.to_i)
@title = options[:title] || Setting.app_title
render template: 'common/feed', layout: false, content_type: 'application/atom+xml'
@@ -643,9 +643,9 @@ class ApplicationController < ActionController::Base
# Converts the errors on an ActiveRecord object into a common JSON format
def object_errors_to_json(object)
object.errors.map do |attribute, error|
object.errors.map { |attribute, error|
{ attribute => error }
end.to_json
}.to_json
end
# Renders API response on validation failure
+1 -1
View File
@@ -62,7 +62,7 @@ class AttachmentsController < ApplicationController
@attachment.container.attachments.delete(@attachment)
respond_to do |format|
format.html { redirect_to url_for(destroy_response_url(@attachment.container)) }
format.html do redirect_to url_for(destroy_response_url(@attachment.container)) end
format.js {}
end
end
+4 -4
View File
@@ -57,7 +57,7 @@ class BoardsController < ApplicationController
'updated_on' => "#{Message.table_name}.updated_on"
respond_to do |format|
format.html {
format.html do
set_topics
gon.rabl 'app/views/messages/index.rabl'
@@ -71,14 +71,14 @@ class BoardsController < ApplicationController
@message = Message.new
render action: 'show', layout: !request.xhr?
}
format.json {
end
format.json do
set_topics
gon.rabl 'app/views/messages/index.rabl'
render template: 'messages/index'
}
end
format.atom {
@messages = @board.messages.order(["#{Message.table_name}.sticked_on ASC", sort_clause].compact.join(', '))
.includes(:author, :board)
+1 -1
View File
@@ -55,7 +55,7 @@ class CategoriesController < ApplicationController
end
else
respond_to do |format|
format.html { render action: :new }
format.html do render action: :new end
format.js do
render(:update) { |page| page.alert(@category.errors.full_messages.join('\n')) }
end
+9 -9
View File
@@ -79,10 +79,10 @@ class GroupsController < ApplicationController
respond_to do |format|
if @group.save
flash[:notice] = l(:notice_successful_create)
format.html { redirect_to(groups_path) }
format.html do redirect_to(groups_path) end
format.xml { render xml: @group, status: :created, location: @group }
else
format.html { render action: 'new' }
format.html do render action: 'new' end
format.xml { render xml: @group.errors, status: :unprocessable_entity }
end
end
@@ -96,10 +96,10 @@ class GroupsController < ApplicationController
respond_to do |format|
if @group.update_attributes(permitted_params.group)
flash[:notice] = l(:notice_successful_update)
format.html { redirect_to(groups_path) }
format.html do redirect_to(groups_path) end
format.xml { head :ok }
else
format.html { render action: 'edit' }
format.html do render action: 'edit' end
format.xml { render xml: @group.errors, status: :unprocessable_entity }
end
end
@@ -111,7 +111,7 @@ class GroupsController < ApplicationController
@group.destroy
respond_to do |format|
format.html { redirect_to(groups_url) }
format.html do redirect_to(groups_url) end
format.xml { head :ok }
end
end
@@ -121,7 +121,7 @@ class GroupsController < ApplicationController
@users = User.includes(:memberships).where(id: params[:user_ids])
@group.users << @users
respond_to do |format|
format.html { redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' }
format.html do redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' end
format.js { render action: 'change_members' }
end
end
@@ -130,7 +130,7 @@ class GroupsController < ApplicationController
@group = Group.includes(:users).find(params[:id])
@group.users.delete(User.includes(:memberships).find(params[:user_id]))
respond_to do |format|
format.html { redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' }
format.html do redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'users' end
format.js { render action: 'change_members' }
end
end
@@ -146,7 +146,7 @@ class GroupsController < ApplicationController
@membership.save
respond_to do |format|
format.html { redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'memberships' }
format.html do redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'memberships' end
format.js { render action: 'change_memberships' }
end
end
@@ -157,7 +157,7 @@ class GroupsController < ApplicationController
membership_params = permitted_params.group_membership
Member.find(membership_params[:membership_id]).destroy
respond_to do |format|
format.html { redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'memberships' }
format.html do redirect_to controller: '/groups', action: 'edit', id: @group, tab: 'memberships' end
format.js { render action: 'destroy_memberships' }
end
end
+4 -4
View File
@@ -66,10 +66,10 @@ class JournalsController < ApplicationController
def edit
(render_403; return false) unless @journal.editable_by?(User.current)
respond_to do |format|
format.html {
format.html do
# TODO: implement non-JS journal update
render nothing: true
}
end
format.js
end
end
@@ -79,10 +79,10 @@ class JournalsController < ApplicationController
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
call_hook(:controller_journals_edit_post, journal: @journal, params: params)
respond_to do |format|
format.html {
format.html do
redirect_to controller: "/#{@journal.journable.class.name.pluralize.downcase}",
action: 'show', id: @journal.journable_id
}
end
format.js { render action: 'update' }
end
end
+9 -9
View File
@@ -54,7 +54,7 @@ class MembersController < ApplicationController
if members.present? && members.all?(&:valid?)
flash.now.notice = l(:notice_successful_create)
format.html { redirect_to settings_project_path(@project, tab: 'members') }
format.html do redirect_to settings_project_path(@project, tab: 'members') end
format.js do
@pagination_url_options = { controller: 'projects', action: 'settings', id: @project }
@@ -88,7 +88,7 @@ class MembersController < ApplicationController
end
respond_to do |format|
format.html { redirect_to controller: '/projects', action: 'settings', tab: 'members', id: @project, page: params[:page] }
format.html do redirect_to controller: '/projects', action: 'settings', tab: 'members', id: @project, page: params[:page] end
format.js do
@pagination_url_options = { controller: 'projects', action: 'settings', id: @project }
@@ -113,7 +113,7 @@ class MembersController < ApplicationController
flash.now.notice = l(:notice_successful_delete)
end
respond_to do |format|
format.html { redirect_to controller: '/projects', action: 'settings', tab: 'members', id: @project }
format.html do redirect_to controller: '/projects', action: 'settings', tab: 'members', id: @project end
format.js do
@pagination_url_options = { controller: 'projects', action: 'settings', id: @project }
render(:update) do |page|
@@ -166,15 +166,15 @@ class MembersController < ApplicationController
user_ids = possibly_seperated_ids_for_entity(params[:member], :user)
roles = Role.where(id: possibly_seperated_ids_for_entity(params[:member], :role))
new_member = lambda do |user_id|
new_member = lambda { |user_id|
Member.new(permitted_params.member).tap do |member|
member.user_id = user_id if user_id
end
end
}
members = user_ids.map do |user_id|
members = user_ids.map { |user_id|
new_member.call(user_id)
end
}
# most likely wrong user input, use a dummy member for error handling
if !members.present? && roles.present?
members << new_member.call(nil)
@@ -183,13 +183,13 @@ class MembersController < ApplicationController
end
def each_comma_seperated(array, &block)
array.map do |e|
array.map { |e|
if e.to_s.match /\d(,\d)*/
block.call(e)
else
e
end
end.flatten
}.flatten
end
def transform_array_of_comma_seperated_ids(array)
+4 -4
View File
@@ -167,7 +167,7 @@ class MyController < ApplicationController
@user = User.current
layout = get_current_layout
# remove if already present in a group
%w(top left right).each { |f| (layout[f] ||= []).delete block }
%w(top left right).each do |f| (layout[f] ||= []).delete block end
# add it on top
layout['top'].unshift block
@user.pref[:my_page_layout] = layout
@@ -182,7 +182,7 @@ class MyController < ApplicationController
@user = User.current
# remove block in all groups
layout = get_current_layout
%w(top left right).each { |f| (layout[f] ||= []).delete block }
%w(top left right).each do |f| (layout[f] ||= []).delete block end
@user.pref[:my_page_layout] = layout
@user.pref.save
render nothing: true
@@ -199,9 +199,9 @@ class MyController < ApplicationController
if group_items and group_items.is_a? Array
layout = get_current_layout
# remove group blocks if they are presents in other groups
%w(top left right).each {|f|
%w(top left right).each do|f|
layout[f] = (layout[f] || []) - group_items
}
end
layout[group] = group_items
@user.pref[:my_page_layout] = layout
@user.pref.save
+1 -1
View File
@@ -50,7 +50,7 @@ class NewsController < ApplicationController
.per_page(per_page_param)
respond_to do |format|
format.html { render layout: !request.xhr? }
format.html do render layout: !request.xhr? end
format.atom { render_feed(@newss, title: (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
end
end
+2 -2
View File
@@ -60,9 +60,9 @@ class ProjectsController < ApplicationController
# Lists visible projects
def index
respond_to do |format|
format.html {
format.html do
@projects = Project.visible.find(:all, order: 'lft')
}
end
format.atom {
projects = Project.visible.find(:all, order: 'created_on DESC',
limit: Setting.feeds_limit.to_i)
+5 -5
View File
@@ -103,7 +103,7 @@ class ReportingsController < ApplicationController
condition += ' AND ' unless condition.empty?
project_parents = params[:project_parents].split(/,/).map(&:to_i)
nested_set_selection = Project.find(project_parents).map { |p| p.lft..p.rgt }.inject([]) { |r, e| e.each { |i| r << i }; r }
nested_set_selection = Project.find(project_parents).map { |p| p.lft..p.rgt }.inject([]) { |r, e| e.each do |i| r << i end; r }
temp_condition += "#{Project.quoted_table_name}.lft IN (?)"
condition_params << nested_set_selection
@@ -128,12 +128,12 @@ class ReportingsController < ApplicationController
@reportings = @project.reportings_via_source.find(:all,
include: :project,
conditions: conditions
)
)
when 'via_target'
@reportings = @project.reportings_via_target.find(:all,
include: :project,
conditions: conditions
)
)
else
@reportings = @project.reportings.all
end
@@ -159,12 +159,12 @@ class ReportingsController < ApplicationController
@ancestor_reportings = @project.reportings_via_source.find(:all,
include: :project,
conditions: conditions
)
)
when 'via_target'
@ancestor_reportings = @project.reportings_via_target.find(:all,
include: :project,
conditions: conditions
)
)
else
@ancestor_reportings = @project.reportings.all
end
+5 -5
View File
@@ -128,7 +128,7 @@ class RepositoriesController < ApplicationController
.per_page(per_page_param)
respond_to do |format|
format.html { render layout: false if request.xhr? }
format.html do render layout: false if request.xhr? end
format.atom { render_feed(@changesets, title: "#{@project.name}: #{l(:label_revision_plural)}") }
end
end
@@ -291,14 +291,14 @@ class RepositoriesController < ApplicationController
@date_from = Date.civil(@date_from.year, @date_from.month, 1)
commits_by_day = Changeset.where(['repository_id = ? AND commit_date BETWEEN ? AND ?', repository.id, @date_from, @date_to]).group(:commit_date).size
commits_by_month = [0] * 12
commits_by_day.each { |c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
commits_by_day.each do |c| commits_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last end
changes_by_day = Change.includes(:changeset).where(["#{Changeset.table_name}.repository_id = ? AND #{Changeset.table_name}.commit_date BETWEEN ? AND ?", repository.id, @date_from, @date_to]).group(:commit_date).size
changes_by_month = [0] * 12
changes_by_day.each { |c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last }
changes_by_day.each do |c| changes_by_month[(@date_to.month - c.first.to_date.month) % 12] += c.last end
fields = []
12.times { |m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1) }
12.times do |m| fields << month_name(((Date.today.month - 1 - m) % 12) + 1) end
graph = SVG::Graph::Bar.new(
height: 300,
@@ -327,7 +327,7 @@ class RepositoriesController < ApplicationController
def graph_commits_per_author(repository)
commits_by_author = Changeset.where(['repository_id = ?', repository.id]).group(:committer).size
commits_by_author.to_a.sort! { |x, y| x.last <=> y.last }
commits_by_author.to_a.sort! do |x, y| x.last <=> y.last end
changes_by_author = Change.includes(:changeset).where(["#{Changeset.table_name}.repository_id = ?", repository.id]).group(:committer).size
h = changes_by_author.inject({}) { |o, i| o[i.first] = i.last; o }
+3 -3
View File
@@ -36,7 +36,7 @@ class SysController < ActionController::Base
def projects
p = Project.active.has_module(:repository).find(:all, include: :repository, order: 'identifier')
respond_to do |format|
format.json { render json: p.to_json(include: :repository) }
format.json do render json: p.to_json(include: :repository) end
format.any(:html, :xml) { render xml: p.to_xml(include: :repository), content_type: Mime::XML }
end
end
@@ -119,10 +119,10 @@ class SysController < ActionController::Base
end
user = nil
user_id = Rails.cache.fetch(OpenProject::RepositoryAuthentication::CACHE_PREFIX + Digest::SHA1.hexdigest("#{username}#{password}"),
expires_in: OpenProject::RepositoryAuthentication::CACHE_EXPIRES_AFTER) do
expires_in: OpenProject::RepositoryAuthentication::CACHE_EXPIRES_AFTER) {
user = user_login(username, password)
user ? user.id.to_s : '-1'
end
}
return nil if user_id.blank? or user_id == '-1'
@@ -107,7 +107,7 @@ class TimeEntries::ReportsController < ApplicationController
end
respond_to do |format|
format.html { render layout: !request.xhr? }
format.html do render layout: !request.xhr? end
format.csv { send_data(report_to_csv(@criterias, @periods, @hours), type: 'text/csv; header=present', filename: 'timelog.csv') }
end
end
+10 -10
View File
@@ -64,7 +64,7 @@ class TimelogController < ApplicationController
cond << ['spent_on BETWEEN ? AND ?', @from, @to]
respond_to do |format|
format.html {
format.html do
# Paginate results
@entry_count = TimeEntry.visible.count(include: [:project, :work_package], conditions: cond.conditions)
@@ -80,20 +80,20 @@ class TimelogController < ApplicationController
gon.settings = client_preferences
render layout: !request.xhr?
}
format.json {
end
format.json do
set_entries(cond)
gon.rabl 'app/views/timelog/index.rabl'
}
format.atom {
end
format.atom do
entries = TimeEntry.visible.find(:all,
include: [:project, :activity, :user, { work_package: :type }],
conditions: cond.conditions,
order: "#{TimeEntry.table_name}.created_on DESC",
limit: Setting.feeds_limit.to_i)
render_feed(entries, title: l(:label_spent_time))
}
end
format.csv {
# Export all entries
@entries = TimeEntry.visible.find(:all,
@@ -174,18 +174,18 @@ class TimelogController < ApplicationController
def destroy
if @time_entry.destroy && @time_entry.destroyed?
respond_to do |format|
format.html {
format.html do
flash[:notice] = l(:notice_successful_delete)
redirect_to :back
}
end
format.json { render json: { text: l(:notice_successful_delete) } }
end
else
respond_to do |format|
format.html {
format.html do
flash[:error] = l(:notice_unable_delete_time_entry)
redirect_to :back
}
end
format.json { render json: { isError: true, text: l(:notice_unable_delete_time_entry) } }
end
end
+7 -7
View File
@@ -99,7 +99,7 @@ class UsersController < ApplicationController
@events_by_day = events.group_by { |e| e.event_datetime.to_date }
unless User.current.admin?
if !(@user.active? || @user.registered?) || (@user != User.current && @memberships.empty? && events.empty?)
if !(@user.active? || @user.registered?) || (@user != User.current && @memberships.empty? && events.empty?)
render_404
return
end
@@ -146,7 +146,7 @@ class UsersController < ApplicationController
redirect_to(params[:continue] ?
new_user_path :
edit_user_path(@user)
)
)
}
end
else
@@ -246,7 +246,7 @@ class UsersController < ApplicationController
@membership.save if request.post?
respond_to do |format|
if @membership.valid?
format.html { redirect_to controller: '/users', action: 'edit', id: @user, tab: 'memberships' }
format.html do redirect_to controller: '/users', action: 'edit', id: @user, tab: 'memberships' end
format.js {
render(:update) {|page|
page.replace_html 'tab-content-memberships', partial: 'users/memberships'
@@ -286,7 +286,7 @@ class UsersController < ApplicationController
@membership.destroy && @membership = nil
end
respond_to do |format|
format.html { redirect_to controller: '/users', action: 'edit', id: @user, tab: 'memberships' }
format.html do redirect_to controller: '/users', action: 'edit', id: @user, tab: 'memberships' end
format.js {
render(:update) { |page|
page.replace_html 'tab-content-memberships', partial: 'users/memberships'
@@ -319,9 +319,9 @@ class UsersController < ApplicationController
!User.current.admin?
respond_to do |format|
format.html { render_403 }
format.xml { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' }
format.js { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' }
format.html do render_403 end
format.xml do head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' end
format.js do head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' end
format.json { head :unauthorized, 'WWW-Authenticate' => 'Basic realm="OpenProject API"' }
end
+2 -2
View File
@@ -98,7 +98,7 @@ class VersionsController < ApplicationController
end
else
respond_to do |format|
format.html { render action: 'new' }
format.html do render action: 'new' end
format.js do
render(:update) { |page| page.alert(@version.errors.full_messages.join('\n')) }
end
@@ -145,7 +145,7 @@ class VersionsController < ApplicationController
def status_by
respond_to do |format|
format.html { render action: 'show' }
format.html do render action: 'show' end
format.js { render_status_by @version, params[:status_by] }
end
end
+3 -3
View File
@@ -52,7 +52,7 @@ class WatchersController < ApplicationController
@watcher.save if request.post?
respond_to do |format|
format.html { redirect_to :back }
format.html do redirect_to :back end
format.js do
render :update do |page|
page.replace_html 'watchers', partial: 'watchers/watchers', locals: { watched: @watched }
@@ -69,7 +69,7 @@ class WatchersController < ApplicationController
def destroy
@watched.set_watcher(@watch.user, false)
respond_to do |format|
format.html { redirect_to :back }
format.html do redirect_to :back end
format.js do
render :update do |page|
page.replace_html 'watchers', partial: 'watchers/watchers', locals: { watched: @watched }
@@ -104,7 +104,7 @@ class WatchersController < ApplicationController
@watched.set_watcher(user, watching)
respond_to do |format|
format.html { redirect_to :back }
format.html do redirect_to :back end
format.js do
if params[:replace].present?
if params[:replace].is_a? Array
+1 -1
View File
@@ -330,7 +330,7 @@ class WikiController < ApplicationController
def list_attachments
respond_to do |format|
format.json { render 'common/list_attachments', locals: { attachments: @page.attachments } }
format.json do render 'common/list_attachments', locals: { attachments: @page.attachments } end
format.html {}
end
end
@@ -40,7 +40,7 @@ class WorkPackageRelationsController < ApplicationController
@relation.save
respond_to do |format|
format.html { redirect_to work_package_path(@work_package) }
format.html do redirect_to work_package_path(@work_package) end
format.js {
render action: 'create', locals: { work_package: work_package,
relation: @relation }
@@ -54,7 +54,7 @@ class WorkPackageRelationsController < ApplicationController
@relation.destroy
respond_to do |format|
format.html { redirect_to work_package_path(@work_package) }
format.html do redirect_to work_package_path(@work_package) end
format.js {}
end
end
@@ -49,12 +49,12 @@ class WorkPackages::AutoCompletesController < ApplicationController
{ q: "%#{query_term.downcase}%" }]
@work_packages |= scope.visible
.where(sql_query)
.order("#{WorkPackage.table_name}.id ASC") # :id does not work because...
.limit(10)
.where(sql_query)
.order("#{WorkPackage.table_name}.id ASC") # :id does not work because...
.limit(10)
respond_to do |format|
format.html { render layout: false }
format.html do render layout: false end
format.any(:xml, :json) { render request.format.to_sym => wp_hashes_with_string }
end
end
@@ -64,7 +64,7 @@ class WorkPackages::AutoCompletesController < ApplicationController
def wp_hashes_with_string
@work_packages.map do |work_package|
wp_hash = Hash.new
work_package.attributes.each { |key, value| wp_hash[key] = Rack::Utils.escape_html(value) }
work_package.attributes.each do |key, value| wp_hash[key] = Rack::Utils.escape_html(value) end
wp_hash['to_s'] = Rack::Utils.escape_html(work_package.to_s)
wp_hash
end
@@ -40,8 +40,8 @@ class WorkPackages::BulkController < ApplicationController
def edit
@work_packages.sort!
@available_statuses = @projects.map { |p|Workflow.available_statuses(p) }.inject { |memo, w|memo & w }
@custom_fields = @projects.map(&:all_work_package_custom_fields).inject { |memo, c|memo & c }
@available_statuses = @projects.map { |p| Workflow.available_statuses(p) }.inject { |memo, w| memo & w }
@custom_fields = @projects.map(&:all_work_package_custom_fields).inject { |memo, c| memo & c }
@assignables = @projects.map(&:possible_assignees).inject { |memo, a| memo & a }
@responsibles = @projects.map(&:possible_responsibles).inject { |memo, a| memo & a }
@types = @projects.map(&:types).inject { |memo, t| memo & t }
@@ -74,10 +74,10 @@ class WorkPackages::BulkController < ApplicationController
unless WorkPackage.cleanup_associated_before_destructing_if_required(@work_packages, current_user, params[:to_do])
respond_to do |format|
format.html {
format.html do
render locals: { work_packages: @work_packages,
associated: WorkPackage.associated_classes_to_address_before_destruction_of(@work_packages) }
}
end
format.json { render json: { error_message: 'Clean up of associated objects required' }, status: 420 }
end
@@ -86,7 +86,7 @@ class WorkPackages::BulkController < ApplicationController
destroy_work_packages(@work_packages)
respond_to do |format|
format.html { redirect_back_or_default(project_work_packages_path(@work_packages.first.project)) }
format.html do redirect_back_or_default(project_work_packages_path(@work_packages.first.project)) end
format.json { head :ok }
end
end
@@ -110,7 +110,7 @@ class WorkPackages::BulkController < ApplicationController
safe_params = permitted_params.update_work_package project: project
attributes = safe_params.reject { |_k, v| v.blank? }
attributes.keys.each { |k| attributes[k] = '' if attributes[k] == 'none' }
attributes.keys.each do |k| attributes[k] = '' if attributes[k] == 'none' end
attributes[:custom_field_values].reject! { |_k, v| v.blank? } if attributes[:custom_field_values]
attributes.delete :custom_field_values if not attributes.has_key?(:custom_field_values) or attributes[:custom_field_values].empty?
attributes
+1 -1
View File
@@ -275,7 +275,7 @@ class WorkPackagesController < ApplicationController
user: current_user }
respond_to do |format|
format.js { render partial: 'edit', locals: locals }
format.js do render partial: 'edit', locals: locals end
format.html { render action: 'edit', locals: locals }
end
end
+2 -2
View File
@@ -44,13 +44,13 @@ class WorkflowsController < ApplicationController
if request.post?
Workflow.destroy_all(['role_id=? and type_id=?', @role.id, @type.id])
(params[:status] || []).each { |status_id, transitions|
(params[:status] || []).each do |status_id, transitions|
transitions.each { |new_status_id, options|
author = options.is_a?(Array) && options.include?('author') && !options.include?('always')
assignee = options.is_a?(Array) && options.include?('assignee') && !options.include?('always')
@role.workflows.build(type_id: @type.id, old_status_id: status_id, new_status_id: new_status_id, author: author, assignee: assignee)
}
}
end
if @role.save
flash[:notice] = l(:notice_successful_update)
redirect_to action: 'edit', role_id: @role, type_id: @type