Commit 86a8796b1322879d01e9cea8fb728458e0e328cb
1 parent
5ac57305
Exists in
master
and in
4 other branches
Create EmailsOnPushService model
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
4 changed files
with
71 additions
and
15 deletions
Show diff stats
app/models/project.rb
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | |
| 26 | 26 | require_relative "project_services/assembla_service" |
| 27 | 27 | require_relative "project_services/campfire_service" |
| 28 | +require_relative "project_services/emails_on_push_service" | |
| 28 | 29 | require_relative "project_services/flowdock_service" |
| 29 | 30 | require_relative "project_services/gitlab_ci_service" |
| 30 | 31 | require_relative "project_services/hipchat_service" |
| ... | ... | @@ -55,6 +56,7 @@ class Project < ActiveRecord::Base |
| 55 | 56 | has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id' |
| 56 | 57 | has_one :gitlab_ci_service, dependent: :destroy |
| 57 | 58 | has_one :campfire_service, dependent: :destroy |
| 59 | + has_one :emails_on_push_service, dependent: :destroy | |
| 58 | 60 | has_one :pivotaltracker_service, dependent: :destroy |
| 59 | 61 | has_one :hipchat_service, dependent: :destroy |
| 60 | 62 | has_one :flowdock_service, dependent: :destroy |
| ... | ... | @@ -244,7 +246,7 @@ class Project < ActiveRecord::Base |
| 244 | 246 | end |
| 245 | 247 | |
| 246 | 248 | def available_services_names |
| 247 | - %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla) | |
| 249 | + %w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push) | |
| 248 | 250 | end |
| 249 | 251 | |
| 250 | 252 | def gitlab_ci? | ... | ... |
| ... | ... | @@ -0,0 +1,45 @@ |
| 1 | +# == Schema Information | |
| 2 | +# | |
| 3 | +# Table name: services | |
| 4 | +# | |
| 5 | +# id :integer not null, primary key | |
| 6 | +# type :string(255) | |
| 7 | +# title :string(255) | |
| 8 | +# token :string(255) | |
| 9 | +# project_id :integer not null | |
| 10 | +# created_at :datetime not null | |
| 11 | +# updated_at :datetime not null | |
| 12 | +# active :boolean default(FALSE), not null | |
| 13 | +# project_url :string(255) | |
| 14 | +# subdomain :string(255) | |
| 15 | +# room :string(255) | |
| 16 | +# | |
| 17 | + | |
| 18 | +class EmailsOnPushService < Service | |
| 19 | + attr_accessible :recipients | |
| 20 | + | |
| 21 | + validates :recipients, presence: true, if: :activated? | |
| 22 | + | |
| 23 | + def title | |
| 24 | + 'Emails on push' | |
| 25 | + end | |
| 26 | + | |
| 27 | + def description | |
| 28 | + 'Send emails to recipients on push' | |
| 29 | + end | |
| 30 | + | |
| 31 | + def to_param | |
| 32 | + 'emails_on_push' | |
| 33 | + end | |
| 34 | + | |
| 35 | + def execute | |
| 36 | + true | |
| 37 | + end | |
| 38 | + | |
| 39 | + def fields | |
| 40 | + [ | |
| 41 | + { type: 'textarea', name: 'recipients', placeholder: 'Recipients' }, | |
| 42 | + ] | |
| 43 | + end | |
| 44 | +end | |
| 45 | + | ... | ... |
db/schema.rb
| ... | ... | @@ -11,7 +11,10 @@ |
| 11 | 11 | # |
| 12 | 12 | # It's strongly recommended that you check this file into your version control system. |
| 13 | 13 | |
| 14 | -ActiveRecord::Schema.define(version: 20131214224427) do | |
| 14 | +ActiveRecord::Schema.define(version: 20131217102743) do | |
| 15 | + | |
| 16 | + # These are extensions that must be enabled in order to support this database | |
| 17 | + enable_extension "plpgsql" | |
| 15 | 18 | |
| 16 | 19 | create_table "broadcast_messages", force: true do |t| |
| 17 | 20 | t.text "message", null: false |
| ... | ... | @@ -94,20 +97,20 @@ ActiveRecord::Schema.define(version: 20131214224427) do |
| 94 | 97 | add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree |
| 95 | 98 | |
| 96 | 99 | create_table "merge_requests", force: true do |t| |
| 97 | - t.string "target_branch", null: false | |
| 98 | - t.string "source_branch", null: false | |
| 99 | - t.integer "source_project_id", null: false | |
| 100 | + t.string "target_branch", null: false | |
| 101 | + t.string "source_branch", null: false | |
| 102 | + t.integer "source_project_id", null: false | |
| 100 | 103 | t.integer "author_id" |
| 101 | 104 | t.integer "assignee_id" |
| 102 | 105 | t.string "title" |
| 103 | - t.datetime "created_at", null: false | |
| 104 | - t.datetime "updated_at", null: false | |
| 105 | - t.text "st_commits", limit: 2147483647 | |
| 106 | - t.text "st_diffs", limit: 2147483647 | |
| 106 | + t.datetime "created_at", null: false | |
| 107 | + t.datetime "updated_at", null: false | |
| 108 | + t.text "st_commits" | |
| 109 | + t.text "st_diffs" | |
| 107 | 110 | t.integer "milestone_id" |
| 108 | 111 | t.string "state" |
| 109 | 112 | t.string "merge_status" |
| 110 | - t.integer "target_project_id", null: false | |
| 113 | + t.integer "target_project_id", null: false | |
| 111 | 114 | t.integer "iid" |
| 112 | 115 | t.text "description" |
| 113 | 116 | end |
| ... | ... | @@ -219,20 +222,21 @@ ActiveRecord::Schema.define(version: 20131214224427) do |
| 219 | 222 | t.string "project_url" |
| 220 | 223 | t.string "subdomain" |
| 221 | 224 | t.string "room" |
| 225 | + t.text "recipients" | |
| 222 | 226 | end |
| 223 | 227 | |
| 224 | 228 | add_index "services", ["project_id"], name: "index_services_on_project_id", using: :btree |
| 225 | 229 | |
| 226 | 230 | create_table "snippets", force: true do |t| |
| 227 | 231 | t.string "title" |
| 228 | - t.text "content", limit: 2147483647 | |
| 229 | - t.integer "author_id", null: false | |
| 232 | + t.text "content" | |
| 233 | + t.integer "author_id", null: false | |
| 230 | 234 | t.integer "project_id" |
| 231 | - t.datetime "created_at", null: false | |
| 232 | - t.datetime "updated_at", null: false | |
| 235 | + t.datetime "created_at", null: false | |
| 236 | + t.datetime "updated_at", null: false | |
| 233 | 237 | t.string "file_name" |
| 234 | 238 | t.datetime "expires_at" |
| 235 | - t.boolean "private", default: true, null: false | |
| 239 | + t.boolean "private", default: true, null: false | |
| 236 | 240 | t.string "type" |
| 237 | 241 | end |
| 238 | 242 | ... | ... |