Progress
This commit is contained in:
18
app/controllers/admin/chat_conversations_controller.rb
Normal file
18
app/controllers/admin/chat_conversations_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ChatConversationsController < BaseController
|
||||
before_action :set_account
|
||||
|
||||
PER_PAGE = 20
|
||||
|
||||
def index
|
||||
authorize :account, :index?
|
||||
@chatConversationAccounts = ChatConversationAccount.where(account: @account).page(params[:page]).per(PER_PAGE)
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:account_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
18
app/controllers/admin/chat_messages_controller.rb
Normal file
18
app/controllers/admin/chat_messages_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class ChatMessagesController < BaseController
|
||||
before_action :set_account
|
||||
|
||||
PER_PAGE = 100
|
||||
|
||||
def index
|
||||
authorize :account, :index?
|
||||
@followers = ChatMessage.where(from_account: @account).page(params[:page]).per(PER_PAGE)
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:account_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,6 +5,9 @@ module Admin
|
||||
class DashboardController < BaseController
|
||||
def index
|
||||
@users_count = User.count
|
||||
@statuses_count = Status.count
|
||||
@pro_accounts_count = Account.where(is_pro: true).count
|
||||
@donor_accounts_count = Account.where(is_donor: true).count
|
||||
@registrations_week = Redis.current.get("activity:accounts:local:#{current_week}") || 0
|
||||
@logins_week = Redis.current.pfcount("activity:logins:#{current_week}")
|
||||
@interactions_week = Redis.current.get("activity:interactions:#{current_week}") || 0
|
||||
|
||||
@@ -1,67 +1,75 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class GroupsController < BaseController
|
||||
before_action :set_group, except: [:index]
|
||||
before_action :set_filter_params
|
||||
|
||||
def index
|
||||
authorize :group, :index?
|
||||
@groups = filtered_groups.page(params[:page])
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize @group, :destroy?
|
||||
@group.destroy!
|
||||
log_action :destroy, @group
|
||||
flash[:notice] = I18n.t('admin.groups.destroyed_msg')
|
||||
redirect_to admin_groups_path(page: params[:page], **@filter_params)
|
||||
end
|
||||
|
||||
def enable_featured
|
||||
authorize @group, :update?
|
||||
@group.is_featured = true
|
||||
@group.save!
|
||||
log_action :update, @group
|
||||
flash[:notice] = I18n.t('admin.groups.updated_msg')
|
||||
redirect_to admin_groups_path(page: params[:page], **@filter_params)
|
||||
end
|
||||
|
||||
def disable_featured
|
||||
authorize @group, :update?
|
||||
@group.is_featured = false
|
||||
@group.save!
|
||||
log_action :update, @group
|
||||
flash[:notice] = I18n.t('admin.groups.updated_msg')
|
||||
redirect_to admin_groups_path(page: params[:page], **@filter_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_group
|
||||
@group = Group.find(params[:id])
|
||||
end
|
||||
|
||||
def set_filter_params
|
||||
@filter_params = filter_params.to_hash.symbolize_keys
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:group).permit(:is_featured, :is_nsfw)
|
||||
end
|
||||
|
||||
def filtered_groups
|
||||
query = Group.order('is_featured DESC, member_count DESC')
|
||||
|
||||
if params[:title]
|
||||
query = query.where("LOWER(title) LIKE LOWER(?)", "%#{params[:title]}%")
|
||||
end
|
||||
|
||||
return query
|
||||
end
|
||||
|
||||
def filter_params
|
||||
params.permit(:sort,)
|
||||
end
|
||||
class GroupsController < BaseController
|
||||
before_action :set_group, except: [:index]
|
||||
before_action :set_filter_params
|
||||
|
||||
def index
|
||||
authorize :group, :index?
|
||||
@groups = filtered_groups.page(params[:page])
|
||||
end
|
||||
|
||||
def show
|
||||
authorize :group, :index?
|
||||
end
|
||||
|
||||
def update
|
||||
#
|
||||
end
|
||||
|
||||
def destroy
|
||||
authorize @group, :destroy?
|
||||
@group.destroy!
|
||||
log_action :destroy, @group
|
||||
flash[:notice] = I18n.t('admin.groups.destroyed_msg')
|
||||
redirect_to admin_groups_path(page: params[:page], **@filter_params)
|
||||
end
|
||||
|
||||
def enable_featured
|
||||
authorize @group, :update?
|
||||
@group.is_featured = true
|
||||
@group.save!
|
||||
log_action :update, @group
|
||||
flash[:notice] = I18n.t('admin.groups.updated_msg')
|
||||
redirect_to admin_groups_path(page: params[:page], **@filter_params)
|
||||
end
|
||||
|
||||
def disable_featured
|
||||
authorize @group, :update?
|
||||
@group.is_featured = false
|
||||
@group.save!
|
||||
log_action :update, @group
|
||||
flash[:notice] = I18n.t('admin.groups.updated_msg')
|
||||
redirect_to admin_groups_path(page: params[:page], **@filter_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_group
|
||||
@group = Group.find(params[:id])
|
||||
end
|
||||
|
||||
def set_filter_params
|
||||
@filter_params = filter_params.to_hash.symbolize_keys
|
||||
end
|
||||
|
||||
def resource_params
|
||||
params.require(:group).permit(:is_featured, :is_nsfw)
|
||||
end
|
||||
|
||||
def filtered_groups
|
||||
query = Group.order('is_featured DESC, member_count DESC')
|
||||
|
||||
if params[:title]
|
||||
query = query.where("LOWER(title) LIKE LOWER(?)", "%#{params[:title]}%")
|
||||
end
|
||||
return query
|
||||
end
|
||||
|
||||
def filter_params
|
||||
params.permit(:sort,)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
18
app/controllers/admin/joined_groups_controller.rb
Normal file
18
app/controllers/admin/joined_groups_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Admin
|
||||
class JoinedGroupsController < BaseController
|
||||
before_action :set_account
|
||||
|
||||
PER_PAGE = 25
|
||||
|
||||
def index
|
||||
authorize :account, :index?
|
||||
@groups = @account.groups.page(params[:page]).per(PER_PAGE)
|
||||
end
|
||||
|
||||
def set_account
|
||||
@account = Account.find(params[:account_id])
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user