mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-28 20:47:10 +00:00

Some checks are pending
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / Libvips tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.2) (push) Blocked by required conditions
Ruby Testing / Libvips tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
65 lines
1.0 KiB
Ruby
65 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Admin
|
|
class RulesController < BaseController
|
|
before_action :set_rule, except: [:index, :new, :create]
|
|
|
|
def index
|
|
authorize :rule, :index?
|
|
|
|
@rules = Rule.ordered
|
|
end
|
|
|
|
def new
|
|
authorize :rule, :create?
|
|
@rule = Rule.new
|
|
end
|
|
|
|
def edit
|
|
authorize @rule, :update?
|
|
end
|
|
|
|
def create
|
|
authorize :rule, :create?
|
|
|
|
@rule = Rule.new(resource_params)
|
|
|
|
if @rule.save
|
|
redirect_to admin_rules_path
|
|
else
|
|
@rules = Rule.ordered
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def update
|
|
authorize @rule, :update?
|
|
|
|
if @rule.update(resource_params)
|
|
redirect_to admin_rules_path
|
|
else
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
authorize @rule, :destroy?
|
|
|
|
@rule.discard
|
|
|
|
redirect_to admin_rules_path
|
|
end
|
|
|
|
private
|
|
|
|
def set_rule
|
|
@rule = Rule.find(params[:id])
|
|
end
|
|
|
|
def resource_params
|
|
params
|
|
.expect(rule: [:text, :hint, :priority])
|
|
end
|
|
end
|
|
end
|