diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index 30de5967..cf9c8599 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -1,30 +1,30 @@ module Admin class ContactsController < ApplicationController - load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource through: :conference, singleton: true + load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource through: :conference, singleton: true - # GET /:conference/contact - def show; end + # GET /:conference/contact + def show; end - # GET /:conference/contact/edit - def edit; end + # GET /:conference/contact/edit + def edit; end - # PATCH/PUT /:conference/contact - def update - if @contact.update(contact_params) - redirect_to admin_conference_contact_path, notice: 'Contact details were successfully updated.' - else - render :edit + # PATCH/PUT /:conference/contact + def update + if @contact.update(contact_params) + redirect_to admin_conference_contact_path, notice: 'Contact details were successfully updated.' + else + render :edit + end end - end - # DELETE /:conference/contact - def destroy - @contact.destroy - redirect_to admin_conference_contacts_url, notice: 'Contact details were successfully destroyed.' - end + # DELETE /:conference/contact + def destroy + @contact.destroy + redirect_to admin_conference_contacts_url, notice: 'Contact details were successfully destroyed.' + end - private + private # Only allow a trusted parameter "white list" through. def contact_params # params.require(:contact).permit(:social_tag, :email, :facebook, :googleplus, :twitter, :instagram, :public) diff --git a/app/controllers/admin/event_types_controller.rb b/app/controllers/admin/event_types_controller.rb index 4c687021..34bebbf8 100644 --- a/app/controllers/admin/event_types_controller.rb +++ b/app/controllers/admin/event_types_controller.rb @@ -16,7 +16,7 @@ module Admin redirect_to(admin_conference_event_types_path( conference_id: @conference.short_title), notice: 'Event types were successfully updated.') - rescue Exception => e + rescue => e redirect_to(admin_conference_event_types_path( conference_id: @conference.short_title), alert: "Event types update failed: #{e.message}") diff --git a/app/controllers/admin/eventtypes_controller.rb b/app/controllers/admin/eventtypes_controller.rb deleted file mode 100644 index 616b4318..00000000 --- a/app/controllers/admin/eventtypes_controller.rb +++ /dev/null @@ -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 diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index a422d6db..7d17c9cf 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -57,7 +57,6 @@ module Admin # DELETE questions/1 def destroy - if can? :destroy, @question # Do not delete global questions if @question.global == false @@ -71,7 +70,7 @@ module Admin 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 diff --git a/app/controllers/admin/volunteers_controller.rb b/app/controllers/admin/volunteers_controller.rb index 970ec1e1..d7a69765 100644 --- a/app/controllers/admin/volunteers_controller.rb +++ b/app/controllers/admin/volunteers_controller.rb @@ -27,7 +27,7 @@ module Admin 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 + rescue => e redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{e.message}") end else diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb index 3116b22b..5b5dade2 100644 --- a/app/controllers/event_attachments_controller.rb +++ b/app/controllers/event_attachments_controller.rb @@ -16,7 +16,6 @@ class EventAttachmentsController < ApplicationController end def show - if @upload.public? send_file @upload.attachment.path return @@ -84,7 +83,6 @@ class EventAttachmentsController < ApplicationController end def update - respond_to do |format| if @upload.update_attributes(params[:upload]) format.html { redirect_to @upload, notice: 'Upload was successfully updated.' } @@ -97,7 +95,6 @@ class EventAttachmentsController < ApplicationController end def destroy - if can? :destroy, @proposal @upload = @proposal.event_attachments.find(params[:id]) end diff --git a/app/models/ability.rb b/app/models/ability.rb index 8f3b262c..f4b72e19 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -27,11 +27,10 @@ class Ability # The following is wrong because a user will only have 'cfp' role for a specific conference # user.is_cfp? # This is always false - user ||= User.new # guest user (not logged in) if user.new_record? - guest(user) + guest else roles = Role::ACTIONABLES.map {|i| i.parameterize.underscore} 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, SupporterLevel, 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' # 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) @@ -108,7 +107,7 @@ class Ability can :manage, Campaign, conference_id: conf_ids_for_organizer end - def guest(user) + def guest ## Abilities for everyone, even guests (not logged in users) can [:show, :gallery_photos], Conference do |conference| conference.make_conference_public == true @@ -122,7 +121,7 @@ class Ability end def signed_in(user) - guest(user) # Inherits abilities of guest + guest # Inherits abilities of guest # Conference Registration can :manage, Registration, user_id: user.id diff --git a/db/seeds.rb b/db/seeds.rb index 8294f19c..91f036d6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -8,8 +8,8 @@ # Questions qtype_yesno = QuestionType.create(title: 'Yes/No') -qtype_single = QuestionType.create(title: 'Single Choice') -qtype_multiple = QuestionType.create(title: 'Multiple Choice') +QuestionType.create(title: 'Single Choice') +QuestionType.create(title: 'Multiple Choice') answer_yes = Answer.create(title: 'Yes') answer_no = Answer.create(title: 'No') diff --git a/spec/controllers/admin/conferences_controller_spec.rb b/spec/controllers/admin/conferences_controller_spec.rb index cb4ac8ea..21c4c91c 100644 --- a/spec/controllers/admin/conferences_controller_spec.rb +++ b/spec/controllers/admin/conferences_controller_spec.rb @@ -43,7 +43,7 @@ describe Admin::ConferenceController do mailer = double allow(mailer).to receive(:deliver) 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 allow(Mailbot).to receive(:conference_date_update_mail).and_return(mailer) end