* First draft - all the big changes * Changing some more references to 'internal' * Relocate internal request tests to admin * Relocate internal system tests to admin * Fix trailing space * Test fix * Move queries from internal to admin * Docs updates * Rename internal stimuls controllers to admin (plus docs) * Rename admin layout * Fix routing after rebase * Fixes for latest added admin interfaces * Serviceworker ignore paths
47 lines
1.4 KiB
Ruby
47 lines
1.4 KiB
Ruby
module Admin
|
|
class ChatChannelsController < Admin::ApplicationController
|
|
layout "admin"
|
|
|
|
def index
|
|
@q = ChatChannel.where(channel_type: "invite_only").includes(:users).ransack(params[:q])
|
|
@group_chat_channels = @q.result.page(params[:page]).per(50)
|
|
end
|
|
|
|
def create
|
|
ChatChannels::CreateWithUsers.call(
|
|
users: users_by_param,
|
|
channel_type: "invite_only",
|
|
contrived_name: chat_channel_params[:channel_name],
|
|
membership_role: "mod",
|
|
)
|
|
redirect_back(fallback_location: "/admin/chat_channels")
|
|
end
|
|
|
|
def update
|
|
@chat_channel = ChatChannel.find(params[:id])
|
|
@chat_channel.invite_users(users: users_by_param)
|
|
redirect_back(fallback_location: "/admin/chat_channels")
|
|
end
|
|
|
|
def remove_user
|
|
@chat_channel = ChatChannel.find(params[:id])
|
|
@chat_channel.remove_user(user_by_param)
|
|
redirect_back(fallback_location: "/admin/chat_channels")
|
|
end
|
|
|
|
private
|
|
|
|
def users_by_param
|
|
User.where(username: chat_channel_params[:usernames_string].downcase.delete(" ").split(","))
|
|
end
|
|
|
|
def user_by_param
|
|
User.find_by(username: chat_channel_params[:username_string])
|
|
end
|
|
|
|
def chat_channel_params
|
|
allowed_params = %i[usernames_string channel_name username_string]
|
|
params.require(:chat_channel).permit(allowed_params)
|
|
end
|
|
end
|
|
end
|