account_moderation_notes_controller.rb 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. # frozen_string_literal: true
  2. module Admin
  3. class AccountModerationNotesController < BaseController
  4. before_action :set_account_moderation_note, only: [:destroy]
  5. def create
  6. authorize AccountModerationNote, :create?
  7. @account_moderation_note = current_account.account_moderation_notes.new(resource_params)
  8. if @account_moderation_note.save
  9. redirect_to admin_account_path(@account_moderation_note.target_account_id), notice: I18n.t('admin.account_moderation_notes.created_msg')
  10. else
  11. @account = @account_moderation_note.target_account
  12. @moderation_notes = @account.targeted_moderation_notes.latest
  13. @warnings = @account.targeted_account_warnings.latest.custom
  14. render template: 'admin/accounts/show'
  15. end
  16. end
  17. def destroy
  18. authorize @account_moderation_note, :destroy?
  19. @account_moderation_note.destroy!
  20. redirect_to admin_account_path(@account_moderation_note.target_account_id), notice: I18n.t('admin.account_moderation_notes.destroyed_msg')
  21. end
  22. private
  23. def resource_params
  24. params.require(:account_moderation_note).permit(
  25. :content,
  26. :target_account_id
  27. )
  28. end
  29. def set_account_moderation_note
  30. @account_moderation_note = AccountModerationNote.find(params[:id])
  31. end
  32. end
  33. end