blob: 46425664d6e8537e5d0dbcfce18f6b75041398f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
class NotesController < ApplicationController
before_filter :project
# Authorize
before_filter :add_project_abilities
before_filter :authorize_write_note!, :only => [:create]
respond_to :js
def create
@note = @project.notes.new(params[:note])
@note.author = current_user
if @note.save
notify if params[:notify] == '1'
end
respond_to do |format|
format.html {redirect_to :back}
format.js
end
end
def destroy
@note = @project.notes.find(params[:id])
return access_denied! unless can?(current_user, :admin_note, @note)
@note.destroy
respond_to do |format|
format.js { render :nothing => true }
end
end
protected
def notify
@project.users.reject { |u| u.id == current_user.id } .each do |u|
case @note.noteable_type
when "Commit" then
Notify.note_commit_email(u, @note).deliver
when "Issue" then
Notify.note_issue_email(u, @note).deliver
when "Snippet"
true
else
Notify.note_wall_email(u, @note).deliver
end
end
end
end
|