From 4e80cd6c7a76f29fc90686eec04c2b13814cf448 Mon Sep 17 00:00:00 2001 From: nfoy Date: Tue, 22 Apr 2014 17:25:37 -0400 Subject: add mailboxer gem --- Gemfile | 3 +++ Gemfile.lock | 12 ++++++++++++ generate.sh | 1 + 3 files changed, 16 insertions(+) diff --git a/Gemfile b/Gemfile index 1f30537..5a5be8b 100644 --- a/Gemfile +++ b/Gemfile @@ -49,6 +49,9 @@ gem 'jbuilder', '~> 1.2' gem 'daemons' gem 'delayed_job_active_record' +# Mailboxer supports a messaging and alerting system. +gem 'mailboxer' + group :doc do # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', require: false diff --git a/Gemfile.lock b/Gemfile.lock index e0d013b..2fc2fe5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,6 +31,11 @@ GEM bootstrap-sass (3.1.1.0) sass (~> 3.2) builder (3.1.4) + carrierwave (0.10.0) + activemodel (>= 3.2.0) + activesupport (>= 3.2.0) + json (>= 1.7) + mime-types (>= 1.16) coffee-rails (4.0.1) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) @@ -46,6 +51,8 @@ GEM delayed_job (>= 3.0, < 4.1) erubis (2.7.0) execjs (2.0.2) + foreigner (1.6.1) + activerecord (>= 3.0.0) hike (1.2.3) httparty (0.13.0) json (~> 1.8) @@ -62,6 +69,10 @@ GEM mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) + mailboxer (0.11.0) + carrierwave (>= 0.5.8) + foreigner (>= 0.9.1) + rails (> 3.0.0) mime-types (1.25.1) minitest (4.7.5) multi_json (1.9.2) @@ -137,6 +148,7 @@ DEPENDENCIES httparty jbuilder (~> 1.2) jquery-rails + mailboxer rails (= 4.0.2) sass-rails (~> 4.0.0) sdoc diff --git a/generate.sh b/generate.sh index e965fde..1aaf1e6 100755 --- a/generate.sh +++ b/generate.sh @@ -16,6 +16,7 @@ git checkout clean-start -- app test config/routes.rb bundle install +bundle exec rails generate mailboxer:install bundle exec rails generate simple_captcha bundle exec rails generate delayed_job:active_record -- cgit v1.2.3-2-g168b From 33725cbfe28125e0535f912cfaf2a44c99edfc31 Mon Sep 17 00:00:00 2001 From: nfoy Date: Tue, 22 Apr 2014 17:28:42 -0400 Subject: run ./generate.sh --- config/initializers/mailboxer.rb | 17 ++++++ .../20140422155038_create_simple_captcha_data.rb | 15 ------ .../20140422172559_create_simple_captcha_data.rb | 15 ++++++ db/migrate/20140422195042_create_delayed_jobs.rb | 22 -------- db/migrate/20140422195045_create_servers.rb | 9 ---- db/migrate/20140422195049_create_matches.rb | 13 ----- db/migrate/20140422195052_create_teams.rb | 8 --- db/migrate/20140422195056_create_alerts.rb | 10 ---- db/migrate/20140422195059_create_pms.rb | 11 ---- db/migrate/20140422195103_create_tournaments.rb | 19 ------- db/migrate/20140422195107_create_games.rb | 17 ------ db/migrate/20140422195110_create_users.rb | 13 ----- db/migrate/20140422195114_create_sessions.rb | 11 ---- db/migrate/20140422195118_create_brackets.rb | 11 ---- db/migrate/20140422195121_create_game_settings.rb | 15 ------ .../20140422195125_create_tournament_settings.rb | 15 ------ .../20140422195128_create_tournament_stages.rb | 11 ---- db/migrate/20140422195132_create_statistics.rb | 12 ----- .../20140422195135_create_remote_usernames.rb | 11 ---- .../20140422195139_create_bracket_matches.rb | 11 ---- db/migrate/20140422195143_create_api_requests.rb | 9 ---- ...2195146_create_tournament_players_join_table.rb | 8 --- ...422195150_create_tournament_hosts_join_table.rb | 8 --- .../20140422195153_create_team_user_join_table.rb | 8 --- .../20140422195157_create_match_team_join_table.rb | 8 --- .../20140422195211_add_hidden_attrs_to_user.rb | 6 --- ...0422212555_create_mailboxer.mailboxer_engine.rb | 62 ++++++++++++++++++++++ ...2212556_add_notified_object.mailboxer_engine.rb | 18 +++++++ ...12557_add_notification_code.mailboxer_engine.rb | 14 +++++ ...40422212558_add_attachments.mailboxer_engine.rb | 10 ++++ ...212559_rename_receipts_read.mailboxer_engine.rb | 10 ++++ ...global_notification_support.mailboxer_engine.rb | 10 ++++ db/migrate/20140422212602_create_delayed_jobs.rb | 22 ++++++++ db/migrate/20140422212605_create_servers.rb | 9 ++++ db/migrate/20140422212609_create_matches.rb | 13 +++++ db/migrate/20140422212613_create_teams.rb | 8 +++ db/migrate/20140422212616_create_alerts.rb | 10 ++++ db/migrate/20140422212619_create_pms.rb | 11 ++++ db/migrate/20140422212623_create_tournaments.rb | 19 +++++++ db/migrate/20140422212627_create_games.rb | 17 ++++++ db/migrate/20140422212630_create_users.rb | 13 +++++ db/migrate/20140422212634_create_sessions.rb | 11 ++++ db/migrate/20140422212637_create_brackets.rb | 11 ++++ db/migrate/20140422212641_create_game_settings.rb | 15 ++++++ .../20140422212644_create_tournament_settings.rb | 15 ++++++ .../20140422212648_create_tournament_stages.rb | 11 ++++ db/migrate/20140422212651_create_statistics.rb | 12 +++++ .../20140422212654_create_remote_usernames.rb | 11 ++++ .../20140422212657_create_bracket_matches.rb | 11 ++++ db/migrate/20140422212701_create_api_requests.rb | 9 ++++ ...2212704_create_tournament_players_join_table.rb | 8 +++ ...422212707_create_tournament_hosts_join_table.rb | 8 +++ .../20140422212711_create_team_user_join_table.rb | 8 +++ .../20140422212714_create_match_team_join_table.rb | 8 +++ .../20140422212727_add_hidden_attrs_to_user.rb | 6 +++ db/schema.rb | 42 ++++++++++++++- generate.sh | 2 +- 57 files changed, 464 insertions(+), 283 deletions(-) create mode 100644 config/initializers/mailboxer.rb delete mode 100644 db/migrate/20140422155038_create_simple_captcha_data.rb create mode 100644 db/migrate/20140422172559_create_simple_captcha_data.rb delete mode 100644 db/migrate/20140422195042_create_delayed_jobs.rb delete mode 100644 db/migrate/20140422195045_create_servers.rb delete mode 100644 db/migrate/20140422195049_create_matches.rb delete mode 100644 db/migrate/20140422195052_create_teams.rb delete mode 100644 db/migrate/20140422195056_create_alerts.rb delete mode 100644 db/migrate/20140422195059_create_pms.rb delete mode 100644 db/migrate/20140422195103_create_tournaments.rb delete mode 100644 db/migrate/20140422195107_create_games.rb delete mode 100644 db/migrate/20140422195110_create_users.rb delete mode 100644 db/migrate/20140422195114_create_sessions.rb delete mode 100644 db/migrate/20140422195118_create_brackets.rb delete mode 100644 db/migrate/20140422195121_create_game_settings.rb delete mode 100644 db/migrate/20140422195125_create_tournament_settings.rb delete mode 100644 db/migrate/20140422195128_create_tournament_stages.rb delete mode 100644 db/migrate/20140422195132_create_statistics.rb delete mode 100644 db/migrate/20140422195135_create_remote_usernames.rb delete mode 100644 db/migrate/20140422195139_create_bracket_matches.rb delete mode 100644 db/migrate/20140422195143_create_api_requests.rb delete mode 100644 db/migrate/20140422195146_create_tournament_players_join_table.rb delete mode 100644 db/migrate/20140422195150_create_tournament_hosts_join_table.rb delete mode 100644 db/migrate/20140422195153_create_team_user_join_table.rb delete mode 100644 db/migrate/20140422195157_create_match_team_join_table.rb delete mode 100644 db/migrate/20140422195211_add_hidden_attrs_to_user.rb create mode 100644 db/migrate/20140422212555_create_mailboxer.mailboxer_engine.rb create mode 100644 db/migrate/20140422212556_add_notified_object.mailboxer_engine.rb create mode 100644 db/migrate/20140422212557_add_notification_code.mailboxer_engine.rb create mode 100644 db/migrate/20140422212558_add_attachments.mailboxer_engine.rb create mode 100644 db/migrate/20140422212559_rename_receipts_read.mailboxer_engine.rb create mode 100644 db/migrate/20140422212560_add_global_notification_support.mailboxer_engine.rb create mode 100644 db/migrate/20140422212602_create_delayed_jobs.rb create mode 100644 db/migrate/20140422212605_create_servers.rb create mode 100644 db/migrate/20140422212609_create_matches.rb create mode 100644 db/migrate/20140422212613_create_teams.rb create mode 100644 db/migrate/20140422212616_create_alerts.rb create mode 100644 db/migrate/20140422212619_create_pms.rb create mode 100644 db/migrate/20140422212623_create_tournaments.rb create mode 100644 db/migrate/20140422212627_create_games.rb create mode 100644 db/migrate/20140422212630_create_users.rb create mode 100644 db/migrate/20140422212634_create_sessions.rb create mode 100644 db/migrate/20140422212637_create_brackets.rb create mode 100644 db/migrate/20140422212641_create_game_settings.rb create mode 100644 db/migrate/20140422212644_create_tournament_settings.rb create mode 100644 db/migrate/20140422212648_create_tournament_stages.rb create mode 100644 db/migrate/20140422212651_create_statistics.rb create mode 100644 db/migrate/20140422212654_create_remote_usernames.rb create mode 100644 db/migrate/20140422212657_create_bracket_matches.rb create mode 100644 db/migrate/20140422212701_create_api_requests.rb create mode 100644 db/migrate/20140422212704_create_tournament_players_join_table.rb create mode 100644 db/migrate/20140422212707_create_tournament_hosts_join_table.rb create mode 100644 db/migrate/20140422212711_create_team_user_join_table.rb create mode 100644 db/migrate/20140422212714_create_match_team_join_table.rb create mode 100644 db/migrate/20140422212727_add_hidden_attrs_to_user.rb diff --git a/config/initializers/mailboxer.rb b/config/initializers/mailboxer.rb new file mode 100644 index 0000000..4d9011d --- /dev/null +++ b/config/initializers/mailboxer.rb @@ -0,0 +1,17 @@ +Mailboxer.setup do |config| + + #Configures if you applications uses or no the email sending for Notifications and Messages + config.uses_emails = true + + #Configures the default from for the email sent for Messages and Notifications of Mailboxer + config.default_from = "no-reply@mailboxer.com" + + #Configures the methods needed by mailboxer + config.email_method = :mailboxer_email + config.name_method = :name + + #Configures if you use or not a search engine and wich one are you using + #Supported enignes: [:solr,:sphinx] + config.search_enabled = false + config.search_engine = :solr +end diff --git a/db/migrate/20140422155038_create_simple_captcha_data.rb b/db/migrate/20140422155038_create_simple_captcha_data.rb deleted file mode 100644 index 4573b20..0000000 --- a/db/migrate/20140422155038_create_simple_captcha_data.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateSimpleCaptchaData < ActiveRecord::Migration - def self.up - create_table :simple_captcha_data do |t| - t.string :key, :limit => 40 - t.string :value, :limit => 6 - t.timestamps - end - - add_index :simple_captcha_data, :key, :name => "idx_key" - end - - def self.down - drop_table :simple_captcha_data - end -end diff --git a/db/migrate/20140422172559_create_simple_captcha_data.rb b/db/migrate/20140422172559_create_simple_captcha_data.rb new file mode 100644 index 0000000..4573b20 --- /dev/null +++ b/db/migrate/20140422172559_create_simple_captcha_data.rb @@ -0,0 +1,15 @@ +class CreateSimpleCaptchaData < ActiveRecord::Migration + def self.up + create_table :simple_captcha_data do |t| + t.string :key, :limit => 40 + t.string :value, :limit => 6 + t.timestamps + end + + add_index :simple_captcha_data, :key, :name => "idx_key" + end + + def self.down + drop_table :simple_captcha_data + end +end diff --git a/db/migrate/20140422195042_create_delayed_jobs.rb b/db/migrate/20140422195042_create_delayed_jobs.rb deleted file mode 100644 index ec0dd93..0000000 --- a/db/migrate/20140422195042_create_delayed_jobs.rb +++ /dev/null @@ -1,22 +0,0 @@ -class CreateDelayedJobs < ActiveRecord::Migration - def self.up - create_table :delayed_jobs, :force => true do |table| - table.integer :priority, :default => 0, :null => false # Allows some jobs to jump to the front of the queue - table.integer :attempts, :default => 0, :null => false # Provides for retries, but still fail eventually. - table.text :handler, :null => false # YAML-encoded string of the object that will do work - table.text :last_error # reason for last failure (See Note below) - table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. - table.datetime :locked_at # Set when a client is working on this object - table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) - table.string :locked_by # Who is working on this object (if locked) - table.string :queue # The name of the queue this job is in - table.timestamps - end - - add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority' - end - - def self.down - drop_table :delayed_jobs - end -end diff --git a/db/migrate/20140422195045_create_servers.rb b/db/migrate/20140422195045_create_servers.rb deleted file mode 100644 index fbe1b02..0000000 --- a/db/migrate/20140422195045_create_servers.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateServers < ActiveRecord::Migration - def change - create_table :servers do |t| - t.integer :default_user_permissions - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195049_create_matches.rb b/db/migrate/20140422195049_create_matches.rb deleted file mode 100644 index bac92d1..0000000 --- a/db/migrate/20140422195049_create_matches.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateMatches < ActiveRecord::Migration - def change - create_table :matches do |t| - t.integer :status - t.references :tournament_stage, index: true - t.references :winner, index: true - t.text :remote_id - t.integer :submitted_peer_evaluations - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195052_create_teams.rb b/db/migrate/20140422195052_create_teams.rb deleted file mode 100644 index dd8397d..0000000 --- a/db/migrate/20140422195052_create_teams.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeams < ActiveRecord::Migration - def change - create_table :teams do |t| - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195056_create_alerts.rb b/db/migrate/20140422195056_create_alerts.rb deleted file mode 100644 index 68a8e10..0000000 --- a/db/migrate/20140422195056_create_alerts.rb +++ /dev/null @@ -1,10 +0,0 @@ -class CreateAlerts < ActiveRecord::Migration - def change - create_table :alerts do |t| - t.references :author, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195059_create_pms.rb b/db/migrate/20140422195059_create_pms.rb deleted file mode 100644 index 93bb5c6..0000000 --- a/db/migrate/20140422195059_create_pms.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreatePms < ActiveRecord::Migration - def change - create_table :pms do |t| - t.references :author, index: true - t.references :recipient, index: true - t.text :message - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195103_create_tournaments.rb b/db/migrate/20140422195103_create_tournaments.rb deleted file mode 100644 index 716871f..0000000 --- a/db/migrate/20140422195103_create_tournaments.rb +++ /dev/null @@ -1,19 +0,0 @@ -class CreateTournaments < ActiveRecord::Migration - def change - create_table :tournaments do |t| - t.references :game, index: true - t.integer :status - t.string :name - t.integer :min_players_per_team - t.integer :max_players_per_team - t.integer :min_teams_per_match - t.integer :max_teams_per_match - t.integer :set_rounds - t.boolean :randomized_teams - t.string :sampling_method - - t.timestamps - end - add_index :tournaments, :name, unique: true - end -end diff --git a/db/migrate/20140422195107_create_games.rb b/db/migrate/20140422195107_create_games.rb deleted file mode 100644 index 46ed30d..0000000 --- a/db/migrate/20140422195107_create_games.rb +++ /dev/null @@ -1,17 +0,0 @@ -class CreateGames < ActiveRecord::Migration - def change - create_table :games do |t| - t.string :name - t.integer :min_players_per_team - t.integer :max_players_per_team - t.integer :min_teams_per_match - t.integer :max_teams_per_match - t.integer :set_rounds - t.boolean :randomized_teams - t.string :sampling_method - - t.timestamps - end - add_index :games, :name, unique: true - end -end diff --git a/db/migrate/20140422195110_create_users.rb b/db/migrate/20140422195110_create_users.rb deleted file mode 100644 index 8032870..0000000 --- a/db/migrate/20140422195110_create_users.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateUsers < ActiveRecord::Migration - def change - create_table :users do |t| - t.string :name - t.string :email - t.string :user_name - - t.timestamps - end - add_index :users, :email, unique: true - add_index :users, :user_name, unique: true - end -end diff --git a/db/migrate/20140422195114_create_sessions.rb b/db/migrate/20140422195114_create_sessions.rb deleted file mode 100644 index f667f1e..0000000 --- a/db/migrate/20140422195114_create_sessions.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateSessions < ActiveRecord::Migration - def change - create_table :sessions do |t| - t.references :user, index: true - t.string :token - - t.timestamps - end - add_index :sessions, :token, unique: true - end -end diff --git a/db/migrate/20140422195118_create_brackets.rb b/db/migrate/20140422195118_create_brackets.rb deleted file mode 100644 index 8813bf2..0000000 --- a/db/migrate/20140422195118_create_brackets.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateBrackets < ActiveRecord::Migration - def change - create_table :brackets do |t| - t.references :user, index: true - t.references :tournament, index: true - t.string :name - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195121_create_game_settings.rb b/db/migrate/20140422195121_create_game_settings.rb deleted file mode 100644 index 06fb72e..0000000 --- a/db/migrate/20140422195121_create_game_settings.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateGameSettings < ActiveRecord::Migration - def change - create_table :game_settings do |t| - t.references :game, index: true - t.string :name - t.integer :vartype - t.text :type_opt - t.text :description - t.integer :display_order - t.text :default - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195125_create_tournament_settings.rb b/db/migrate/20140422195125_create_tournament_settings.rb deleted file mode 100644 index e56697f..0000000 --- a/db/migrate/20140422195125_create_tournament_settings.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateTournamentSettings < ActiveRecord::Migration - def change - create_table :tournament_settings do |t| - t.references :tournament, index: true - t.string :name - t.integer :vartype - t.text :type_opt - t.text :description - t.integer :display_order - t.text :value - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195128_create_tournament_stages.rb b/db/migrate/20140422195128_create_tournament_stages.rb deleted file mode 100644 index e3668cb..0000000 --- a/db/migrate/20140422195128_create_tournament_stages.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateTournamentStages < ActiveRecord::Migration - def change - create_table :tournament_stages do |t| - t.references :tournament, index: true - t.string :scheduling - t.text :structure - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195132_create_statistics.rb b/db/migrate/20140422195132_create_statistics.rb deleted file mode 100644 index cc2e97d..0000000 --- a/db/migrate/20140422195132_create_statistics.rb +++ /dev/null @@ -1,12 +0,0 @@ -class CreateStatistics < ActiveRecord::Migration - def change - create_table :statistics do |t| - t.references :user, index: true - t.references :match, index: true - t.string :name - t.integer :value - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195135_create_remote_usernames.rb b/db/migrate/20140422195135_create_remote_usernames.rb deleted file mode 100644 index e265985..0000000 --- a/db/migrate/20140422195135_create_remote_usernames.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateRemoteUsernames < ActiveRecord::Migration - def change - create_table :remote_usernames do |t| - t.references :game, index: true - t.references :user, index: true - t.text :json_value - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195139_create_bracket_matches.rb b/db/migrate/20140422195139_create_bracket_matches.rb deleted file mode 100644 index 3323e31..0000000 --- a/db/migrate/20140422195139_create_bracket_matches.rb +++ /dev/null @@ -1,11 +0,0 @@ -class CreateBracketMatches < ActiveRecord::Migration - def change - create_table :bracket_matches do |t| - t.references :bracket, index: true - t.references :match, index: true - t.references :predicted_winner, index: true - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195143_create_api_requests.rb b/db/migrate/20140422195143_create_api_requests.rb deleted file mode 100644 index 544c330..0000000 --- a/db/migrate/20140422195143_create_api_requests.rb +++ /dev/null @@ -1,9 +0,0 @@ -class CreateApiRequests < ActiveRecord::Migration - def change - create_table :api_requests do |t| - t.string :api_name - - t.timestamps - end - end -end diff --git a/db/migrate/20140422195146_create_tournament_players_join_table.rb b/db/migrate/20140422195146_create_tournament_players_join_table.rb deleted file mode 100644 index be240e8..0000000 --- a/db/migrate/20140422195146_create_tournament_players_join_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentPlayersJoinTable < ActiveRecord::Migration - def change - create_join_table :players, :tournaments do |t| - # t.index [:player_id, :tournament_id] - # t.index [:tournament_id, :player_id] - end - end -end diff --git a/db/migrate/20140422195150_create_tournament_hosts_join_table.rb b/db/migrate/20140422195150_create_tournament_hosts_join_table.rb deleted file mode 100644 index 7521d89..0000000 --- a/db/migrate/20140422195150_create_tournament_hosts_join_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTournamentHostsJoinTable < ActiveRecord::Migration - def change - create_join_table :hosts, :tournaments do |t| - # t.index [:host_id, :tournament_id] - # t.index [:tournament_id, :host_id] - end - end -end diff --git a/db/migrate/20140422195153_create_team_user_join_table.rb b/db/migrate/20140422195153_create_team_user_join_table.rb deleted file mode 100644 index f3b57fc..0000000 --- a/db/migrate/20140422195153_create_team_user_join_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateTeamUserJoinTable < ActiveRecord::Migration - def change - create_join_table :teams, :users do |t| - # t.index [:team_id, :user_id] - # t.index [:user_id, :team_id] - end - end -end diff --git a/db/migrate/20140422195157_create_match_team_join_table.rb b/db/migrate/20140422195157_create_match_team_join_table.rb deleted file mode 100644 index c2ed1b7..0000000 --- a/db/migrate/20140422195157_create_match_team_join_table.rb +++ /dev/null @@ -1,8 +0,0 @@ -class CreateMatchTeamJoinTable < ActiveRecord::Migration - def change - create_join_table :matches, :teams do |t| - # t.index [:match_id, :team_id] - # t.index [:team_id, :match_id] - end - end -end diff --git a/db/migrate/20140422195211_add_hidden_attrs_to_user.rb b/db/migrate/20140422195211_add_hidden_attrs_to_user.rb deleted file mode 100644 index 9b5c505..0000000 --- a/db/migrate/20140422195211_add_hidden_attrs_to_user.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddHiddenAttrsToUser < ActiveRecord::Migration - def change - add_column :users, :password_digest, :string - add_column :users, :permissions, :integer - end -end diff --git a/db/migrate/20140422212555_create_mailboxer.mailboxer_engine.rb b/db/migrate/20140422212555_create_mailboxer.mailboxer_engine.rb new file mode 100644 index 0000000..690cec2 --- /dev/null +++ b/db/migrate/20140422212555_create_mailboxer.mailboxer_engine.rb @@ -0,0 +1,62 @@ +# This migration comes from mailboxer_engine (originally 20110511145103) +class CreateMailboxer < ActiveRecord::Migration + def self.up + #Tables + #Conversations + create_table :conversations do |t| + t.column :subject, :string, :default => "" + t.column :created_at, :datetime, :null => false + t.column :updated_at, :datetime, :null => false + end + #Receipts + create_table :receipts do |t| + t.references :receiver, :polymorphic => true + t.column :notification_id, :integer, :null => false + t.column :read, :boolean, :default => false + t.column :trashed, :boolean, :default => false + t.column :deleted, :boolean, :default => false + t.column :mailbox_type, :string, :limit => 25 + t.column :created_at, :datetime, :null => false + t.column :updated_at, :datetime, :null => false + end + #Notifications and Messages + create_table :notifications do |t| + t.column :type, :string + t.column :body, :text + t.column :subject, :string, :default => "" + t.references :sender, :polymorphic => true + t.references :object, :polymorphic => true + t.column :conversation_id, :integer + t.column :draft, :boolean, :default => false + t.column :updated_at, :datetime, :null => false + t.column :created_at, :datetime, :null => false + end + + + #Indexes + #Conversations + #Receipts + add_index "receipts","notification_id" + + #Messages + add_index "notifications","conversation_id" + + #Foreign keys + #Conversations + #Receipts + add_foreign_key "receipts", "notifications", :name => "receipts_on_notification_id" + #Messages + add_foreign_key "notifications", "conversations", :name => "notifications_on_conversation_id" + end + + def self.down + #Tables + remove_foreign_key "receipts", :name => "receipts_on_notification_id" + remove_foreign_key "notifications", :name => "notifications_on_conversation_id" + + #Indexes + drop_table :receipts + drop_table :conversations + drop_table :notifications + end +end diff --git a/db/migrate/20140422212556_add_notified_object.mailboxer_engine.rb b/db/migrate/20140422212556_add_notified_object.mailboxer_engine.rb new file mode 100644 index 0000000..7f41ac6 --- /dev/null +++ b/db/migrate/20140422212556_add_notified_object.mailboxer_engine.rb @@ -0,0 +1,18 @@ +# This migration comes from mailboxer_engine (originally 20110719110700) +class AddNotifiedObject < ActiveRecord::Migration + def self.up + change_table :notifications do |t| + t.references :notified_object, :polymorphic => true + t.remove :object_id + t.remove :object_type + end + end + + def self.down + change_table :notifications do |t| + t.remove :notified_object_id + t.remove :notified_object_type + t.references :object, :polymorphic => true + end + end +end diff --git a/db/migrate/20140422212557_add_notification_code.mailboxer_engine.rb b/db/migrate/20140422212557_add_notification_code.mailboxer_engine.rb new file mode 100644 index 0000000..04c12ef --- /dev/null +++ b/db/migrate/20140422212557_add_notification_code.mailboxer_engine.rb @@ -0,0 +1,14 @@ +# This migration comes from mailboxer_engine (originally 20110912163911) +class AddNotificationCode < ActiveRecord::Migration + def self.up + change_table :notifications do |t| + t.string :notification_code, :default => nil + end + end + + def self.down + change_table :notifications do |t| + t.remove :notification_code + end + end +end \ No newline at end of file diff --git a/db/migrate/20140422212558_add_attachments.mailboxer_engine.rb b/db/migrate/20140422212558_add_attachments.mailboxer_engine.rb new file mode 100644 index 0000000..b8d6588 --- /dev/null +++ b/db/migrate/20140422212558_add_attachments.mailboxer_engine.rb @@ -0,0 +1,10 @@ +# This migration comes from mailboxer_engine (originally 20111204163911) +class AddAttachments < ActiveRecord::Migration + def self.up + add_column :notifications, :attachment, :string + end + + def self.down + remove_column :notifications, :attachment + end +end diff --git a/db/migrate/20140422212559_rename_receipts_read.mailboxer_engine.rb b/db/migrate/20140422212559_rename_receipts_read.mailboxer_engine.rb new file mode 100644 index 0000000..9ce904f --- /dev/null +++ b/db/migrate/20140422212559_rename_receipts_read.mailboxer_engine.rb @@ -0,0 +1,10 @@ +# This migration comes from mailboxer_engine (originally 20120813110712) +class RenameReceiptsRead < ActiveRecord::Migration + def up + rename_column :receipts, :read, :is_read + end + + def down + rename_column :receipts, :is_read, :read + end +end diff --git a/db/migrate/20140422212560_add_global_notification_support.mailboxer_engine.rb b/db/migrate/20140422212560_add_global_notification_support.mailboxer_engine.rb new file mode 100644 index 0000000..60f67ab --- /dev/null +++ b/db/migrate/20140422212560_add_global_notification_support.mailboxer_engine.rb @@ -0,0 +1,10 @@ +# This migration comes from mailboxer_engine (originally 20130305144212) +class AddGlobalNotificationSupport < ActiveRecord::Migration + + def change + change_table :notifications do |t| + t.boolean :global, default: false + t.datetime :expires + end + end +end diff --git a/db/migrate/20140422212602_create_delayed_jobs.rb b/db/migrate/20140422212602_create_delayed_jobs.rb new file mode 100644 index 0000000..ec0dd93 --- /dev/null +++ b/db/migrate/20140422212602_create_delayed_jobs.rb @@ -0,0 +1,22 @@ +class CreateDelayedJobs < ActiveRecord::Migration + def self.up + create_table :delayed_jobs, :force => true do |table| + table.integer :priority, :default => 0, :null => false # Allows some jobs to jump to the front of the queue + table.integer :attempts, :default => 0, :null => false # Provides for retries, but still fail eventually. + table.text :handler, :null => false # YAML-encoded string of the object that will do work + table.text :last_error # reason for last failure (See Note below) + table.datetime :run_at # When to run. Could be Time.zone.now for immediately, or sometime in the future. + table.datetime :locked_at # Set when a client is working on this object + table.datetime :failed_at # Set when all retries have failed (actually, by default, the record is deleted instead) + table.string :locked_by # Who is working on this object (if locked) + table.string :queue # The name of the queue this job is in + table.timestamps + end + + add_index :delayed_jobs, [:priority, :run_at], :name => 'delayed_jobs_priority' + end + + def self.down + drop_table :delayed_jobs + end +end diff --git a/db/migrate/20140422212605_create_servers.rb b/db/migrate/20140422212605_create_servers.rb new file mode 100644 index 0000000..fbe1b02 --- /dev/null +++ b/db/migrate/20140422212605_create_servers.rb @@ -0,0 +1,9 @@ +class CreateServers < ActiveRecord::Migration + def change + create_table :servers do |t| + t.integer :default_user_permissions + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212609_create_matches.rb b/db/migrate/20140422212609_create_matches.rb new file mode 100644 index 0000000..bac92d1 --- /dev/null +++ b/db/migrate/20140422212609_create_matches.rb @@ -0,0 +1,13 @@ +class CreateMatches < ActiveRecord::Migration + def change + create_table :matches do |t| + t.integer :status + t.references :tournament_stage, index: true + t.references :winner, index: true + t.text :remote_id + t.integer :submitted_peer_evaluations + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212613_create_teams.rb b/db/migrate/20140422212613_create_teams.rb new file mode 100644 index 0000000..dd8397d --- /dev/null +++ b/db/migrate/20140422212613_create_teams.rb @@ -0,0 +1,8 @@ +class CreateTeams < ActiveRecord::Migration + def change + create_table :teams do |t| + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212616_create_alerts.rb b/db/migrate/20140422212616_create_alerts.rb new file mode 100644 index 0000000..68a8e10 --- /dev/null +++ b/db/migrate/20140422212616_create_alerts.rb @@ -0,0 +1,10 @@ +class CreateAlerts < ActiveRecord::Migration + def change + create_table :alerts do |t| + t.references :author, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212619_create_pms.rb b/db/migrate/20140422212619_create_pms.rb new file mode 100644 index 0000000..93bb5c6 --- /dev/null +++ b/db/migrate/20140422212619_create_pms.rb @@ -0,0 +1,11 @@ +class CreatePms < ActiveRecord::Migration + def change + create_table :pms do |t| + t.references :author, index: true + t.references :recipient, index: true + t.text :message + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212623_create_tournaments.rb b/db/migrate/20140422212623_create_tournaments.rb new file mode 100644 index 0000000..716871f --- /dev/null +++ b/db/migrate/20140422212623_create_tournaments.rb @@ -0,0 +1,19 @@ +class CreateTournaments < ActiveRecord::Migration + def change + create_table :tournaments do |t| + t.references :game, index: true + t.integer :status + t.string :name + t.integer :min_players_per_team + t.integer :max_players_per_team + t.integer :min_teams_per_match + t.integer :max_teams_per_match + t.integer :set_rounds + t.boolean :randomized_teams + t.string :sampling_method + + t.timestamps + end + add_index :tournaments, :name, unique: true + end +end diff --git a/db/migrate/20140422212627_create_games.rb b/db/migrate/20140422212627_create_games.rb new file mode 100644 index 0000000..46ed30d --- /dev/null +++ b/db/migrate/20140422212627_create_games.rb @@ -0,0 +1,17 @@ +class CreateGames < ActiveRecord::Migration + def change + create_table :games do |t| + t.string :name + t.integer :min_players_per_team + t.integer :max_players_per_team + t.integer :min_teams_per_match + t.integer :max_teams_per_match + t.integer :set_rounds + t.boolean :randomized_teams + t.string :sampling_method + + t.timestamps + end + add_index :games, :name, unique: true + end +end diff --git a/db/migrate/20140422212630_create_users.rb b/db/migrate/20140422212630_create_users.rb new file mode 100644 index 0000000..8032870 --- /dev/null +++ b/db/migrate/20140422212630_create_users.rb @@ -0,0 +1,13 @@ +class CreateUsers < ActiveRecord::Migration + def change + create_table :users do |t| + t.string :name + t.string :email + t.string :user_name + + t.timestamps + end + add_index :users, :email, unique: true + add_index :users, :user_name, unique: true + end +end diff --git a/db/migrate/20140422212634_create_sessions.rb b/db/migrate/20140422212634_create_sessions.rb new file mode 100644 index 0000000..f667f1e --- /dev/null +++ b/db/migrate/20140422212634_create_sessions.rb @@ -0,0 +1,11 @@ +class CreateSessions < ActiveRecord::Migration + def change + create_table :sessions do |t| + t.references :user, index: true + t.string :token + + t.timestamps + end + add_index :sessions, :token, unique: true + end +end diff --git a/db/migrate/20140422212637_create_brackets.rb b/db/migrate/20140422212637_create_brackets.rb new file mode 100644 index 0000000..8813bf2 --- /dev/null +++ b/db/migrate/20140422212637_create_brackets.rb @@ -0,0 +1,11 @@ +class CreateBrackets < ActiveRecord::Migration + def change + create_table :brackets do |t| + t.references :user, index: true + t.references :tournament, index: true + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212641_create_game_settings.rb b/db/migrate/20140422212641_create_game_settings.rb new file mode 100644 index 0000000..06fb72e --- /dev/null +++ b/db/migrate/20140422212641_create_game_settings.rb @@ -0,0 +1,15 @@ +class CreateGameSettings < ActiveRecord::Migration + def change + create_table :game_settings do |t| + t.references :game, index: true + t.string :name + t.integer :vartype + t.text :type_opt + t.text :description + t.integer :display_order + t.text :default + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212644_create_tournament_settings.rb b/db/migrate/20140422212644_create_tournament_settings.rb new file mode 100644 index 0000000..e56697f --- /dev/null +++ b/db/migrate/20140422212644_create_tournament_settings.rb @@ -0,0 +1,15 @@ +class CreateTournamentSettings < ActiveRecord::Migration + def change + create_table :tournament_settings do |t| + t.references :tournament, index: true + t.string :name + t.integer :vartype + t.text :type_opt + t.text :description + t.integer :display_order + t.text :value + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212648_create_tournament_stages.rb b/db/migrate/20140422212648_create_tournament_stages.rb new file mode 100644 index 0000000..e3668cb --- /dev/null +++ b/db/migrate/20140422212648_create_tournament_stages.rb @@ -0,0 +1,11 @@ +class CreateTournamentStages < ActiveRecord::Migration + def change + create_table :tournament_stages do |t| + t.references :tournament, index: true + t.string :scheduling + t.text :structure + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212651_create_statistics.rb b/db/migrate/20140422212651_create_statistics.rb new file mode 100644 index 0000000..cc2e97d --- /dev/null +++ b/db/migrate/20140422212651_create_statistics.rb @@ -0,0 +1,12 @@ +class CreateStatistics < ActiveRecord::Migration + def change + create_table :statistics do |t| + t.references :user, index: true + t.references :match, index: true + t.string :name + t.integer :value + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212654_create_remote_usernames.rb b/db/migrate/20140422212654_create_remote_usernames.rb new file mode 100644 index 0000000..e265985 --- /dev/null +++ b/db/migrate/20140422212654_create_remote_usernames.rb @@ -0,0 +1,11 @@ +class CreateRemoteUsernames < ActiveRecord::Migration + def change + create_table :remote_usernames do |t| + t.references :game, index: true + t.references :user, index: true + t.text :json_value + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212657_create_bracket_matches.rb b/db/migrate/20140422212657_create_bracket_matches.rb new file mode 100644 index 0000000..3323e31 --- /dev/null +++ b/db/migrate/20140422212657_create_bracket_matches.rb @@ -0,0 +1,11 @@ +class CreateBracketMatches < ActiveRecord::Migration + def change + create_table :bracket_matches do |t| + t.references :bracket, index: true + t.references :match, index: true + t.references :predicted_winner, index: true + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212701_create_api_requests.rb b/db/migrate/20140422212701_create_api_requests.rb new file mode 100644 index 0000000..544c330 --- /dev/null +++ b/db/migrate/20140422212701_create_api_requests.rb @@ -0,0 +1,9 @@ +class CreateApiRequests < ActiveRecord::Migration + def change + create_table :api_requests do |t| + t.string :api_name + + t.timestamps + end + end +end diff --git a/db/migrate/20140422212704_create_tournament_players_join_table.rb b/db/migrate/20140422212704_create_tournament_players_join_table.rb new file mode 100644 index 0000000..be240e8 --- /dev/null +++ b/db/migrate/20140422212704_create_tournament_players_join_table.rb @@ -0,0 +1,8 @@ +class CreateTournamentPlayersJoinTable < ActiveRecord::Migration + def change + create_join_table :players, :tournaments do |t| + # t.index [:player_id, :tournament_id] + # t.index [:tournament_id, :player_id] + end + end +end diff --git a/db/migrate/20140422212707_create_tournament_hosts_join_table.rb b/db/migrate/20140422212707_create_tournament_hosts_join_table.rb new file mode 100644 index 0000000..7521d89 --- /dev/null +++ b/db/migrate/20140422212707_create_tournament_hosts_join_table.rb @@ -0,0 +1,8 @@ +class CreateTournamentHostsJoinTable < ActiveRecord::Migration + def change + create_join_table :hosts, :tournaments do |t| + # t.index [:host_id, :tournament_id] + # t.index [:tournament_id, :host_id] + end + end +end diff --git a/db/migrate/20140422212711_create_team_user_join_table.rb b/db/migrate/20140422212711_create_team_user_join_table.rb new file mode 100644 index 0000000..f3b57fc --- /dev/null +++ b/db/migrate/20140422212711_create_team_user_join_table.rb @@ -0,0 +1,8 @@ +class CreateTeamUserJoinTable < ActiveRecord::Migration + def change + create_join_table :teams, :users do |t| + # t.index [:team_id, :user_id] + # t.index [:user_id, :team_id] + end + end +end diff --git a/db/migrate/20140422212714_create_match_team_join_table.rb b/db/migrate/20140422212714_create_match_team_join_table.rb new file mode 100644 index 0000000..c2ed1b7 --- /dev/null +++ b/db/migrate/20140422212714_create_match_team_join_table.rb @@ -0,0 +1,8 @@ +class CreateMatchTeamJoinTable < ActiveRecord::Migration + def change + create_join_table :matches, :teams do |t| + # t.index [:match_id, :team_id] + # t.index [:team_id, :match_id] + end + end +end diff --git a/db/migrate/20140422212727_add_hidden_attrs_to_user.rb b/db/migrate/20140422212727_add_hidden_attrs_to_user.rb new file mode 100644 index 0000000..9b5c505 --- /dev/null +++ b/db/migrate/20140422212727_add_hidden_attrs_to_user.rb @@ -0,0 +1,6 @@ +class AddHiddenAttrsToUser < ActiveRecord::Migration + def change + add_column :users, :password_digest, :string + add_column :users, :permissions, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 3f39538..a160f22 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140422195211) do +ActiveRecord::Schema.define(version: 20140422212727) do create_table "alerts", force: true do |t| t.integer "author_id" @@ -51,6 +51,12 @@ ActiveRecord::Schema.define(version: 20140422195211) do add_index "brackets", ["tournament_id"], name: "index_brackets_on_tournament_id" add_index "brackets", ["user_id"], name: "index_brackets_on_user_id" + create_table "conversations", force: true do |t| + t.string "subject", default: "" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "delayed_jobs", force: true do |t| t.integer "priority", default: 0, null: false t.integer "attempts", default: 0, null: false @@ -119,6 +125,26 @@ ActiveRecord::Schema.define(version: 20140422195211) do t.integer "team_id", null: false end + create_table "notifications", force: true do |t| + t.string "type" + t.text "body" + t.string "subject", default: "" + t.integer "sender_id" + t.string "sender_type" + t.integer "conversation_id" + t.boolean "draft", default: false + t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.integer "notified_object_id" + t.string "notified_object_type" + t.string "notification_code" + t.string "attachment" + t.boolean "global", default: false + t.datetime "expires" + end + + add_index "notifications", ["conversation_id"], name: "index_notifications_on_conversation_id" + create_table "players_tournaments", id: false, force: true do |t| t.integer "player_id", null: false t.integer "tournament_id", null: false @@ -135,6 +161,20 @@ ActiveRecord::Schema.define(version: 20140422195211) do add_index "pms", ["author_id"], name: "index_pms_on_author_id" add_index "pms", ["recipient_id"], name: "index_pms_on_recipient_id" + create_table "receipts", force: true do |t| + t.integer "receiver_id" + t.string "receiver_type" + t.integer "notification_id", null: false + t.boolean "is_read", default: false + t.boolean "trashed", default: false + t.boolean "deleted", default: false + t.string "mailbox_type", limit: 25 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "receipts", ["notification_id"], name: "index_receipts_on_notification_id" + create_table "remote_usernames", force: true do |t| t.integer "game_id" t.integer "user_id" diff --git a/generate.sh b/generate.sh index 1aaf1e6..b3e9343 100755 --- a/generate.sh +++ b/generate.sh @@ -67,4 +67,4 @@ bundle exec rake db:seed find app -type f -name '*.rb' -exec bin/autoindent {} \; -git add app test config/routes.rb db/migrate db/schema.rb Gemfile.lock +git add app test config/routes.rb config/initializers db/migrate db/schema.rb Gemfile.lock -- cgit v1.2.3-2-g168b From bb53f8ac2ab52301b32fe65ddc10a32f6bc730e8 Mon Sep 17 00:00:00 2001 From: tkimia Date: Tue, 22 Apr 2014 17:42:57 -0400 Subject: prelim search --- app/controllers/search_controller.rb | 11 ++++++++++ app/views/common/_show_tournament.html.erb | 32 ++++++++++++++++++++++++++++ app/views/layouts/application.html.erb | 12 ++++++++--- app/views/search/go.html.erb | 6 ++++++ app/views/tournaments/index.html.erb | 34 +----------------------------- config/routes.rb | 6 ++++++ 6 files changed, 65 insertions(+), 36 deletions(-) create mode 100644 app/views/common/_show_tournament.html.erb create mode 100644 app/views/search/go.html.erb diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index ee61487..9da649d 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,2 +1,13 @@ class SearchController < ApplicationController + + def go + @query = params[:query] + + if (@query.nil?) return; + + @tournaments = Tournament.where("name LIKE '#{@query}'") + @players = User.where("name LIKE '#{@query}") + + end + end diff --git a/app/views/common/_show_tournament.html.erb b/app/views/common/_show_tournament.html.erb new file mode 100644 index 0000000..89d8f53 --- /dev/null +++ b/app/views/common/_show_tournament.html.erb @@ -0,0 +1,32 @@ +
+
<%= image_tag ('http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(target.hosts.first.email) + '?s=100&d=mm') %>
+
+ <%# "header" %> + <%= link_to(target) do %>

<%= target.name %>

<% end %> +
+
+ Hosted by: <%= target.hosts.first.name %> +
+
+

Players per team: <%= target.min_players_per_team %>

+

Players signed up: <%= target.players.count %>

+
+
+

<%= (target.randomized_teams)? "Teams are Random" : "Teams are Chosen" %>

+

Players signed up: <%= target.players.count %>

+
+
+
+
+ <% if signed_in? %> + <% if !target.players.include?(current_user) %> + <%= form_tag(tournament_path(target), method: "put") do %> + + <%= submit_tag("Join")%> + <% end %> + <% else %> +

You've signed up for this tournament!

+ <% end %> + <% end %> +
+
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index e6b5b25..fb5c1c5 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,15 +13,20 @@ BetterDragSort.makeListSortable(document.getElementById("boxes")); }; -
+
<% if notice %>

<%= notice %>

<% end %> diff --git a/app/views/search/go.html.erb b/app/views/search/go.html.erb new file mode 100644 index 0000000..12a76c8 --- /dev/null +++ b/app/views/search/go.html.erb @@ -0,0 +1,6 @@ +

Showing results for: <%= @query %>

+ + +<% if @tounaments.empty? and @players.empty %> +

No results found for "<%= @query %>"

+<% else %> \ No newline at end of file diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index eef9577..129f3de 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -4,39 +4,7 @@ <% if @tournaments.length > 0 %> <%# Each tournament has a div for its listing %> <% @tournaments.each do |t| %> -
-
<%= image_tag 'http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(t.hosts.first.email) + '?s=100&d=mm' %>
-
- <%# "header" %> - <%= link_to(t) do %>

<%= t.name %>

<% end %> -
-
- Hosted by: <%= t.hosts.first.name %> -
-
-

Players per team: <%= t.min_players_per_team %>

-

Players signed up: <%= t.players.count %>

-
-
-

<%= (t.randomized_teams)? "Teams are Random" : "Teams are Chosen" %>

-

Players signed up: <%= t.players.count %>

-
-
-
-
- <% if signed_in? %> - <% if !t.players.include?(current_user) %> - <%= form_tag(tournament_path(t), method: "put") do %> - - <%= submit_tag("Join") - %> - <% end %> - <% else %> -

You've signed up for this tournament!

- <% end %> - <% end %> -
-
+ <%= render "common/show_tournament", :target => t %> <% end %> <% else %>

No tournaments going on right now... diff --git a/config/routes.rb b/config/routes.rb index f94bd2f..c1bbf52 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -24,8 +24,14 @@ Leaguer::Application.routes.draw do end root to: 'static#homepage' + get '/testsvg', to: 'static#test' + + get '/search', to: 'search#go' + end + + Leaguer::Application.routes.named_routes.module.module_eval do def match_path(match, options={}) tournament_match_path(match.tournament_stage.tournament, match, options) -- cgit v1.2.3-2-g168b From 266602ea1e97d886f031b80add7a760034221f76 Mon Sep 17 00:00:00 2001 From: tkimia Date: Tue, 22 Apr 2014 18:04:41 -0400 Subject: basic search complete --- app/controllers/search_controller.rb | 8 +++++--- app/views/search/go.html.erb | 25 +++++++++++++++++++++---- app/views/tournaments/index.html.erb | 4 ++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 9da649d..51aee9e 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -3,10 +3,12 @@ class SearchController < ApplicationController def go @query = params[:query] - if (@query.nil?) return; + if (@query.nil?) then + return + end - @tournaments = Tournament.where("name LIKE '#{@query}'") - @players = User.where("name LIKE '#{@query}") + @tournaments = Tournament.where("name LIKE '%#{@query}%'") + @players = User.where("name LIKE '%#{@query}%'") end diff --git a/app/views/search/go.html.erb b/app/views/search/go.html.erb index 12a76c8..6d5826f 100644 --- a/app/views/search/go.html.erb +++ b/app/views/search/go.html.erb @@ -1,6 +1,23 @@ -

Showing results for: <%= @query %>

+<%# Show search results if a query was not nill %> +<% if !@query.empty? %> +

Showing results for: <%= @query %>

+ <% if @tournaments.empty? and @players.empty? %> +

No results found for "<%= @query %>"

+ <% else %> + <% if @tournaments.length > 0 %> +

Tournaments

+ <% end %> + <% @tournaments.each do |t| %> + <%= render "common/show_tournament", :target => t %> + <% end %> -<% if @tounaments.empty? and @players.empty %> -

No results found for "<%= @query %>"

-<% else %> \ No newline at end of file + <% if @players.length > 0 %> +

Players

+ <% end %> + <% @players.each do |p| %> + <%= render "common/show_player", :target => p %> + <% end %> + + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index 129f3de..06e1b25 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -2,16 +2,20 @@
<% if @tournaments.length > 0 %> + <%# Each tournament has a div for its listing %> <% @tournaments.each do |t| %> <%= render "common/show_tournament", :target => t %> <% end %> + <% else %> +

No tournaments going on right now... <% if current_user.can?(:create_tournament) %> Why not start your own? <% end %>

+ <% end %>
-- cgit v1.2.3-2-g168b From 7deb9c1c7acadf9a5b638313f51ba9dc60624672 Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Tue, 22 Apr 2014 18:17:13 -0400 Subject: made naming conventions consistent --- lib/scoring/FibonacciPeerWithBlowout.rb | 16 ---------------- lib/scoring/MarginalPeer.rb | 15 --------------- lib/scoring/ScoringAlgorithm.rb | 8 -------- lib/scoring/WinnerTakesAll.rb | 16 ---------------- lib/scoring/fibonacci_peer_with_blowout.rb | 16 ++++++++++++++++ lib/scoring/marginal_peer.rb | 15 +++++++++++++++ lib/scoring/scoring_algorithm.rb | 8 ++++++++ lib/scoring/winner_takes_all.rb | 16 ++++++++++++++++ 8 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 lib/scoring/FibonacciPeerWithBlowout.rb delete mode 100644 lib/scoring/MarginalPeer.rb delete mode 100644 lib/scoring/ScoringAlgorithm.rb delete mode 100644 lib/scoring/WinnerTakesAll.rb create mode 100644 lib/scoring/fibonacci_peer_with_blowout.rb create mode 100644 lib/scoring/marginal_peer.rb create mode 100644 lib/scoring/scoring_algorithm.rb create mode 100644 lib/scoring/winner_takes_all.rb diff --git a/lib/scoring/FibonacciPeerWithBlowout.rb b/lib/scoring/FibonacciPeerWithBlowout.rb deleted file mode 100644 index 19ac9a7..0000000 --- a/lib/scoring/FibonacciPeerWithBlowout.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'ScoringAlgorithm' - -class FibonacciPeerWithBlowout < ScoringAlgorithm - - def self.score(match, interface) - match.players.each do |player| - scores[player.user_name] = scoreUser(interface.getStatistic(match, player, :votes), match.win?(player), match.blowout) - end - scores - end - - def self.scoreUser(votes, win, blowout) - fibonacci = Hash.new { |h,k| h[k] = k < 2 ? k : h[k-1] + h[k-2] } - fibonacci[votes+3] + (win ? blowout ? 12 : 10 : blowout ? 5 : 7) - end -end \ No newline at end of file diff --git a/lib/scoring/MarginalPeer.rb b/lib/scoring/MarginalPeer.rb deleted file mode 100644 index 0e1cfa8..0000000 --- a/lib/scoring/MarginalPeer.rb +++ /dev/null @@ -1,15 +0,0 @@ -require 'ScoringAlgorithm' - -class MarginalPeer < ScoringAlgorithm - - def self.score(match, interface) - match.players.each do |player| - scores[player.user_name] = scoreUser(interface.getStatistic(match, player, rating)) - end - scores - end - - def self.score(rating) - rating - end -end \ No newline at end of file diff --git a/lib/scoring/ScoringAlgorithm.rb b/lib/scoring/ScoringAlgorithm.rb deleted file mode 100644 index 6277da8..0000000 --- a/lib/scoring/ScoringAlgorithm.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Leaguer - module Scoring - class ScoringAlgorithm - def self.score(match, interface) - end - end - end -end \ No newline at end of file diff --git a/lib/scoring/WinnerTakesAll.rb b/lib/scoring/WinnerTakesAll.rb deleted file mode 100644 index ad2471b..0000000 --- a/lib/scoring/WinnerTakesAll.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'ScoringAlgorithm' - -class WinnerTakesAll < ScoringAlgorithm - - def self.score(match, interface) - match.players.each do |player| - scores[player.user_name] = scoreUser(match.win?(player)) - end - scores - end - - - def self.score(win) - win.nil? ? 0.5 : win ? 1 : 0 - end -end \ No newline at end of file diff --git a/lib/scoring/fibonacci_peer_with_blowout.rb b/lib/scoring/fibonacci_peer_with_blowout.rb new file mode 100644 index 0000000..19ac9a7 --- /dev/null +++ b/lib/scoring/fibonacci_peer_with_blowout.rb @@ -0,0 +1,16 @@ +require 'ScoringAlgorithm' + +class FibonacciPeerWithBlowout < ScoringAlgorithm + + def self.score(match, interface) + match.players.each do |player| + scores[player.user_name] = scoreUser(interface.getStatistic(match, player, :votes), match.win?(player), match.blowout) + end + scores + end + + def self.scoreUser(votes, win, blowout) + fibonacci = Hash.new { |h,k| h[k] = k < 2 ? k : h[k-1] + h[k-2] } + fibonacci[votes+3] + (win ? blowout ? 12 : 10 : blowout ? 5 : 7) + end +end \ No newline at end of file diff --git a/lib/scoring/marginal_peer.rb b/lib/scoring/marginal_peer.rb new file mode 100644 index 0000000..0e1cfa8 --- /dev/null +++ b/lib/scoring/marginal_peer.rb @@ -0,0 +1,15 @@ +require 'ScoringAlgorithm' + +class MarginalPeer < ScoringAlgorithm + + def self.score(match, interface) + match.players.each do |player| + scores[player.user_name] = scoreUser(interface.getStatistic(match, player, rating)) + end + scores + end + + def self.score(rating) + rating + end +end \ No newline at end of file diff --git a/lib/scoring/scoring_algorithm.rb b/lib/scoring/scoring_algorithm.rb new file mode 100644 index 0000000..6277da8 --- /dev/null +++ b/lib/scoring/scoring_algorithm.rb @@ -0,0 +1,8 @@ +module Leaguer + module Scoring + class ScoringAlgorithm + def self.score(match, interface) + end + end + end +end \ No newline at end of file diff --git a/lib/scoring/winner_takes_all.rb b/lib/scoring/winner_takes_all.rb new file mode 100644 index 0000000..ad2471b --- /dev/null +++ b/lib/scoring/winner_takes_all.rb @@ -0,0 +1,16 @@ +require 'ScoringAlgorithm' + +class WinnerTakesAll < ScoringAlgorithm + + def self.score(match, interface) + match.players.each do |player| + scores[player.user_name] = scoreUser(match.win?(player)) + end + scores + end + + + def self.score(win) + win.nil? ? 0.5 : win ? 1 : 0 + end +end \ No newline at end of file -- cgit v1.2.3-2-g168b From cd54af413c57581f35026f60dc24e4bc21bb0bd1 Mon Sep 17 00:00:00 2001 From: tkimia Date: Tue, 22 Apr 2014 18:25:02 -0400 Subject: footer is ok? --- app/assets/stylesheets/application.css | 7 ------- app/assets/stylesheets/scaffolds.css.scss | 13 +++++++------ app/assets/stylesheets/static.css.scss | 3 ++- app/views/search/go.html.erb | 5 +++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index ebb963c..677791c 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -22,10 +22,3 @@ padding: 0px 5px; } -footer { - clear: both; - margin: 0 auto; - margin-top: 10px; - color: white; - width: 90%; -} \ No newline at end of file diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss index 509cb19..e8fe9c5 100644 --- a/app/assets/stylesheets/scaffolds.css.scss +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -19,7 +19,7 @@ body { height: 100%; } -h1, h2, h3, h4, h5, p{ +h1, h2, h3, h4, h5, p, li{ color: $orange; } @@ -96,20 +96,21 @@ div { .wrapper { width: 80%; - margin: 0 auto; margin-top: 10px; + min-height: 80%; + height: auto !important; + height: 99%; + margin: 0 auto; } button, input[type="submit"] { @extend .btn; } - - footer { clear: both; border-top: solid 1px $orange; - padding-top: 10px; text-align: center; - bottom: 0; + margin: 0 auto; + width: 90%; } \ No newline at end of file diff --git a/app/assets/stylesheets/static.css.scss b/app/assets/stylesheets/static.css.scss index 14443f3..6732370 100644 --- a/app/assets/stylesheets/static.css.scss +++ b/app/assets/stylesheets/static.css.scss @@ -5,7 +5,8 @@ .jumbotron { background-color: #FFF; box-shadow: 1px 1px 20px black; - + width: 93%; + p { line-height: 1.5em; } diff --git a/app/views/search/go.html.erb b/app/views/search/go.html.erb index 6d5826f..324fa48 100644 --- a/app/views/search/go.html.erb +++ b/app/views/search/go.html.erb @@ -1,10 +1,11 @@ <%# Show search results if a query was not nill %> <% if !@query.empty? %> -

Showing results for: <%= @query %>

+ <% if @tournaments.empty? and @players.empty? %> -

No results found for "<%= @query %>"

+

No results found for "<%= @query %>"

<% else %> +

Showing results for: <%= @query %>

<% if @tournaments.length > 0 %>

Tournaments

<% end %> -- cgit v1.2.3-2-g168b From b7cbf3df615575fe1d24a9ea1ddfded094ae529f Mon Sep 17 00:00:00 2001 From: AndrewMurrell Date: Tue, 22 Apr 2014 18:27:30 -0400 Subject: Added images for League and chess, need copyright notice for league and copyleft notice for chess. --- app/assets/images/ChessBlackKnightIcon.png | Bin 0 -> 893 bytes app/assets/images/LOLG_icon_large.gif | Bin 0 -> 8207 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/assets/images/ChessBlackKnightIcon.png create mode 100644 app/assets/images/LOLG_icon_large.gif diff --git a/app/assets/images/ChessBlackKnightIcon.png b/app/assets/images/ChessBlackKnightIcon.png new file mode 100644 index 0000000..6bcffe6 Binary files /dev/null and b/app/assets/images/ChessBlackKnightIcon.png differ diff --git a/app/assets/images/LOLG_icon_large.gif b/app/assets/images/LOLG_icon_large.gif new file mode 100644 index 0000000..1f0fa43 Binary files /dev/null and b/app/assets/images/LOLG_icon_large.gif differ -- cgit v1.2.3-2-g168b From b4bc055585dee532653a8c64e45385e085ec22a8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 22 Apr 2014 18:29:17 -0400 Subject: I hate code --- app/controllers/matches_controller.rb | 11 +++-------- app/controllers/tournaments_controller.rb | 25 ++++++++++++++++--------- app/models/tournament_stage.rb | 4 ++-- app/views/matches/index.html.erb | 2 +- app/views/matches/show.html.erb | 4 ---- lib/scheduling/elimination.rb | 14 ++++++++------ 6 files changed, 30 insertions(+), 30 deletions(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 59f376a..b50aca5 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -1,6 +1,4 @@ class MatchesController < ApplicationController - before_action :set_tournament, only: [:index, :update] - require 'httparty' require 'json' require 'delayed_job' @@ -118,7 +116,7 @@ class MatchesController < ApplicationController # GET /tournaments/1/matches/1 # GET /tournaments/1/matches/1.json def show - if Tournament.find_by_id(@match.tournament_id).game_id == 1 + if @match.tournament_stage.tournament.game_id == 1 file_blue = "blue.yaml" file_purple = "purple.yaml" @blue2 = YAML.load_file(file_blue) @@ -235,11 +233,8 @@ class MatchesController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_match - set_tournament - @match = @tournament.matches.find(params[:id]) - end - def set_tournament - @tournament = Tournament.find(params[:tournament_id]) + @match = Match.find(params[:id]) + @tournament = @match.tournament_stage.tournament end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 4b0e1af..03dc5b8 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -95,17 +95,24 @@ class TournamentsController < ApplicationController end when "start" check_permission(:edit, @tournament) - @tournament.status = 1 - ok = - @tournament.save && - @tournament.tournament_stages.create(scheduling: "elimination") && - @tournament.tournament_stages.first.create_matches respond_to do |format| - if ok - format.html { redirect_to @tournament, notice: 'You have started this tournament.' } - format.json { head :no_content } + if @tournament.status == 0 + @tournament.status = 1 + success = true + ActiveRecord::Base.transaction do + success &= @tournament.save && + success &= @tournament.tournament_stages.create(scheduling: "elimination") + success &= @tournament.tournament_stages.first.create_matches + end + if success + format.html { redirect_to @tournament, notice: 'You have started this tournament.' } + format.json { head :no_content } + else + format.html { redirect_to @tournament, notice: "You don't have permission to start this tournament." } + format.json { render json: "Permission denied", status: :forbidden } + end else - format.html { redirect_to @tournament, notice: "You don't have permission to start this tournament." } + format.html { redirect_to @tournament, notice: "This tournament is not in a state that it can be started." } format.json { render json: "Permission denied", status: :forbidden } end end diff --git a/app/models/tournament_stage.rb b/app/models/tournament_stage.rb index 9fa6dcd..762f6a7 100644 --- a/app/models/tournament_stage.rb +++ b/app/models/tournament_stage.rb @@ -17,9 +17,9 @@ class TournamentStage < ActiveRecord::Base @scheduling.create_matches end - def to_svg + def to_svg(current_user) set_scheduling - return @scheduling.graph + return @scheduling.graph(current_user) end private diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 058477a..fda8582 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -37,5 +37,5 @@
<% @tournament.stages_ordered.keys.sort.each do |stage_key| %> -
<%= raw @tournament.stages_ordered[stage_key].to_svg %>
+
<%= raw @tournament.stages_ordered[stage_key].to_svg(current_user) %>
<% end %> diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index e7fe791..a1d82a3 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -7,10 +7,6 @@ <%= @match.tournament_stage %>

-

- Name: - <%= @match.name %> -