Compare commits
3 Commits
e8f912360b
...
0dcfefd66c
Author | SHA1 | Date | |
---|---|---|---|
0dcfefd66c | |||
c6a187b25a | |||
c99d8545c1 |
@ -1,12 +1,28 @@
|
|||||||
class Admin::InvitationsController < Admin::BaseController
|
class Admin::InvitationsController < Admin::BaseController
|
||||||
|
before_action :set_current_section
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@current_section = :invitations
|
@username = params[:username].presence
|
||||||
@pagy, @invitations_used = pagy(Invitation.used.order('used_at desc'))
|
accepted_scope = Invitation.used.order('used_at desc')
|
||||||
|
unused_scope = Invitation.unused
|
||||||
|
|
||||||
|
if @username
|
||||||
|
accepted_scope = accepted_scope.joins(:user).where(users: { cn: @username })
|
||||||
|
unused_scope = unused_scope.joins(:user).where(users: { cn: @username })
|
||||||
|
end
|
||||||
|
|
||||||
|
@pagy, @invitations_used = pagy(accepted_scope)
|
||||||
|
|
||||||
@stats = {
|
@stats = {
|
||||||
available: Invitation.unused.count,
|
available: unused_scope.count,
|
||||||
accepted: @invitations_used.length,
|
accepted: accepted_scope.count,
|
||||||
users_with_referrals: Invitation.used.distinct.count(:user_id)
|
users_with_referrals: accepted_scope.distinct.count(:user_id)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def set_current_section
|
||||||
|
@current_section = :invitations
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -24,6 +24,10 @@ class Admin::UsersController < Admin::BaseController
|
|||||||
|
|
||||||
# GET /admin/users/:username
|
# GET /admin/users/:username
|
||||||
def show
|
def show
|
||||||
|
@invitees = @user.invitees
|
||||||
|
@recent_invitees = @user.invitees.order(created_at: :desc).limit(5)
|
||||||
|
@more_invitees = (@invitees - @recent_invitees).count
|
||||||
|
|
||||||
if Setting.lndhub_admin_enabled?
|
if Setting.lndhub_admin_enabled?
|
||||||
@lndhub_user = @user.lndhub_user
|
@lndhub_user = @user.lndhub_user
|
||||||
end
|
end
|
||||||
|
11
app/views/admin/_username_search_form.html.erb
Normal file
11
app/views/admin/_username_search_form.html.erb
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<%= form_with url: path, method: :get, local: true, class: "flex gap-1" do %>
|
||||||
|
<%= text_field_tag :username, @username, placeholder: 'Filter by username' %>
|
||||||
|
<%= button_tag type: 'submit', name: nil, title: "Filter", class: 'btn-md btn-icon btn-outline' do %>
|
||||||
|
<%= render partial: "icons/filter", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
|
||||||
|
<% end %>
|
||||||
|
<% if @username %>
|
||||||
|
<%= link_to path, title: "Remove filter", class: 'btn-md btn-icon btn-outline' do %>
|
||||||
|
<%= render partial: "icons/x", locals: { custom_class: "text-red-600 h-4 w-4 inline" } %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
@ -19,17 +19,8 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<%= form_with url: admin_donations_path, method: :get, local: true, class: "flex gap-1" do %>
|
<%= render partial: "admin/username_search_form",
|
||||||
<%= text_field_tag :username, @username, placeholder: 'Filter by username' %>
|
locals: { path: admin_donations_path } %>
|
||||||
<%= button_tag type: 'submit', name: nil, title: "Filter", class: 'btn-md btn-icon btn-outline' do %>
|
|
||||||
<%= render partial: "icons/filter", locals: { custom_class: "text-blue-600 h-4 w-4 inline" } %>
|
|
||||||
<% end %>
|
|
||||||
<% if @username %>
|
|
||||||
<%= link_to admin_donations_path, title: "Remove filter", class: 'btn-md btn-icon btn-outline' do %>
|
|
||||||
<%= render partial: "icons/x", locals: { custom_class: "text-red-600 h-4 w-4 inline" } %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<% if @pending_donations.present? %>
|
<% if @pending_donations.present? %>
|
||||||
|
@ -21,6 +21,12 @@
|
|||||||
) %>
|
) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<%= render partial: "admin/username_search_form",
|
||||||
|
locals: { path: admin_invitations_path } %>
|
||||||
|
</section>
|
||||||
|
|
||||||
<% if @invitations_used.any? %>
|
<% if @invitations_used.any? %>
|
||||||
<section>
|
<section>
|
||||||
<h3>Accepted</h3>
|
<h3>Accepted</h3>
|
||||||
|
@ -99,10 +99,13 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th class="align-top">Invited users</th>
|
<th class="align-top">Invited users</th>
|
||||||
<td class="align-top">
|
<td class="align-top">
|
||||||
<% if @user.invitees.length > 0 %>
|
<% if @invitees.any? %>
|
||||||
<ul class="mb-0">
|
<ul class="mb-0">
|
||||||
<% @user.invitees.order(cn: :asc).each do |invitee| %>
|
<% @recent_invitees.each do |invitee| %>
|
||||||
<li class="leading-none mb-2 last:mb-0"><%= link_to invitee.cn, admin_user_path(invitee.cn), class: 'ks-text-link' %></li>
|
<li class="leading-none mb-2 last:mb-0"><%= link_to invitee.cn, admin_user_path(invitee.cn), class: "ks-text-link" %></li>
|
||||||
|
<% end %>
|
||||||
|
<% if @more_invitees > 0 %>
|
||||||
|
<li>and <%= link_to "#{@more_invitees} more", admin_invitations_path(username: @user.cn), class: "ks-text-link" %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
<% else %>—<% end %>
|
<% else %>—<% end %>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user