diff --git a/app/models/project.rb b/app/models/project.rb index 2843d5603604ad7aa40a7041774d40173e0e7722..d55714662b282cd03f4447ae144b478c8f6c95c7 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 0000000000000000000000000000000000000000..c01748a81b00f62a617e1d6d7047caee51ba4bf8 --- /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 0000000000000000000000000000000000000000..9695c25135202edacea014e237179a4fb1ee62fa --- /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 77d245913e248f608ac57e98adebfc73dea47f8b..f6a2bc0ebc37e3312de6bc382b3a08b89e01201a 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