summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock12
-rw-r--r--app/models/user.rb2
-rw-r--r--config/initializers/mailboxer.rb17
-rw-r--r--db/migrate/20140422172559_create_simple_captcha_data.rb (renamed from db/migrate/20140422155038_create_simple_captcha_data.rb)0
-rw-r--r--db/migrate/20140422212555_create_mailboxer.mailboxer_engine.rb62
-rw-r--r--db/migrate/20140422212556_add_notified_object.mailboxer_engine.rb18
-rw-r--r--db/migrate/20140422212557_add_notification_code.mailboxer_engine.rb14
-rw-r--r--db/migrate/20140422212558_add_attachments.mailboxer_engine.rb10
-rw-r--r--db/migrate/20140422212559_rename_receipts_read.mailboxer_engine.rb10
-rw-r--r--db/migrate/20140422212560_add_global_notification_support.mailboxer_engine.rb10
-rw-r--r--db/migrate/20140422212602_create_delayed_jobs.rb (renamed from db/migrate/20140422195042_create_delayed_jobs.rb)0
-rw-r--r--db/migrate/20140422212605_create_servers.rb (renamed from db/migrate/20140422195045_create_servers.rb)0
-rw-r--r--db/migrate/20140422212609_create_matches.rb (renamed from db/migrate/20140422195049_create_matches.rb)0
-rw-r--r--db/migrate/20140422212613_create_teams.rb (renamed from db/migrate/20140422195052_create_teams.rb)0
-rw-r--r--db/migrate/20140422212616_create_alerts.rb (renamed from db/migrate/20140422195056_create_alerts.rb)0
-rw-r--r--db/migrate/20140422212619_create_pms.rb (renamed from db/migrate/20140422195059_create_pms.rb)0
-rw-r--r--db/migrate/20140422212623_create_tournaments.rb (renamed from db/migrate/20140422195103_create_tournaments.rb)0
-rw-r--r--db/migrate/20140422212627_create_games.rb (renamed from db/migrate/20140422195107_create_games.rb)0
-rw-r--r--db/migrate/20140422212630_create_users.rb (renamed from db/migrate/20140422195110_create_users.rb)0
-rw-r--r--db/migrate/20140422212634_create_sessions.rb (renamed from db/migrate/20140422195114_create_sessions.rb)0
-rw-r--r--db/migrate/20140422212637_create_brackets.rb (renamed from db/migrate/20140422195118_create_brackets.rb)0
-rw-r--r--db/migrate/20140422212641_create_game_settings.rb (renamed from db/migrate/20140422195121_create_game_settings.rb)0
-rw-r--r--db/migrate/20140422212644_create_tournament_settings.rb (renamed from db/migrate/20140422195125_create_tournament_settings.rb)0
-rw-r--r--db/migrate/20140422212648_create_tournament_stages.rb (renamed from db/migrate/20140422195128_create_tournament_stages.rb)0
-rw-r--r--db/migrate/20140422212651_create_statistics.rb (renamed from db/migrate/20140422195132_create_statistics.rb)0
-rw-r--r--db/migrate/20140422212654_create_remote_usernames.rb (renamed from db/migrate/20140422195135_create_remote_usernames.rb)0
-rw-r--r--db/migrate/20140422212657_create_bracket_matches.rb (renamed from db/migrate/20140422195139_create_bracket_matches.rb)0
-rw-r--r--db/migrate/20140422212701_create_api_requests.rb (renamed from db/migrate/20140422195143_create_api_requests.rb)0
-rw-r--r--db/migrate/20140422212704_create_tournament_players_join_table.rb (renamed from db/migrate/20140422195146_create_tournament_players_join_table.rb)0
-rw-r--r--db/migrate/20140422212707_create_tournament_hosts_join_table.rb (renamed from db/migrate/20140422195150_create_tournament_hosts_join_table.rb)0
-rw-r--r--db/migrate/20140422212711_create_team_user_join_table.rb (renamed from db/migrate/20140422195153_create_team_user_join_table.rb)0
-rw-r--r--db/migrate/20140422212714_create_match_team_join_table.rb (renamed from db/migrate/20140422195157_create_match_team_join_table.rb)0
-rw-r--r--db/migrate/20140422212727_add_hidden_attrs_to_user.rb (renamed from db/migrate/20140422195211_add_hidden_attrs_to_user.rb)0
-rw-r--r--db/schema.rb42
-rwxr-xr-xgenerate.sh3
36 files changed, 201 insertions, 2 deletions
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/app/models/user.rb b/app/models/user.rb
index 57746b7..aacd7b1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -10,6 +10,8 @@ class User < ActiveRecord::Base
apply_simple_captcha
+ acts_as_messageable
+
before_save { self.email = email.downcase }
before_save { self.user_name = user_name }
diff --git a/config/initializers/mailboxer.rb b/config/initializers/mailboxer.rb
new file mode 100644
index 0000000..2778a10
--- /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 = false
+
+ #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/20140422172559_create_simple_captcha_data.rb
index 4573b20..4573b20 100644
--- a/db/migrate/20140422155038_create_simple_captcha_data.rb
+++ b/db/migrate/20140422172559_create_simple_captcha_data.rb
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/20140422195042_create_delayed_jobs.rb b/db/migrate/20140422212602_create_delayed_jobs.rb
index ec0dd93..ec0dd93 100644
--- a/db/migrate/20140422195042_create_delayed_jobs.rb
+++ b/db/migrate/20140422212602_create_delayed_jobs.rb
diff --git a/db/migrate/20140422195045_create_servers.rb b/db/migrate/20140422212605_create_servers.rb
index fbe1b02..fbe1b02 100644
--- a/db/migrate/20140422195045_create_servers.rb
+++ b/db/migrate/20140422212605_create_servers.rb
diff --git a/db/migrate/20140422195049_create_matches.rb b/db/migrate/20140422212609_create_matches.rb
index bac92d1..bac92d1 100644
--- a/db/migrate/20140422195049_create_matches.rb
+++ b/db/migrate/20140422212609_create_matches.rb
diff --git a/db/migrate/20140422195052_create_teams.rb b/db/migrate/20140422212613_create_teams.rb
index dd8397d..dd8397d 100644
--- a/db/migrate/20140422195052_create_teams.rb
+++ b/db/migrate/20140422212613_create_teams.rb
diff --git a/db/migrate/20140422195056_create_alerts.rb b/db/migrate/20140422212616_create_alerts.rb
index 68a8e10..68a8e10 100644
--- a/db/migrate/20140422195056_create_alerts.rb
+++ b/db/migrate/20140422212616_create_alerts.rb
diff --git a/db/migrate/20140422195059_create_pms.rb b/db/migrate/20140422212619_create_pms.rb
index 93bb5c6..93bb5c6 100644
--- a/db/migrate/20140422195059_create_pms.rb
+++ b/db/migrate/20140422212619_create_pms.rb
diff --git a/db/migrate/20140422195103_create_tournaments.rb b/db/migrate/20140422212623_create_tournaments.rb
index 716871f..716871f 100644
--- a/db/migrate/20140422195103_create_tournaments.rb
+++ b/db/migrate/20140422212623_create_tournaments.rb
diff --git a/db/migrate/20140422195107_create_games.rb b/db/migrate/20140422212627_create_games.rb
index 46ed30d..46ed30d 100644
--- a/db/migrate/20140422195107_create_games.rb
+++ b/db/migrate/20140422212627_create_games.rb
diff --git a/db/migrate/20140422195110_create_users.rb b/db/migrate/20140422212630_create_users.rb
index 8032870..8032870 100644
--- a/db/migrate/20140422195110_create_users.rb
+++ b/db/migrate/20140422212630_create_users.rb
diff --git a/db/migrate/20140422195114_create_sessions.rb b/db/migrate/20140422212634_create_sessions.rb
index f667f1e..f667f1e 100644
--- a/db/migrate/20140422195114_create_sessions.rb
+++ b/db/migrate/20140422212634_create_sessions.rb
diff --git a/db/migrate/20140422195118_create_brackets.rb b/db/migrate/20140422212637_create_brackets.rb
index 8813bf2..8813bf2 100644
--- a/db/migrate/20140422195118_create_brackets.rb
+++ b/db/migrate/20140422212637_create_brackets.rb
diff --git a/db/migrate/20140422195121_create_game_settings.rb b/db/migrate/20140422212641_create_game_settings.rb
index 06fb72e..06fb72e 100644
--- a/db/migrate/20140422195121_create_game_settings.rb
+++ b/db/migrate/20140422212641_create_game_settings.rb
diff --git a/db/migrate/20140422195125_create_tournament_settings.rb b/db/migrate/20140422212644_create_tournament_settings.rb
index e56697f..e56697f 100644
--- a/db/migrate/20140422195125_create_tournament_settings.rb
+++ b/db/migrate/20140422212644_create_tournament_settings.rb
diff --git a/db/migrate/20140422195128_create_tournament_stages.rb b/db/migrate/20140422212648_create_tournament_stages.rb
index e3668cb..e3668cb 100644
--- a/db/migrate/20140422195128_create_tournament_stages.rb
+++ b/db/migrate/20140422212648_create_tournament_stages.rb
diff --git a/db/migrate/20140422195132_create_statistics.rb b/db/migrate/20140422212651_create_statistics.rb
index cc2e97d..cc2e97d 100644
--- a/db/migrate/20140422195132_create_statistics.rb
+++ b/db/migrate/20140422212651_create_statistics.rb
diff --git a/db/migrate/20140422195135_create_remote_usernames.rb b/db/migrate/20140422212654_create_remote_usernames.rb
index e265985..e265985 100644
--- a/db/migrate/20140422195135_create_remote_usernames.rb
+++ b/db/migrate/20140422212654_create_remote_usernames.rb
diff --git a/db/migrate/20140422195139_create_bracket_matches.rb b/db/migrate/20140422212657_create_bracket_matches.rb
index 3323e31..3323e31 100644
--- a/db/migrate/20140422195139_create_bracket_matches.rb
+++ b/db/migrate/20140422212657_create_bracket_matches.rb
diff --git a/db/migrate/20140422195143_create_api_requests.rb b/db/migrate/20140422212701_create_api_requests.rb
index 544c330..544c330 100644
--- a/db/migrate/20140422195143_create_api_requests.rb
+++ b/db/migrate/20140422212701_create_api_requests.rb
diff --git a/db/migrate/20140422195146_create_tournament_players_join_table.rb b/db/migrate/20140422212704_create_tournament_players_join_table.rb
index be240e8..be240e8 100644
--- a/db/migrate/20140422195146_create_tournament_players_join_table.rb
+++ b/db/migrate/20140422212704_create_tournament_players_join_table.rb
diff --git a/db/migrate/20140422195150_create_tournament_hosts_join_table.rb b/db/migrate/20140422212707_create_tournament_hosts_join_table.rb
index 7521d89..7521d89 100644
--- a/db/migrate/20140422195150_create_tournament_hosts_join_table.rb
+++ b/db/migrate/20140422212707_create_tournament_hosts_join_table.rb
diff --git a/db/migrate/20140422195153_create_team_user_join_table.rb b/db/migrate/20140422212711_create_team_user_join_table.rb
index f3b57fc..f3b57fc 100644
--- a/db/migrate/20140422195153_create_team_user_join_table.rb
+++ b/db/migrate/20140422212711_create_team_user_join_table.rb
diff --git a/db/migrate/20140422195157_create_match_team_join_table.rb b/db/migrate/20140422212714_create_match_team_join_table.rb
index c2ed1b7..c2ed1b7 100644
--- a/db/migrate/20140422195157_create_match_team_join_table.rb
+++ b/db/migrate/20140422212714_create_match_team_join_table.rb
diff --git a/db/migrate/20140422195211_add_hidden_attrs_to_user.rb b/db/migrate/20140422212727_add_hidden_attrs_to_user.rb
index 9b5c505..9b5c505 100644
--- a/db/migrate/20140422195211_add_hidden_attrs_to_user.rb
+++ b/db/migrate/20140422212727_add_hidden_attrs_to_user.rb
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 e965fde..b3e9343 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
@@ -66,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