Commit 117baf005cd3308336f468680f33f57774ebd061
1 parent
11173e81
Exists in
master
and in
1 other branch
Turn on/off email notifications for deploys and errors on a per-application basi…
…s. Allow message with deploy notifications (so we know what is was for)
Showing
8 changed files
with
23 additions
and
4 deletions
Show diff stats
app/controllers/deploys_controller.rb
1 | class DeploysController < ApplicationController | 1 | class DeploysController < ApplicationController |
2 | + | ||
3 | + protect_from_forgery :except => :create | ||
2 | 4 | ||
3 | skip_before_filter :verify_authenticity_token, :only => :create | 5 | skip_before_filter :verify_authenticity_token, :only => :create |
4 | skip_before_filter :authenticate_user!, :only => :create | 6 | skip_before_filter :authenticate_user!, :only => :create |
@@ -9,7 +11,8 @@ class DeploysController < ApplicationController | @@ -9,7 +11,8 @@ class DeploysController < ApplicationController | ||
9 | :username => params[:deploy][:local_username], | 11 | :username => params[:deploy][:local_username], |
10 | :environment => params[:deploy][:rails_env], | 12 | :environment => params[:deploy][:rails_env], |
11 | :repository => params[:deploy][:scm_repository], | 13 | :repository => params[:deploy][:scm_repository], |
12 | - :revision => params[:deploy][:scm_revision] | 14 | + :revision => params[:deploy][:scm_revision], |
15 | + :message => params[:deploy][:message] | ||
13 | }) | 16 | }) |
14 | render :xml => @deploy | 17 | render :xml => @deploy |
15 | end | 18 | end |
app/models/app.rb
@@ -5,6 +5,8 @@ class App | @@ -5,6 +5,8 @@ class App | ||
5 | field :name, :type => String | 5 | field :name, :type => String |
6 | field :api_key | 6 | field :api_key |
7 | field :resolve_errs_on_deploy, :type => Boolean, :default => false | 7 | field :resolve_errs_on_deploy, :type => Boolean, :default => false |
8 | + field :notify_on_errs, :type => Boolean, :default => false | ||
9 | + field :notify_on_deploys, :type => Boolean, :default => false | ||
8 | key :name | 10 | key :name |
9 | 11 | ||
10 | embeds_many :watchers | 12 | embeds_many :watchers |
app/models/deploy.rb
@@ -6,6 +6,7 @@ class Deploy | @@ -6,6 +6,7 @@ class Deploy | ||
6 | field :repository | 6 | field :repository |
7 | field :environment | 7 | field :environment |
8 | field :revision | 8 | field :revision |
9 | + field :message | ||
9 | 10 | ||
10 | index :created_at, Mongo::DESCENDING | 11 | index :created_at, Mongo::DESCENDING |
11 | 12 | ||
@@ -27,7 +28,7 @@ class Deploy | @@ -27,7 +28,7 @@ class Deploy | ||
27 | protected | 28 | protected |
28 | 29 | ||
29 | def should_notify? | 30 | def should_notify? |
30 | - app.watchers.any? | 31 | + app.notify_on_deploys? && app.watchers.any? |
31 | end | 32 | end |
32 | 33 | ||
33 | def should_resolve_app_errs? | 34 | def should_resolve_app_errs? |
app/models/err.rb
@@ -13,6 +13,7 @@ class Err | @@ -13,6 +13,7 @@ class Err | ||
13 | field :resolved, :type => Boolean, :default => false | 13 | field :resolved, :type => Boolean, :default => false |
14 | 14 | ||
15 | index :last_notice_at | 15 | index :last_notice_at |
16 | + index :app_id | ||
16 | 17 | ||
17 | referenced_in :app | 18 | referenced_in :app |
18 | embeds_many :notices | 19 | embeds_many :notices |
app/models/notice.rb
@@ -73,7 +73,7 @@ class Notice | @@ -73,7 +73,7 @@ class Notice | ||
73 | protected | 73 | protected |
74 | 74 | ||
75 | def should_notify? | 75 | def should_notify? |
76 | - Errbit::Config.email_at_notices.include?(err.notices.count) && err.app.watchers.any? | 76 | + err.app.notify_on_errs? && Errbit::Config.email_at_notices.include?(err.notices.count) && err.app.watchers.any? |
77 | end | 77 | end |
78 | 78 | ||
79 | end | 79 | end |
80 | \ No newline at end of file | 80 | \ No newline at end of file |
app/views/apps/_fields.html.haml
@@ -5,9 +5,17 @@ | @@ -5,9 +5,17 @@ | ||
5 | = f.text_field :name | 5 | = f.text_field :name |
6 | 6 | ||
7 | %div.checkbox | 7 | %div.checkbox |
8 | + = f.check_box :notify_on_errs | ||
9 | + = f.label :notify_on_errs, 'Notify on errors' | ||
10 | + | ||
11 | +%div.checkbox | ||
8 | = f.check_box :resolve_errs_on_deploy | 12 | = f.check_box :resolve_errs_on_deploy |
9 | = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy' | 13 | = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy' |
10 | - | 14 | + |
15 | +%div.checkbox | ||
16 | + = f.check_box :notify_on_deploys | ||
17 | + = f.label :notify_on_deploys, 'Notify on deploys' | ||
18 | + | ||
11 | %fieldset.nested-wrapper | 19 | %fieldset.nested-wrapper |
12 | %legend Watchers | 20 | %legend Watchers |
13 | - f.fields_for :watchers do |w| | 21 | - f.fields_for :watchers do |w| |
app/views/apps/show.html.haml
@@ -32,6 +32,7 @@ | @@ -32,6 +32,7 @@ | ||
32 | %tr | 32 | %tr |
33 | %th When | 33 | %th When |
34 | %th Who | 34 | %th Who |
35 | + %th Message | ||
35 | %th Repository | 36 | %th Repository |
36 | %th Revision | 37 | %th Revision |
37 | 38 | ||
@@ -40,6 +41,7 @@ | @@ -40,6 +41,7 @@ | ||
40 | %tr | 41 | %tr |
41 | %td.when #{deploy.created_at.to_s(:micro)} | 42 | %td.when #{deploy.created_at.to_s(:micro)} |
42 | %td.who #{deploy.username} | 43 | %td.who #{deploy.username} |
44 | + %td.message #{deploy.message} | ||
43 | %td.repository #{deploy.repository} | 45 | %td.repository #{deploy.repository} |
44 | %td.revision #{deploy.revision} | 46 | %td.revision #{deploy.revision} |
45 | = link_to "All Deploys (#{@app.deploys.count})", app_deploys_path(@app), :class => 'button' | 47 | = link_to "All Deploys (#{@app.deploys.count})", app_deploys_path(@app), :class => 'button' |
app/views/deploys/_table.html.haml
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | %th App | 4 | %th App |
5 | %th When | 5 | %th When |
6 | %th Who | 6 | %th Who |
7 | + %th Message | ||
7 | %th Repository | 8 | %th Repository |
8 | %th Revision | 9 | %th Revision |
9 | %tbody | 10 | %tbody |
@@ -14,5 +15,6 @@ | @@ -14,5 +15,6 @@ | ||
14 | %span.environment= deploy.environment | 15 | %span.environment= deploy.environment |
15 | %td.latest #{time_ago_in_words(deploy.created_at)} ago | 16 | %td.latest #{time_ago_in_words(deploy.created_at)} ago |
16 | %td.who #{deploy.username} | 17 | %td.who #{deploy.username} |
18 | + %td.message #{deploy.message} | ||
17 | %td.repository #{deploy.repository} | 19 | %td.repository #{deploy.repository} |
18 | %td.revision #{deploy.revision} | 20 | %td.revision #{deploy.revision} |