diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-04-27 12:41:26 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-05-02 13:07:53 +0200 |
commit | 8c3a03c1b9bf5c80571c9dc07ba258fa10dd61c8 (patch) | |
tree | a83db3e692f01ad711f1693c739f43f6cca400ca /app/controllers/snippets | |
parent | 8100f9686dcd729f42d14e86cb9b36b403e036ac (diff) | |
download | gitlab-ce-8c3a03c1b9bf5c80571c9dc07ba258fa10dd61c8.tar.gz |
Display comments for personal snippets12910-personal-snippets-notes-show
Diffstat (limited to 'app/controllers/snippets')
-rw-r--r-- | app/controllers/snippets/notes_controller.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/controllers/snippets/notes_controller.rb b/app/controllers/snippets/notes_controller.rb new file mode 100644 index 00000000000..3c4ddc1680d --- /dev/null +++ b/app/controllers/snippets/notes_controller.rb @@ -0,0 +1,44 @@ +class Snippets::NotesController < ApplicationController + include NotesActions + include ToggleAwardEmoji + + skip_before_action :authenticate_user!, only: [:index] + before_action :snippet + before_action :authorize_read_snippet!, only: [:show, :index, :create] + + private + + def note + @note ||= snippet.notes.find(params[:id]) + end + alias_method :awardable, :note + + def note_html(note) + render_to_string( + "shared/notes/_note", + layout: false, + formats: [:html], + locals: { note: note } + ) + end + + def project + nil + end + + def snippet + PersonalSnippet.find_by(id: params[:snippet_id]) + end + + def note_params + super.merge(noteable_id: params[:snippet_id]) + end + + def finder_params + params.merge(last_fetched_at: last_fetched_at, target_id: snippet.id, target_type: 'personal_snippet') + end + + def authorize_read_snippet! + return render_404 unless can?(current_user, :read_personal_snippet, snippet) + end +end |