From f91467a00ac1d2190b796d0497cfc44c0b828c63 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Mon, 18 Aug 2014 21:26:45 +0300 Subject: [PATCH 1/6] remove trailing spaces and blank lines --- .rubocop.yml | 16 ++ .rubocop_todo.yml | 22 -- app/controllers/admin/photos_controller.rb | 1 - app/controllers/admin/stats_controller.rb | 231 ++++++++++++++++++ app/models/answer.rb | 2 +- app/models/qanswer.rb | 2 +- app/models/question_type.rb | 2 +- config/environments/test.rb | 2 +- .../20121223135240_create_roles_table.rb | 2 +- db/migrate/20121223135447_user_roles_table.rb | 2 +- db/migrate/20130104142209_create_comments.rb | 2 +- ...9_acts_as_commentable_upgrade_migration.rb | 4 +- ...add_use_difficulty_levels_to_conference.rb | 2 +- ...305102505_use_vdays_vpositions_defaults.rb | 4 +- spec/support/database_cleaner.rb | 2 +- 15 files changed, 259 insertions(+), 37 deletions(-) create mode 100644 app/controllers/admin/stats_controller.rb diff --git a/.rubocop.yml b/.rubocop.yml index 235aa49a..4eaad6ea 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -108,6 +108,21 @@ Style/BracesAroundHashParameters: Style/CaseEquality: Enabled: true +Style/ClassAndModuleChildren: + Enabled: true + +# Offense count: 577 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +Style/StringLiterals: + Enabled: false + +Style/TrailingBlankLines: + Enabled: true + +Style/TrailingWhitespace: + Enabled: true + AllCops: Include: - '**/Rakefile' @@ -115,3 +130,4 @@ AllCops: Exclude: - 'db/schema.rb' - 'vendor/bundle/**/*' + - 'bundle/**/*' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5cb90241..9624f5f8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -5,11 +5,6 @@ # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 20 -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/ClassAndModuleChildren: - Enabled: true - # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -258,32 +253,15 @@ Style/SpaceInsideBrackets: Style/SpaceInsideHashLiteralBraces: Enabled: false -# Offense count: 577 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/StringLiterals: - Enabled: false - # Offense count: 1 Style/Tab: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/TrailingBlankLines: - Enabled: false - # Offense count: 24 # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. Style/TrailingComma: Enabled: false -# Offense count: 38 -# Cop supports --auto-correct. -Style/TrailingWhitespace: - Enabled: false - # Offense count: 8 # Cop supports --auto-correct. Style/WordArray: diff --git a/app/controllers/admin/photos_controller.rb b/app/controllers/admin/photos_controller.rb index 14c5dc17..bde977a0 100644 --- a/app/controllers/admin/photos_controller.rb +++ b/app/controllers/admin/photos_controller.rb @@ -51,4 +51,3 @@ module Admin end end end - diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb new file mode 100644 index 00000000..a98d3aab --- /dev/null +++ b/app/controllers/admin/stats_controller.rb @@ -0,0 +1,231 @@ +module Admin + class StatsController < Admin::BaseController + load_and_authorize_resource + load_and_authorize_resource :conference, find_by: :short_title + + def index + @registrations = @conference.registrations.includes(:user) + @registrations = @registrations.order('registrations.created_at ASC') + @registered = @conference.registrations.count + @attendees = @conference.registrations.where('attended = ?', true).count + @pre_registered = @conference.registrations + @pre_registered = @pre_registered.where('created_at < ?', @conference.start_date).count + @pre_registered_attended = @conference.registrations.where('created_at < ? AND attended = ?', + @conference.start_date, true).count + + @registered_with_partner = @conference.registrations.where('attending_with_partner = ?', + true).count + @attended_with_partner = @conference.registrations.where( + 'attending_with_partner = ? AND attended = ?', true, true).count + + @handicapped_access = @conference.registrations.where(handicapped_access_required: true).count + @handicapped_access_attended = @conference.registrations.where(handicapped_access_required: + true) + @handicapped_access_attended = @handicapped_access_attended.where(attended: true).count + @suggested_hotel_stay = @conference.registrations.where('using_affiliated_lodging = ?', + true).count + + @events = @conference.events + # Events charts + @machine_states = [['confirmed'], ['cancelled'], ['rejected'], ['withdrawn'], + ['new', 'review'], ['unconfirmed', 'accepted']] + # Types distribution per state + @type_state = {} + @machine_states.each do |state| + @type_state[state[0]] = var_state_func(@conference.event_types, 'event_type', state) + end + + # Tracks distribution per state + @no_track_all = @events.where(track_id: nil) + @no_track_new = @events.where(track_id: nil).where(state: ['new', 'review']) + @no_track_unconfirmed = @events.where(track_id: nil).where(state: 'unconfirmed') + @no_track_confirmed = @events.where(track_id: nil).where(state: 'confirmed') + @track_state = {} + @machine_states.each do |state| + @track_state[state[0]] = var_state_func(@conference.tracks, 'track', state) + end + + # Events_time chart + if @events.count > 0 + start_date = @events.minimum('created_at').strftime('%Y-%m-%d') + end_date = @events.maximum('created_at').strftime('%Y-%m-%d') + unless start_date.nil? || end_date.nil? + @events_time = var_time(start_date, end_date, @events, 'created_at') + end + end + + # Code for the table in events + @mystates = [] + @mytypes = [] + @eventstats = {} + @totallength = 0 + # Get totals per state + @events.state_machine.states.map.each do |mystate| + length = 0 + events_mystate = @events.where('state' => mystate.name) + if events_mystate.count > 0 + @mystates << mystate + events_mystate.each do |myevent| + length += myevent.event_type.length + end + @eventstats["#{mystate.name}"] = { 'count' => events_mystate.count, 'length' => length } + end + end + + @conference.event_types.each do |mytype| + events_mytype = @events.where('event_type_id' => mytype.id) + if events_mytype.count > 0 + @mytypes << mytype + end + end + @mytypes.each do |mytype| + @mystates.each do |mystate| + events_mytype = @events.where('event_type_id' => mytype.id) + events_mytype_mystate = events_mytype.where('state' => mystate.name) + typelength = 0 + if events_mytype_mystate.count > 0 + events_mytype_mystate.each do |myevent| + typelength += myevent.event_type.length + @totallength += myevent.event_type.length + end + if @eventstats[mytype.title].nil? + @eventstats[mytype.title] = { 'count' => events_mytype.count, + 'length' => events_mytype.count * mytype.length } + end + + tmp = { "#{mystate.name}" => { 'type_state_count' => events_mytype_mystate.count, + 'type_state_length' => typelength } } + @eventstats[mytype.title].merge!(tmp) + end + end + end + @eventstats['totallength'] = @totallength + + # SPEAKERS stats + @speakers = User.joins(:events).where('events.conference_id = ? AND events.state LIKE ?', + @conference.id, 'confirmed').uniq + @speaker_fields_user = %w(name email affiliation) + @speaker_fields_reg = %w(arrival departure) + # TICKETS stats + @supporter_levels = @conference.supporter_levels + @tickets = @conference.registrations.joins(supporter_registration: :supporter_level) + @tickets = @tickets.where('supporter_levels.title NOT LIKE ? ', '%Free%') + + @tickets_time = [] + + if @conference.registration_start_date && @conference.end_date && @registered > 0 && @supporter_levels + start_date = @conference.registration_start_date + end_date = @conference.end_date + levels = [] + @conference.supporter_levels.each do |level| + @tickets_time << { 'key' => level.title, 'values' => [] } + levels << ["#{level.title}"] + end + + (start_date..end_date).each do |day| + if @tickets.where('supporter_registrations.created_at LIKE ?', "%#{day}%").where( + 'supporter_levels.title' => levels).count != 0 + @conference.supporter_levels.each do |level| + + day_ticket_count = @tickets.where('supporter_registrations.created_at LIKE ? + AND supporter_levels.title LIKE ?', + "%#{day}%", "%#{level.title}%").count + + index = @tickets_time.index { |v| v['key'] == "#{level.title}" } + @tickets_time[index]['values'] << { 'label' => "#{day}", 'value' => day_ticket_count } + end + end + end + end + @tickets_distribution = [] + @tickets_time.each do |ticket| + value = ticket['values'].map { |x| x['value'] }.sum + percent = (value.to_f / @tickets.count * 100).round(2) + @tickets_distribution << { 'status' => ticket['key'], + 'value' => value, 'percent' => percent } + end + + # OTHER_INFO chart / To be 'Questions' + @other_info = [ + { 'status' => 'with partner (registered)', 'value' => @registered_with_partner }, + { 'status' => 'with partner (attended)', 'value' => @attended_with_partner }, + { 'status' => 'handicapped (registered)', 'value' => @handicapped_access }, + { 'status' => 'handicapped (attended)', 'value' => @handicapped_access_attended }, + { 'status' => 'stay at suggested hotel', 'value' => @suggested_hotel_stay } + ] + + # REGISTRATIONS, registered_time + if @conference.registration_start_date && @conference.end_date && @registered > 0 + start_date = @conference.registration_start_date + end_date = @conference.end_date + @registered_time = var_time(start_date, end_date, @registrations, 'created_at') + end + + respond_to do |format| + format.html + format.json { render json: @tickets_time.to_json } + end + end + # FUNCTIONS + def var_time(start_date, end_date, var, field) + result = [] + (start_date..end_date).each do |day| + day_var_count = var.where("#{field} LIKE ?", "%#{day}%").count + if day_var_count != 0 + result << { 'status' => "#{day}", 'value' => day_var_count } + end + end + result + end + + def var_state_func(vars, field, mystate) + result = [] + + vars.each do |myvar| + # Find events per track and state + value = @conference.events.where("#{field}_id" => myvar.id).where(state: mystate).count + # Find all events in that state + total = @conference.events.where(state: mystate).count + status = "#{myvar.name}" + + percent = 0 # rubocop:disable Lint/UselessAssignment + if value != 0 + percent = (value.to_f / total * 100).round(2) + result << { 'status' => status, 'value' => value, 'percent' => percent } + end + end + # Get no of events for which the field is not set (So that pie shows half piece for 50%) + sum = result.inject(0) { |s, hash| s + hash['value'] } + value = total - sum + if sum != 0 && value != 0 + percent = (value.to_f / total * 100).round(2) + result << { 'status' => "no #{field} set", 'value' => value, 'percent' => percent } + end + + result + end + + def speaker_reg(speaker) + speaker.registrations.where('conference_id = ? AND user_id = ?', + @conference.id, speaker.id).first + end + + def speaker_diet(reg) + @conference.dietary_choices.find(reg.dietary_choice_id) + end + + def diet_count(diet) + @conference.registrations.where('dietary_choice_id = ?', diet) + end + + def social_event_count(event) + @conference.registrations.joins(:social_events).where( + 'registrations_social_events.social_event_id = ?', event).count + end + + helper_method :speaker_reg + helper_method :speaker_diet + helper_method :diet_count + helper_method :social_event_count + end +end diff --git a/app/models/answer.rb b/app/models/answer.rb index fa0894fd..0a38d33c 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -1,6 +1,6 @@ class Answer < ActiveRecord::Base attr_accessible :title - + has_many :qanswers has_many :questions, through: :qanswers diff --git a/app/models/qanswer.rb b/app/models/qanswer.rb index 3376814d..bcb72da9 100644 --- a/app/models/qanswer.rb +++ b/app/models/qanswer.rb @@ -3,6 +3,6 @@ class Qanswer < ActiveRecord::Base belongs_to :question belongs_to :answer, dependent: :delete - + has_and_belongs_to_many :registrations end diff --git a/app/models/question_type.rb b/app/models/question_type.rb index 1326c5b2..4d349253 100644 --- a/app/models/question_type.rb +++ b/app/models/question_type.rb @@ -1,5 +1,5 @@ class QuestionType < ActiveRecord::Base attr_accessible :title, :description - + has_many :questions end diff --git a/config/environments/test.rb b/config/environments/test.rb index 5fe68d99..df75cb36 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -11,7 +11,7 @@ Osem::Application.configure do config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" - # Do not eager load code on boot. + # Do not eager load code on boot. config.eager_load = false # Show full error reports and disable caching diff --git a/db/migrate/20121223135240_create_roles_table.rb b/db/migrate/20121223135240_create_roles_table.rb index b9417255..2fa3e899 100644 --- a/db/migrate/20121223135240_create_roles_table.rb +++ b/db/migrate/20121223135240_create_roles_table.rb @@ -5,7 +5,7 @@ class CreateRolesTable < ActiveRecord::Migration t.timestamps end end - + def self.down drop_table :roles end diff --git a/db/migrate/20121223135447_user_roles_table.rb b/db/migrate/20121223135447_user_roles_table.rb index 1f23cbb1..459b3172 100644 --- a/db/migrate/20121223135447_user_roles_table.rb +++ b/db/migrate/20121223135447_user_roles_table.rb @@ -4,7 +4,7 @@ class UserRolesTable < ActiveRecord::Migration t.references :role, :user end end - + def self.down drop_table :roles_users end diff --git a/db/migrate/20130104142209_create_comments.rb b/db/migrate/20130104142209_create_comments.rb index f52c0c2b..23abf7f6 100644 --- a/db/migrate/20130104142209_create_comments.rb +++ b/db/migrate/20130104142209_create_comments.rb @@ -1,7 +1,7 @@ class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| - t.string :title, limit: 50, default: "" + t.string :title, limit: 50, default: "" t.text :comment t.references :commentable, polymorphic: true t.references :user diff --git a/db/migrate/20130104142839_acts_as_commentable_upgrade_migration.rb b/db/migrate/20130104142839_acts_as_commentable_upgrade_migration.rb index d89ae1f6..d70bee0f 100644 --- a/db/migrate/20130104142839_acts_as_commentable_upgrade_migration.rb +++ b/db/migrate/20130104142839_acts_as_commentable_upgrade_migration.rb @@ -5,15 +5,13 @@ class ActsAsCommentableUpgradeMigration < ActiveRecord::Migration add_column :comments, :parent_id, :integer add_column :comments, :lft, :integer add_column :comments, :rgt, :integer - end - + def self.down rename_column :comments, :body, :comment remove_column :comments, :subject remove_column :comments, :parent_id remove_column :comments, :lft remove_column :comments, :rgt - end end diff --git a/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb b/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb index 00df5c25..c60721e4 100644 --- a/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb +++ b/db/migrate/20140212175251_add_use_difficulty_levels_to_conference.rb @@ -1,5 +1,5 @@ class AddUseDifficultyLevelsToConference < ActiveRecord::Migration def change - add_column :conferences, :use_difficulty_levels, :boolean, default: false + add_column :conferences, :use_difficulty_levels, :boolean, default: false end end diff --git a/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb b/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb index c579854e..4ab07be9 100644 --- a/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb +++ b/db/migrate/20140305102505_use_vdays_vpositions_defaults.rb @@ -5,7 +5,7 @@ class UseVdaysVpositionsDefaults < ActiveRecord::Migration end def down - change_column :conferences, :use_vpositions, :boolean, default: nil - change_column :conferences, :use_vdays, :boolean, default: nil + change_column :conferences, :use_vpositions, :boolean, default: nil + change_column :conferences, :use_vdays, :boolean, default: nil end end diff --git a/spec/support/database_cleaner.rb b/spec/support/database_cleaner.rb index 4fb7551f..e0dbc9aa 100644 --- a/spec/support/database_cleaner.rb +++ b/spec/support/database_cleaner.rb @@ -6,7 +6,7 @@ RSpec.configure do |config| config.before(:each) do DatabaseCleaner.strategy = :transaction end - + config.before(:each, js: true) do DatabaseCleaner.strategy = :truncation end From b7c45718d82929dd19d177b15f98212945d368be Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Mon, 18 Aug 2014 21:54:43 +0300 Subject: [PATCH 2/6] apply StringLiterals cop (remove double quotes, unless there is string interpolation) --- .rubocop.yml | 5 +- Guardfile | 2 +- .../admin/callforpapers_controller.rb | 4 +- .../admin/difficulty_levels_controller.rb | 8 +- app/controllers/admin/questions_controller.rb | 8 +- .../admin/supporters_controller.rb | 19 +++ .../admin/volunteers_controller.rb | 2 +- app/controllers/application_controller.rb | 4 +- app/controllers/conference_controller.rb | 8 +- .../event_attachments_controller.rb | 110 ++++++++++++++++++ app/controllers/home_controller.rb | 2 +- app/controllers/proposal_controller.rb | 4 +- app/controllers/schedule_controller.rb | 6 +- app/helpers/application_helper.rb | 28 ++--- app/helpers/proposal_helper.rb | 2 +- app/helpers/registration_helper.rb | 14 +++ app/mailers/mailbot.rb | 2 +- app/models/ahoy/event.rb | 2 +- app/models/contact.rb | 2 +- app/models/datatable.rb | 4 +- app/models/event_attachment.rb | 26 +++++ app/models/photo.rb | 2 +- app/models/visit.rb | 2 +- config/application.rb | 2 +- config/environment.rb | 2 +- config/environments/test.rb | 2 +- config/initializers/formtastic.rb | 2 +- config/initializers/time_formats.rb | 2 +- config/routes.rb | 14 +-- .../20121223110942_devise_create_users.rb | 4 +- .../20121223115106_create_people_table.rb | 8 +- .../20121223115125_create_tracks_table.rb | 2 +- .../20121223115135_create_events_table.rb | 4 +- ...0121223122307_create_event_people_table.rb | 2 +- db/migrate/20130104142209_create_comments.rb | 2 +- ...20140212172244_create_difficulty_levels.rb | 2 +- db/seeds.rb | 6 +- spec/factories/email_settings.rb | 12 +- spec/features/event_types_spec.rb | 2 +- spec/features/omniauth_spec.rb | 14 +-- spec/features/photo_spec.rb | 2 +- spec/support/save_feature_failures.rb | 4 +- .../admin/conference/roles.html.haml_spec.rb | 12 +- .../admin/emails/index.html.haml_spec.rb | 12 +- spec/views/home/index.html.haml_spec.rb | 6 +- 45 files changed, 275 insertions(+), 109 deletions(-) create mode 100644 app/controllers/admin/supporters_controller.rb create mode 100644 app/controllers/event_attachments_controller.rb create mode 100644 app/helpers/registration_helper.rb create mode 100644 app/models/event_attachment.rb diff --git a/.rubocop.yml b/.rubocop.yml index 4eaad6ea..f893244b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -111,11 +111,8 @@ Style/CaseEquality: Style/ClassAndModuleChildren: Enabled: true -# Offense count: 577 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. Style/StringLiterals: - Enabled: false + Enabled: true Style/TrailingBlankLines: Enabled: true diff --git a/Guardfile b/Guardfile index 43fd63b2..3f92b1a3 100644 --- a/Guardfile +++ b/Guardfile @@ -8,7 +8,7 @@ guard_opts = { cmd: 'spring rspec' } -def model_specs ; "spec/models" end +def model_specs ; 'spec/models' end def model_spec(model) "spec/models/#{model}_spec.rb" diff --git a/app/controllers/admin/callforpapers_controller.rb b/app/controllers/admin/callforpapers_controller.rb index b18d80de..650c9901 100644 --- a/app/controllers/admin/callforpapers_controller.rb +++ b/app/controllers/admin/callforpapers_controller.rb @@ -28,7 +28,7 @@ module Admin else redirect_to(admin_conference_callforpapers_path( id: @conference.short_title), - alert: "Updating call for papers failed. #{@cfp.errors.to_a.join(". ")}.") + alert: "Updating call for papers failed. #{@cfp.errors.to_a.join('. ')}.") end end @@ -44,7 +44,7 @@ module Admin else redirect_to(admin_conference_callforpapers_path( id: @conference.short_title), - alert: "Creating the call for papers failed. #{@cfp.errors.to_a.join(". ")}.") + alert: "Creating the call for papers failed. #{@cfp.errors.to_a.join('. ')}.") end end end diff --git a/app/controllers/admin/difficulty_levels_controller.rb b/app/controllers/admin/difficulty_levels_controller.rb index cfab7528..b8cb674c 100644 --- a/app/controllers/admin/difficulty_levels_controller.rb +++ b/app/controllers/admin/difficulty_levels_controller.rb @@ -13,18 +13,18 @@ module Admin begin @conference.use_difficulty_levels = false @conference.save! - flash[:error] = "You cannot enable the usage of difficulty levels without having set any levels." + flash[:error] = 'You cannot enable the usage of difficulty levels without having set any levels.' redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) rescue ActiveRecord::RecordInvalid - flash[:error] = "Something went wrong. Difficulty Levels update failed." + flash[:error] = 'Something went wrong. Difficulty Levels update failed.' redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) end else - flash[:notice] = "Difficulty Levels were successfully updated." + flash[:notice] = 'Difficulty Levels were successfully updated.' redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) end else - flash[:error] = "Difficulty Levels update failed." + flash[:error] = 'Difficulty Levels update failed.' redirect_to(admin_conference_difficulty_levels_path(conference_id: @conference.short_title)) end end diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index 08a17728..f001155e 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -33,7 +33,7 @@ module Admin # GET questions/1/edit def edit if @question.global - redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: "Sorry, you cannot edit global questions. Create a new one.") + redirect_to(admin_conference_questions_path(conference_id: @conference.short_title), alert: 'Sorry, you cannot edit global questions. Create a new one.') end end @@ -73,13 +73,13 @@ module Admin flash[:notice] = "Deleted question: #{@question.title} and its answers: #{@question.answers.map {|a| a.title}.join ','}" end rescue ActiveRecord::RecordInvalid - flash[:error] = "Could not delete question." + flash[:error] = 'Could not delete question.' end else - flash[:error] = "You cannot delete global questions." + flash[:error] = 'You cannot delete global questions.' end else - flash[:error] = "You must be an admin to delete a question." + flash[:error] = 'You must be an admin to delete a question.' end @questions = Question.where(global: true).all | Question.where(conference_id: @conference.id) diff --git a/app/controllers/admin/supporters_controller.rb b/app/controllers/admin/supporters_controller.rb new file mode 100644 index 00000000..62a1b5a9 --- /dev/null +++ b/app/controllers/admin/supporters_controller.rb @@ -0,0 +1,19 @@ +module Admin + class SupportersController < Admin::BaseController + load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource through: :conference + + def index + respond_to do |format| + format.html + format.json { render json: DatatableSupporters.new(@conference.supporter_registrations, view_context) } + end + end + + def create + params[:supporter_registration][:conference_id] = @conference.id + SupporterRegistration.create!(params[:supporter_registration]) + redirect_to(admin_conference_supporters_path(conference_id: @conference.short_title), notice: 'Supporter added') + end + end +end diff --git a/app/controllers/admin/volunteers_controller.rb b/app/controllers/admin/volunteers_controller.rb index e6c53e6e..558b20cb 100644 --- a/app/controllers/admin/volunteers_controller.rb +++ b/app/controllers/admin/volunteers_controller.rb @@ -25,7 +25,7 @@ module Admin def update if can_manage_volunteers(@conference) if @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.') else redirect_to(admin_conference_volunteers_info_path(conference_id: params[:conference_id]), alert: "Volunteering options update failed: #{@conference.errors.full_messages.join '. '}") end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1e8d6cd1..e01a9d00 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,7 +8,7 @@ class ApplicationController < ActionController::Base check_authorization unless: :devise_controller? def store_location - session[:return_to] = request.fullpath if request.get? && controller_name != "user_sessions" && controller_name != "sessions" + session[:return_to] = request.fullpath if request.get? && controller_name != 'user_sessions' && controller_name != 'sessions' end def after_sign_in_path_for(resource) @@ -49,7 +49,7 @@ class ApplicationController < ActionController::Base end rescue_from CanCan::AccessDenied do |exception| - Rails.logger.debug("Access denied!") + Rails.logger.debug('Access denied!') redirect_to root_path, alert: exception.message end diff --git a/app/controllers/conference_controller.rb b/app/controllers/conference_controller.rb index 488ec052..34f2adc6 100644 --- a/app/controllers/conference_controller.rb +++ b/app/controllers/conference_controller.rb @@ -9,14 +9,14 @@ class ConferenceController < ApplicationController subscription = Subscription.new(user_id: current_user.id, conference_id: conference.id) begin subscription.save! - flash[:success] = "You have been subscribed to receive Email Notifications from this Conference." + flash[:success] = 'You have been subscribed to receive Email Notifications from this Conference.' redirect_to root_path rescue ActiveRecord::RecordInvalid flash[:error] = subscription.errors.full_messages.to_sentence redirect_to root_path end else - flash[:notice] = "Already Subscribed" + flash[:notice] = 'Already Subscribed' redirect_to root_path end end @@ -25,7 +25,7 @@ class ConferenceController < ApplicationController conference = Conference.find_by_short_title(params[:id]) subscription = current_user.subscriptions.where(conference_id: conference.id).first if subscription.blank? - flash[:notice] = "Already Unsubscribed" + flash[:notice] = 'Already Unsubscribed' redirect_to root_path else begin @@ -41,6 +41,6 @@ class ConferenceController < ApplicationController def gallery_photos @photos = @conference.photos - render "photos", formats: [:js] + render 'photos', formats: [:js] end end diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb new file mode 100644 index 00000000..146e5dae --- /dev/null +++ b/app/controllers/event_attachments_controller.rb @@ -0,0 +1,110 @@ +class EventAttachmentsController < ApplicationController + load_and_authorize_resource :conference, find_by: :short_title + load_and_authorize_resource :proposal, class: Event + load_and_authorize_resource :upload, class: EventAttachment, through: :proposal + before_filter :verify_user + skip_before_filter :verify_user, only: [:show] + + def index + @uploads = @proposal.event_attachments + @uploads = @uploads.map{|upload| upload.to_jq_upload } + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @uploads.to_json} + end + end + + def show + if @upload.public? + send_file @upload.attachment.path + return + end + + if current_user.nil? + verify_user + return + end + + if organizer_or_admin? || current_user == upload.event.submitter + send_file @upload.attachment.path + else + raise ActionController::RoutingError.new('Not Found') + end + end + + def new + @upload = EventAttachment.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @upload } + end + end + + def edit; end + + def create + params[:event_attachment][:title] = params[:title][0] + params[:event_attachment][:public] = false + params[:event_attachment][:event_id] = params[:proposal_id] + + if cannot? :create, EventAttachment + begin + current_user.events.find(params[:proposal_id]) + rescue + # They certainly aren't allowed to attach a file to someone else's proposal + raise ActionController::RoutingError.new('Invalid proposal') + end + end + + if params.has_key?(:public) + params[:event_attachment][:public] = true + end + @upload = EventAttachment.new(params[:event_attachment]) + + respond_to do |format| + if @upload.save + format.html do + render json: [@upload.to_jq_upload].to_json, + content_type: 'text/html', + layout: false + end + format.json do + render json: [@upload.to_jq_upload].to_json, status: :created, + location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) + end + else + format.html { render action: 'new' } + format.json { render json: @upload.errors, status: :unprocessable_entity } + end + end + end + + def update + respond_to do |format| + if @upload.update_attributes(params[:upload]) + format.html { redirect_to @upload, notice: 'Upload was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: 'edit' } + format.json { render json: @upload.errors, status: :unprocessable_entity } + end + end + end + + def destroy + if can? :destroy, @proposal + @upload = @proposal.event_attachments.find(params[:id]) + end + + @upload.destroy if !@upload.nil? + + respond_to do |format| + + format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), notice: "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" } + + format.json { head :no_content } + end + end +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 8da4883f..8a53dfcb 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,7 +4,7 @@ class HomeController < ApplicationController def index @today = Date.current - @current = Conference.where("end_date >= ?", @today).order("start_date ASC") + @current = Conference.where('end_date >= ?', @today).order('start_date ASC') end def respond_to_options diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 10c2a94f..76bdded6 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -76,7 +76,7 @@ class ProposalController < ApplicationController end redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), - notice: "Proposal was successfully updated.") + notice: 'Proposal was successfully updated.') end def destroy @@ -92,7 +92,7 @@ class ProposalController < ApplicationController @event.save(validate: false) redirect_to(conference_proposal_index_path(conference_id: @conference.short_title), - notice: "Proposal was successfully withdrawn.") + notice: 'Proposal was successfully withdrawn.') end def confirm diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index 85aa6d19..efdc65c8 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -1,6 +1,6 @@ class ScheduleController < ApplicationController authorize_resource class: false - layout "application" + layout 'application' def index @conference = Conference. @@ -11,9 +11,9 @@ class ScheduleController < ApplicationController @dates = @conference.start_date..@conference.end_date if @dates == Date.current - @today = Date.current.strftime("%Y-%m-%d") + @today = Date.current.strftime('%Y-%m-%d') else - @today = @conference.start_date.strftime("%Y-%m-%d") + @today = @conference.start_date.strftime('%Y-%m-%d') end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8047d250..788e9b96 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -92,17 +92,17 @@ module ApplicationHelper def getdatetime(registration, field) if registration.send(field.to_sym).kind_of?(String) - DateTime.parse(registration.send(field.to_sym)).strftime("%d %b %H:%M") if registration.send(field.to_sym) + DateTime.parse(registration.send(field.to_sym)).strftime('%d %b %H:%M') if registration.send(field.to_sym) else - registration.send(field.to_sym).strftime("%d %b %H:%M") if registration.send(field.to_sym) + registration.send(field.to_sym).strftime('%d %b %H:%M') if registration.send(field.to_sym) end end def getdate(var) if var.kind_of?(String) - DateTime.parse(var).strftime("%a, %d %b") + DateTime.parse(var).strftime('%a, %d %b') else - var.strftime("%a, %d %b") + var.strftime('%a, %d %b') end end @@ -122,24 +122,24 @@ module ApplicationHelper end def pre_registered(event) - @conference.events.joins(:registrations).where("events.id = ?", event.id) + @conference.events.joins(:registrations).where('events.id = ?', event.id) end def add_association_link(association_name, form_builder, div_class, html_options = {}) - link_to_add_association "Add " + association_name.to_s.singularize, form_builder, div_class, html_options.merge(class: "assoc btn btn-success") + link_to_add_association 'Add ' + association_name.to_s.singularize, form_builder, div_class, html_options.merge(class: 'assoc btn btn-success') end def remove_association_link(association_name, form_builder) - link_to_remove_association("Remove " + association_name.to_s.singularize, form_builder, class: "assoc btn btn-danger") + tag(:hr) + link_to_remove_association('Remove ' + association_name.to_s.singularize, form_builder, class: 'assoc btn btn-danger') + tag(:hr) end def dynamic_association(association_name, title, form_builder, options = {}) - render "shared/dynamic_association", association_name: association_name, title: title, f: form_builder, hint: options[:hint] + render 'shared/dynamic_association', association_name: association_name, title: title, f: form_builder, hint: options[:hint] end # Same as redirect_to(:back) if there is a valid HTTP referer, otherwise redirect_to() def redirect_back_or_to(options = {}, response_status = {}) - if request.env["HTTP_REFERER"] + if request.env['HTTP_REFERER'] redirect_to(:back) else redirect_to(options, response_status) @@ -148,7 +148,7 @@ module ApplicationHelper # TODO Output better html def format_comments(comment, padding = 0) - result = "" + result = '' result += "
" result += "
" result += "#{comment.user.name} #{comment.created_at}

" @@ -160,12 +160,12 @@ module ApplicationHelper result += "" result += "" result += "" - result += "
" - result += "" + result += '' + result += '' #result += edit_admin_conference_event_path(@conference.short_title, @event) comment.children.each do |child| result += format_comments(child, 50) - result += "" + result += '' end result @@ -181,7 +181,7 @@ module ApplicationHelper markdown.render(text).html_safe end - def markdown_hint(text="") + def markdown_hint(text='') markdown("#{text} Please look at #{link_to '**Markdown Syntax**', 'https://daringfireball.net/projects/markdown/syntax', target: '_blank'} to format your text") end diff --git a/app/helpers/proposal_helper.rb b/app/helpers/proposal_helper.rb index 567b2c1f..f5b565fc 100644 --- a/app/helpers/proposal_helper.rb +++ b/app/helpers/proposal_helper.rb @@ -1,6 +1,6 @@ module ProposalHelper def generate_abstract_length_js(conference) - str = "" + str = '' conference.event_types.map do |t| str += "if ($('select option:selected').text() == '#{t.title}') {\n" str += "str = '#{t.maximum_abstract_length}';\n" diff --git a/app/helpers/registration_helper.rb b/app/helpers/registration_helper.rb new file mode 100644 index 00000000..824ee1bb --- /dev/null +++ b/app/helpers/registration_helper.rb @@ -0,0 +1,14 @@ +module RegistrationHelper + def generate_supporter_level_js(conference) + str = '' + conference.supporter_levels.map do |t| + next if t.url.empty? + + str += "if ($('#registration_supporter_registration_attributes_supporter_level_id option:selected').text() == '#{t.title}') {\n" + str += "console.log('#{t.title}');\n" + str += "str = 'If you have a confirmation or registration code, enter it here. Otherwise, you can purchase a #{t.title} ticket here, if you need to.';\n" + str += "}\n\n" + end.join("\n") + str + end +end diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index 381b77bb..9cf89b88 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -1,5 +1,5 @@ class Mailbot < ActionMailer::Base - default from: "no-reply@example.com" + default from: 'no-reply@example.com' def registration_mail(conference, person) build_email(conference, diff --git a/app/models/ahoy/event.rb b/app/models/ahoy/event.rb index 7599143a..a70e7e41 100644 --- a/app/models/ahoy/event.rb +++ b/app/models/ahoy/event.rb @@ -1,6 +1,6 @@ module Ahoy class Event < ActiveRecord::Base - self.table_name = "ahoy_events" + self.table_name = 'ahoy_events' belongs_to :visit belongs_to :user diff --git a/app/models/contact.rb b/app/models/contact.rb index a4e28035..6efa8db0 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -4,7 +4,7 @@ class Contact < ActiveRecord::Base validates :conference, presence: true # Conferences only have one contact - validates :conference_id, uniqueness: {message: "has already contact details"} + validates :conference_id, uniqueness: {message: 'has already contact details'} validates :facebook, :twitter, :googleplus, :instagram, format: URI::regexp(%w(http https)), allow_blank: true diff --git a/app/models/datatable.rb b/app/models/datatable.rb index 4ba59673..03ec9038 100644 --- a/app/models/datatable.rb +++ b/app/models/datatable.rb @@ -79,7 +79,7 @@ class Datatable sort_by << "#{sort_column(colnum)} #{sort_direction(colnum)}" colnum += 1 end - sort_by.join(", ") + sort_by.join(', ') end def sorted? index=0 @@ -93,6 +93,6 @@ class Datatable def sort_direction index=0 index = "sSortDir_#{index}" - params[index] == "desc" ? "desc" : "asc" + params[index] == 'desc' ? 'desc' : 'asc' end end diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb new file mode 100644 index 00000000..1fb3a1ee --- /dev/null +++ b/app/models/event_attachment.rb @@ -0,0 +1,26 @@ +class EventAttachment < ActiveRecord::Base + has_paper_trail + + belongs_to :event + attr_accessible :public, :attachment, :event_id, :title + + has_attached_file :attachment, path: ':rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension' + include Rails.application.routes.url_helpers + + def to_jq_upload + { + 'name' => read_attribute(:attachment_file_name), + 'size' => read_attribute(:attachment_file_size), + 'title' => read_attribute(:title), + 'public' => read_attribute(:public), + #"url" => attachment.url(:original), + 'url' => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), + 'delete_url' => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), + 'delete_type' => 'DELETE' + } + end + #:path => ":rails_root/public/system/:attachment/:id/:style/:filename", + # :url => "/system/:attachment/:id/:style/:filename" + + #has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"} +end diff --git a/app/models/photo.rb b/app/models/photo.rb index c7871db5..94be8716 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -3,7 +3,7 @@ class Photo < ActiveRecord::Base belongs_to :conference validates_presence_of :picture has_attached_file :picture, - styles: { thumb: "100x100>", large: "300x300>", banner: "600x300>" } + styles: { thumb: '100x100>', large: '300x300>', banner: '600x300>' } validates_attachment_content_type :picture, content_type: [/jpg/, /jpeg/, /png/, /gif/], diff --git a/app/models/visit.rb b/app/models/visit.rb index 6bb47fed..4ae9bb97 100644 --- a/app/models/visit.rb +++ b/app/models/visit.rb @@ -1,4 +1,4 @@ class Visit < ActiveRecord::Base - has_many :ahoy_events, class_name: "Ahoy::Event" + has_many :ahoy_events, class_name: 'Ahoy::Event' belongs_to :user end diff --git a/config/application.rb b/config/application.rb index a9790016..43872169 100644 --- a/config/application.rb +++ b/config/application.rb @@ -36,7 +36,7 @@ module Osem # config.i18n.default_locale = :de # Configure the default encoding used in templates for Ruby 1.9. - config.encoding = "utf-8" + config.encoding = 'utf-8' # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] diff --git a/config/environment.rb b/config/environment.rb index bcd18b20..0e52b624 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -2,7 +2,7 @@ require File.expand_path('../application', __FILE__) # Load the configuration file -path = Rails.root.join("config", "config.yml") +path = Rails.root.join('config', 'config.yml') begin CONFIG = YAML.load_file(path)[Rails.env] rescue diff --git a/config/environments/test.rb b/config/environments/test.rb index df75cb36..05845254 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -9,7 +9,7 @@ Osem::Application.configure do # Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true - config.static_cache_control = "public, max-age=3600" + config.static_cache_control = 'public, max-age=3600' # Do not eager load code on boot. config.eager_load = false diff --git a/config/initializers/formtastic.rb b/config/initializers/formtastic.rb index b676d4a0..29962539 100644 --- a/config/initializers/formtastic.rb +++ b/config/initializers/formtastic.rb @@ -22,7 +22,7 @@ Formtastic::FormBuilder.include_blank_for_select_by_default = false # '*'. In other words, if you configure formtastic.required # in your locale, it will replace the abbr title properly. But if you don't want to use # abbr tag, you can simply give a string as below -Formtastic::FormBuilder.required_string = "(required)" +Formtastic::FormBuilder.required_string = '(required)' # Set the string that will be appended to the labels/fieldsets which are optional # Defaults to an empty string ("") and also accepts procs (see required_string above) diff --git a/config/initializers/time_formats.rb b/config/initializers/time_formats.rb index 437e1646..41eeb416 100644 --- a/config/initializers/time_formats.rb +++ b/config/initializers/time_formats.rb @@ -1 +1 @@ -Time::DATE_FORMATS[:db_without_seconds] = "%Y-%m-%d %H:%M" +Time::DATE_FORMATS[:db_without_seconds] = '%Y-%m-%d %H:%M' diff --git a/config/routes.rb b/config/routes.rb index 3d3b98f3..d3d1366f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -69,7 +69,7 @@ Osem::Application.routes.draw do end end - patch "/questions/update_conference" => "questions#update_conference" + patch '/questions/update_conference' => 'questions#update_conference' resources :questions resources :events do @@ -91,7 +91,7 @@ Osem::Application.routes.draw do resources :conference, only: [:show] do resources :proposal do resources :commercials, except: [:show, :index] - resources :event_attachment, controller: "event_attachments" + resources :event_attachment, controller: 'event_attachments' member do patch '/confirm' => 'proposal#confirm' patch '/restart' => 'proposal#restart' @@ -103,13 +103,13 @@ Osem::Application.routes.draw do resources :ticket_purchases, only: [:create, :destroy] resource :schedule, only: [] do - get "/" => "schedule#index" + get '/' => 'schedule#index' end member do - get "gallery_photos" - patch "subscription" => "conference#subscribe" - delete "subscription" => "conference#unsubscribe" + get 'gallery_photos' + patch 'subscription' => 'conference#subscribe' + delete 'subscription' => 'conference#unsubscribe' end end @@ -129,7 +129,7 @@ Osem::Application.routes.draw do end end - get "/admin" => redirect("/admin/conference") + get '/admin' => redirect('/admin/conference') root to: 'home#index', via: [:get, :options] end diff --git a/db/migrate/20121223110942_devise_create_users.rb b/db/migrate/20121223110942_devise_create_users.rb index aa694e16..60cc97dc 100644 --- a/db/migrate/20121223110942_devise_create_users.rb +++ b/db/migrate/20121223110942_devise_create_users.rb @@ -2,8 +2,8 @@ class DeviseCreateUsers < ActiveRecord::Migration def up create_table(:users) do |t| ## Database authenticatable - t.string :email, null: false, default: "" - t.string :encrypted_password, null: false, default: "" + t.string :email, null: false, default: '' + t.string :encrypted_password, null: false, default: '' ## Recoverable t.string :reset_password_token diff --git a/db/migrate/20121223115106_create_people_table.rb b/db/migrate/20121223115106_create_people_table.rb index f378afaa..75563b7d 100644 --- a/db/migrate/20121223115106_create_people_table.rb +++ b/db/migrate/20121223115106_create_people_table.rb @@ -2,10 +2,10 @@ class CreatePeopleTable < ActiveRecord::Migration def up create_table :people do |t| t.string :guid, null: false - t.string :first_name, default: "" - t.string :last_name, default: "" - t.string :public_name, default: "" - t.string :company, default: "" + t.string :first_name, default: '' + t.string :last_name, default: '' + t.string :public_name, default: '' + t.string :company, default: '' t.string :email, null: false t.boolean :email_public t.string :avatar_file_name diff --git a/db/migrate/20121223115125_create_tracks_table.rb b/db/migrate/20121223115125_create_tracks_table.rb index 58d50fda..5680c476 100644 --- a/db/migrate/20121223115125_create_tracks_table.rb +++ b/db/migrate/20121223115125_create_tracks_table.rb @@ -5,7 +5,7 @@ class CreateTracksTable < ActiveRecord::Migration t.references :conference t.string :name, null: false t.text :description - t.string :color, default: "#ffffff" + t.string :color, default: '#ffffff' t.timestamps end diff --git a/db/migrate/20121223115135_create_events_table.rb b/db/migrate/20121223115135_create_events_table.rb index a0c9fac0..56f14f36 100644 --- a/db/migrate/20121223115135_create_events_table.rb +++ b/db/migrate/20121223115135_create_events_table.rb @@ -7,8 +7,8 @@ class CreateEventsTable < ActiveRecord::Migration t.string :title, null: false t.string :subtitle t.integer :time_slots - t.string :state, null: false, default: "new" - t.string :progress, null: false, default: "new" + t.string :state, null: false, default: 'new' + t.string :progress, null: false, default: 'new' t.string :language t.datetime :start_time t.text :abstract diff --git a/db/migrate/20121223122307_create_event_people_table.rb b/db/migrate/20121223122307_create_event_people_table.rb index 3459b433..27e32a44 100644 --- a/db/migrate/20121223122307_create_event_people_table.rb +++ b/db/migrate/20121223122307_create_event_people_table.rb @@ -4,7 +4,7 @@ class CreateEventPeopleTable < ActiveRecord::Migration t.references :proposal t.references :person t.references :event - t.string :event_role, null: false, default: "participant" + t.string :event_role, null: false, default: 'participant' t.string :comment t.timestamps diff --git a/db/migrate/20130104142209_create_comments.rb b/db/migrate/20130104142209_create_comments.rb index 23abf7f6..b9c9ce79 100644 --- a/db/migrate/20130104142209_create_comments.rb +++ b/db/migrate/20130104142209_create_comments.rb @@ -1,7 +1,7 @@ class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| - t.string :title, limit: 50, default: "" + t.string :title, limit: 50, default: '' t.text :comment t.references :commentable, polymorphic: true t.references :user diff --git a/db/migrate/20140212172244_create_difficulty_levels.rb b/db/migrate/20140212172244_create_difficulty_levels.rb index dd5be4d0..bdd9547c 100644 --- a/db/migrate/20140212172244_create_difficulty_levels.rb +++ b/db/migrate/20140212172244_create_difficulty_levels.rb @@ -4,7 +4,7 @@ class CreateDifficultyLevels < ActiveRecord::Migration t.references :conference t.string :title t.text :description - t.string :color, default: "#ffffff" + t.string :color, default: '#ffffff' t.timestamps end diff --git a/db/seeds.rb b/db/seeds.rb index 5d8d6774..286cec69 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -14,9 +14,9 @@ user.skip_confirmation! user.save! # Questions -qtype_yesno = QuestionType.create(title: "Yes/No") -QuestionType.create(title: "Single Choice") -QuestionType.create(title: "Multiple Choice") +qtype_yesno = QuestionType.create(title: 'Yes/No') +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/factories/email_settings.rb b/spec/factories/email_settings.rb index fb009931..4fc7764e 100644 --- a/spec/factories/email_settings.rb +++ b/spec/factories/email_settings.rb @@ -15,13 +15,13 @@ FactoryGirl.define do updated_conference_registration_dates_subject 'Conference registration dates have been updated' updated_conference_registration_dates_template 'Sample Conference\n New Dates: January 17 - 21 2014' send_on_venue_update true - venue_update_subject "Venue has been updated" - venue_update_template "Venue has been Updated to Sample Location" + venue_update_subject 'Venue has been updated' + venue_update_template 'Venue has been Updated to Sample Location' registration_subject 'Lorem Ipsum Dolsum' registration_email_template 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' - call_for_papers_dates_updates_subject "Call for Papers dates have been updated" - call_for_papers_dates_updates_template "Please checkout the new updates to submit your proposal for Sample Conference" - call_for_papers_schedule_public_subject "Sample Conference Cfp schedule is Public" - call_for_papers_schedule_public_template "Call for Papers schedule is Public.Checkout the link" + call_for_papers_dates_updates_subject 'Call for Papers dates have been updated' + call_for_papers_dates_updates_template 'Please checkout the new updates to submit your proposal for Sample Conference' + call_for_papers_schedule_public_subject 'Sample Conference Cfp schedule is Public' + call_for_papers_schedule_public_template 'Call for Papers schedule is Public.Checkout the link' end end diff --git a/spec/features/event_types_spec.rb b/spec/features/event_types_spec.rb index a71aacfa..425aab75 100644 --- a/spec/features/event_types_spec.rb +++ b/spec/features/event_types_spec.rb @@ -44,7 +44,7 @@ feature EventType do value).to eq('300') # Remove event type - within("div.nested-fields:nth-of-type(3)") do + within('div.nested-fields:nth-of-type(3)') do click_link 'Remove event_type' end expect(page.all('div.nested-fields').count == 2).to be true diff --git a/spec/features/omniauth_spec.rb b/spec/features/omniauth_spec.rb index 3d343a8f..93ccd4a4 100644 --- a/spec/features/omniauth_spec.rb +++ b/spec/features/omniauth_spec.rb @@ -15,7 +15,7 @@ feature Openid do visit '/accounts/sign_in' mock_auth_new_user - within("#openidlinks") do + within('#openidlinks') do click_link 'omniauth-google' end expect(flash).to eq('test-1@gmail.com signed in successfully with google') @@ -30,7 +30,7 @@ feature Openid do visit '/accounts/sign_in' mock_auth_existing_user_participant - within("#openidlinks") do + within('#openidlinks') do click_link 'omniauth-google' end expect(flash).to eq('test-participant-1@google.com signed in successfully with google') @@ -42,7 +42,7 @@ feature Openid do OmniAuth.config.mock_auth[:google] = :invalid_credentials visit '/accounts/sign_in' expect(page.has_content?('or sign in using')).to be true - within("#openidlinks") do + within('#openidlinks') do click_link 'omniauth-google' end @@ -60,7 +60,7 @@ feature Openid do visit '/accounts/edit' mock_auth_new_user - within("#openidlinks") do + within('#openidlinks') do click_link 'omniauth-google' end expect(flash).to eq('test-participant-1@google.com signed in successfully with google') @@ -77,7 +77,7 @@ feature Openid do visit '/accounts/sign_in' mock_auth_existing_user_participant - within("#openidlinks") do + within('#openidlinks') do click_link 'omniauth-google' end expect(flash).to eq('test-participant-1@google.com signed in successfully with google') @@ -90,7 +90,7 @@ feature Openid do visit '/accounts/edit' mock_auth_new_user - within("#openidlinks") do + within('#openidlinks') do click_link 'omniauth-google' end expect(flash).to eq('test-participant-1@google.com signed in successfully with google') @@ -106,7 +106,7 @@ feature Openid do visit '/accounts/sign_in' mock_auth_new_user_fb - within("#openidlinks") do + within('#openidlinks') do click_link 'omniauth-facebook' end expect(flash).to eq('test-participant-1@google.com signed in successfully with facebook') diff --git a/spec/features/photo_spec.rb b/spec/features/photo_spec.rb index 9f9a94c0..b803eaeb 100644 --- a/spec/features/photo_spec.rb +++ b/spec/features/photo_spec.rb @@ -56,7 +56,7 @@ feature Photo do click_button 'Save Photo' expect(flash). - to eq("A error prohibited this Photo from being saved: Picture content type is invalid. Picture is invalid.") + to eq('A error prohibited this Photo from being saved: Picture content type is invalid. Picture is invalid.') expect(Photo.count).to eq(expected_count) end end diff --git a/spec/support/save_feature_failures.rb b/spec/support/save_feature_failures.rb index 8ff680cd..4cfb68d4 100644 --- a/spec/support/save_feature_failures.rb +++ b/spec/support/save_feature_failures.rb @@ -3,9 +3,9 @@ RSpec.configure do |config| config.after(:each, type: :feature) do ename = RSpec.current_example.full_description - ename = ename.gsub " ", "_" + ename = ename.gsub ' ', '_' ename.downcase! - ename = ename + ".html" + ename = ename + '.html' if RSpec.current_example.exception.present? save_page(ename) else diff --git a/spec/views/admin/conference/roles.html.haml_spec.rb b/spec/views/admin/conference/roles.html.haml_spec.rb index 0223cf4c..cce0bef4 100644 --- a/spec/views/admin/conference/roles.html.haml_spec.rb +++ b/spec/views/admin/conference/roles.html.haml_spec.rb @@ -16,11 +16,11 @@ describe 'admin/conference/roles' do expect(rendered).to include("Add role 'Organizer' to user:") expect(rendered).to include('Add role') expect(rendered).to include('Users with role Organizer') - expect(rendered).to have_selector("table thead th:nth-of-type(1)", text: 'ID') - expect(rendered).to have_selector("table thead th:nth-of-type(2)", text: 'Name') - expect(rendered).to have_selector("table thead th:nth-of-type(3)", text: 'Email') - expect(rendered).to have_selector("table tbody tr:nth-of-type(1) td:nth-of-type(1)", text: organizer.id) - expect(rendered).to have_selector("table tbody tr:nth-of-type(1) td:nth-of-type(2)", text: 'test name') - expect(rendered).to have_selector("table tbody tr:nth-of-type(1) td:nth-of-type(3)", text: 'test@email.com') + expect(rendered).to have_selector('table thead th:nth-of-type(1)', text: 'ID') + expect(rendered).to have_selector('table thead th:nth-of-type(2)', text: 'Name') + expect(rendered).to have_selector('table thead th:nth-of-type(3)', text: 'Email') + expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(1)', text: organizer.id) + expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(2)', text: 'test name') + expect(rendered).to have_selector('table tbody tr:nth-of-type(1) td:nth-of-type(3)', text: 'test@email.com') end end diff --git a/spec/views/admin/emails/index.html.haml_spec.rb b/spec/views/admin/emails/index.html.haml_spec.rb index 44fd435c..89c3c394 100644 --- a/spec/views/admin/emails/index.html.haml_spec.rb +++ b/spec/views/admin/emails/index.html.haml_spec.rb @@ -18,15 +18,15 @@ describe 'admin/emails/index' do to include('Conference dates have been updated') expect(rendered). to include('Conference registration dates have been updated') - expect(rendered).to include("Venue has been updated") - expect(rendered).to include("Venue has been Updated to Sample Location") + expect(rendered).to include('Venue has been updated') + expect(rendered).to include('Venue has been Updated to Sample Location') expect(rendered). - to include("Call for Papers dates have been updated") + to include('Call for Papers dates have been updated') expect(rendered). - to include("Please checkout the new updates to submit your proposal for Sample Conference") + to include('Please checkout the new updates to submit your proposal for Sample Conference') expect(rendered). - to include("Sample Conference Cfp schedule is Public") + to include('Sample Conference Cfp schedule is Public') expect(rendered). - to include("Call for Papers schedule is Public.Checkout the link") + to include('Call for Papers schedule is Public.Checkout the link') end end diff --git a/spec/views/home/index.html.haml_spec.rb b/spec/views/home/index.html.haml_spec.rb index 5c258854..2beff825 100644 --- a/spec/views/home/index.html.haml_spec.rb +++ b/spec/views/home/index.html.haml_spec.rb @@ -1,10 +1,10 @@ require 'spec_helper' describe 'home/index' do - it "renders _conference partial for each conference" do - allow(view).to receive(:date_string).and_return("January 17 - 21 2014") + it 'renders _conference partial for each conference' do + allow(view).to receive(:date_string).and_return('January 17 - 21 2014') assign(:current, [create(:conference), create(:conference)]) render - expect(view).to render_template(partial: "_conference_details", count: 2) + expect(view).to render_template(partial: '_conference_details', count: 2) end end From da061b3902e70759592d86590830e4dec52fdb16 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Tue, 19 Aug 2014 20:14:27 +0300 Subject: [PATCH 3/6] exclude config/ from rubocop styling, more style fixes --- .rubocop.yml | 1 + app/controllers/admin/registration_periods_controller.rb | 2 +- spec/controllers/admin/registration_periods_controller_spec.rb | 1 - spec/features/registration_periods_spec.rb | 2 +- spec/views/conference/show.html.haml_spec.rb | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f893244b..a7e5fc01 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -128,3 +128,4 @@ AllCops: - 'db/schema.rb' - 'vendor/bundle/**/*' - 'bundle/**/*' + - 'config/**/*' diff --git a/app/controllers/admin/registration_periods_controller.rb b/app/controllers/admin/registration_periods_controller.rb index aa9ba661..05cdf705 100644 --- a/app/controllers/admin/registration_periods_controller.rb +++ b/app/controllers/admin/registration_periods_controller.rb @@ -36,7 +36,7 @@ module Admin redirect_to admin_conference_registration_period_path(@conference.short_title), notice: 'Registration Period successfully updated.' else - flash[:alert] = "A error prohibited the Registration Period from being saved: " \ + flash[:alert] = 'A error prohibited the Registration Period from being saved: ' \ "#{@registration_period.errors.full_messages.join('. ')}." render :edit end diff --git a/spec/controllers/admin/registration_periods_controller_spec.rb b/spec/controllers/admin/registration_periods_controller_spec.rb index a95064e0..982ae938 100644 --- a/spec/controllers/admin/registration_periods_controller_spec.rb +++ b/spec/controllers/admin/registration_periods_controller_spec.rb @@ -162,4 +162,3 @@ describe Admin::RegistrationPeriodsController do end end - diff --git a/spec/features/registration_periods_spec.rb b/spec/features/registration_periods_spec.rb index e26b6dd2..88035d76 100644 --- a/spec/features/registration_periods_spec.rb +++ b/spec/features/registration_periods_spec.rb @@ -17,7 +17,7 @@ feature RegistrationPeriod do click_button 'Save Registration Period' expect(flash). - to eq("A error prohibited the Registration Period from being saved: " \ + to eq('A error prohibited the Registration Period from being saved: ' \ "Start date can't be blank. End date can't be blank.") page. diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 6c60ca70..a30b850b 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'conference/show.html.haml' do before(:each) do - allow(view).to receive(:date_string).and_return("January 17 - 21 2014") + allow(view).to receive(:date_string).and_return('January 17 - 21 2014') @conference = create(:conference, sponsor_email: 'example@example.com') From 1fbbbdae6e85d83677bc076599896b1155ba33ea Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Tue, 26 Aug 2014 11:06:14 +0300 Subject: [PATCH 4/6] deletions --- app/controllers/admin/stats_controller.rb | 231 ------------------ .../event_attachments_controller.rb | 110 --------- app/models/event_attachment.rb | 26 -- 3 files changed, 367 deletions(-) delete mode 100644 app/controllers/admin/stats_controller.rb delete mode 100644 app/controllers/event_attachments_controller.rb delete mode 100644 app/models/event_attachment.rb diff --git a/app/controllers/admin/stats_controller.rb b/app/controllers/admin/stats_controller.rb deleted file mode 100644 index a98d3aab..00000000 --- a/app/controllers/admin/stats_controller.rb +++ /dev/null @@ -1,231 +0,0 @@ -module Admin - class StatsController < Admin::BaseController - load_and_authorize_resource - load_and_authorize_resource :conference, find_by: :short_title - - def index - @registrations = @conference.registrations.includes(:user) - @registrations = @registrations.order('registrations.created_at ASC') - @registered = @conference.registrations.count - @attendees = @conference.registrations.where('attended = ?', true).count - @pre_registered = @conference.registrations - @pre_registered = @pre_registered.where('created_at < ?', @conference.start_date).count - @pre_registered_attended = @conference.registrations.where('created_at < ? AND attended = ?', - @conference.start_date, true).count - - @registered_with_partner = @conference.registrations.where('attending_with_partner = ?', - true).count - @attended_with_partner = @conference.registrations.where( - 'attending_with_partner = ? AND attended = ?', true, true).count - - @handicapped_access = @conference.registrations.where(handicapped_access_required: true).count - @handicapped_access_attended = @conference.registrations.where(handicapped_access_required: - true) - @handicapped_access_attended = @handicapped_access_attended.where(attended: true).count - @suggested_hotel_stay = @conference.registrations.where('using_affiliated_lodging = ?', - true).count - - @events = @conference.events - # Events charts - @machine_states = [['confirmed'], ['cancelled'], ['rejected'], ['withdrawn'], - ['new', 'review'], ['unconfirmed', 'accepted']] - # Types distribution per state - @type_state = {} - @machine_states.each do |state| - @type_state[state[0]] = var_state_func(@conference.event_types, 'event_type', state) - end - - # Tracks distribution per state - @no_track_all = @events.where(track_id: nil) - @no_track_new = @events.where(track_id: nil).where(state: ['new', 'review']) - @no_track_unconfirmed = @events.where(track_id: nil).where(state: 'unconfirmed') - @no_track_confirmed = @events.where(track_id: nil).where(state: 'confirmed') - @track_state = {} - @machine_states.each do |state| - @track_state[state[0]] = var_state_func(@conference.tracks, 'track', state) - end - - # Events_time chart - if @events.count > 0 - start_date = @events.minimum('created_at').strftime('%Y-%m-%d') - end_date = @events.maximum('created_at').strftime('%Y-%m-%d') - unless start_date.nil? || end_date.nil? - @events_time = var_time(start_date, end_date, @events, 'created_at') - end - end - - # Code for the table in events - @mystates = [] - @mytypes = [] - @eventstats = {} - @totallength = 0 - # Get totals per state - @events.state_machine.states.map.each do |mystate| - length = 0 - events_mystate = @events.where('state' => mystate.name) - if events_mystate.count > 0 - @mystates << mystate - events_mystate.each do |myevent| - length += myevent.event_type.length - end - @eventstats["#{mystate.name}"] = { 'count' => events_mystate.count, 'length' => length } - end - end - - @conference.event_types.each do |mytype| - events_mytype = @events.where('event_type_id' => mytype.id) - if events_mytype.count > 0 - @mytypes << mytype - end - end - @mytypes.each do |mytype| - @mystates.each do |mystate| - events_mytype = @events.where('event_type_id' => mytype.id) - events_mytype_mystate = events_mytype.where('state' => mystate.name) - typelength = 0 - if events_mytype_mystate.count > 0 - events_mytype_mystate.each do |myevent| - typelength += myevent.event_type.length - @totallength += myevent.event_type.length - end - if @eventstats[mytype.title].nil? - @eventstats[mytype.title] = { 'count' => events_mytype.count, - 'length' => events_mytype.count * mytype.length } - end - - tmp = { "#{mystate.name}" => { 'type_state_count' => events_mytype_mystate.count, - 'type_state_length' => typelength } } - @eventstats[mytype.title].merge!(tmp) - end - end - end - @eventstats['totallength'] = @totallength - - # SPEAKERS stats - @speakers = User.joins(:events).where('events.conference_id = ? AND events.state LIKE ?', - @conference.id, 'confirmed').uniq - @speaker_fields_user = %w(name email affiliation) - @speaker_fields_reg = %w(arrival departure) - # TICKETS stats - @supporter_levels = @conference.supporter_levels - @tickets = @conference.registrations.joins(supporter_registration: :supporter_level) - @tickets = @tickets.where('supporter_levels.title NOT LIKE ? ', '%Free%') - - @tickets_time = [] - - if @conference.registration_start_date && @conference.end_date && @registered > 0 && @supporter_levels - start_date = @conference.registration_start_date - end_date = @conference.end_date - levels = [] - @conference.supporter_levels.each do |level| - @tickets_time << { 'key' => level.title, 'values' => [] } - levels << ["#{level.title}"] - end - - (start_date..end_date).each do |day| - if @tickets.where('supporter_registrations.created_at LIKE ?', "%#{day}%").where( - 'supporter_levels.title' => levels).count != 0 - @conference.supporter_levels.each do |level| - - day_ticket_count = @tickets.where('supporter_registrations.created_at LIKE ? - AND supporter_levels.title LIKE ?', - "%#{day}%", "%#{level.title}%").count - - index = @tickets_time.index { |v| v['key'] == "#{level.title}" } - @tickets_time[index]['values'] << { 'label' => "#{day}", 'value' => day_ticket_count } - end - end - end - end - @tickets_distribution = [] - @tickets_time.each do |ticket| - value = ticket['values'].map { |x| x['value'] }.sum - percent = (value.to_f / @tickets.count * 100).round(2) - @tickets_distribution << { 'status' => ticket['key'], - 'value' => value, 'percent' => percent } - end - - # OTHER_INFO chart / To be 'Questions' - @other_info = [ - { 'status' => 'with partner (registered)', 'value' => @registered_with_partner }, - { 'status' => 'with partner (attended)', 'value' => @attended_with_partner }, - { 'status' => 'handicapped (registered)', 'value' => @handicapped_access }, - { 'status' => 'handicapped (attended)', 'value' => @handicapped_access_attended }, - { 'status' => 'stay at suggested hotel', 'value' => @suggested_hotel_stay } - ] - - # REGISTRATIONS, registered_time - if @conference.registration_start_date && @conference.end_date && @registered > 0 - start_date = @conference.registration_start_date - end_date = @conference.end_date - @registered_time = var_time(start_date, end_date, @registrations, 'created_at') - end - - respond_to do |format| - format.html - format.json { render json: @tickets_time.to_json } - end - end - # FUNCTIONS - def var_time(start_date, end_date, var, field) - result = [] - (start_date..end_date).each do |day| - day_var_count = var.where("#{field} LIKE ?", "%#{day}%").count - if day_var_count != 0 - result << { 'status' => "#{day}", 'value' => day_var_count } - end - end - result - end - - def var_state_func(vars, field, mystate) - result = [] - - vars.each do |myvar| - # Find events per track and state - value = @conference.events.where("#{field}_id" => myvar.id).where(state: mystate).count - # Find all events in that state - total = @conference.events.where(state: mystate).count - status = "#{myvar.name}" - - percent = 0 # rubocop:disable Lint/UselessAssignment - if value != 0 - percent = (value.to_f / total * 100).round(2) - result << { 'status' => status, 'value' => value, 'percent' => percent } - end - end - # Get no of events for which the field is not set (So that pie shows half piece for 50%) - sum = result.inject(0) { |s, hash| s + hash['value'] } - value = total - sum - if sum != 0 && value != 0 - percent = (value.to_f / total * 100).round(2) - result << { 'status' => "no #{field} set", 'value' => value, 'percent' => percent } - end - - result - end - - def speaker_reg(speaker) - speaker.registrations.where('conference_id = ? AND user_id = ?', - @conference.id, speaker.id).first - end - - def speaker_diet(reg) - @conference.dietary_choices.find(reg.dietary_choice_id) - end - - def diet_count(diet) - @conference.registrations.where('dietary_choice_id = ?', diet) - end - - def social_event_count(event) - @conference.registrations.joins(:social_events).where( - 'registrations_social_events.social_event_id = ?', event).count - end - - helper_method :speaker_reg - helper_method :speaker_diet - helper_method :diet_count - helper_method :social_event_count - end -end diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb deleted file mode 100644 index 146e5dae..00000000 --- a/app/controllers/event_attachments_controller.rb +++ /dev/null @@ -1,110 +0,0 @@ -class EventAttachmentsController < ApplicationController - load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :proposal, class: Event - load_and_authorize_resource :upload, class: EventAttachment, through: :proposal - before_filter :verify_user - skip_before_filter :verify_user, only: [:show] - - def index - @uploads = @proposal.event_attachments - @uploads = @uploads.map{|upload| upload.to_jq_upload } - - respond_to do |format| - format.html # index.html.erb - format.json { render json: @uploads.to_json} - end - end - - def show - if @upload.public? - send_file @upload.attachment.path - return - end - - if current_user.nil? - verify_user - return - end - - if organizer_or_admin? || current_user == upload.event.submitter - send_file @upload.attachment.path - else - raise ActionController::RoutingError.new('Not Found') - end - end - - def new - @upload = EventAttachment.new - - respond_to do |format| - format.html # new.html.erb - format.json { render json: @upload } - end - end - - def edit; end - - def create - params[:event_attachment][:title] = params[:title][0] - params[:event_attachment][:public] = false - params[:event_attachment][:event_id] = params[:proposal_id] - - if cannot? :create, EventAttachment - begin - current_user.events.find(params[:proposal_id]) - rescue - # They certainly aren't allowed to attach a file to someone else's proposal - raise ActionController::RoutingError.new('Invalid proposal') - end - end - - if params.has_key?(:public) - params[:event_attachment][:public] = true - end - @upload = EventAttachment.new(params[:event_attachment]) - - respond_to do |format| - if @upload.save - format.html do - render json: [@upload.to_jq_upload].to_json, - content_type: 'text/html', - layout: false - end - format.json do - render json: [@upload.to_jq_upload].to_json, status: :created, - location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) - end - else - format.html { render action: 'new' } - format.json { render json: @upload.errors, status: :unprocessable_entity } - end - end - end - - def update - respond_to do |format| - if @upload.update_attributes(params[:upload]) - format.html { redirect_to @upload, notice: 'Upload was successfully updated.' } - format.json { head :no_content } - else - format.html { render action: 'edit' } - format.json { render json: @upload.errors, status: :unprocessable_entity } - end - end - end - - def destroy - if can? :destroy, @proposal - @upload = @proposal.event_attachments.find(params[:id]) - end - - @upload.destroy if !@upload.nil? - - respond_to do |format| - - format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), notice: "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" } - - format.json { head :no_content } - end - end -end diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb deleted file mode 100644 index 1fb3a1ee..00000000 --- a/app/models/event_attachment.rb +++ /dev/null @@ -1,26 +0,0 @@ -class EventAttachment < ActiveRecord::Base - has_paper_trail - - belongs_to :event - attr_accessible :public, :attachment, :event_id, :title - - has_attached_file :attachment, path: ':rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension' - include Rails.application.routes.url_helpers - - def to_jq_upload - { - 'name' => read_attribute(:attachment_file_name), - 'size' => read_attribute(:attachment_file_size), - 'title' => read_attribute(:title), - 'public' => read_attribute(:public), - #"url" => attachment.url(:original), - 'url' => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), - 'delete_url' => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id), - 'delete_type' => 'DELETE' - } - end - #:path => ":rails_root/public/system/:attachment/:id/:style/:filename", - # :url => "/system/:attachment/:id/:style/:filename" - - #has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"} -end From 0b04179be9e6e192a6d9b807db43cb18a7b2be16 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Tue, 2 Sep 2014 22:17:54 +0300 Subject: [PATCH 5/6] fix quotes on tickets --- app/controllers/admin/splashpages_controller.rb | 2 +- app/controllers/admin/tickets_controller.rb | 2 +- app/controllers/ticket_purchases_controller.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/splashpages_controller.rb b/app/controllers/admin/splashpages_controller.rb index 20295865..fe06ae2c 100644 --- a/app/controllers/admin/splashpages_controller.rb +++ b/app/controllers/admin/splashpages_controller.rb @@ -35,7 +35,7 @@ module Admin if @splashpage.destroy redirect_to admin_conference_splashpage_path, notice: 'Splashpage was successfully destroyed.' else - redirect_to admin_conference_splashpage_path, alert: "A error prohibited this Splashpage from being destroyed: "\ + redirect_to admin_conference_splashpage_path, alert: 'A error prohibited this Splashpage from being destroyed: '\ "#{@splashpage.errors.full_messages.join('. ')}." end end diff --git a/app/controllers/admin/tickets_controller.rb b/app/controllers/admin/tickets_controller.rb index c90fe2cc..5920b759 100644 --- a/app/controllers/admin/tickets_controller.rb +++ b/app/controllers/admin/tickets_controller.rb @@ -40,7 +40,7 @@ module Admin notice: 'Ticket successfully destroyed.') else redirect_to(admin_conference_tickets_path(conference_id: @conference.short_title), - alert: "Ticket was successfully destroyed." \ + alert: 'Ticket was successfully destroyed.' \ "#{@ticket.errors.full_messages.join('. ')}.") end end diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index d15a5f1c..5f548d88 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -7,7 +7,7 @@ class TicketPurchasesController < ApplicationController message = TicketPurchase.purchase(@conference, current_user, params[:tickets][0]) if message.blank? redirect_to conference_conference_registrations_path(@conference.short_title), - notice: "Congratulations, you have successfully purchased a ticket! " \ + notice: 'Congratulations, you have successfully purchased a ticket! ' \ "You can pay it cash on check in! Thank you for supporting #{@conference.title}!" else redirect_to conference_conference_registrations_path(@conference.short_title), @@ -22,7 +22,7 @@ class TicketPurchasesController < ApplicationController notice: 'Ticket successfully destroyed.' else redirect_to conference_conference_registrations_path(@conference.short_title), - notice: "A error prohibited deleting your purchase! "\ + notice: 'A error prohibited deleting your purchase! '\ "#{@ticket_purchases.errors.full_messages.join('. ')}." end end From 2d2b60506316674c05929209ac4947b9f3d0e093 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Tue, 2 Sep 2014 22:23:49 +0300 Subject: [PATCH 6/6] deletions --- .../admin/supporters_controller.rb | 19 ------------------- app/helpers/registration_helper.rb | 14 -------------- 2 files changed, 33 deletions(-) delete mode 100644 app/controllers/admin/supporters_controller.rb delete mode 100644 app/helpers/registration_helper.rb diff --git a/app/controllers/admin/supporters_controller.rb b/app/controllers/admin/supporters_controller.rb deleted file mode 100644 index 62a1b5a9..00000000 --- a/app/controllers/admin/supporters_controller.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Admin - class SupportersController < Admin::BaseController - load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource through: :conference - - def index - respond_to do |format| - format.html - format.json { render json: DatatableSupporters.new(@conference.supporter_registrations, view_context) } - end - end - - def create - params[:supporter_registration][:conference_id] = @conference.id - SupporterRegistration.create!(params[:supporter_registration]) - redirect_to(admin_conference_supporters_path(conference_id: @conference.short_title), notice: 'Supporter added') - end - end -end diff --git a/app/helpers/registration_helper.rb b/app/helpers/registration_helper.rb deleted file mode 100644 index 824ee1bb..00000000 --- a/app/helpers/registration_helper.rb +++ /dev/null @@ -1,14 +0,0 @@ -module RegistrationHelper - def generate_supporter_level_js(conference) - str = '' - conference.supporter_levels.map do |t| - next if t.url.empty? - - str += "if ($('#registration_supporter_registration_attributes_supporter_level_id option:selected').text() == '#{t.title}') {\n" - str += "console.log('#{t.title}');\n" - str += "str = 'If you have a confirmation or registration code, enter it here. Otherwise, you can purchase a #{t.title} ticket here, if you need to.';\n" - str += "}\n\n" - end.join("\n") - str - end -end