houndci fixes

This commit is contained in:
Gopesh Tulsyan 2014-05-26 15:43:19 +05:30
parent c67700e0ae
commit a0aa523122
11 changed files with 39 additions and 36 deletions

View file

@ -35,7 +35,7 @@ class Admin::ConferenceController < ApplicationController
else
redirect_to(edit_admin_conference_path(id: short_title),
alert: 'Updating conference failed. ' \
"#{@conference.errors.full_messages.join('. ')}.")
"#{@conference.errors.full_messages.join('. ')}.")
end
end

View file

@ -13,7 +13,7 @@ class Admin::OrganizationsController < ApplicationController
def create
@organization = Organization.new(params[:organization])
flash[:notice] = 'Organization was successfully created.' if @organization.save
respond_with @organization, :location => admin_organizations_path
respond_with @organization, location: admin_organizations_path
end
def show
@ -27,7 +27,7 @@ class Admin::OrganizationsController < ApplicationController
def update
@organization = Organization.find(params[:id])
flash[:notice] = 'Organization was successfully updated' if @organization.update_attributes(params[:organization])
respond_with @organization, :location => admin_organizations_path
respond_with @organization, location: admin_organizations_path
end
def delete
@ -37,7 +37,7 @@ class Admin::OrganizationsController < ApplicationController
def destroy
@organization = Organization.find(params[:id])
@organization.destroy
redirect_to admin_organizations_path, :notice => "Organization got deleted"
redirect_to admin_organizations_path, notice: 'Organization got deleted'
end
end
end

View file

@ -6,11 +6,14 @@ class Admin::SponsorshipLevelsController < ApplicationController
end
def update
begin
@conference.update_attributes!(params[:conference])
redirect_to(admin_conference_sponsorship_levels_path(:conference_id => @conference.short_title), :notice => 'Sponsorship levels were successfully updated.')
rescue Exception => e
redirect_to(admin_conference_sponsorship_levels_path(:conference_id => @conference.short_title), :alert => "Sponsorship levels update failed: #{e.message}")
if @conference.update_attributes!(params[:conference])
redirect_to(admin_conference_sponsorship_levels_path(
conference_id: @conference.short_title),
notice: 'Sponsorship levels were successfully updated.')
else
redirect_to(admin_conference_sponsorship_levels_path(
conference_id: @conference.short_title),
alert: 'Sponsorship levels update failed')
end
end
end

View file

@ -8,10 +8,12 @@ class Admin::SponsorshipsController < ApplicationController
params[:sponsorship_registration][:conference_id] = @conference.id
sponsorship = SponsorshipRegistration.new(params[:sponsorship_registration])
if sponsorship.save
redirect_to(admin_conference_sponsorships_path(:conference_id => @conference.short_title), :notice => "Sponsorship added")
redirect_to(admin_conference_sponsorships_path(
conference_id: @conference.short_title), notice: 'Sponsorship added')
else
redirect_to(admin_conference_sponsorships_path(:conference_id => @conference.short_title),
:alert => "Sponsorship creation failed.#{sponsorship.errors.full_messages.join('. ')}")
redirect_to(admin_conference_sponsorships_path(conference_id: @conference.short_title),
alert: 'Sponsorship creation failed.' \
"#{sponsorship.errors.full_messages.join('. ')}")
end
end
end

View file

@ -45,7 +45,7 @@ class Conference < ActiveRecord::Base
accepts_nested_attributes_for :venue
accepts_nested_attributes_for :dietary_choices, :allow_destroy => true
accepts_nested_attributes_for :supporter_levels, :allow_destroy => true
accepts_nested_attributes_for :sponsorship_levels, :allow_destroy => true
accepts_nested_attributes_for :sponsorship_levels, allow_destroy: true
accepts_nested_attributes_for :event_types, :allow_destroy => true
accepts_nested_attributes_for :email_settings
accepts_nested_attributes_for :questions, :allow_destroy => true

View file

@ -2,15 +2,13 @@ class Organization < ActiveRecord::Base
attr_accessible :title, :photo, :email_id, :description, :website_url
has_many :sponsorship_registrations, dependent: :destroy
has_attached_file :photo,
:styles => {:thumb => "100x100>", :large => "300x300>" }
styles: { thumb: '100x100>', large: '300x300>' }
validates_attachment_content_type :photo,
:content_type => [/jpg/, /jpeg/, /png/, /gif/],
:size => { :in => 0..500.kilobytes }
content_type: [/jpg/, /jpeg/, /png/, /gif/],
size: { :in => 0..500.kilobytes }
validates_presence_of :title,
:email_id,
:website_url
validates_uniqueness_of :email_id
end

View file

@ -1,5 +1,5 @@
class SponsorshipRegistration < ActiveRecord::Base
attr_accessible :name, :email_id, :contact_no, :amount_donated, :method_of_donation,
attr_accessible :name, :email_id, :contact_no, :amount_donated, :method_of_donation,
:sponsorship_level_id, :conference_id, :organization_id
belongs_to :organization
belongs_to :sponsorship_level

View file

@ -1,11 +1,11 @@
class CreateSponsorshipRegistrations < ActiveRecord::Migration
def change
create_table :sponsorship_registrations do |t|
t.string :name
t.string :email_id
t.string :contact_no
t.float :amount_donated
t.string :method_of_donation
t.string :name
t.string :email_id
t.string :contact_no
t.float :amount_donated
t.string :method_of_donation
t.belongs_to :organization
t.belongs_to :sponsorship_level
t.belongs_to :conference

View file

@ -1,13 +1,13 @@
class CreateOrganizations < ActiveRecord::Migration
def change
create_table :organizations do |t|
t.string :title
t.string :email_id
t.text :description
t.string :photo_file_name
t.string :photo_content_type
t.integer :photo_file_size
t.datetime :photo_updated_at
t.string :title
t.string :email_id
t.text :description
t.string :photo_file_name
t.string :photo_content_type
t.integer :photo_file_size
t.datetime :photo_updated_at
t.timestamps
end
end

View file

@ -11,7 +11,7 @@ FactoryGirl.define do
end_date Date.tomorrow
factory :conference_with_sponsorship_level do
after(:build) do |conference|
conference.sponsorship_levels << build(:sponsorship_level, conference: conference)
conference.sponsorship_levels << build(:sponsorship_level, conference: conference)
end
end
end

View file

@ -11,9 +11,9 @@ FactoryGirl.define do
sponsorship_level
organization
after(:build) do |sponsorship_registration|
sponsorship_registration.sponsorship_level =
build(:sponsorship_level,
conference: sponsorship_registration.conference)
sponsorship_registration.sponsorship_level =
build(:sponsorship_level,
conference: sponsorship_registration.conference)
end
end
end