member-user connection, download stats menu label
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
ActiveAdmin.register AdminUser do
|
||||
permit_params :email, :password, :password_confirmation
|
||||
permit_params :email, :password, :password_confirmation, :member_id
|
||||
|
||||
index do
|
||||
selectable_column
|
||||
id_column
|
||||
column :email
|
||||
column(:member) { |u| u.member ? link_to(u.member.nick, admin_member_path(u.member)) : "–" }
|
||||
column :created_at
|
||||
actions
|
||||
end
|
||||
|
||||
filter :email
|
||||
filter :member_id, as: :select, collection: -> { Member.order(:nick).map { |m| [m.nick, m.id] } }
|
||||
filter :created_at
|
||||
|
||||
form do |f|
|
||||
@@ -17,6 +19,9 @@ ActiveAdmin.register AdminUser do
|
||||
f.input :email
|
||||
f.input :password
|
||||
f.input :password_confirmation
|
||||
f.input :member_id, as: :select,
|
||||
collection: Member.order(:nick).map { |m| [m.nick, m.id] },
|
||||
include_blank: "— none —"
|
||||
end
|
||||
f.actions
|
||||
end
|
||||
@@ -25,8 +30,15 @@ ActiveAdmin.register AdminUser do
|
||||
attributes_table do
|
||||
row :id
|
||||
row :email
|
||||
row(:member) { |u| u.member ? link_to(u.member.nick, admin_member_path(u.member)) : "–" }
|
||||
row :created_at
|
||||
row :updated_at
|
||||
end
|
||||
end
|
||||
|
||||
controller do
|
||||
def scoped_collection
|
||||
super.includes(:member)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
ActiveAdmin.register Download do
|
||||
actions :index, :show
|
||||
|
||||
menu priority: 6
|
||||
menu priority: 6, label: "Download Stats"
|
||||
|
||||
scope :all, default: true
|
||||
scope("Today") { |scope| scope.where("downloads.created_at >= ?", Date.current.beginning_of_day) }
|
||||
|
||||
@@ -20,6 +20,7 @@ ActiveAdmin.register Member do
|
||||
image_tag "/api/image/#{m.image.id}", style: "max-height:40px;max-width:80px;object-fit:contain;"
|
||||
end
|
||||
end
|
||||
column(:admin_user) { |m| m.admin_user ? link_to(m.admin_user.email, admin_admin_user_path(m.admin_user)) : "–" }
|
||||
column :created_at
|
||||
actions
|
||||
end
|
||||
@@ -50,7 +51,7 @@ ActiveAdmin.register Member do
|
||||
|
||||
controller do
|
||||
def scoped_collection
|
||||
super.includes(:image)
|
||||
super.includes(:image, :admin_user)
|
||||
end
|
||||
|
||||
def find_resource
|
||||
|
||||
@@ -2,7 +2,13 @@ class AdminUser < ApplicationRecord
|
||||
devise :database_authenticatable,
|
||||
:recoverable, :rememberable, :validatable
|
||||
|
||||
belongs_to :member, optional: true
|
||||
|
||||
def self.ransackable_attributes(auth_object = nil)
|
||||
%w[created_at email id updated_at]
|
||||
%w[created_at email id member_id updated_at]
|
||||
end
|
||||
|
||||
def self.ransackable_associations(auth_object = nil)
|
||||
%w[member]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Member < ApplicationRecord
|
||||
belongs_to :image, optional: true
|
||||
has_one :admin_user
|
||||
|
||||
def self.ransackable_attributes(auth_object = nil)
|
||||
%w[avatar_filename created_at id image_id motto nick real_nick updated_at]
|
||||
|
||||
Reference in New Issue
Block a user