Create issued blocks resource
This commit is contained in:
parent
0b755d8630
commit
7a4115f090
12 changed files with 147 additions and 119 deletions
|
@ -24,7 +24,7 @@ class Ability
|
|||
can [:create, :destroy], :session
|
||||
can [:read, :data, :georss], Trace
|
||||
can [:read, :terms, :create, :save, :suspended, :auth_success, :auth_failure], User
|
||||
can [:read, :blocks_on, :blocks_by], UserBlock
|
||||
can [:read, :blocks_on], UserBlock
|
||||
end
|
||||
|
||||
if user&.active?
|
||||
|
|
|
@ -9,7 +9,7 @@ class UserBlocksController < ApplicationController
|
|||
|
||||
authorize_resource
|
||||
|
||||
before_action :lookup_user, :only => [:new, :create, :revoke_all, :blocks_on, :blocks_by]
|
||||
before_action :lookup_user, :only => [:new, :create, :revoke_all, :blocks_on]
|
||||
before_action :lookup_user_block, :only => [:show, :edit, :update]
|
||||
before_action :require_valid_params, :only => [:create, :update]
|
||||
before_action :check_database_readable
|
||||
|
@ -130,21 +130,6 @@ class UserBlocksController < ApplicationController
|
|||
render :partial => "page" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
|
||||
##
|
||||
# shows a list of all the blocks by the given user.
|
||||
def blocks_by
|
||||
@params = params.permit(:display_name)
|
||||
|
||||
user_blocks = UserBlock.where(:creator => @user)
|
||||
|
||||
@user_blocks, @newer_user_blocks_id, @older_user_blocks_id = get_page_items(user_blocks, :includes => [:user, :creator, :revoker])
|
||||
|
||||
@show_user_name = true
|
||||
@show_creator_name = false
|
||||
|
||||
render :partial => "page" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
|
|
31
app/controllers/users/issued_blocks_controller.rb
Normal file
31
app/controllers/users/issued_blocks_controller.rb
Normal file
|
@ -0,0 +1,31 @@
|
|||
module Users
|
||||
class IssuedBlocksController < ApplicationController
|
||||
include UserMethods
|
||||
include PaginationMethods
|
||||
|
||||
layout "site"
|
||||
|
||||
before_action :authorize_web
|
||||
before_action :set_locale
|
||||
|
||||
authorize_resource :class => UserBlock
|
||||
|
||||
before_action :lookup_user
|
||||
before_action :check_database_readable
|
||||
|
||||
##
|
||||
# shows a list of all the blocks by the given user.
|
||||
def show
|
||||
@params = params.permit(:user_display_name)
|
||||
|
||||
user_blocks = UserBlock.where(:creator => @user)
|
||||
|
||||
@user_blocks, @newer_user_blocks_id, @older_user_blocks_id = get_page_items(user_blocks, :includes => [:user, :creator, :revoker])
|
||||
|
||||
@show_user_name = true
|
||||
@show_creator_name = false
|
||||
|
||||
render :partial => "user_blocks/page" if turbo_frame_request_id == "pagination"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -22,16 +22,16 @@
|
|||
<% if current_user&.blocks_created&.exists? %>
|
||||
<li class="nav-item">
|
||||
<%= link_to t(".blocks_by_me"),
|
||||
user_blocks_by_path(current_user),
|
||||
:class => ["nav-link", { :active => action_name == "blocks_by" && current_user == @user }] %>
|
||||
user_issued_blocks_path(current_user),
|
||||
:class => ["nav-link", { :active => controller_name == "issued_blocks" && current_user == @user }] %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% by_user = @user || @user_block&.creator %>
|
||||
<% if by_user != current_user && by_user&.blocks_created&.exists? %>
|
||||
<li class="nav-item">
|
||||
<%= link_to t(".blocks_by_user_html", :user => tag.span(by_user.display_name, :class => "username text-truncate d-inline-block align-bottom", :dir => "auto")),
|
||||
user_blocks_by_path(by_user),
|
||||
:class => ["nav-link", { :active => action_name == "blocks_by" }] %>
|
||||
user_issued_blocks_path(by_user),
|
||||
:class => ["nav-link", { :active => controller_name == "issued_blocks" }] %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% if @user_block&.persisted? %>
|
||||
|
|
|
@ -16,10 +16,11 @@
|
|||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<%= render :partial => "block", :collection => @user_blocks %>
|
||||
<%= render :partial => "user_blocks/block", :collection => @user_blocks %>
|
||||
</table>
|
||||
|
||||
<%= render "shared/pagination",
|
||||
:translation_scope => "shared.pagination.user_blocks",
|
||||
:newer_id => @newer_user_blocks_id,
|
||||
:older_id => @older_user_blocks_id %>
|
||||
</turbo-frame>
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
<% content_for :heading_class, "pb-0" %>
|
||||
<% content_for :heading do %>
|
||||
<h1><%= t(".heading_html", :name => link_to(@user.display_name, @user)) %></h1>
|
||||
<%= render :partial => "navigation" %>
|
||||
<%= render :partial => "user_blocks/navigation" %>
|
||||
<% end %>
|
||||
|
||||
<% unless @user_blocks.empty? %>
|
||||
<%= render :partial => "page" %>
|
||||
<%= render :partial => "user_blocks/page" %>
|
||||
<% else %>
|
||||
<p><%= t ".empty", :name => @user.display_name %></p>
|
||||
<% end %>
|
|
@ -42,7 +42,7 @@
|
|||
|
||||
<% if can?(:create, UserBlock) and current_user.blocks_created.exists? %>
|
||||
<li>
|
||||
<%= link_to t(".blocks by me"), user_blocks_by_path(current_user) %>
|
||||
<%= link_to t(".blocks by me"), user_issued_blocks_path(current_user) %>
|
||||
<span class='badge count-number'><%= number_with_delimiter(current_user.blocks_created.active.size) %></span>
|
||||
</li>
|
||||
<% end %>
|
||||
|
@ -100,7 +100,7 @@
|
|||
|
||||
<% if @user.moderator? and @user.blocks_created.exists? %>
|
||||
<li>
|
||||
<%= link_to t(".moderator_history"), user_blocks_by_path(@user) %>
|
||||
<%= link_to t(".moderator_history"), user_issued_blocks_path(@user) %>
|
||||
<span class='badge count-number'><%= number_with_delimiter(@user.blocks_created.active.size) %></span>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue