diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-12-17 14:42:40 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-12-17 14:42:40 +0400 |
commit | 86a8796b1322879d01e9cea8fb728458e0e328cb (patch) | |
tree | 4b35e22f09d2b64018cd8bd0ed039ad99794e3fa | |
parent | 5ac57305477ed90bf416b3c795516e9b9135bf5b (diff) |
Create EmailsOnPushService model
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/project_services/emails_on_push_service.rb | 45 | ||||
-rw-r--r-- | db/migrate/20131217102743_add_recipients_to_service.rb | 5 | ||||
-rw-r--r-- | db/schema.rb | 32 |
4 files changed, 71 insertions, 15 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 2843d560360..d55714662b2 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -25,6 +25,7 @@ require_relative "project_services/assembla_service" require_relative "project_services/campfire_service" +require_relative "project_services/emails_on_push_service" require_relative "project_services/flowdock_service" require_relative "project_services/gitlab_ci_service" require_relative "project_services/hipchat_service" @@ -55,6 +56,7 @@ class Project < ActiveRecord::Base has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id' has_one :gitlab_ci_service, dependent: :destroy has_one :campfire_service, dependent: :destroy + has_one :emails_on_push_service, dependent: :destroy has_one :pivotaltracker_service, dependent: :destroy has_one :hipchat_service, dependent: :destroy has_one :flowdock_service, dependent: :destroy @@ -244,7 +246,7 @@ class Project < ActiveRecord::Base end def available_services_names - %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla) + %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push) end def gitlab_ci? diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb new file mode 100644 index 00000000000..c01748a81b0 --- /dev/null +++ b/app/models/project_services/emails_on_push_service.rb @@ -0,0 +1,45 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# token :string(255) +# project_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# active :boolean default(FALSE), not null +# project_url :string(255) +# subdomain :string(255) +# room :string(255) +# + +class EmailsOnPushService < Service + attr_accessible :recipients + + validates :recipients, presence: true, if: :activated? + + def title + 'Emails on push' + end + + def description + 'Send emails to recipients on push' + end + + def to_param + 'emails_on_push' + end + + def execute + true + end + + def fields + [ + { type: 'textarea', name: 'recipients', placeholder: 'Recipients' }, + ] + end +end + diff --git a/db/migrate/20131217102743_add_recipients_to_service.rb b/db/migrate/20131217102743_add_recipients_to_service.rb new file mode 100644 index 00000000000..9695c251352 --- /dev/null +++ b/db/migrate/20131217102743_add_recipients_to_service.rb @@ -0,0 +1,5 @@ +class AddRecipientsToService < ActiveRecord::Migration + def change + add_column :services, :recipients, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 77d245913e2..f6a2bc0ebc3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,10 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20131214224427) do +ActiveRecord::Schema.define(version: 20131217102743) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" create_table "broadcast_messages", force: true do |t| t.text "message", null: false @@ -94,20 +97,20 @@ ActiveRecord::Schema.define(version: 20131214224427) do add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree create_table "merge_requests", force: true do |t| - t.string "target_branch", null: false - t.string "source_branch", null: false - t.integer "source_project_id", null: false + t.string "target_branch", null: false + t.string "source_branch", null: false + t.integer "source_project_id", null: false t.integer "author_id" t.integer "assignee_id" t.string "title" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.text "st_commits", limit: 2147483647 - t.text "st_diffs", limit: 2147483647 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "st_commits" + t.text "st_diffs" t.integer "milestone_id" t.string "state" t.string "merge_status" - t.integer "target_project_id", null: false + t.integer "target_project_id", null: false t.integer "iid" t.text "description" end @@ -219,20 +222,21 @@ ActiveRecord::Schema.define(version: 20131214224427) do t.string "project_url" t.string "subdomain" t.string "room" + t.text "recipients" end add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree create_table "snippets", force: true do |t| t.string "title" - t.text "content", limit: 2147483647 - t.integer "author_id", null: false + t.text "content" + t.integer "author_id", null: false t.integer "project_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.string "file_name" t.datetime "expires_at" - t.boolean "private", default: true, null: false + t.boolean "private", default: true, null: false t.string "type" end |