updated rails to 4.2.4

This commit is contained in:
raluka 2015-09-17 12:12:51 +02:00
parent 37697517df
commit 42e8bb11ea
55 changed files with 766 additions and 365 deletions

View file

@ -0,0 +1,30 @@
module Admin
class CommentsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource
def index
# All available comments, grouped and sorted
@comments = grouped_comments(accessible_ordered_comments)
# Grouped, sorted, available comments, posted since current_user last login
@unread_comments = grouped_comments(accessible_ordered_comments.find_since_last_login(current_user))
# Grouped, sorted, available comments, posted by current_user
@posted_comments = grouped_comments(accessible_ordered_comments.find_comments_by_user(current_user))
end
private
# Returning all available comments, ordered by created_at: :desc and by event.title
def accessible_ordered_comments
Comment.accessible_by(current_ability).joins('INNER JOIN events ON commentable_id = events.id').order('events.title', 'comments.created_at DESC')
end
# Grouping all comments by conference, and by event. It returns {:conference => {:event => [{comment_2}, {comment_1 }]}}
def grouped_comments(remarks)
remarks.group_by{ |comment| comment.commentable.conference }.map {|conference, comments| [conference, comments.group_by{|comment| comment.commentable}]}.to_h
end
end
end

View file

@ -27,7 +27,6 @@ module Admin
@recent_users = User.limit(5).order(created_at: :desc)
@recent_events = Event.limit(5).order(created_at: :desc)
@recent_registrations = Registration.limit(5).order(created_at: :desc)
@top_submitter = Conference.get_top_submitter
@submissions = {}

View file

@ -179,12 +179,12 @@ module Admin
def update_state(transition, notice, mail = false, subject = false, send_mail = false)
alert = @event.update_state(transition, mail, subject, send_mail, params[:send_mail].blank?)
if !alert.blank?
flash[:error] = error
return redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return
else
if alert.blank?
flash[:notice] = notice
redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return
else
flash[:error] = alert
return redirect_back_or_to(admin_conference_events_path(conference_id: @conference.short_title)) && return
end
end
end

View file

@ -17,9 +17,9 @@ module Admin
@registration.update_attributes(registration_params)
if @registration.save
redirect_to admin_conference_registrations_path(@conference.short_title),
notice: 'Successfully updated registration!'
notice: "Successfully updated registration for #{@registration.user.email}!"
else
flash[:error] = "An error prohibited the Registration for #{@conference.title}: "\
flash[:error] = "An error prohibited the Registration for #{@registration.user.email}: "\
"#{@registration.errors.full_messages.join('. ')}."
render :edit
end
@ -56,7 +56,7 @@ module Admin
permit(
:conference_id, :arrival, :departure,
:volunteer,
vchoice_ids: [], qanswer_ids: [],
vchoice_ids: [], qanswer_ids: [], event_ids: [],
qanswers_attributes: [],
user_attributes: [
:id, :name, :tshirt, :mobile, :volunteer_experience, :languages,