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

@ -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)

View file

@ -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}")

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
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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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')

View file

@ -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