diff options
author | gitlabhq <m@gitlabhq.com> | 2011-10-09 00:36:38 +0300 |
---|---|---|
committer | gitlabhq <m@gitlabhq.com> | 2011-10-09 00:36:38 +0300 |
commit | 9ba1224867665844b117fa037e1465bb706b3685 (patch) | |
tree | 52fbfc1cdb55df21843965479c97be0c91121a9a /app/controllers/notes_controller.rb | |
parent | 93efff945215a4407afcaf0cba15ac601b56df0d (diff) | |
download | gitlab-ce-9ba1224867665844b117fa037e1465bb706b3685.tar.gz |
init commit
Diffstat (limited to 'app/controllers/notes_controller.rb')
-rw-r--r-- | app/controllers/notes_controller.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb new file mode 100644 index 00000000000..d0a40eb18e4 --- /dev/null +++ b/app/controllers/notes_controller.rb @@ -0,0 +1,49 @@ +class NotesController < ApplicationController + before_filter :project + + # Authorize + before_filter :add_project_abilities + before_filter :authorize_write_note!, :only => [:create] + before_filter :authorize_admin_note!, :only => [:destroy] + + 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]) + @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 + else + Notify.note_wall_email(u, @note).deliver + end + end + end +end |