-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
class Settings::DomainBlocksController < ApplicationController | ||
respond_to :html | ||
|
||
def index | ||
@blocks = policy_scope(Federails::Moderation::DomainBlock).all | ||
render layout: "settings" | ||
end | ||
|
||
def new | ||
authorize Federails::Moderation::DomainBlock | ||
@domain_block = Federails::Moderation::DomainBlock.new | ||
render layout: "settings" | ||
end | ||
|
||
def create | ||
authorize Federails::Moderation::DomainBlock | ||
@domain_block = Federails::Moderation::DomainBlock.create(domain_block_params) | ||
if @domain_block.valid? | ||
redirect_to settings_domain_blocks_path, notice: t(".success") | ||
else | ||
render "new", layout: "settings", status: :unprocessable_entity | ||
end | ||
end | ||
|
||
def destroy | ||
@domain_block = Federails::Moderation::DomainBlock.find(params[:id]) | ||
authorize @domain_block | ||
@domain_block.destroy | ||
redirect_to settings_domain_blocks_path, notice: t(".success") | ||
end | ||
|
||
private | ||
|
||
def domain_block_params | ||
params.require(:domain_block).permit(:domain) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class Federails::Moderation::DomainBlockPolicy < ApplicationPolicy | ||
def index? | ||
all_of( | ||
SiteSettings.federation_enabled?, | ||
@user.is_moderator? | ||
) | ||
end | ||
|
||
def show? | ||
index? | ||
end | ||
|
||
def edit? | ||
index? | ||
end | ||
|
||
def update? | ||
index? | ||
end | ||
|
||
def destroy? | ||
index? | ||
end | ||
|
||
class Scope < ApplicationPolicy::Scope | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<h3><%= t(".title") %></h3> | ||
|
||
<p class="lead"><%= t(".description") %></p> | ||
|
||
<table class="table table-striped"> | ||
<tr> | ||
<th><%= Federails::Moderation::DomainBlock.human_attribute_name(:domain) %></th> | ||
<th><%= Federails::Moderation::DomainBlock.human_attribute_name(:created_at) %></th> | ||
<th></th> | ||
</tr> | ||
<% @blocks.each do |block| %> | ||
<tr> | ||
<td><%= block.domain %></td> | ||
<td><%= block.created_at %></td> | ||
<td><%= link_to safe_join([icon("trash", t("general.delete")), t("general.delete")], " "), settings_domain_block_path(block), {method: :delete, class: "float-end btn btn-outline-danger", data: {confirm: translate(".confirm_destroy")}} if policy(block).destroy? %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<%= link_to t(".new"), new_settings_domain_block_path, class: "btn btn-primary" if policy(Federails::Moderation::DomainBlock).new? %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<h3><%= t(".title") %></h3> | ||
|
||
<%= form_with model: [:settings, @domain_block] do |form| %> | ||
<%= text_input_row form, :domain %> | ||
<%= form.submit translate(".submit"), class: "btn btn-primary" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters