style fixes

This commit is contained in:
Stella Rouzi 2014-08-12 20:23:51 +03:00
parent eaf637e9bd
commit f7ef401be7
9 changed files with 29 additions and 54 deletions

View file

@ -16,7 +16,7 @@ module Admin
redirect_to(admin_conference_event_types_path( redirect_to(admin_conference_event_types_path(
conference_id: @conference.short_title), conference_id: @conference.short_title),
notice: 'Event types were successfully updated.') notice: 'Event types were successfully updated.')
rescue Exception => e rescue => e
redirect_to(admin_conference_event_types_path( redirect_to(admin_conference_event_types_path(
conference_id: @conference.short_title), conference_id: @conference.short_title),
alert: "Event types update failed: #{e.message}") alert: "Event types update failed: #{e.message}")

View file

@ -1,20 +0,0 @@
module Admin
class EventtypesController < ApplicationController
before_filter :verify_organizer
def show
render :eventtypes
end
def update
@conference.update_attributes!(params[:conference])
redirect_to(admin_conference_eventtypes_path(
conference_id: @conference.short_title),
notice: 'Event types were successfully updated.')
rescue => e
redirect_to(admin_conference_eventtypes_path(
conference_id: @conference.short_title),
alert: "Event types update failed: #{e.message}")
end
end
end

View file

@ -57,7 +57,6 @@ module Admin
# DELETE questions/1 # DELETE questions/1
def destroy def destroy
if can? :destroy, @question if can? :destroy, @question
# Do not delete global questions # Do not delete global questions
if @question.global == false if @question.global == false

View file

@ -27,7 +27,7 @@ module Admin
begin begin
@conference.update_attributes!(params[:conference]) @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.") redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), notice: "Volunteering options were successfully updated.")
rescue Exception => e rescue => 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]), alert: "Volunteering options update failed: #{e.message}")
end end
else else

View file

@ -16,7 +16,6 @@ class EventAttachmentsController < ApplicationController
end end
def show def show
if @upload.public? if @upload.public?
send_file @upload.attachment.path send_file @upload.attachment.path
return return
@ -84,7 +83,6 @@ class EventAttachmentsController < ApplicationController
end end
def update def update
respond_to do |format| respond_to do |format|
if @upload.update_attributes(params[:upload]) if @upload.update_attributes(params[:upload])
format.html { redirect_to @upload, notice: 'Upload was successfully updated.' } format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }
@ -97,7 +95,6 @@ class EventAttachmentsController < ApplicationController
end end
def destroy def destroy
if can? :destroy, @proposal if can? :destroy, @proposal
@upload = @proposal.event_attachments.find(params[:id]) @upload = @proposal.event_attachments.find(params[:id])
end end

View file

@ -27,11 +27,10 @@ class Ability
# The following is wrong because a user will only have 'cfp' role for a specific conference # The following is wrong because a user will only have 'cfp' role for a specific conference
# user.is_cfp? # This is always false # user.is_cfp? # This is always false
user ||= User.new # guest user (not logged in) user ||= User.new # guest user (not logged in)
if user.new_record? if user.new_record?
guest(user) guest
else else
roles = Role::ACTIONABLES.map {|i| i.parameterize.underscore} roles = Role::ACTIONABLES.map {|i| i.parameterize.underscore}
if (user.roles.pluck(:name) & roles).empty? && !user.is_admin # User has no roles if (user.roles.pluck(:name) & roles).empty? && !user.is_admin # User has no roles
@ -100,7 +99,7 @@ class Ability
can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer can :manage, SponsorshipLevel, conference_id: conf_ids_for_organizer
can :manage, SupporterLevel, conference_id: conf_ids_for_organizer can :manage, SupporterLevel, conference_id: conf_ids_for_organizer
can :manage, Target, conference_id: conf_ids_for_organizer can :manage, Target, conference_id: conf_ids_for_organizer
can :manage, Commercial#, commercialable_type: 'Conference', commercialable_id: conf_ids_for_organizer can :manage, Commercial # , commercialable_type: 'Conference', commercialable_id: conf_ids_for_organizer
can :index, Commercial, commercialable_type: 'Conference' can :index, Commercial, commercialable_type: 'Conference'
# Manage commercials for events that belong to a conference of which user is organizer # Manage commercials for events that belong to a conference of which user is organizer
can :manage, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(conference_id: conf_ids_for_organizer + conf_ids_for_cfp).pluck(:id) can :manage, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(conference_id: conf_ids_for_organizer + conf_ids_for_cfp).pluck(:id)
@ -108,7 +107,7 @@ class Ability
can :manage, Campaign, conference_id: conf_ids_for_organizer can :manage, Campaign, conference_id: conf_ids_for_organizer
end end
def guest(user) def guest
## Abilities for everyone, even guests (not logged in users) ## Abilities for everyone, even guests (not logged in users)
can [:show, :gallery_photos], Conference do |conference| can [:show, :gallery_photos], Conference do |conference|
conference.make_conference_public == true conference.make_conference_public == true
@ -122,7 +121,7 @@ class Ability
end end
def signed_in(user) def signed_in(user)
guest(user) # Inherits abilities of guest guest # Inherits abilities of guest
# Conference Registration # Conference Registration
can :manage, Registration, user_id: user.id can :manage, Registration, user_id: user.id

View file

@ -8,8 +8,8 @@
# Questions # Questions
qtype_yesno = QuestionType.create(title: 'Yes/No') qtype_yesno = QuestionType.create(title: 'Yes/No')
qtype_single = QuestionType.create(title: 'Single Choice') QuestionType.create(title: 'Single Choice')
qtype_multiple = QuestionType.create(title: 'Multiple Choice') QuestionType.create(title: 'Multiple Choice')
answer_yes = Answer.create(title: 'Yes') answer_yes = Answer.create(title: 'Yes')
answer_no = Answer.create(title: 'No') answer_no = Answer.create(title: 'No')

View file

@ -43,7 +43,7 @@ describe Admin::ConferenceController do
mailer = double mailer = double
allow(mailer).to receive(:deliver) allow(mailer).to receive(:deliver)
conference.email_settings = create(:email_settings) conference.email_settings = create(:email_settings)
patch :update, id: conference.short_title#, conference: attributes_for(:conference, start_date: Date.today + 2.days, end_date: Date.today + 4.days) patch :update, id: conference.short_title, conference: attributes_for(:conference, start_date: Date.today + 2.days, end_date: Date.today + 4.days)
conference.reload conference.reload
allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer) allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer)
end end