diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-12-09 13:28:09 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-12-09 16:08:04 +0100 |
commit | e7f1bfdc2d528f137299ba0c3ab2a30f2f91f53c (patch) | |
tree | 2693ffce4d340a9b77a7ca52c856aaae7af8c913 /app/controllers/admin | |
parent | e3682c9c1750e5e7e5d2f817e29f6760a18400ca (diff) | |
parent | 81bda7d67c984c9bfcb5bca94e50cec6405b492e (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - app/javascript/packs/public.js - app/models/user.rb - config/settings.yml - db/schema.rb Moved public.js changes to settings.js.
Diffstat (limited to 'app/controllers/admin')
-rw-r--r-- | app/controllers/admin/tags_controller.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/app/controllers/admin/tags_controller.rb b/app/controllers/admin/tags_controller.rb new file mode 100644 index 000000000..3f2256566 --- /dev/null +++ b/app/controllers/admin/tags_controller.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Admin + class TagsController < BaseController + before_action :set_tags, only: :index + before_action :set_tag, except: :index + before_action :set_filter_params + + def index + authorize :tag, :index? + end + + def hide + authorize @tag, :hide? + @tag.account_tag_stat.update!(hidden: true) + redirect_to admin_tags_path(@filter_params) + end + + def unhide + authorize @tag, :unhide? + @tag.account_tag_stat.update!(hidden: true) + redirect_to admin_tags_path(@filter_params) + end + + private + + def set_tags + @tags = Tag.discoverable + @tags.merge!(Tag.hidden) if filter_params[:hidden] + end + + def set_tag + @tag = Tag.find(params[:id]) + end + + def set_filter_params + @filter_params = filter_params.to_hash.symbolize_keys + end + + def filter_params + params.permit(:hidden) + end + end +end |