mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-16 13:14:03 +00:00
Merge pull request #349 from openSUSE/review_140721_basic_rubocop_rules
[Review] Request from 'KalabiYau' @ 'openSUSE/osem/review_140721_basic_rubocop_rules'
This commit is contained in:
commit
d9d72eae07
103 changed files with 686 additions and 260 deletions
|
|
@ -8,9 +8,9 @@ class Admin::DietchoicesController < ApplicationController
|
|||
def update
|
||||
begin
|
||||
@conference.update_attributes!(params[:conference])
|
||||
redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :notice => 'Dietary choices were successfully updated.')
|
||||
rescue Exception => e
|
||||
redirect_to(admin_conference_dietary_list_path(:conference_id => @conference.short_title), :alert => "Dietary choices update failed: #{e.message}")
|
||||
redirect_to(admin_conference_dietary_list_path(conference_id: @conference.short_title), notice: 'Dietary choices were successfully updated.')
|
||||
rescue => e
|
||||
redirect_to(admin_conference_dietary_list_path(conference_id: @conference.short_title), alert: "Dietary choices update failed: #{e.message}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,19 +12,18 @@ class Admin::DifficultyLevelsController < ApplicationController
|
|||
@conference.use_difficulty_levels = false
|
||||
@conference.save!
|
||||
flash[:error] = "You cannot enable the usage of difficulty levels without having set any levels."
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash[:error] = "Something went wrong. Difficulty Levels update failed."
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
end
|
||||
else
|
||||
flash[:notice] = "Difficulty Levels were successfully updated."
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
end
|
||||
else
|
||||
flash[:error] = "Difficulty Levels update failed."
|
||||
redirect_to(admin_conference_difficulty_levels_path(:conference_id => @conference.short_title))
|
||||
redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title))
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ module Admin
|
|||
|
||||
@mystates = []
|
||||
@mytypes = []
|
||||
@eventstats = Hash.new
|
||||
@eventstats = {}
|
||||
@totallength = 0
|
||||
|
||||
@machine_states.each do |mystate|
|
||||
|
|
@ -50,7 +50,7 @@ module Admin
|
|||
@totallength += myevent.event_type.length
|
||||
end
|
||||
|
||||
if @eventstats[mytype.title] == nil
|
||||
if @eventstats[mytype.title].nil?
|
||||
@eventstats[mytype.title] = { 'count' => events_mytype.count,
|
||||
'length' => events_mytype.count * mytype.length }
|
||||
end
|
||||
|
|
@ -150,7 +150,7 @@ module Admin
|
|||
@event = Event.find(params[:id])
|
||||
@ratings = @event.votes.includes(:user)
|
||||
|
||||
if votes = current_user.votes.find_by_event_id(params[:id])
|
||||
if (votes = current_user.votes.find_by_event_id(params[:id]))
|
||||
votes.update_attributes(rating: params[:rating])
|
||||
else
|
||||
@myvote = @event.votes.build
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Admin::EventtypesController < ApplicationController
|
|||
redirect_to(admin_conference_eventtypes_path(
|
||||
conference_id: @conference.short_title),
|
||||
notice: 'Event types were successfully updated.')
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
redirect_to(admin_conference_eventtypes_path(
|
||||
conference_id: @conference.short_title),
|
||||
alert: "Event types update failed: #{e.message}")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ class Admin::QuestionsController < ApplicationController
|
|||
|
||||
def index
|
||||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id)
|
||||
@questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
|
||||
@questions_conference = @conference.questions
|
||||
@new_question = @conference.questions.new
|
||||
end
|
||||
|
|
@ -34,7 +34,7 @@ class Admin::QuestionsController < ApplicationController
|
|||
@question = Question.find(params[:id])
|
||||
|
||||
if @question.global == true && !has_role?(current_user, "Admin")
|
||||
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :alert => "Sorry, you cannot edit global questions. Create a new one.")
|
||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -45,9 +45,9 @@ class Admin::QuestionsController < ApplicationController
|
|||
@question = Question.find(params[:id])
|
||||
|
||||
if @question.update_attributes(params[:question])
|
||||
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
|
||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Question '#{@question.title}' for #{@conference.short_title} successfully updated.")
|
||||
else
|
||||
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.")
|
||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -56,9 +56,9 @@ class Admin::QuestionsController < ApplicationController
|
|||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
|
||||
if @conference.update_attributes(params[:conference])
|
||||
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Questions for #{@conference.short_title} successfully updated.")
|
||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Questions for #{@conference.short_title} successfully updated.")
|
||||
else
|
||||
redirect_to(admin_conference_questions_path(:conference_id => @conference.short_title), :notice => "Update of questions for #{@conference.short_title} failed.")
|
||||
redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), notice: "Update of questions for #{@conference.short_title} failed.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ class Admin::QuestionsController < ApplicationController
|
|||
a.delete
|
||||
end
|
||||
flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}"
|
||||
end
|
||||
end
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash[:error] = "Could not delete question."
|
||||
end
|
||||
|
|
@ -90,7 +90,7 @@ class Admin::QuestionsController < ApplicationController
|
|||
flash[:error] = "You must be an admin to delete a question."
|
||||
end
|
||||
|
||||
@questions = Question.where(:global => true).all | Question.where(:conference_id => @conference.id)
|
||||
@questions_conference = @conference.questions
|
||||
@questions = Question.where(global: true).all | Question.where(conference_id: @conference.id)
|
||||
@questions_conference = @conference.questions
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ module Admin
|
|||
@registration.update_attributes!(params[:registration])
|
||||
flash[:success] = "Successfully updated registration for #{@user.name} #{@user.email}"
|
||||
redirect_to(admin_conference_registrations_path(@conference.short_title))
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
Rails.logger.debug e.backtrace.join("\n")
|
||||
redirect_to(admin_conference_registrations_path(@conference.short_title),
|
||||
alert: 'Failed to update registration:' + e.message)
|
||||
|
|
@ -104,7 +104,7 @@ module Admin
|
|||
begin registration.destroy
|
||||
redirect_to admin_conference_registrations_path
|
||||
flash[:notice] = "Deleted registration for #{user.name} #{user.email}"
|
||||
rescue Exception => e
|
||||
rescue => e
|
||||
Rails.logger.debug e.backtrace.join("\n")
|
||||
redirect_to(admin_conference_registrations_path(@conference.short_title),
|
||||
alert: 'Failed to delete registration:' + e.message)
|
||||
|
|
|
|||
|
|
@ -7,11 +7,9 @@ class Admin::SocialEventsController < ApplicationController
|
|||
|
||||
def update
|
||||
if @conference.update_attributes(params[:conference])
|
||||
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events were successfully updated.')
|
||||
redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events were successfully updated.')
|
||||
else
|
||||
redirect_to(admin_conference_social_events_path(:conference_id => @conference.short_title), :notice => 'Social events update failed.')
|
||||
redirect_to(admin_conference_social_events_path(conference_id: @conference.short_title), notice: 'Social events update failed.')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ module Admin
|
|||
if @events.count > 0
|
||||
start_date = @events.minimum('created_at').strftime('%Y-%m-%d')
|
||||
end_date = @events.maximum('created_at').strftime('%Y-%m-%d')
|
||||
unless start_date == nil || end_date == nil
|
||||
unless start_date.nil? || end_date.nil?
|
||||
@events_time = var_time(start_date, end_date, @events, 'created_at')
|
||||
end
|
||||
end
|
||||
|
|
@ -87,7 +87,7 @@ module Admin
|
|||
typelength += myevent.event_type.length
|
||||
@totallength += myevent.event_type.length
|
||||
end
|
||||
if @eventstats[mytype.title] == nil
|
||||
if @eventstats[mytype.title].nil?
|
||||
@eventstats[mytype.title] = { 'count' => events_mytype.count,
|
||||
'length' => events_mytype.count * mytype.length }
|
||||
end
|
||||
|
|
@ -187,7 +187,7 @@ module Admin
|
|||
total = @conference.events.where(state: mystate).count
|
||||
status = "#{myvar.name}"
|
||||
|
||||
percent = 0
|
||||
percent = 0 # rubocop:disable Lint/UselessAssignment
|
||||
if value != 0
|
||||
percent = (value.to_f / total * 100).round(2)
|
||||
result << { 'status' => status, 'value' => value, 'percent' => percent }
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ class Admin::SupporterLevelsController < ApplicationController
|
|||
def update
|
||||
begin
|
||||
@conference.update_attributes!(params[:conference])
|
||||
redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :notice => 'Supporter levels were successfully updated.')
|
||||
rescue Exception => e
|
||||
redirect_to(admin_conference_supporter_levels_path(:conference_id => @conference.short_title), :alert => "Supporter levels update failed: #{e.message}")
|
||||
redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), notice: 'Supporter levels were successfully updated.')
|
||||
rescue => e
|
||||
redirect_to(admin_conference_supporter_levels_path(conference_id: @conference.short_title), alert: "Supporter levels update failed: #{e.message}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class Admin::SupportersController < ApplicationController
|
|||
|
||||
def create
|
||||
params[:supporter_registration][:conference_id] = @conference.id
|
||||
supporter = SupporterRegistration.create!(params[:supporter_registration])
|
||||
redirect_to(admin_conference_supporters_path(:conference_id => @conference.short_title), :notice => "Supporter added")
|
||||
SupporterRegistration.create!(params[:supporter_registration])
|
||||
redirect_to(admin_conference_supporters_path(conference_id: @conference.short_title), notice: "Supporter added")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,5 +27,4 @@ class Admin::VenueController < ApplicationController
|
|||
@venue = @conference.venue
|
||||
render :venue_info
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class Admin::VolunteersController < ApplicationController
|
|||
if @conference.use_vpositions
|
||||
@volunteers = @conference.registrations.joins(:vchoices).uniq
|
||||
else
|
||||
@volunteers = @conference.registrations.where(:volunteer => true)
|
||||
@volunteers = @conference.registrations.where(volunteer: true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -17,9 +17,9 @@ class Admin::VolunteersController < ApplicationController
|
|||
@conference = Conference.find_by(short_title: params[:conference_id])
|
||||
begin
|
||||
@conference.update_attributes!(params[:conference])
|
||||
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :notice => "Volunteering options were successfully updated.")
|
||||
rescue Exception => e
|
||||
redirect_to(admin_conference_volunteers_info_path(:conference_id => params[:conference_id]), :alert => "Volunteering options update failed: #{e.message}")
|
||||
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.")
|
||||
rescue => e
|
||||
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{e.message}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue