Merge branch 'dev_forum' of http://git.trustie.net/jasder/forgeplus into dev_forum

This commit is contained in:
Jasder 2020-10-14 15:54:46 +08:00
commit 4cd459ce58
132 changed files with 1523 additions and 1362 deletions

View File

@ -14,7 +14,7 @@ gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'
gem 'groupdate', '~> 4.1.0'
gem 'chartkick'
gem 'grape', '~> 0.9.0'
# gem 'grape', '~> 0.9.0'
gem 'grape-entity', '~> 0.7.1'
gem 'kaminari', '~> 1.1', '>= 1.1.1'

View File

@ -70,10 +70,6 @@ GEM
autoprefixer-rails (9.7.4)
execjs
awesome_print (1.8.0)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
axlsx (3.0.0.pre)
htmlentities (~> 4.3, >= 4.3.4)
mimemagic (~> 0.3)
@ -109,15 +105,11 @@ GEM
archive-zip (~> 0.10)
nokogiri (~> 1.8)
chunky_png (1.3.11)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
concurrent-ruby (1.1.6)
connection_pool (2.2.2)
crass (1.0.6)
deep_cloneable (3.0.0)
activerecord (>= 3.1.0, < 7)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.3)
diffy (3.3.0)
e2mmap (0.1.0)
@ -131,7 +123,6 @@ GEM
multi_json
enumerize (2.3.1)
activesupport (>= 3.2)
equalizer (0.0.11)
erubi (1.9.0)
execjs (2.7.0)
faraday (0.15.4)
@ -141,16 +132,6 @@ GEM
sass (>= 3.2)
globalid (0.4.2)
activesupport (>= 4.2.0)
grape (0.9.0)
activesupport
builder
hashie (>= 2.1.0)
multi_json (>= 1.3.2)
multi_xml (>= 0.5.2)
rack (>= 1.3.0)
rack-accept
rack-mount
virtus (>= 1.0.0)
grape-entity (0.7.1)
activesupport (>= 4.0)
multi_json (>= 1.3.2)
@ -164,7 +145,6 @@ GEM
multi_xml (>= 0.5.2)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
io-like (0.3.1)
jaro_winkler (1.5.4)
jbuilder (2.10.0)
@ -244,14 +224,10 @@ GEM
public_suffix (4.0.3)
puma (3.12.2)
rack (2.0.9)
rack-accept (0.4.5)
rack (>= 0.4)
rack-cors (1.1.1)
rack (>= 2.0.0)
rack-mini-profiler (2.0.1)
rack (>= 1.2.0)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-protection (2.0.8.1)
rack
rack-test (1.1.0)
@ -441,11 +417,6 @@ GEM
uglifier (4.2.0)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.6.1)
virtus (1.0.5)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
web-console (3.7.0)
actionview (>= 5.0)
activemodel (>= 5.0)
@ -485,7 +456,6 @@ DEPENDENCIES
faraday (~> 0.15.4)
font-awesome-sass (= 4.7.0)
gitlab!
grape (~> 0.9.0)
grape-entity (~> 0.7.1)
groupdate (~> 4.1.0)
harmonious_dictionary (~> 0.0.1)

View File

@ -1,107 +0,0 @@
#coding=utf-8
# status值
# 0成功-1500错误403无权限404页面不存在
module Mobile
require_relative 'middleware/error_handler'
require_relative 'apis/auth'
require_relative 'apis/memos'
require_relative 'apis/forum_sections'
require_relative 'apis/my_memos'
# require_relative 'apis/my_forums'
class API < Grape::API
version 'v1', using: :path
format :json
content_type :json, "application/json;charset=UTF-8"
# use ActionDispatch::Session::CookieStore
use Middleware::ErrorHandler
helpers do
def logger
API.logger
end
def authenticate!
begin
# current_user = User.find(2) if current_user.blank?
if params[:debug] == 'admin'
logger.info("Login as admin user, for test only")
User.current = User.find 1
elsif params[:debug] == 'normal'
logger.info("Login as normal user, for test only")
User.current = User.where(admin:false).first
end
rescue Exception => e
return {:status => -2, :message => 'Unauthorized. 用户认证失败.'}
end
end
# def manager_of_game
# myshixun_id = Game.where(:identifier => params[:identifier]).pluck(:myshixun_id).first
# myshixun = Myshixun.find(myshixun_id)
# unless (current_user.admin? || myshixun.user_id == current_user.id)
# return {}
# end
# end
#
def session
env['rack.session']
end
def current_user
openid = session[:wechat_openid]
if openid
uw = UserWechat.find_by_openid(openid)
return uw.user if uw
end
token = ApiKey.where(access_token: params[:token]).first
if token && !token.expired?
return User.find(token.user_id)
end
# 本地调试找不到用户信息
if Rails.env.development? && session[:user_id].blank?
# session[:user_id] = 12 #116
end
if session[:user_id].blank? || params[:debug].present?
if params[:debug] == 'admin'
Rails.logger.info("######________session_user_id________#############{session[:user_id]}")
logger.info("Login as admin user, for test only")
User.current = User.find 1
session[:user_id] = 1
elsif params[:debug] == 'normal'
logger.info("Login as normal user, for test only")
User.current = User.find 49
session[:user_id] = 49
else
session[:user_id] = 2
end
end
Rails.logger.info("####### session user_id is #{session[:user_id]}")
if session[:user_id]
user = (User.find(session[:user_id]) rescue nil)
return user if user
end
nil
end
def current_user_ip
env['REMOTE_ADDR']
end
end
mount Apis::Auth
mount Apis::Memos
mount Apis::ForumSections
mount Apis::MyMemos
# add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?
end
end

View File

@ -1,60 +0,0 @@
#coding=utf-8
module Mobile
module Entities
class Auth < Grape::Entity
expose :token
expose :user, using: User
end
end
module Apis
class Auth < Grape::API
resource :auth do
desc "用户登录"
params do
requires :login, type: String, desc: 'Username or email'
requires :password, type: String, desc: 'Password'
end
post do
user,last_logon = ::User.try_to_login(params[:login], params[:password])
if user
::ApiKey.delete_all(user_id: user.id)
key = ::ApiKey.create!(user_id: user.id)
api_user = ::UsersService.new.show_user({id:user.id})
present :data, {token: key.access_token, user: api_user}, using: Entities::Auth
present :status, 0
else
present :message, "无效的用户名或密码"
present :status,1
end
end
desc "用户登出"
params do
requires :token, type: String
end
delete do
authenticate!
::ApiKey.delete_all(user_id: current_user.id)
{status: 0}
end
desc "忘记密码"
params do
requires :mail,type: String
end
post 'lost_password' do
us = UsersService.new
message = us.lost_password params
present :message, message
present :status, 0
end
end
end
end
end

View File

@ -1,199 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class ForumSections < Grape::API
before {authenticate!}
content_type :json, 'application/json;charset=UTF-8'
resources :forum_sections do
desc "获取板块的筛选分类"
get "select_sections" do
ForumSectionsService.new.select_sections
end
desc "获取板块的全部分类"
get do
ForumSectionsService.new.index params
end
desc "申请版主"
params do
requires :id, type: Integer, desc: "版块的id"
end
route_param :id do
post "user_apply" do
ForumSectionsService.new.user_apply params, current_user, current_user_ip
end
end
desc "发布公告"
params do
requires :id, type: Integer, desc: "版块的id"
requires :content, type: String, desc: "公告的内容"
end
route_param :id do
post "edit_notice" do
ForumSectionsService.new.edit_notice params
end
end
desc "版块的头部信息"
params do
requires :id, type: Integer, desc: "版块的id"
end
route_param :id do
get "forum_section_header" do
ForumSectionsService.new.forum_section_header params, current_user
end
end
desc "新增二级版块"
params do
requires :id, type: Integer, desc: "版块的id"
requires :title, type: String, desc: "版块的名称"
end
route_param :id do
post 'create' do
ForumSectionsService.new.create params, current_user
end
end
desc "重命名"
params do
requires :id, type: Integer, desc: "版块的id"
requires :children_section_id, type: Integer, desc: "二级版块的id"
requires :title, type: String, desc: "版块的名称"
end
route_param :id do
post "rename" do
ForumSectionsService.new.rename params, current_user
end
end
desc "删除二级版块"
params do
requires :id, type: Integer, desc: "版块的id"
requires :children_section_id, type: Integer, desc: "二级版块的id"
end
route_param :id do
post "destroy" do
ForumSectionsService.new.destroy params, current_user
end
end
desc "排序"
params do
requires :id, type: Integer, desc: "版块的id"
requires :order_type, type: String, desc: "排序按desc和asc排序"
end
route_param :id do
get "order_forums" do
ForumSectionsService.new.order_forums params, current_user
end
end
desc "搜索用户"
params do
requires :id, type: Integer, desc: "版块的id"
requires :page, type: Integer, desc: "初次第一页为0"
# requires :user_name, type: String, desc: "输入的关键字"
end
route_param :id do
get "search_users" do
ForumSectionsService.new.search_users params, current_user
end
end
desc "二级版块添加管理员"
params do
requires :id, type: Integer, desc: "版块的id"
requires :user_ids, type: Array, desc: "输入的关键字"
requires :children_section_id, type: Integer, desc: "二级版块的id"
end
route_param :id do
post "add_users" do
ForumSectionsService.new.add_users params, current_user
end
end
desc "管理员页面的版块管理"
params do
requires :id, type: Integer, desc: "版块的id"
end
route_param :id do
get "managements" do
ForumSectionsService.new.managements params, current_user
end
end
desc "管理员页面的申请接口"
params do
requires :id, type: Integer, desc: "版块的id"
end
route_param :id do
get "applied_forums" do
ForumSectionsService.new.applied_forums params, current_user
end
end
desc "管理员页面的申请处理"
params do
requires :id, type: Integer, desc: "版块的id"
requires :apply_id, type: Integer, desc: "申请的id"
requires :deal_type, type: Integer, desc: "处理的方式1为同意2为拒绝"
end
route_param :id do
post "deal_applies/:apply_id" do
ForumSectionsService.new.deal_applies params, current_user
end
end
desc "管理员页面的删除二级版主"
params do
requires :id, type: Integer, desc: "版块的id"
requires :moderator_id, type: Integer, desc: "版主的id"
end
route_param :id do
post "destroy_moderator/:moderator_id" do
ForumSectionsService.new.destroy_moderator params, current_user
end
end
desc "待审核的帖子"
params do
requires :id, type: Integer, desc: "版块的待审核id"
requires :page, type: String, desc: "初次第一页为0"
end
route_param :id do
get "unchecked_memos" do
ForumSectionsService.new.unchecked_memos params, current_user
end
end
desc "待审查的回复"
params do
requires :id, type: Integer, desc: "版块的待审核id"
requires :page, type: String, desc: "初次第一页为0"
end
route_param :id do
get "unchecked_replies" do
ForumSectionsService.new.unchecked_replies params, current_user
end
end
desc "已发布的帖子"
params do
requires :id, type: Integer, desc: "版块的待审核id"
requires :page, type: String, desc: "初次第一页为0"
end
route_param :id do
get "checked_memos" do
ForumSectionsService.new.checked_memos params, current_user
end
end
end
end
end
end

View File

@ -1,241 +0,0 @@
# encoding=utf-8
module Mobile
module Apis
class Memos < Grape::API
before {authenticate!}
content_type :json, 'application/json;charset=UTF-8'
resources :memos do
desc "帖子详情推荐"
params do
requires :id, type: Integer, desc: "帖子详情推荐"
end
get ':id/related_memos' do
MemosService.new.related_memos params
end
desc "新建帖子"
get 'new' do
MemosService.new.new params, current_user, session
end
desc "新建保存帖子"
params do
requires :memo, type: Hash do
requires :subject, type: String, desc: "帖子名"
requires :content, type: String, desc: "帖子内容"
end
requires :forum_id, type: Integer, desc: "帖子类型"
end
post 'create' do
MemosService.new.create params, current_user
end
desc "帖子详情"
params do
requires :id, type: Integer, desc: "帖子ID"
end
get ':id' do
MemosService.new.show params, current_user
end
desc "收藏帖子"
params do
requires :id, type: Integer, desc: "帖子ID"
requires :is_watch, type: Integer, desc:"顶置: 1 关注,0 取消关注 "
end
route_param :id do
post 'watch_memo' do
MemosService.new.watch_memo params, current_user
end
end
desc "讨论区列表"
get do
MemosService.new.index params, current_user
end
desc "编辑帖子"
params do
requires :id, type: Integer, desc: "编辑帖子的ID"
end
route_param :id do
get 'edit' do
MemosService.new.edit params, current_user
end
end
desc "更新帖子"
params do
requires :id, type: Integer, desc: "帖子ID"
end
route_param :id do
post 'update' do
MemosService.new.update params, current_user
end
end
# TODO 本来可以跟实训评论一起用,但说不要动实训,所以另起一个方法
desc "隐藏帖子"
params do
requires :id, type: Integer, desc: "帖子ID"
end
route_param :id do
get :hidden do
Memo.find(params[:id]).update_attribute(:hidden, true)
{status: 0, message: "隐藏成功"}
end
end
desc "帖子设置审核通过/不通过"
params do
requires :id, type: Integer, desc: "帖子ID"
end
route_param :id do
post :memo_hidden do
MemosService.new.memo_hidden params, current_user
end
end
desc "回复帖子"
params do
requires :parent_id, type: Integer, desc: "给那个帖子的回复id"
requires :content, type: String, desc: "回复内容"
end
route_param :root_id do
post :reply do
MemosService.new.reply params, current_user
end
end
desc "隐藏回复帖子"
params do
requires :id, type: Integer, desc: "要隐藏的对象id。如memo.id"
requires :hidden, type: String
end
route_param :id do
post 'hidden' do
MemosService.new.hidden(params, current_user)
return {:status => 1, :message => "success"}
end
end
desc "删除帖子/评论"
params do
requires :id, type: Integer, desc: "帖子ID"
end
route_param :id do
post "destroy" do
MemosService.new.destroy params, current_user
end
end
# delete ":id" do
# Memo.find(params[:id]).destroy
# end
desc "设置贴子顶置/取消顶置"
params do
requires :id, type: Integer, desc: "帖子ID"
requires :sticky, type: Integer, desc:"顶置: 1 置顶,0 取消置顶 "
end
route_param :id do
get "set-top-or-down" do
MemosService.new.set_top_or_down params, current_user
end
end
desc "设置贴子加精/取消加精推荐"
params do
requires :id, type: Integer, desc: "帖子ID"
requires :is_fine, type: Integer, desc:"加精: 1 加精,0 取消加精 "
end
route_param :id do
post "is_fine" do
MemosService.new.is_fine params, current_user
end
end
desc "用户禁言或取消禁言"
params do
requires :id, type: Integer, desc: "帖子ID"
requires :user_id, type: Integer, desc:"被禁言用户的id"
requires :banned, type: Integer, desc:"顶置: 1 禁言,0 取消禁言 "
end
route_param :id do
post "banned_user" do
MemosService.new.banned_user params, current_user
end
end
desc "帖子回复更多"
params do
requires :id, type: Integer, desc: "帖子ID"
requires :page, type: String, desc: "初次第一页为0"
end
route_param :id do
get "more_reply" do
MemosService.new.more_reply params, current_user
end
end
desc "版块的全部帖子"
params do
requires :id, type: Integer, desc: "版块的ID"
requires :page, type: String, desc: "初次第一页为0"
# requires :forum_type, type: String, desc: "列表页的分类选择"
end
get "forum_memos/:id" do
MemosService.new.forum_memos params, current_user
end
desc "版块的头部信息"
params do
requires :id, type: Integer, desc: "版块的ID"
end
get "forum_memos_head/:id" do
MemosService.new.forum_memos_head params, current_user
end
desc "版块的右侧信息"
params do
requires :id, type: Integer, desc: "版块的ID"
end
get "forum_memos_right/:id" do
MemosService.new.forum_memos_right params, current_user
end
# route_param :id do
#
# end
desc "版块的关注"
params do
requires :id, type: Integer, desc: "版块的ID"
requires :is_watch, type: Integer, desc:"顶置: 1 关注,0 取消关注 "
end
post "forum_memos/:id/is_watch" do
MemosService.new.is_watch params, current_user
end
desc "申请删除帖子"
params do
requires :id, type: Integer, desc: "帖子的id"
end
post ":id/confirm_delete" do
MemosService.new.confirm_delete params, current_user
end
# desc "版块的首页"
# params do
# requires :page, type: String, desc: "初次第一页为0"
# end
# get "index" do
# MemosService.new.index params, current_user
# end
end
end
end
end

View File

@ -1,32 +0,0 @@
#coding=utf-8
module Mobile
module Apis
class MyMemos < Grape::API
before {authenticate!}
content_type :json, 'application/json;charset=UTF-8'
resources :my_memos do
desc "我的话题"
get ":login/memos" do
MyMemosService.new.index params, current_user
end
desc "我感兴趣的话题"
get ":login/my_interested" do
MyMemosService.new.my_interested params, current_user
end
desc "我的回帖"
get ":login/replies_memos" do
MyMemosService.new.replies_memos params,current_user
end
desc "右侧推荐"
get "recommend_memos" do
MyMemosService.new.recommend_memos current_user
end
end
end
end
end

View File

@ -1,13 +0,0 @@
#coding=utf-8
#
module Mobile
module Exceptions
class AuthException < StandardError
attr_reader :err_code, :msg
def initialize(code, msg)
@err_code = code
@msg = msg
end
end
end
end

View File

@ -1,26 +0,0 @@
#coding=utf-8
module Mobile
module Middleware
class ErrorHandler < Grape::Middleware::Base
def call!(env)
@env = env
begin
@app.call(@env)
rescue =>e
code = -1
message = {status: code, message: e.message }.to_json
Rails.logger.error e.inspect
Rails.logger.error e.backtrace.join("\n")
status = 200
headers = { 'Content-Type' => content_type }
Rack::Response.new([message], status, headers).finish
# throw :error, :message => e.message || options[:default_message], :status => 500
end
end
end
end
end

View File

@ -0,0 +1,4 @@
$(document).on('turbolinks:load', function() {
var $addSectionModal = $('.admin-import-user-modal');
});

View File

@ -0,0 +1,7 @@
// .admins-banned-users-index-page {
// .width240 {
// width: 240px;
// }
// .mr15{margin-right: 15px;}
// .mt2{margin-top: 2px;}
// }

View File

@ -136,5 +136,36 @@
background: #fff;
}
.mt-10{margin-top: 10px;}
.nav_blueline_status{
list-style-type: none;
padding: 0;
margin: 0;
li {
padding: 0px 15px;
border-radius: 15px;
border: 1px solid #CDCDCD;
height: 30px;
line-height: 30px;
float: left;
margin-right: 30px;
a {
color: #CDCDCD!important;
display: block;
}
};
li.active {
border: 1px solid #4CACFF;
a {
color: #4CACFF!important;
}
}
}
.fr{float: right;}
.width240 {
width: 240px;
}
.mr15{margin-right: 15px;}
.mt2{margin-top: 2px;}
}

View File

@ -0,0 +1,11 @@
.admins-forum-moderators-index-page {
.df{
display: flex;
}
.flex1 {
flex: 1;
}
.text-center {
text-align: center;
}
}

View File

@ -0,0 +1,128 @@
.admins-forum-sections-index-page {
.color-grey{color: #888;}
.grid-item-top {
display: grid;
grid-template-columns: max-content 1fr;
align-self: start;
}
.mt20{margin-top: 20px;}
.none{display: none;}
.color-red{color: red!important;}
.upload-image-100 {
height: 100px;
width: 100px;
border-radius: 8px;
text-align: center;
/* line-height: 100px; */
background: #f5f5f5;
color: #999;
position: relative;
}
.pointer {
cursor: pointer;
}
.avatar100{
height: 100px;
width: 100px;
border-radius: 8px;
}
.upload-image-100:hover .admin-show-again-upload{display: block;}
.admin-show-again-upload {
bottom: 0;
width: 100px;
height: 100%;
line-height: 100px;
/* top: 0; */
background: rgba(0,0,0,0.6);
color: #fff;
position: absolute;
border-radius: 8px;
}
.menu_operate {
position: relative;
cursor: pointer;
.operateList {
position: absolute;
right: -110px;
top: 9px;
background: #fff;
width: 100px;
color: #999;
box-shadow: 0px 0px 9px rgba(0,0,0,0.2);
z-index: 100;
display: none;
a {
display: block;
height: 30px;
line-height: 30px;
padding: 0px 10px;
}
}
.operateList.active {
display: block !important;
}
}
.color-grey-6 {
color: #666!important;
}
.set_l_submenu {
padding-left: 50px;
display: none;
width: 180px;
list-style-type: none;
li{
padding: 4px 0;
}
}
.set_l_submenu.active {
display: block;
}
.set_l_premenu {
position: relative;
display: flex;
height: 30px;
line-height: 30px;
cursor: pointer;
}
.df{
display: flex;
}
.flex1 {
flex: 1;
}
.text-center {
text-align: center;
}
.grid-item-left {
display: grid;
grid-template-columns:1fr max-content;
align-self: start;
}
.ml20{margin-left: 20px;}
.forum-moderators-items {
padding: 10px 30px;
max-height: 175px;
overflow-y: auto;
background: #F4FAFF;
margin-top: 20px;
}
.mr4 {margin-right: 4px;}
.blue-user-btn {
margin: 0 5px;
padding: 2px 8px;
background: #F4F8FA!important;
color: #fff!important;
border: 1px solid #4CACFF;
border-radius: 4px;
white-space: nowrap;
}
.mr5 {
margin-right: 5px;
}
.moderator-list-content{
display: inline-block;
margin: 5px 0;
}
}

View File

@ -0,0 +1,5 @@
.admins-memos-index-page {
.users-list-container {
text-align: center;
}
}

View File

@ -0,0 +1,31 @@
class Admins::ApplyDestroyController < Admins::BaseController
def index
memos = Memo.where(destroy_status: 1).includes(:author).order("created_at desc")
@memos = paginate memos
respond_to do |format|
format.html
format.js
end
end
def confirm_apply_destroy
memo = Memo.find(params[:id])
apply_status = params[:confirm]
if apply_status == "delete"
memo.destroy
extra = "d_2"
Tiding.create!(:user_id => memo.author_id, :trigger_user_id => 0,
container_id: memo.id, container_type: 'Memo',
:viewed => 0, :tiding_type => "System", :extra => "d_2")
else
memo.common!
memo.save
extra = "d_3"
Tiding.create!(:user_id => memo.author_id, :trigger_user_id => 0,
container_id: memo.id, container_type: 'Memo',
:viewed => 0, :tiding_type => "System", :extra => "d_3")
end
@status = 1
@message = "操作成功"
end
end

View File

@ -22,13 +22,14 @@ class Admins::BannedUsersController < Admins::BaseController
end
banned_users = banned_users.order("updated_at desc")
page = (params[:page] || 1).to_i
per_page = 15
@banned_users_count = banned_users.size
@banned_users_pages = Paginator.new @banned_users_count, per_page, page
@banned_users = banned_users.limit(@banned_users_pages.per_page).offset(@banned_users_pages.offset).to_a
@banned_users = paginate banned_users
# page = (params[:page] || 1).to_i
# per_page = 15
# @banned_users_pages = Paginator.new @banned_users_count, per_page, page
# @banned_users = banned_users.limit(@banned_users_pages.per_page).offset(@banned_users_pages.offset).to_a
end

View File

@ -43,4 +43,30 @@ class Admins::BaseController < ApplicationController
def setup_laboratory
Laboratory.current = Laboratory.find_by_subdomain(request.subdomain) || Laboratory.find(1)
end
def up_and_down(opr,current_target,position,model_name)
modal_target = model_name.capitalize.classify.constantize
if model_name == "forum_section" #只有root才能移动
modal_target = modal_target.roots
end
if opr.to_s == "up"
last_target = modal_target.where("position > ?",position)&.first
if last_target.present?
current_target.update_attribute(:position, last_target.position)
last_target.update_attribute(:position, position) # 重新获取当前问题的位置
return 0
else
return -1
end
elsif opr.to_s == "down"
next_target = modal_target.where("position < ?",position)&.last
if next_target.present?
current_target.update_attribute(:position, next_target.position)
next_target.update_attribute(:position, position)
return 0
else
return -1
end
end
end
end

View File

@ -22,13 +22,14 @@ class Admins::ForumAppliesController < Admins::BaseController
forum_applies = forum_applies.joins(:user).where("LOWER(users.login) LIKE ? or LOWER(concat(users.lastname, users.firstname)) LIKE ?", "%#{@search_name}%", "%#{@search_name}%")
end
forum_applies = forum_applies.order("apply_forums.updated_at desc")
page = (params[:page] || 1).to_i
per_page = 15
@forum_applies_count = forum_applies.size
@forum_applies_pages = Paginator.new @forum_applies_count, per_page, page
@forum_applies = forum_applies.limit(@forum_applies_pages.per_page).offset(@forum_applies_pages.offset).to_a
@forum_applies = paginate forum_applies
# page = (params[:page] || 1).to_i
# per_page = 15
# @forum_applies_pages = Paginator.new @forum_applies_count, per_page, page
# @forum_applies = forum_applies.limit(@forum_applies_pages.per_page).offset(@forum_applies_pages.offset).to_a
end

View File

@ -43,7 +43,7 @@ class Admins::ForumModeratorsController < Admins::BaseController
users = User.where("( LOWER(login) LIKE ? or LOWER(concat(lastname, firstname)) LIKE ? or LOWER(mail) LIKE ? )",
"%#{user_name}%","%#{user_name}%","%#{user_name}%")
users.each do |u|
check_html = "<input id='check_user_#{u.login}' class='magic-checkbox' type='checkbox' name='member_ids[]' value=""#{u.id}"" checked='false'><label for='check_user_#{u.login}'>#{u.try(:show_name)}</label>"
check_html = "<div class='search-user-check'><input id='check_user_#{u.login}' class='magic-checkbox mr4' type='checkbox' name='member_ids[]' value=""#{u.id}"" checked='false'><label for='check_user_#{u.login}'>#{u.try(:show_real_name)}</label></div>"
return_html << check_html
end
end

View File

@ -9,41 +9,50 @@ class Admins::ForumSectionsController < Admins::BaseController
forum_sections = ForumSection.roots.includes(:forum_moderators).order("position desc")
@max_position = forum_sections&.maximum(:position).to_i
@min_position = forum_sections&.minimum(:position).to_i
@forum_sections_count = forum_sections.count
page = (params[:page] || 1).to_i
per_page = 15
@forum_sections_pages = Paginator.new @forum_sections_count, per_page, page
@forum_sections = forum_sections.limit(@forum_sections_pages.per_page).offset(@forum_sections_pages.offset).to_a
@forum_sections_count = forum_sections.size
# page = (params[:page] || 1).to_i
# per_page = 15
# @forum_sections_pages = Paginator.new @forum_sections_count, per_page, page
# @forum_sections = forum_sections.limit(@forum_sections_pages.per_page).offset(@forum_sections_pages.offset).to_a
@forum_sections = paginate forum_sections
respond_to do |format|
format.html
format.js
end
end
def new
@parent_id = params[:parent_id]
@forum_section = ForumSection.new
respond_to do |format|
format.js
end
end
def create
attachment_id = params[:attachments]&.first
positions = ForumSection.pluck(:position).select { |a| a.is_a? Integer }
positions = positions.max.to_i
if params[:parent_id].present?
@parent_forum = ForumSection.find_by_id(params[:parent_id])
if params[:forum_section][:parent_id].present?
@parent_forum = ForumSection.find_by_id(params[:forum_section][:parent_id])
end
if params[:title].blank?
if params[:forum_section][:title].blank?
forum_status = 0
forum_msg = "不能为空"
elsif params[:title].strip.length > 20
forum_msg = "标题不能为空"
elsif params[:forum_section][:title].strip.length > 20
forum_status = 0
forum_msg = "不能超过最大限制20个字符"
elsif ForumSection.exists?(title: params[:title].strip)
elsif ForumSection.exists?(title: params[:forum_section][:title].strip)
forum_status = 0
forum_msg = "不能重名"
else
forum_section_params = {
user_id: current_user.id,
title: params[:title].strip,
title: params[:forum_section][:title].strip,
position: positions + 1,
parent_id: params[:parent_id],
parent_id: params[:forum_section][:parent_id],
is_recommend: false,
description: params[:description].to_s.truncate(200)
description: params[:forum_section][:description].to_s.truncate(200)
}
@forum_section = ForumSection.new(forum_section_params)
if @forum_section.save
@ -71,18 +80,18 @@ class Admins::ForumSectionsController < Admins::BaseController
def update
attachment_id = params[:attachments]&.first
if params[:title].blank?
if params[:forum_section][:title].blank?
forum_status = 0
forum_msg = "不能为空"
elsif params[:title].strip.length > 20
forum_msg = "名称不能为空"
elsif params[:forum_section][:title].strip.length > 20
forum_status = 0
forum_msg = "不能超过最大限制20个字符"
elsif params[:title].strip != @forum_section.title && ForumSection.exists?(title: params[:title].strip)
elsif params[:forum_section][:title].strip != @forum_section.title && ForumSection.exists?(title: params[:forum_section][:title].strip)
forum_status = 0
forum_msg = "不能重名"
else
if @forum_section.update_attributes(title: params[:title].strip, description: params[:description].to_s.truncate(200))
if @forum_section.update_attributes(title: params[:forum_section][:title].strip, description: params[:forum_section][:description].to_s.truncate(200))
unless attachment_id.blank? || @forum_section.attachment_id.to_i == attachment_id.to_i
Attachment.where(id: @forum_section.attachment_id.to_i).destroy_all if @forum_section.attachment_id.present?
@ -92,18 +101,6 @@ class Admins::ForumSectionsController < Admins::BaseController
@forum_section.attachment_id = attachment_id
@forum_section.save
end
# if attachment_id.present?
# unless @forum_section.attachment_id.to_i == attachment_id.to_i
# if @forum_section.attachment_id.to_i != attachment_id.to_i
# Attachment.where(id: @forum_section.attachment_id.to_i).destroy_all
# end
# attachment = Attachment.find(attachment_id)
# attachment.container = @forum_section
# attachment.save
# @forum_section.attachment_id = attachment_id
# @forum_section.save
# end
# end
forum_status = 1
forum_msg = "更新成功"
else
@ -142,6 +139,7 @@ class Admins::ForumSectionsController < Admins::BaseController
else
@c_msg = "移动失败"
end
redirect_to admins_forum_sections_path
end
private
@ -150,4 +148,6 @@ class Admins::ForumSectionsController < Admins::BaseController
@forum_section = ForumSection.find_by_id(params[:id])
end
end

View File

@ -0,0 +1,16 @@
class Admins::MemoReplyListsController < Admins::BaseController
def index
@memo_hidden_type = params[:hidden] || ""
memos = Memo.where("parent_id is not null").includes(:author, :parent)
if @memo_hidden_type.present?
memos = memos.where(hidden: @memo_hidden_type.to_s == "hidden")
end
memos = memos.order("created_at desc")
@memos = paginate memos
respond_to do |format|
format.html
format.js
end
end
end

View File

@ -2,8 +2,6 @@ class Admins::MemosController < Admins::BaseController
# include Admins::BaseHelper
# 帖子
def index
@menu_type = 8
@sub_type = 3
@memo_hidden_type = params[:hidden] || ""
memos = Memo.where(parent_id: nil).includes(:author)
@ -18,38 +16,6 @@ class Admins::MemosController < Admins::BaseController
end
end
def apply_destroy_memos
@menu_type = 8
@sub_type = 2
memos = Memo.where(destroy_status: 1).includes(:author).order("created_at desc")
@memos = paginate memos
respond_to do |format|
format.html
format.js
end
end
def confirm_apply_destroy
memo = Memo.find(params[:id])
apply_status = params[:confirm]
if apply_status == "delete"
memo.destroy
extra = "d_2"
Tiding.create!(:user_id => memo.author_id, :trigger_user_id => 0,
container_id: memo.id, container_type: 'Memo',
:viewed => 0, :tiding_type => "System", :extra => "d_2")
else
memo.common!
memo.save
extra = "d_3"
Tiding.create!(:user_id => memo.author_id, :trigger_user_id => 0,
container_id: memo.id, container_type: 'Memo',
:viewed => 0, :tiding_type => "System", :extra => "d_3")
end
@status = 1
@message = "操作成功"
end
def memo_homepage_show
memo = Memo.find params[:id]
memo.update_column(:homepage_show, params[:checked]) unless memo.hidden?
@ -89,25 +55,25 @@ class Admins::MemosController < Admins::BaseController
def delete_memo
memo = Memo.find params[:id]
memo.destroy if memo.hidden?
redirect_to memo.parent_id.present? ? memo_reply_list_managements_path : messages_list_managements_path
redirect_to memo.parent_id.present? ? admins_memo_reply_lists_path : admins_memos_path
end
def memo_reply_list
@menu_type = 8
@sub_type = 4
@memo_hidden_type = params[:hidden] || ""
Rails.logger.info("======================sub_type==================#@sub_type")
# def memo_reply_list
# @menu_type = 8
# @sub_type = 4
# @memo_hidden_type = params[:hidden] || ""
# Rails.logger.info("======================sub_type==================#@sub_type")
memos = Memo.where("parent_id is not null").includes(:author, :parent)
if @memo_hidden_type.present?
memos = memos.where(hidden: @memo_hidden_type.to_s == "hidden")
end
memos = memos.order("created_at desc")
@memos = paginate memos
respond_to do |format|
format.html
format.js
end
end
# memos = Memo.where("parent_id is not null").includes(:author, :parent)
# if @memo_hidden_type.present?
# memos = memos.where(hidden: @memo_hidden_type.to_s == "hidden")
# end
# memos = memos.order("created_at desc")
# @memos = paginate memos
# respond_to do |format|
# format.html
# format.js
# end
# end
end

View File

@ -92,6 +92,44 @@ class AttachmentsController < ApplicationController
end
end
#后台上传图片
def upload_images
upload_file = params["file"] || params["#{params[:file_param_name]}"]# 这里的file_param_name是为了方便其他插件名称
raise "未上传文件" unless upload_file
folder = edu_setting('attachment_folder')
raise "存储目录未定义" unless folder.present?
month_folder = current_month_folder
save_path = File.join(folder, month_folder)
ext = SecureRandom.urlsafe_base64
local_path, digest = file_save_to_local(save_path, upload_file.tempfile, ext)
content_type = upload_file.content_type.presence || 'application/octet-stream'
disk_filename = local_path[save_path.size + 1, local_path.size]
@attachment = Attachment.where(disk_filename: disk_filename,author_id: current_user.id).first
if @attachment.blank?
@attachment = Attachment.new
@attachment.filename = upload_file.original_filename
@attachment.disk_filename = disk_filename
@attachment.filesize = upload_file.tempfile.size
@attachment.content_type = content_type
@attachment.digest = digest
@attachment.author_id = current_user.id
@attachment.disk_directory = month_folder
@attachment.save!
@status = 1
else
@status = -1
end
respond_to do |format|
format.js
end
end
def destroy
begin
@file_path = absolute_path(local_path(@file))

View File

@ -0,0 +1,101 @@
class ForumSectionsController < ApplicationController
def index
targets = ForumSectionsService.new.index params
render json: targets
end
def select_sections
targets = ForumSectionsService.new.select_sections
render json: targets
end
def user_apply
targets = ForumSectionsService.new.user_apply params, current_user, current_user_ip
render json: targets
end
def edit_notice
targets = ForumSectionsService.new.edit_notice params
render json: targets
end
def forum_section_header
targets = ForumSectionsService.new.forum_section_header params, current_user
render json: targets
end
def create
targets = ForumSectionsService.new.create params, current_user
render json: targets
end
def rename
targets = ForumSectionsService.new.rename params, current_user
render json: targets
end
def destroy
targets = ForumSectionsService.new.destroy params, current_user
render json: targets
end
def order_forums
targets = ForumSectionsService.new.order_forums params, current_user
render json: targets
end
def search_users
targets = ForumSectionsService.new.search_users params, current_user
render json: targets
end
def add_users
targets = ForumSectionsService.new.add_users params, current_user
render json: targets
end
def managements
targets = ForumSectionsService.new.managements params, current_user
render json: targets
end
def applied_forums
targets = ForumSectionsService.new.applied_forums params, current_user
render json: targets
end
def deal_applies
targets = ForumSectionsService.new.deal_applies params, current_user
render json: targets
end
def destroy_moderator
targets = ForumSectionsService.new.destroy_moderator params, current_user
render json: targets
end
def unchecked_memos
targets = ForumSectionsService.new.unchecked_memos params, current_user
render json: targets
end
def unchecked_replies
targets = ForumSectionsService.new.unchecked_replies params, current_user
render json: targets
end
def checked_memos
targets = ForumSectionsService.new.checked_memos params, current_user
render json: targets
end
private
def current_user_ip
env['REMOTE_ADDR']
end
end

View File

@ -0,0 +1,109 @@
class MemosController < ApplicationController
before_action :require_login, only: [:create, :edit, :update, :watch_memo]
def index
memos = MemosService.new.index params, current_user
render json: memos
end
def related_memos
targets = MemosService.new.related_memos params, current_user
render json: targets
end
def edit
targets = MemosService.new.edit params, current_user
render json: targets
end
def update
targets = MemosService.new.update params, current_user
render json: targets
end
def create
params.permit!
targets = MemosService.new.create params, current_user
render json: targets
end
def show
targets = MemosService.new.show params, current_user
render json: targets
end
def watch_memo
targets = MemosService.new.watch_memo params, current_user
render json: targets
end
def hidden
Memo.find(params[:id]).update_attribute(:hidden, true)
{status: 0, message: "隐藏成功"}
end
def memo_hidden
targets = MemosService.new.memo_hidden params, current_user
render json: targets
end
def reply
targets = MemosService.new.reply params, current_user
render json: targets
end
def destroy
targets = MemosService.new.destroy params, current_user
render json: targets
end
def set_top_or_down
targets = MemosService.new.set_top_or_down params, current_user
render json: targets
end
def is_fine
targets = MemosService.new.is_fine params, current_user
render json: targets
end
def banned_user
targets = MemosService.new.banned_user params, current_user
render json: targets
end
def more_reply
targets = MemosService.new.more_reply params, current_user
render json: targets
end
def forum_memos
targets = MemosService.new.forum_memos params, current_user
render json: targets
end
def forum_memos_head
targets = MemosService.new.forum_memos_head params, current_user
render json: targets
end
def forum_memos_right
targets = MemosService.new.forum_memos_right params, current_user
render json: targets
end
def is_watch
targets = MemosService.new.is_watch params, current_user
render json: targets
end
def confirm_delete
targets = MemosService.new.confirm_delete params, current_user
render json: targets
end
def plus
targets = MemosService.new.plus params, current_user
render json: targets
end
end

View File

@ -0,0 +1,22 @@
class MyMemosController < ApplicationController
def index
targets = MyMemosService.new.index params, current_user
render json: targets
end
def my_interested
targets = MyMemosService.new.my_interested params, current_user
render json: targets
end
def replies_memos
targets = MyMemosService.new.replies_memos params,current_user
render json: targets
end
def recommend_memos
targets = MyMemosService.new.recommend_memos current_user
render json: targets
end
end

View File

@ -38,12 +38,12 @@ module ApiHelper
end
def stars_to_json_like starts,show_jour,homework,show_name
def stars_to_json_like starts,show_jour,homework,show_real_name
result = []
starts.each do |s|
comment = get_homework_review homework,show_jour,s.rater
rater_name = show_name ? s.rater.login : l(:label_anonymous)
rater_id = show_name ? s.rater.id : ''
rater_name = show_real_name ? s.rater.login : l(:label_anonymous)
rater_id = show_real_name ? s.rater.id : ''
result << {:rater_id =>rater_id ,:rater_name => rater_name,:created_at => format_time(s.created_at),:stars => s.stars,:comment => comment}
end
result

View File

@ -8,7 +8,7 @@ module ApiIndexHelper
def format_for_current_user(current_user)
if current_user.present? && (current_user.id != 2)
{username: current_user.show_name,
{username: current_user.show_real_name,
login: current_user.login,
user_id: current_user.id,
image_url: "/images/#{url_to_avatar(current_user)}?#{Time.now.to_i}",
@ -23,7 +23,7 @@ module ApiIndexHelper
end
def format_common_user(user)
{username: user.show_name,
{username: user.show_real_name,
user_id: user.id,
login: user.login,
image_url: "/images/#{url_to_avatar(user)}?#{Time.now.to_i}",
@ -92,7 +92,7 @@ module ApiIndexHelper
moderator_id: moder.id,
user_id: user.id,
login: user.login,
username: user.try(:show_name),
username: user.try(:show_real_name),
image_url: url_to_avatar(user),
user_url: "/users/#{user.try(:login)}"
}
@ -167,8 +167,9 @@ module ApiIndexHelper
memo_parent_id = memo.parent_id
memo_parent_type = "Memo"
end
admin_role_ids= AdminRole.includes(:admin_permissions).joins(:admin_permissions).where("admin_permissions.name = '#{type}'").pluck(:id)
user_ids = UserAdminRole.where(admin_role_id: admin_role_ids).pluck(:user_id).uniq
user_ids = User.select(:admin, :id).admin_users.pluck(:id)
# admin_role_ids= AdminRole.includes(:admin_permissions).joins(:admin_permissions).where("admin_permissions.name = '#{type}'").pluck(:id)
# user_ids = UserAdminRole.where(admin_role_id: admin_role_ids).pluck(:user_id).uniq
if user_ids.size > 0
user_ids.each do |id|
Tiding.create(:user_id => id, :trigger_user_id => memo.author_id,
@ -221,7 +222,7 @@ module ApiIndexHelper
last_memo = memo&.last_reply_memo(show_hidden_memo)
if last_memo
new_reply = {
username: last_memo&.author.try(:show_name),
username: last_memo&.author.try(:show_real_name),
user_login: last_memo&.author.try(:login),
user_id: last_memo&.author.try(:id),
content: last_memo&.content,
@ -240,7 +241,7 @@ module ApiIndexHelper
sticky: memo.sticky,
is_fine: memo.is_fine,
is_original: memo.is_original,
username: memo.author.show_name,
username: memo.author.show_real_name,
image_url: "#{url_to_avatar(memo.author)}?#{Time.now.to_i}",
user_login: memo.author.try(:login),
user_id: memo.author.try(:id),

4
app/models/block_user.rb Normal file
View File

@ -0,0 +1,4 @@
class BlockUser < ApplicationRecord
belongs_to :user
scope :block_user_present, ->(target_id){where(block_user_id: target_id)}
end

View File

@ -0,0 +1,2 @@
class CheckedAction < ApplicationRecord
end

View File

@ -4,14 +4,18 @@ module Watchable
included do
has_many :watchers, as: :watchable, dependent: :destroy
has_many :watcher_users, through: :watchers, source: :user, validate: false
scope :watched_by, -> (user_id) { includes(:watchers).where(watchers: { user_id: user_id }) }
attr_reader :watcher_ids, :watcher_user_ids
end
def watched?(watchable)
watchable.watchers.exists?(user: self)
end
def watched_by?(user)
!!(user && self.watcher_user_ids && self.watcher_user_ids.detect {|uid| uid == user.id })
end
def watch!(watchable)
watchable.watchers.create!(user: self, created_at: Time.current)
end

View File

@ -1,4 +1,5 @@
class ForumSection < ApplicationRecord
include Watchable
has_ancestry
#论坛板块的表
# attr_accessible :title, :body

View File

@ -4,16 +4,12 @@
# is_fine 是否加精默认为false
# hidden 是否隐藏
# require 'elasticsearch/model'
class Memo < ApplicationRecord
# include Redmine::SafeAttributes
# include UserScoreHelper
include ApplicationHelper, Watchable
# include Elasticsearch::Model
#敏感词过滤
# include DunCheckAble
has_many :forums, :through => :memo_forums
belongs_to :forum_section, counter_cache: true
belongs_to :forum_section, counter_cache: true, optional: true
has_many :memo_forums, :dependent => :destroy
has_many :visit_actions, as: :visitable, dependent: :destroy
#用户是否禁言
@ -30,39 +26,9 @@ class Memo < ApplicationRecord
scope :total_replies, ->{where("hidden = false and root_id is not null")}
# scope :roots, -> {where()}
has_many :attachments, as: :container, dependent: :destroy
# 创意征集方式 0-默认1-申请, ps. 删除后,该帖子即删除, 拒绝后,该帖子状态将为初始状态
enum destroy_status: { common: 0, apply_destroy: 1 }
# acts_as_watchable
#elasticsearch kaminari init
# Kaminari::Hooks.init
# Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
# settings index: {
# number_of_shards: 5 ,
# analysis: {
# char_filter: {
# and_filter: {
# type: "mapping",
# mappings: [ "&=> and "]
# }
# },
# analyzer: {
# my_analyzer: {
# type: 'custom',
# tokenizer: 'standard',
# filter: ['classic'],
# char_filter: ['html_strip']
# }
# }
# }
# } do
# mappings dynamic: 'false' do
# indexes :subject, analyzer: 'smartcn',index_options: 'offsets'#, char_filter: 'html_strip'
# indexes :content, analyzer:'my_analyzer',index_options: 'offsets',search_analyzer: 'smartcn'
# indexes :updated_at,index:"not_analyzed" ,type:'date'
# end
# end
acts_as_tree :counter_cache => :replies_count, :order => "#{Memo.table_name}.created_at ASC", dependent: :destroy
# acts_as_attachable
has_many :user_score_details, :class_name => 'UserScoreDetails',:as => :score_changeable_obj
@ -72,46 +38,7 @@ class Memo < ApplicationRecord
# 消息
has_many :memo_messages, :class_name =>'MemoMessage', :dependent => :destroy
# end
belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id'
# acts_as_searchable :column => ['subject', 'content'],
# #:include => { :forum => :p}
# #:project_key => "#{Forum.table_name}.project_id"
# :date_column => "#{table_name}.created_at"
#acts_as_event :title => Proc.new {|o| "#{o.forum.name}: #{o.subject}"},
#:datetime => :updated_at,
# :datetime => :created_at,
#:description => :content,
#:author => :author,
#:type => Proc.new {|o| o.parent_id.nil? ? 'Memo' : 'Reply'},
#:url => Proc.new {|o| {:controller => 'memos', :action => 'show', :forum_id => o.forum_id}.merge(o.parent_id.nil? ? {:id => o.id} : {:id => o.parent_id, :r => o.id, :anchor => "reply-#{o.id}"})}
# acts_as_activity_provider :author_key => :author_id,
# :func => 'memos',
# :timestamp => 'created_at'
# :find_options => {:type => 'memos'}
# acts_as_watchable
# safe_attributes "author_id",
# "subject",
# "content",
# "last_memo_id",
# "lock",
# "sticky",
# "parent_id",
# "replies_count",
# "root_id",
# "language"
# after_create :add_author_as_watcher, :reset_counters!, :send_tiding
# after_create :add_author_as_watcher #浏览记录
# after_update
# after_destroy :reset_counters!,:delete_kindeditor_assets #,:down_user_score -- 公共区发帖暂不计入得分,
# after_create :send_notification
# after_save :plusParentAndForum
# after_destroy :minusParentAndForum
#before_save :be_user_score
# scope :visible, lambda { |*args|
# includes(:forum => ).where()
# }
belongs_to :last_reply, :class_name => 'Memo', :foreign_key => 'last_reply_id', optional: true
scope :indexable,lambda {
where('parent_id is null')
}
@ -135,35 +62,7 @@ class Memo < ApplicationRecord
def self.search_by_time(time_type, start_time, end_time)
where("#{time_type} between ? and ?",start_time.present? ? start_time.to_time : Time.now, end_time.present? ? end_time.to_time.end_of_day : Time.now)
end
# def self.search(query)
# __elasticsearch__.search(
# {
# query: {
# multi_match: {
# query: query,
# type:"most_fields",
# operator: "or",
# fields: ['subject','content^0.5']
# }
# },
# sort: {
# _score:{order: "desc" },
# updated_at:{order: "desc" }
# },
# highlight: {
# pre_tags: ['<span class="c_red">'],
# post_tags: ['</span>'],
# fields: {
# subject: {},
# content: {}
# }
# }
# }
# )
# end
def memo_parent
Memo.find(parent_id)
end
@ -201,11 +100,11 @@ class Memo < ApplicationRecord
end
def self.hottest_five_memos
order("replies_count desc, praises_count desc, viewed_count desc").limit(8).select([:id,:subject])
order("replies_count desc, praises_count desc, viewed_count desc").limit(8).select(:id,:subject)
end
def self.recommend_five_memos
recommend_memos.order("updated_at desc").limit(8).select([:id,:subject])
recommend_memos.order("updated_at desc").limit(8).select(:id,:subject)
end

View File

@ -0,0 +1,2 @@
class MemoMessage < ApplicationRecord
end

View File

@ -14,6 +14,10 @@ class PraiseTread < ApplicationRecord
end
end
def self.is_user_praise(target_id,target_type, target_user_id)
where(:praise_tread_object_id => target_id, :praise_tread_object_type => target_type, :user_id => target_user_id, :praise_or_tread => 1)
end
def self.find_object_by_type_and_id(id, type)
type.constantize find_by_id id
end

View File

@ -54,6 +54,7 @@ class User < ApplicationRecord
has_one :qq_open_user, class_name: 'OpenUsers::QQ'
accepts_nested_attributes_for :user_extension, update_only: true
has_many :fork_users, dependent: :destroy
has_many :block_users, :dependent => :destroy
has_many :versions
has_many :issue_times, :dependent => :destroy
@ -72,7 +73,7 @@ class User < ApplicationRecord
has_many :be_watchers, foreign_key: :user_id, dependent: :destroy # 我的关注
has_many :be_watcher_users, through: :be_watchers, dependent: :destroy # 我关注的用户
has_many :watchers, as: :watchable, dependent: :destroy
# has_many :watchers, as: :watchable, dependent: :destroy
# 认证
has_many :apply_user_authentication
@ -320,6 +321,10 @@ class User < ApplicationRecord
status == STATUS_LOCKED
end
def self.admin_users
where(admin: true)
end
def activate
self.status = STATUS_ACTIVE
end
@ -579,6 +584,10 @@ class User < ApplicationRecord
end
end
def blocked_for(user_id)
block_users.where(block_user_id: user_id).exists?
end
def salt_password(clear_password)
self.salt = User.generate_salt
self.hashed_password = User.hash_password("#{salt}#{User.hash_password clear_password}")

View File

@ -1,31 +0,0 @@
<div class="edu-back-white mt20 mb20 clearfix padding20">
<ul class="fl mt2 nav_blueline_status">
<li class="<%= @banned_type == "banned" ? "active" : "" %>" >
<%= link_to "禁言用户 #{@banned_users_size > 0 ? "(#{@banned_users_size})" : ""}", admin_banned_users_path(banned_type: "banned"),remote: true %>
</li>
<li class="<%= @banned_type == "unbanned" ? "active" : "" %>">
<%= link_to "解除禁言记录", admin_banned_users_path(banned_type: "unbanned"),remote: true %>
</li>
</ul>
<ul class="fr">
<input type="text" name="search_banned_user" value="<%= @search_params %>" class="winput-240-35 fl mr10 " placeholder="请输入用户名称进行搜索">
<a href="javascript:void(0)" class="edu-default-btn edu-blueback-btn fl mr15 mt2" id="searchBanned">搜索</a>
<%= link_to "清除", admin_banned_users_path(search: nil, banned_type: @banned_type),remote: true, class: "edu-default-btn edu-greyback-btn fl mt2 mr15" %>
</ul>
</div>
<div id="banned-user-item">
<%= render partial: "admin/banned_users/banned_user_item" %>
</div>
<script>
$("#searchBanned").on("click",function () {
let task_status = "<%= @banned_type %>";
let search_name =$("input[name='search_banned_user']").val();
$.ajax({
url: "<%= admin_banned_users_path %>",
type: "get",
dataType: "script",
data: {banned_type:task_status,search: search_name }
});
});
</script>

View File

@ -1,3 +0,0 @@
<div class="edu-class-container" id="banned-users-container">
<%= render partial: "admin/banned_users/banned_users_items" %>
</div>

View File

@ -1 +0,0 @@
$("#banned-users-container").html("<%= j render partial: "admin/banned_users/banned_users_items" %>")

View File

@ -1,33 +0,0 @@
<div class="edu-back-white mt20 mb20 clearfix padding20">
<ul class="fl mt2 nav_blueline_status">
<li class="<%= @select_type == "unconfirm" ? "active" : "" %>" >
<%= link_to "待审批", admin_forum_applies_path(select_type: "unconfirm"),remote: true %>
</li>
<li class="<%= @select_type == "confirm" ? "active" : "" %>">
<%= link_to "已审批", admin_forum_applies_path(select_type: "confirm"),remote: true %>
</li>
</ul>
<ul class="fr">
<input type="text" name="search_section_name" value="<%= @section_name %>" class="winput-240-35 fl mr10 " placeholder="请输入板块名称进行检索">
<input type="text" name="search_user_name" value="<%= @search_name %>" class="winput-240-35 fl mr10 " placeholder="请输入用户名称进行检索">
<a href="javascript:void(0)" class="edu-default-btn edu-blueback-btn fl mr15 mt2" id="searchApplies">搜索</a>
<%= link_to "清除", admin_forum_applies_path(user_name: nil,section_name: nil, select_type: @select_type),remote: true, class: "edu-default-btn edu-greyback-btn fl mt2 mr15" %>
</ul>
</div>
<div id="forum-apply-item">
<%= render partial: "admin/forum_applies/forum_apply_item" %>
</div>
<script>
$("#searchApplies").on("click",function () {
let select_status = "<%= @select_type %>";
let search_name =$("input[name='search_user_name']").val();
let section_name = $("input[name='search_section_name']").val();
$.ajax({
url: "<%= admin_forum_applies_path %>",
type: "get",
dataType: "script",
data: {select_type:select_status,user_name: search_name, section_name: section_name }
});
});
</script>

View File

@ -1,3 +0,0 @@
<div class="edu-class-container" id="forum-applies-container">
<%= render partial: "admin/forum_applies/forum_applies_items" %>
</div>

View File

@ -1,9 +0,0 @@
<% if users.present? && users.size > 0 %>
<% users.each do |u| %>
<% user = u.user %>
<span class="blue-user-btn" id="forum_section_moderator_user_<%= u.id %>">
<span class="mr5"><%= link_to user.try(:show_name), user_path(user) %></span>
<span><%= link_to "<i class='fa fa-close font16'></i>".html_safe,admin_forum_section_forum_moderator_path(forum, u), method: :delete, data:{confirm: "确认删除吗?"}, remote: true, class: "color-grey-9" %></span>
</span>
<% end %>
<% end %>

View File

@ -1,6 +0,0 @@
<% if @forum_status > 0 %>
$("#forum_sections_moderators_<%= @forum_section.id %>").html("<%= j render partial: "admin/forum_moderators/forum_moderator_item", locals: {users: @forum_moderators, forum: @forum_section} %>")
op_know("添加成功")
<% else %>
op_know("没有选择版主")
<% end %>

View File

@ -1,8 +0,0 @@
<a href="javascript:void(0)" class="fl" ><%= children_forum.try(:title) %></a>
<span href="javascript:void(0)" class="menu_operate ml20 fr" onclick="first_menu_action(this)">
<i class="iconfont icon-sandian color-grey-6 font-12"> </i>
<div class="operateList">
<%= link_to "重命名", edit_admin_forum_section_path(children_forum, children_forum: true), remote: true %>
<%= link_to "删除", admin_forum_section_path(children_forum, children_forum: true),method: :delete, data:{confirm: "确认删除吗?"}, remote: true %>
</div>
</span>

View File

@ -1,3 +0,0 @@
<tr id="forum-section-detail-<%= forum.id %>">
<%= render partial: "admin/forum_sections/td_forum_section", locals: {forum: forum} %>
</tr>

View File

@ -1,49 +0,0 @@
<%=javascript_include_tag '../javascripts/attachments.js' %>
<div class="task-popup" style="width:500px;">
<div class="task-popup-title clearfix f14">
<%= parent_id.present? ? "新建二级版块" : "新建一级版块" %>
</div>
<%= form_tag(admin_forum_sections_path, method: :post, class: "", remote: true) do %>
<%= hidden_field_tag :parent_id,parent_id %>
<div class="task-popup-content ml55">
<div class="grid-item-top">
<span class="mr10 color-grey">名称:</span>
<div>
<%= text_field_tag :title, nil,class: "winput-300-35", placeholder: "请输入名称最大限制20个字符", maxlength: 20 %>
<div id="edit_forum_section_notice" class="none color-red">不能重名</div>
</div>
</div>
<div class="grid-item-top mt20">
<span class="mr10 color-grey">描述:</span>
<div>
<%= text_area_tag :description,nil,class: "width300", placeholder: "请输入描述", maxlength: 200, rows: 4 %>
<div id="new_forum_section_notice" class="none color-red">不能超过200字</div>
</div>
</div>
<div class="grid-item-top mt20">
<span class="mr10 color-grey">封面:</span>
<div>
<div class="upload-image-100 pointer" onclick="$('#_file_section_picture').click();" id="admin-logo-upload">
<div style="line-height: 100px;">上传封面</div>
</div>
<div class="none poa top-bottom-0">
<%=render partial: "admin/forum_sections/upload_logo" %>
</div>
<div class="font-12 color-grey">
尺寸 100*100支持.jpg .jpeg .bmp .gif .png格式照片。
</div>
</div>
</div>
</div>
<div class="cl"></div>
<div class="edu-txt-center mbt10">
<li class="inline">
<a href="javascript:void(0)" class="task-btn fl mr50" onclick="hideModal();">取消</a>
<%= submit_tag "确定", class: "edu-default-btn edu-blueback-btn" %>
</li>
</div>
<% end %>
</div>

View File

@ -1,42 +0,0 @@
<td>
<li class="set_l_main">
<div class="set_l_premenu">
<span class="ml10 max-width-300" onclick="first_menu_click(this)">
<i class="fa fa-plus-square-o color-grey-6"></i>
<span class="ml5"><%= forum.try(:title) %></span>
</span>
<span href="javascript:void(0)" class="menu_operate ml20" onclick="first_menu_action(this)">
<i class="iconfont icon-sandian color-grey-6 font-12">
</i>
<div class="operateList">
<%= link_to "重命名", edit_admin_forum_section_path(forum), remote: true %>
<%= link_to "删除", admin_forum_section_path(forum),method: :delete, data:{confirm: "确认删除吗?"}, remote: true %>
<%= link_to "新增子版块".html_safe, new_admin_forum_section_path(parent_id: forum.id),remote: true %>
<% if forum&.position.to_i != @min_position %>
<%= link_to "下移",move_admin_forum_section_path(forum,opr:"down"), method: :post, remote: true %>
<% end %>
<% if forum&.position.to_i != @max_position %>
<%= link_to "上移",move_admin_forum_section_path(forum,opr:"up"), method: :post, remote: true %>
<% end %>
</div>
</span>
</div>
<div id="children-forum-section-<%= forum.id %>">
<%= render partial: "admin/forum_sections/children_forum_sections", locals: {children_forums: forum.get_children_section("desc")} %>
</div>
</li>
</td>
<td id="forum-section-recommend-<%= forum.id %>">
<%= render partial: "admin/forum_sections/recommend_forum_sections", locals: {forum: forum} %>
</td>
<td>
<div class="grid-item pbt5">
<div class="grid-item-1">
<%= link_to "<i class='fa fa-plus-square-o'></i>".html_safe,new_admin_forum_section_forum_moderator_path(forum), class: "font-20 color-blue mr10", title: "添加版主", remote: true %>
</div>
<div class="width100 inline-block edu-txt-left" id="forum_sections_moderators_<%= forum.id %>">
<%= render partial: "admin/forum_moderators/forum_moderator_item", locals: {users: forum.forum_moderators, forum: forum} %>
</div>
</div>
</td>

View File

@ -1,19 +0,0 @@
<%= file_field_tag 'attachments[dummy][file]',
:id => "_file_section_picture",
:class => ie8? ? '':'file_selector',
:onchange => "addInputFiles_board(this, '','"+"submit_resource"+"');",
:style => ie8? ? '': 'display:none',
accept: 'image/png,image/gif,image/jpeg,image/jpg,image/bmp',
:data => {
:max_file_size => 5120.kilobytes,
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(5120.kilobytes)),
:max_concurrent_uploads => 1,
:upload_path => upload_image_path(:format => 'js'),
:description_placeholder => l(:label_optional_description),
:field_is_public => l(:field_is_public),
:are_you_sure => l(:text_are_you_sure),
:file_count => l(:label_file_count),
:delete_all_files => l(:text_are_you_sure_all),
:label_file_uploding => l(:label_file_uploding),
:containerid => ""
} %>

View File

@ -1,14 +0,0 @@
<% if @forum_status[:status] == 0 %>
$("#new_forum_section_notice").removeClass("none").html("<%= @forum_status[:msg] %>")
$("#new_forum_section_notice").siblings("input").addClass("error_tip");
<% elsif @forum_status[:status] > 0 %>
op_know("<%= @forum_status[:msg] %>")
<% if params[:parent_id].present? %>
$("#forum-section-detail-<%= params[:parent_id] %>").html("<%= j render partial: "admin/forum_sections/td_forum_section", locals: {forum: @parent_forum} %>")
<% else %>
$("#forum-section-contents").prepend("<%= j render partial: "admin/forum_sections/forum_section_detail", locals: {forum: @forum_section} %>")
<% end %>
<% else %>
op_know("<%= @forum_status[:msg] %>")
<% end %>

View File

@ -1,10 +0,0 @@
<% if @delete_status[:status] > 0 %>
op_know("<%= @delete_status[:msg] %>")
<% if params[:children_forum].present? %>
$("#children-forum-detail-<%= @forum_section.id %>").remove()
<% else %>
$("#forum-section-detail-<%= @forum_section.id %>").remove()
<% end %>
<% else %>
op_know("<%= @delete_status[:msg] %>")
<% end %>

View File

@ -1,2 +0,0 @@
var htmlvalue = "<%= j render :partial => 'admin/forum_sections/edit_forum' %>";
pop_box_new(htmlvalue, 520, 400);

View File

@ -1,3 +0,0 @@
<div class="edu-class-container" id="forum-section-container">
<%= render partial: "managements/forums_plateSetting.html.erb" %>
</div>

View File

@ -1,2 +0,0 @@
var htmlvalue = "<%= j render :partial => 'admin/forum_sections/new_forum', locals: {parent_id: @parent_id} %>";
pop_box_new(htmlvalue, 520, 400);

View File

@ -1 +0,0 @@
$("#children-forum-section-<%= @forum_section.id %>").html("<%= j render partial: "admin/forum_sections/children_forum_sections", locals: {children_forums: @children_forums} %>")

View File

@ -1 +0,0 @@
$("#forum-section-recommend-<%= @forum_section.id %>").html("<%= j render partial: "admin/forum_sections/recommend_forum_sections", locals: {forum: @forum_section} %>")

View File

@ -1,13 +0,0 @@
<% if @edit_forum_status[:status] == 0 %>
$("#edit_forum_section_notice").removeClass("none").html("<%= @edit_forum_status[:msg] %>")
$("#edit_forum_section_notice").siblings("input").addClass("error_tip");
<% elsif @edit_forum_status[:status] > 0 %>
op_know("<%= @edit_forum_status[:msg] %>")
<% if params[:children_forum].present? %>
$("#children-forum-detail-<%= @forum_section.id %>").html("<%= j render partial: "admin/forum_sections/children_forum_detail", locals: {children_forum: @forum_section} %>")
<% else %>
$("#forum-section-detail-<%= @forum_section.id %>").html("<%= j render partial: "admin/forum_sections/td_forum_section", locals: {forum: @forum_section} %>")
<% end %>
<% else %>
op_know("<%= @edit_forum_status[:msg] %>")
<% end %>

View File

@ -4,7 +4,7 @@
<!--<div class="homepageEditProfile"><a href="javascript:void(0);" class="homepageEditProfileIcon"></a></div>-->
</div>
<div class="fl" style="width: 135px;">
<% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %>
<% user_name = @forum.creator.show_real_name.empty? ? @forum.creator.name : @forum.creator.show_real_name %>
<div class="fl mb8 mt10">吧主:</div>
<a href="<%= user_path(@forum.creator)%>" target="_blank" class="linkBlue w80 fl mb8 mt10" style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis; "><%= user_name %></a>
<div class="fontGrey3 fl">回答:<a href="javascript:void(0);" class="linkOrange mr5" style="cursor: default"><%= @my_replies_count %></a>

View File

@ -4,7 +4,7 @@
<!--<div class="homepageEditProfile"><a href="javascript:void(0);" class="homepageEditProfileIcon"></a></div>-->
</div>
<div class="fl" style="width: 135px;">
<% user_name = @forum.creator.show_name.empty? ? @forum.creator.name : @forum.creator.show_name %>
<% user_name = @forum.creator.show_real_name.empty? ? @forum.creator.name : @forum.creator.show_real_name %>
<div class="fl mb8 mt10">吧主:</div>
<a href="<%= user_path(@forum.creator)%>" target="_blank" class="linkBlue w80 fl mb8 mt10" style="overflow: hidden;white-space: nowrap;text-overflow:ellipsis; "><%= user_name %></a>
<div class="fontGrey3 fl">回答:<a href="javascript:void(0);" class="linkOrange mr5" style="cursor: default"><%= @my_replies_count %></a>

View File

@ -1,7 +1,7 @@
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
<i class="fa fa-map-marker mr5 color-grey"></i>
<a href="<%= user_path(@user) %>"><%= @user.show_name %></a> &gt; <a href="<%= forums_path %>">讨论 </a> &gt; 编辑
<a href="<%= user_path(@user) %>"><%= @user.show_real_name %></a> &gt; <a href="<%= forums_path %>">讨论 </a> &gt; 编辑
</p>
<div class="edu-con-top user_bg_shadow bor-grey-e">
<p class="ml15 color-grey3">编辑话题</p>

View File

@ -1,7 +1,7 @@
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
<i class="fa fa-map-marker mr5 color-grey"></i>
<a href="<%= user_path(@user) %>"><%= @user.show_name %></a> &gt; <a href="<%= forums_path %>">讨论区 </a> &gt; 新建
<a href="<%= user_path(@user) %>"><%= @user.show_real_name %></a> &gt; <a href="<%= forums_path %>">讨论区 </a> &gt; 新建
</p>
<div class="edu-con-top user_bg_shadow bor-grey-e">
<p class="ml15 color-grey3">新建话题</p>

View File

@ -5,7 +5,7 @@
<div class="edu-class-container edu-position">
<p class="mb10 font-14">
<i class="fa fa-map-marker mr5 color-grey"></i>
<a href="<%= user_path(@user)%>"><%= @user.show_name %></a> &gt; <a href="<%= forums_path %>">讨论区 </a>
<a href="<%= user_path(@user)%>"><%= @user.show_real_name %></a> &gt; <a href="<%= forums_path %>">讨论区 </a>
</p>
<div class="edu-con-top user_bg_shadow bor-grey-e clearfix mb20">
<p class="ml15 color-grey3 fl">
@ -32,7 +32,7 @@
<!-- <p class="color-grey fr font-12 mr15 mt5"><a href="javascript:void(0)">返回</a></p>-->
</div>
<p class="mb10">
<a href="<%= user_path(@memo.author) %>" class="font-14 mr15 color-grey" target="_blank"><%= @memo.author.show_name %></a><span class="font-14 color-grey">更新于<%= time_from_now @memo.updated_at %></span>
<a href="<%= user_path(@memo.author) %>" class="font-14 mr15 color-grey" target="_blank"><%= @memo.author.show_real_name %></a><span class="font-14 color-grey">更新于<%= time_from_now @memo.updated_at %></span>
<span id="reword_score_<%= @memo.id %>">
<% if @memo.try(:reward).present? %>
<span class="ml15 color-orange03" style="cursor: default;" data-tip-down="获得平台奖励金币:<%= @memo.try(:reward) %>"><i class="fa fa-gift mr5 font-16"></i><%= @memo.try(:reward) %></span>
@ -156,7 +156,7 @@
<div class="cl"></div>
<div class="postDetailCreater">
<%= link_to @memo.author.show_name, user_path(@memo.author), :class => "linkBlue2", :target=> "_blank"%></div>
<%= link_to @memo.author.show_real_name, user_path(@memo.author), :class => "linkBlue2", :target=> "_blank"%></div>
<div class="postDetailDate mb5"><%= format_date( @memo.created_at)%></div>
<div class="cl"></div>
<div class="homepagePostIntro memo-content ke-block" id="activity_description_<%= @memo.id %>" style="word-break: break-all; word-wrap:break-word;margin-bottom: 0px !important;" >

View File

@ -103,7 +103,7 @@ class ForumSectionsService
user_item = {
id: u.id,
login: u.try(:login),
username: u.try(:show_name),
username: u.try(:show_real_name),
nickname: u.try(:nickname)
}
search_users.push(user_item)
@ -133,7 +133,7 @@ class ForumSectionsService
user_list = {
forum_moderator_id: new_forum_moder.id,
login: user.try(:login),
username: user.try(:show_name),
username: user.try(:show_real_name),
user_url: "/users/#{user.try(:login)}"
}
forum_users.push(user_list)
@ -230,7 +230,7 @@ class ForumSectionsService
end
apply_user = {
apply_id: apply.id,
username: user.try(:show_name),
username: user.try(:show_real_name),
login: user.try(:login),
image_url: "#{url_to_avatar(user)}?#{Time.now.to_i}",
user_url: "/users/#{user.try(:login)}",
@ -335,8 +335,9 @@ class ForumSectionsService
extra = "2"
else
parent_section_id = ""
admin_role_ids= AdminRole.includes(:admin_permissions).joins(:admin_permissions).where("admin_permissions.name = 'forum_post'").pluck(:id)
manager_ids = UserAdminRole.where(admin_role_id: admin_role_ids).pluck(:user_id).uniq
manager_ids = User.select(:admin, :id).admin_users.pluck(:id)
# admin_role_ids= AdminRole.includes(:admin_permissions).joins(:admin_permissions).where("admin_permissions.name = 'forum_post'").pluck(:id)
# manager_ids = UserAdminRole.where(admin_role_id: admin_role_ids).pluck(:user_id).uniq
extra = "1"
end
if manager_ids.size == 0
@ -394,7 +395,7 @@ class ForumSectionsService
memo_id: memo.id,
is_banned: is_banned,
memo_title: memo.subject,
username: user.try(:show_name),
username: user.try(:show_real_name),
login: user.try(:login),
image_url: "#{url_to_avatar(user)}?#{Time.now.to_i}",
user_url: "/users/#{user.try(:login)}",
@ -441,7 +442,7 @@ class ForumSectionsService
is_banned: is_banned,
reply_id: memo.id,
reply_content: memo.content,
username: user.try(:show_name),
username: user.try(:show_real_name),
login: user.try(:login),
image_url: "#{url_to_avatar(user)}?#{Time.now.to_i}",
user_url: "/users/#{user.try(:login)}",
@ -504,7 +505,7 @@ class ForumSectionsService
memo_id: memo.id,
is_banned: is_banned,
memo_title: memo.subject,
username: user.try(:show_name),
username: user.try(:show_real_name),
login: user.try(:login),
image_url: "#{url_to_avatar(user)}?#{Time.now.to_i}",
user_url: "/users/#{user.try(:login)}",

View File

@ -12,7 +12,7 @@ class MemosService
search = params[:search].to_s.strip
sort_name = params[:sort] || "published_at"
all_memos = Memo&.visible&.roots&.includes(:forum_section,author: :user_extensions)
all_memos = Memo&.visible&.roots
all_hottest_memos = all_memos.hottest_five_memos
hottest_memos = object_to_hash(all_hottest_memos)
@ -25,7 +25,7 @@ class MemosService
end
memos_count = all_memos.size # 帖子的总数
all_memos = all_memos.order_index(sort_name).limit(index_limit).offset(offset)
all_memos = all_memos.order_index(sort_name)&.includes(:forum_section,author: :user_extension).limit(index_limit).offset(offset)
memo_lists = get_memo_lists(all_memos, false, current_user, false)
@ -34,10 +34,10 @@ class MemosService
end
def related_memos params
def related_memos params, current_user
memo = Memo.find(params[:id])
return { status: 404 } if memo.hidden? && (!current_user || !(current_user.admin? || current_user.id == memo.author_id))
all_memos = Memo.visible.roots.where("id != ?", params[:id].to_i).includes(memo_forums: :forum_section,author: :user_extensions).related_search_name(memo.try(:subject).to_s).order_index("published_at").limit(5).offset(0)
all_memos = Memo.visible.roots.where("id != ?", params[:id].to_i).includes(memo_forums: :forum_section,author: :user_extension).related_search_name(memo.try(:subject).to_s).order_index("published_at").limit(5).offset(0)
memo_lists = get_memo_lists(all_memos, false, current_user, false)
{status: 0, memos: memo_lists}
end
@ -81,7 +81,7 @@ class MemosService
# memo.published_at = Time.now if params[:memo][:published_at].blank?
memo.hidden = true
# memo.save!
if memo.save
if memo.save!
memo.update_attachments(params[:attachments]) if params[:attachments].present?
# 为了区分帖子头像改变其类型为MemoIcon
create_user_tidings(memo, "forum_post")
@ -95,8 +95,7 @@ class MemosService
{status: -1, message: memo.errors.messages.values[0][0]}
end
rescue => e
{status: -1, message: "出现错误"}
raise ActiveRecord::Rollback
{status: -1, message: e}
end
end
@ -147,7 +146,7 @@ class MemosService
is_md = memo.is_md
author_info = {username: memo_author.show_name,
author_info = {username: memo_author.show_real_name,
watched: watched,
is_blocked: current_user&.blocked_for(memo_author.id),
is_blocked_by: memo_author&.blocked_for(current_user.id),
@ -156,10 +155,10 @@ class MemosService
identity: memo_author.identity,
login: memo_author.login,
user_id: memo_author.id,
description: memo_author&.user_extensions&.brief_introduction,
description: memo_author&.user_extension&.brief_introduction,
memos_count: memo_author_memos.posts.size,
replies_count: memo_author_memos.total_replies.size,
watchers_count: memo_author.watcher_users.size,
watchers_count: memo_author.fan_count,
current_login: current_user.try(:login),
is_current_user: memo.author_id == current_user.try(:id)
}
@ -189,20 +188,21 @@ class MemosService
}
if current_user
unless memo.children.blank?
memo.children.includes(:memo_messages).each do |child|
child.memo_messages.each do |memo_message|
memo_message.update_attributes(:viewed => true) if current_user.id == memo_message.user_id
end
end
end
#TODO 通知消息暂时隐藏
# unless memo.children.blank?
# memo.children.includes(:memo_messages).each do |child|
# child.memo_messages.each do |memo_message|
# memo_message.update_attributes(:viewed => true) if current_user.id == memo_message.user_id
# end
# end
# end
query_memo_messages = memo.memo_messages
unless query_memo_messages
query_memo_messages.each do |query_memo_message|
query_memo_message.update_attributes(:viewed => true) if current_user.id == query_memo_message.user_id
end
end
# query_memo_messages = memo.memo_messages
# unless query_memo_messages
# query_memo_messages.each do |query_memo_message|
# query_memo_message.update_attributes(:viewed => true) if current_user.id == query_memo_message.user_id
# end
# end
if memo.author_id != current_user.id
if memo.visit_actions.exists?(watcher_params)
@ -268,7 +268,7 @@ class MemosService
def destroy params, current_user
user_permission = check_banned_permission current_user, params[:id]
memo = Memo.select([:id,:parent_id]).find(params[:id])
memo = Memo.select(:id,:parent_id, :forum_section_id).find(params[:id])
return {status: -1, message: "帖子不存在!"} unless memo.present?
return {status: -1, message: "您没有权限操作!"} unless user_permission
if memo.destroy
@ -412,7 +412,7 @@ class MemosService
memo.children << reply
create_user_tidings(reply, "forum_comment")
replies = {:id => reply.id, :content => reply.content, :time => time_from_now(reply.created_at), :user_id => reply.author_id,
:image_url => "/images/#{url_to_avatar(reply.author)}?#{Time.now.to_i}", :username => reply.author.show_name, :reward => memo.reward, :hidden => reply.hidden,
:image_url => "/images/#{url_to_avatar(reply.author)}?#{Time.now.to_i}", :username => reply.author.show_real_name, :reward => memo.reward, :hidden => reply.hidden,
:praise_count => reply.praises_count,:user_login => reply.author.try(:login), replies_count: reply.can_see_reply_count(current_user)}
{
status: 0,
@ -483,6 +483,30 @@ class MemosService
end
def plus params, current_user
plus_type = params[:container_type].to_s
plus_id = params[:id]
pt = PraiseTread.where(:praise_tread_object_id => params[:id], :praise_tread_object_type => params[:container_type],
:user_id => current_user, :praise_or_tread => 1).first
# 如果当前用户已赞过,则不能重复赞
if params[:type] == 1 && pt.blank?
if pt.blank?
PraiseTread.create!(:praise_tread_object_id => plus_id, :praise_tread_object_type => plus_type,
:user_id => current_user.id, :praise_or_tread => 1) if pt.blank?
plus_name = plus_type.constantize.find(params[:id])
Tiding.create(:user_id => plus_name.try(:author_id), :trigger_user_id => current_user.id,
container_id: plus_id, container_type: plus_type,
:parent_container_id => plus_id, :parent_container_type => plus_type,
:viewed => 0, :tiding_type => "PraiseTread")
end
else
pt.destroy if pt.present? # 如果已赞过,则删掉这条赞(取消);如果没赞过,则为非法请求不处理
end
{:praise_count => PraiseTread.where(:praise_tread_object_id => params[:id], :praise_tread_object_type => params[:container_type],
:praise_or_tread => 1).count}
end
def banned_user params, current_user
user_permission = check_banned_permission current_user, params[:id]
@ -533,14 +557,14 @@ class MemosService
forum_section = ForumSection.find_by_id(params[:id])
return {status: -1, message: "版块不存在"} if forum_section.blank?
section_author = forum_section.user
forum_section_user = {username: section_author.try(:show_name), user_login: section_author.try(:login)}
forum_section_user = {username: section_author.try(:show_real_name), user_login: section_author.try(:login)}
forum_moders = []
if ForumModerator.exists?(forum_section_id: forum_section.id)
all_forum_moderators = forum_section.forum_moderators.includes(user: :user_extensions).select([:id, :user_id])
all_forum_moderators = forum_section.forum_moderators.includes(user: :user_extension).select([:id, :user_id])
all_forum_moderators.each do |moder|
moder_user = moder.user
forum_moder = {
username: moder_user.show_name,
username: moder_user.show_real_name,
user_login: moder_user.try(:login)
}
forum_moders << forum_moder
@ -616,13 +640,13 @@ class MemosService
active_user_array = []
active_users.each do |user|
active_user_array.push({
username: user.show_name,
username: user.show_real_name,
login: user.login,
image_url: "#{url_to_avatar(user)}?#{Time.now.to_i}"
})
end
{
username: forum_section.user.show_name,
username: forum_section.user.show_real_name,
user_login: forum_section.user.login,
notice: notice.try(:content),
recommend_forum_sections: new_childre_section,
@ -685,7 +709,7 @@ class MemosService
memo_list = []
memos.each do |m|
forum_name = m.forums.map(&:name)
user_info = {username: m.author.show_name, login: m.author.login, image_url: "#{url_to_avatar(m.author)}?#{Time.now.to_i}", forum_name:forum_name, praise_count: m.praises_count}
user_info = {username: m.author.show_real_name, login: m.author.login, image_url: "#{url_to_avatar(m.author)}?#{Time.now.to_i}", forum_name:forum_name, praise_count: m.praises_count}
memo_list << m.attributes.dup.merge(user_info)
end
memo_list
@ -702,7 +726,7 @@ class MemosService
end
end
def check_banned_permission current_user, memo_id
forum_id = MemoForum&.where(is_children: false, memo_id: memo_id)&.first.try(:forum_id).to_s
user_banned_permission current_user, forum_id
@ -731,7 +755,7 @@ class MemosService
permission = current_user ? current_user.manager_of_memo?(memo) : false
# 实训TPM的管理员可以看到隐藏的评论
replies = {:id => memo.id, :content => memo.content, :time => time_from_now(memo.created_at), :user_id => memo.author_id,
:image_url => "/images/#{url_to_avatar(memo.author)}?#{Time.now.to_i}", :username => memo.author.show_name, :reward => memo.reward, :hidden => memo.hidden,
:image_url => "/images/#{url_to_avatar(memo.author)}?#{Time.now.to_i}", :username => memo.author.show_real_name, :reward => memo.reward, :hidden => memo.hidden,
:permission => permission, :praise_count => memo.praises_count, :user_praise => user_praise,
:user_login => memo.author.try(:login), :admin => current_user&.admin, is_banned: is_banned, replies_count: memo.can_see_reply_count(current_user)}
childrens = Memo.where(:parent_id => memo.id).includes(:author).reorder("created_at desc").limit(5)
@ -743,7 +767,7 @@ class MemosService
children_praise = child.praise_tread.exists?(user_id: current_user.try(:id).to_i)
children_is_banned = user_is_banned?(child.author) #帖子的用户是否被禁言
children_list << {:id => child.id, :content => child.content, :time => time_from_now(child.created_at),:praise_count => memo.praises_count, :user_praise => children_praise,
:image_url => "/images/#{url_to_avatar(child.author)}?#{Time.now.to_i}", :username => child.author.show_name, :hidden => child.hidden, replies_count: child.can_see_reply_count(current_user),
:image_url => "/images/#{url_to_avatar(child.author)}?#{Time.now.to_i}", :username => child.author.show_real_name, :hidden => child.hidden, replies_count: child.can_see_reply_count(current_user),
:permission => permission, :user_login => child.author.try(:login), :user_id => child.author.try(:id), :parent_id => child.parent_id, is_banned: children_is_banned}
end
list << replies.merge({children: children_list})

View File

@ -61,7 +61,7 @@ class MyMemosService
def recommend_memos current_user
return {status: -1, message: "请登录"} unless current_user
all_memos = Memo.includes(memo_forums: :forum_section,author: :user_extensions)
all_memos = Memo.includes(memo_forums: :forum_section,author: :user_extension)
all_hottest_memos = all_memos.visible.hottest_five_memos
hottest_memos = object_to_hash(all_hottest_memos)

View File

@ -66,7 +66,7 @@ class Projects::ApplyJoinService < ApplicationService
return if owner.phone.blank?
Educoder::Sms.send(mobile: owner.phone, send_type:'applied_project_info',
user_name: owner.show_name, name: project.name)
user_name: owner.show_real_name, name: project.name)
rescue Exception => ex
Rails.logger.error("发送短信失败 => #{ex.message}")
end

View File

@ -0,0 +1,71 @@
<div class="box admin-list-container users-list-container">
<table class="table table-hover users-list-table">
<thead class="thead-light">
<tr>
<th width="9%">序号</th>
<th width="15%">作者</th>
<th width="32%" class="edu-txt-left" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">标题</th>
<th width="18%">发布时间<i class="fa fa-long-arrow-down %> color-light-green ml5"></i></th>
<th>回复数</th>
<th width="18%">操作</th>
</tr>
</thead>
<tbody>
<% @memos.each_with_index do |memo,index| %>
<tr id="apply_destroy_memo_<%= memo.id %>">
<td><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td>
<%= link_to(memo.try(:author).try(:show_real_name), "/users/#{memo.author.login}", target: "_blank") %>
</td>
<td class="edu-txt-left" style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis;">
<%= link_to(memo.subject, "/forums/#{memo.id}/detail", target: "_blank") %>
</td>
<td><%= format_time(memo.created_at) %></td>
<td>
<%= link_to(memo.replies_count, "/forums/#{memo.id}/detail", target: "_blank") %>
</td>
<td>
<%= link_to '拒绝', confirm_apply_destroy_admins_apply_destroy_index_path(id: memo.id, confirm: "reject"), method: :post, remote: true, data: {confirm: "拒绝删除该帖子吗?"} %>
<%= link_to '同意', confirm_apply_destroy_admins_apply_destroy_index_path(id: memo.id, confirm: "delete"), method: :post, remote: true, data: {confirm: "确认删除该帖子吗?"} %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<%= render partial: 'admins/shared/paginate', locals: { objects: @memos } %>
<script>
$(".magic-checkbox").on("click", function() {
var $link = $(this);
var id = $link.data('id');
var url = $link.data('url');
var checked = $link.is(':checked');
$.ajax({
url: url,
type: 'post',
data: {
id: id,
checked: checked
},
dataType: 'json',
success: function(data) {
if ($link.data('type') === 'hidden') {
console.log('#home_show_' + id, !checked);
$('#home_show_' + id).attr('disabled', !checked);
if (checked) {
$('.delete-link-' + id).hide();
} else {
$('.delete-link-' + id).show();
}
}
},
error: function() {
notice_box('操作失败');
$link.attr('checked', !checked);
}
})
});
</script>

View File

@ -0,0 +1 @@
$("#apply_destroy_memo_<%= params[:id] %>").remove()

View File

@ -0,0 +1,9 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('申请删帖', admins_apply_destroy_index_path) %>
<% end %>
<div class="edu-class-container">
<div class="ex_container" id="apply_destory_memos">
<%= render :partial => "admins/apply_destroy/apply_destroy_memos_list" %>
</div>
</div>

View File

@ -0,0 +1 @@
$("#apply_destory_memos").html('<%= escape_javascript( render :partial => 'admins/apply_destroy/apply_destroy_memos_list') %>');

View File

@ -1,9 +1,7 @@
<div class="edu-back-white pl30 pr30 mb30">
<% if @banned_users_count == 0 %>
<%= render :partial => "welcome/no_data" %>
<% else %>
<% if @banned_users_count > 0 %>
<% @banned_users.each do |ban| %>
<% user = ban.user %>
<% author = ban.author %>
@ -13,15 +11,15 @@
<%= image_tag(url_to_avatar(user),width:"50px",height:"50px",class:"radius mr15") %>
<div class="flex1">
<li class="clearfix mb20">
<%= link_to user.try(:show_name),user,class: "fl mr15 color-grey-3 font-16" %>
<%= link_to user.try(:show_real_name),user,class: "fl mr15 color-grey-3 font-16" %>
<span class="fl color-grey-9 mt3 mr15"><%= time_from_now(ban.updated_at) %></span>
<span class="fl color-grey-9 mt3">第<span class="color-orange"><%= ban.banned_count %></span>次 被禁言</span>
<span class="fr">
<% if @banned_type == "banned" %>
<% remove_ban_message = "是否确认解除"+"\"#{user.try(:show_name)}\""+"的禁言?" %>
<% remove_ban_message = "是否确认解除"+"\"#{user.try(:show_real_name)}\""+"的禁言?" %>
<%= link_to "取消禁言", "javascript:void(0)", class: "color-blue_4C", onclick: "custom_confirm_remote_box('#{confirm_banned_admin_banned_users_path(user_id: user.id, id: memo.id)}','#{remove_ban_message}','post');"%>
<% else %>
<%= link_to author.try(:show_name), user_path(author), class: "" %>
<%= link_to author.try(:show_real_name), user_path(author), class: "" %>
<span class="color-grey-9 ml20">
<%= time_from_now(ban.updated_at) %>
</span>
@ -29,19 +27,12 @@
</span>
</li>
<div class="color-grey-9">
在【<span class="max-width-300"><%= link_to memo.subject.truncate(50), "forums/#{memo.id}", class: "color-blue_4C" %></span>】被<%= author_type %><%= link_to author.try(:show_name), user_path(author), class: "" %> 禁言
在【<span class="max-width-300"><%= link_to memo.subject.truncate(50), "forums/#{memo.id}", class: "color-blue_4C" %></span>】被<%= author_type %><%= link_to author.try(:show_real_name), user_path(author), class: "" %> 禁言
</div>
</div>
</div>
<% end %>
<% end %>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @banned_users_pages, @banned_users_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<%= render partial: 'admins/shared/paginate', locals: { objects: @banned_users } %>
</div>

View File

@ -0,0 +1,32 @@
<div class="box admin-list-container users-list-container">
<ul class="fl mt2 nav_blueline_status">
<li class="<%= @banned_type == "banned" ? "active" : "" %>" >
<%= link_to "禁言用户 #{@banned_users_size > 0 ? "(#{@banned_users_size})" : ""}", admins_banned_users_path(banned_type: "banned"),remote: true %>
</li>
<li class="<%= @banned_type == "unbanned" ? "active" : "" %>">
<%= link_to "解除禁言记录", admins_banned_users_path(banned_type: "unbanned"),remote: true %>
</li>
</ul>
<ul class="fr">
<input type="text" name="search_banned_user" value="<%= @search_params %>" class="form-control mr15 fl width240" placeholder="请输入用户名称进行搜索">
<a href="javascript:void(0)" class="btn btn-primary fl mr15 btn-sm" id="searchBanned">搜索</a>
<%= link_to "清除", admins_banned_users_path(search: nil, banned_type: @banned_type),remote: true, class: "btn btn-secondary fl btn-sm" %>
</ul>
</div>
<div id="banned-user-item">
<%= render partial: "admins/banned_users/banned_user_item" %>
</div>
<script>
$("#searchBanned").on("click",function () {
let task_status = "<%= @banned_type %>";
let search_name =$("input[name='search_banned_user']").val();
$.ajax({
url: "<%= admins_banned_users_path %>",
type: "get",
dataType: "script",
data: {banned_type:task_status,search: search_name }
});
});
</script>

View File

@ -0,0 +1,6 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('禁言列表', admins_banned_users_path) %>
<% end %>
<div class="edu-class-container" id="banned-users-container">
<%= render partial: "admins/banned_users/banned_users_items" %>
</div>

View File

@ -0,0 +1 @@
$("#banned-users-container").html("<%= j render partial: "admins/banned_users/banned_users_items" %>")

View File

@ -0,0 +1,33 @@
<div class="box admin-list-container users-list-container">
<ul class="fl mt2 nav_blueline_status">
<li class="<%= @select_type == "unconfirm" ? "active" : "" %>" >
<%= link_to "待审批", admins_forum_applies_path(select_type: "unconfirm"),remote: true %>
</li>
<li class="<%= @select_type == "confirm" ? "active" : "" %>">
<%= link_to "已审批", admins_forum_applies_path(select_type: "confirm"),remote: true %>
</li>
</ul>
<ul class="fr">
<input type="text" name="search_section_name" value="<%= @section_name %>" class="form-control mr15 fl width240 " placeholder="请输入板块名称进行检索">
<input type="text" name="search_user_name" value="<%= @search_name %>" class="form-control mr15 fl width240 " placeholder="请输入用户名称进行检索">
<a href="javascript:void(0)" class="btn btn-primary fl mr15 mt2 btn-sm" id="searchApplies">搜索</a>
<%= link_to "清除", admins_forum_applies_path(user_name: nil,section_name: nil, select_type: @select_type),remote: true, class: "btn btn-secondary fl btn-sm" %>
</ul>
</div>
<div id="forum-apply-item">
<%= render partial: "admins/forum_applies/forum_apply_item" %>
</div>
<script>
$("#searchApplies").on("click",function () {
let select_status = "<%= @select_type %>";
let search_name =$("input[name='search_user_name']").val();
let section_name = $("input[name='search_section_name']").val();
$.ajax({
url: "<%= admins_forum_applies_path %>",
type: "get",
dataType: "script",
data: {select_type:select_status,user_name: search_name, section_name: section_name }
});
});
</script>

View File

@ -1,8 +1,6 @@
<div class="edu-back-white pl30 pr30 mb30">
<!-- 签订协议托管-待审批 -->
<% if @forum_applies_count == 0 %>
<%= render :partial => "welcome/no_data" %>
<% else %>
<% if @forum_applies_count > 0 %>
<% @forum_applies.each do |apply| %>
<% user = apply&.user %>
<% if user.present? %>
@ -13,14 +11,8 @@
<% end %>
<% end %>
<div style="text-align:center;" class="new_expand">
<div class="pages_user_show" style="width:auto; display:inline-block;margin: 18px 0;">
<ul id="homework_pository_ref_pages">
<%= pagination_links_full @forum_applies_pages, @forum_applies_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
</ul>
<div class="cl"></div>
</div>
</div>
<%= render partial: 'admins/shared/paginate', locals: { objects: @forum_applies } %>
</div>
<script type="text/javascript">

View File

@ -1,7 +1,7 @@
<%= image_tag(url_to_avatar(user),width:"50px",height:"50px",class:"radius mr15") %>
<div class="flex1">
<li class="clearfix mb20">
<%= link_to user.try(:show_name),user_path(user),class: "fl mr15 color-grey-3 font-16" %>
<%= link_to user.try(:show_real_name),user_path(user),class: "fl mr15 color-grey-3 font-16" %>
<span class="fl color-grey-9 mt3"><%= time_from_now(apply.updated_at) %></span>
<span class="fl color-grey-9 mt3 ml50">IP<%= user_ip_addr apply.user_ip %></span>
<span class="fr">
@ -9,7 +9,7 @@
<% apply_user = apply&.reviews&.acted_forum&.last&.user %>
<% if apply_user.present? %>
<span class="fl mr20">
<%= link_to apply_user.try(:show_name), user_path(apply_user) %>
<%= link_to apply_user.try(:show_real_name), user_path(apply_user) %>
</span>
<% end %>
<% if apply.is_confirm == 2 %>
@ -20,7 +20,8 @@
<% end %>
<% else %>
<%= link_to "私信", message_detail_user_path(current_user, :user_id => apply.user_id), :class => "edu-default-btn edu-orangeline-btn ml20 fl",target:"_blank" %>
<a href="javascript:void(0)" class="edu-default-btn edu-blueline-btn ml20 fl" onclick='custom_confirm_remote_box("<%= confirm_apply_admin_forum_apply_path(id:apply.id,review_result:"0") %>","是否同意申请版主?","post");'>同意</a>
<%= link_to "同意", confirm_apply_admins_forum_apply_path(id:apply.id,review_result:"0"),remote: true, method: :post, class: "edu-default-btn edu-blueline-btn ml20 fl", data:{confirm: "是否同意申请版主?"} %>
<%# <%= link_to "拒绝", confirm_apply_admins_forum_apply_path(id:apply.id,review_result:"0"),remote: true, method: :post, class: "edu-default-btn edu-blueline-btn ml20 fl", data:{confirm: "是否同意申请版主?"} %> %>
<a href="javascript:void(0)" class="edu-default-btn edu-greyline-btn ml20 fl" onclick="refuseClick(<%= apply.id %>)">拒绝</a>
<% end %>
</span>
@ -32,7 +33,7 @@
<p class="color-orange lineh-35 mt10"><span class="fl color-orange mr5">拒绝原因:</span><%= apply&.reviews&.apply_forum&.first&.reason.to_s %></p>
<% end %>
<% if apply.is_confirm != 2 %>
<%= labelled_form_for apply, :url => confirm_apply_admin_forum_apply_path(apply, is_confirm: apply.is_confirm), :html => {id:"refuseContent_#{apply.id}",class:"none",method: :post, remote: true} do |f| %>
<%= labelled_form_for apply, :url => confirm_apply_admins_forum_apply_path(apply, is_confirm: apply.is_confirm), :html => {id:"refuseContent_#{apply.id}",class:"none",method: :post, remote: true} do |f| %>
<div class="df mt10">
<input type="hidden" id="review_result_type" name="review_result" value="1" />
<span class="refuse_reason color-orange mr5"><%= apply.is_confirm == 0 ? "拒绝原因" : "撤销审核原因" %>:</span>

View File

@ -3,7 +3,7 @@
<% if @is_confirm == 0 %>
$("#forum-apply-action-<%= @forum_apply.id %>").remove()
<% else %>
$("#forum-apply-action-<%= @forum_apply.id %>").html("<%= j render partial: "admin/forum_applies/item_list", locals: {user: @forum_apply.user, apply: @forum_apply} %>")
$("#forum-apply-action-<%= @forum_apply.id %>").html("<%= j render partial: "admins/forum_applies/item_list", locals: {user: @forum_apply.user, apply: @forum_apply} %>")
<% end %>
<% end %>
op_know("<%= @message %>")

View File

@ -0,0 +1,7 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('版主审批', admins_forum_applies_path) %>
<% end %>
<div class="edu-class-container" id="forum-applies-container">
<%= render partial: "admins/forum_applies/forum_applies_items" %>
</div>

View File

@ -1 +1 @@
$("#forum-applies-container").html("<%= j render partial: "admin/forum_applies/forum_applies_items" %>")
$("#forum-applies-container").html("<%= j render partial: "admins/forum_applies/forum_applies_items" %>")

View File

@ -0,0 +1,12 @@
<% if users.present? && users.size > 0 %>
<% users.each do |u| %>
<% user = u.user %>
<span class="moderator-list-content">
<span class="blue-user-btn" id="forum_section_moderator_user_<%= u.id %>">
<span class="mr5"><%= link_to user.try(:show_real_name), user_path(user) %></span>
<span><%= link_to "<i class='fa fa-close font16'></i>".html_safe,admins_forum_section_forum_moderator_path(forum, u), method: :delete, data:{confirm: "确认删除吗?"}, remote: true, class: "color-grey-9" %></span>
</span>
</span>
<% end %>
<% end %>

View File

@ -0,0 +1,4 @@
<% if @forum_status > 0 %>
$("#forum_sections_moderators_<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_moderators/forum_moderator_item", locals: {users: @forum_moderators, forum: @forum_section} %>")
$('#admin-managers-modal').modal("hide")
<% end %>

View File

@ -1,11 +1,13 @@
var htmlvalue = "<%= j render :partial => 'admin/forum_moderators/new_forum_moderators' %>";
pop_box_new(htmlvalue, 520, 400);
var htmlvalue = "<%= j render :partial => 'admins/forum_moderators/shared/form'%>";
$("#admin-forum-managers-content").html(htmlvalue)
$('#admin-managers-modal').modal('show')
function search_forum_users(target) {
var t_value = $("#"+ target).val()
$.ajax({
type: "POST",
url:'/admin/forum_sections/<%= @forum_section.id %>/forum_moderators/search_user?user_name='+t_value,
url:'/admins/forum_sections/<%= @forum_section.id %>/forum_moderators/search_user?user_name='+t_value,
dataType:'JSON',
success: function (data) {
if(data.html.length > 0){

View File

@ -0,0 +1,26 @@
<div class="modal-header">
<h5 class="modal-title">
添加版主
</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<%= simple_form_for(ForumModerator.new, url: admins_forum_section_forum_moderators_path(@forum_section), html: { remote: true}) do |f|%>
<div class="modal-body">
<div class="task-popup-content mt10">
<div class="grid-item-left">
<%= text_field_tag :user_name,nil,class: "form-control input-lg" ,id: "search-forum-moderators",placeholder: "请输入用户的名称搜索" %>
<%= link_to "搜索", "javascript:void(0)", class: "btn btn-primary btn-sm ml20", onclick: "search_forum_users('search-forum-moderators')", disable_with: '搜索中...' %>
</div>
<div id="has-none-moderators" class="none forum-moderators-items">
</div>
<div id="forum-moderators-show" class="none forum-moderators-items">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= f.submit "确定", disable_with: '提交中...', class: "btn btn-primary submit-btn" %>
</div>
<% end %>

View File

@ -0,0 +1,8 @@
<a href="javascript:void(0)" class="fl" ><%= children_forum.try(:title) %></a>
<span href="javascript:void(0)" class="menu_operate ml20 fr" onclick="first_menu_action(this)">
<i class="fa fa-ellipsis-v color-grey-6"></i>
<div class="operateList">
<%= link_to "重命名", edit_admins_forum_section_path(children_forum, children_forum: true), remote: true %>
<%= link_to "删除", admins_forum_section_path(children_forum, children_forum: true),method: :delete, data:{confirm: "确认删除吗?"}, remote: true %>
</div>
</span>

View File

@ -2,7 +2,7 @@
<ul class="set_l_submenu">
<% children_forums.each do |children_forum| %>
<li class="clearfix" id="children-forum-detail-<%= children_forum.id %>">
<%= render partial: "admin/forum_sections/children_forum_detail", locals: {children_forum: children_forum} %>
<%= render partial: "admins/forum_sections/children_forum_detail", locals: {children_forum: children_forum} %>
</li>
<% end %>
</ul>

View File

@ -3,7 +3,7 @@
<div class="task-popup-title clearfix f14">
<%= @forum_section.parent_id.present? ? "重命名二级版块" : "重命名一级版块" %>
</div>
<%= form_tag(admin_forum_section_path(@forum_section, children_forum: @children_forum), method: :put, class: "", remote: true) do %>
<%= form_tag(admins_forum_section_path(@forum_section, children_forum: @children_forum), method: :put, class: "", remote: true) do %>
<div class="task-popup-content ml55">
<div class="grid-item-top">
<span class="mr10 color-grey">名称:</span>
@ -24,13 +24,13 @@
<div>
<div class="upload-image-100 pointer" onclick="$('#_file_section_picture').click();" id="admin-logo-upload">
<% if @attachment.present? %>
<%= render partial: "admin/forum_sections/show_image_forum", locals: {logo_url: download_attachment_path(@attachment.id), attachment: @attachment, image_type: 'image'} %>
<%= render partial: "admins/forum_sections/show_image_forum", locals: {logo_url: download_attachment_path(@attachment.id), attachment: @attachment, image_type: 'image'} %>
<% else %>
<div style="line-height: 100px;">上传封面</div>
<% end %>
</div>
<div class="none poa top-bottom-0">
<%=render partial: "admin/forum_sections/upload_logo" %>
<%=render partial: "admins/forum_sections/upload_logo" %>
</div>
<div class="font-12 color-grey">
尺寸 100*100支持.jpg .jpeg .bmp .gif .png格式照片。

View File

@ -0,0 +1,3 @@
<tr id="forum-section-detail-<%= forum.id %>">
<%= render partial: "admins/forum_sections/td_forum_section", locals: {forum: forum} %>
</tr>

View File

@ -0,0 +1,68 @@
<div class="box admin-list-container users-list-container">
<table class="table table-hover users-list-table">
<thead class="thead-light">
<tr>
<th width="30%" class="edu-txt-left">
<span class="pl15">版块</span>
<%= link_to "<i class='fa fa-plus-circle'></i>".html_safe,new_admins_forum_section_path, remote: true, class: "btn btn-primary btn-sm" %>
</th>
<th width="30%">主页推荐</th>
<th width="40%" class="edu-txt-left"><span class="pl15">一级版主任命/解除</span></th>
</tr>
</thead>
<tbody id="forum-section-contents">
<% if @forum_sections_count > 0 %>
<% @forum_sections.each do |forum| %>
<%= render partial: "admins/forum_sections/forum_section_detail", locals: {forum: forum} %>
<% end %>
<% else %>
<tr id="forum-section-detail-no-data">
<td colspan="100">
没有数据
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div class="edu-back-white mt10">
<%= render partial: 'admins/shared/paginate', locals: { objects: @forum_sections } %>
</div>
<script>
function first_menu_click(that) {
var target = $(that);
var menu_i = target.find(".fa");
var children_tags = target.parent().parent().find(".set_l_submenu");
if(menu_i.hasClass("fa-plus-square-o")){
menu_i.removeClass("fa-plus-square-o").addClass("fa-minus-square-o");
children_tags.addClass("active")
}else{
menu_i.removeClass("fa-minus-square-o").addClass("fa-plus-square-o");
children_tags.removeClass("active")
}
}
function first_menu_action(that) {
console.log('ddddd')
var target = $(that);
var target_action = target.find(".operateList");
if(target_action.hasClass("active")){
$(".operateList").removeClass("active");
target_action.removeClass("active");
}else {
$(".operateList").removeClass("active");
target_action.addClass("active");
}
}
function recommend_form_submit(id) {
$("#"+id).trigger("click")
}
$(document).mouseup(function(e){
var _con = $('.menu_operate'); // 设置目标区域
if(!_con.is(e.target) && _con.has(e.target).length === 0){
_con.find(".operateList").removeClass("active")
}
});
</script>

View File

@ -0,0 +1,29 @@
<div class="task-popup" style="width:500px;"><div class="task-popup-title clearfix">提示</div>
<div class="task-popup-content">
<div class="df padding10-20">
<span class="fl mt3">名称:</span>
<div class="flex1">
<input type="text" class="input-100-35" name="itemName" placeholder="请输入名称最大限制20个字符"/>
<p class="mt5" style="height: 18px;line-height: 18px"><span class="color-red none" id="name_notice">请输入名称</span></p>
</div>
</div>
</div>
<div class="clearfix mb20 edu-txt-center">
<a href="javascript:void(0);" class="task-btn mr25" onclick="hideModal();">取消</a>
<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="sureFun();">确定</a>
</div>
</div>
<script>
function sureFun() {
var name=$("input[name='itemName']").val();
if(name == ""){
$("#name_notice").removeClass("none").html("请输入名称");
return;
}else if(name.length > 20){
$("#name_notice").removeClass("none").html("名称内容不能超过20个字符");
return;
}else{
$("#name_notice").addClass("none").html("");
}
}
</script>

View File

@ -1,5 +1,5 @@
<p class="ml10">
<%= form_tag(recommend_forums_admin_forum_section_path(forum), method: :post, remote: true) do %>
<%= form_tag(recommend_forums_admins_forum_section_path(forum), method: :post, remote: true) do %>
<span class="fl mr15">
<%= radio_button_tag :is_recommend, 0, forum.is_recommend == 0, id: "forum_is_recommend_#{forum.id}_0", class: "magic-radio", onchange: "recommend_form_submit('forum_recommend_submit_#{forum.id}')" %>
<label for="forum_is_recommend_<%= forum.id %>_0">不推荐</label>

View File

@ -0,0 +1,41 @@
<td>
<div class="set_l_main">
<div class="set_l_premenu">
<span class="ml10 max-width-300" onclick="first_menu_click(this)">
<i class="fa fa-plus-square-o color-grey-6"></i>
<span class="ml5"><%= forum.try(:title) %></span>
</span>
<span href="javascript:void(0)" class="menu_operate ml20" onclick="first_menu_action(this)">
<i class="fa fa-ellipsis-v color-grey-6"></i>
<div class="operateList">
<%= link_to "重命名", edit_admins_forum_section_path(forum), remote: true %>
<%= link_to "删除", admins_forum_section_path(forum),method: :delete, data:{confirm: "确认删除吗?"}, remote: true %>
<%= link_to "新增子版块".html_safe, new_admins_forum_section_path(parent_id: forum.id),remote: true %>
<% if forum&.position.to_i != @min_position %>
<%= link_to "下移",move_admins_forum_section_path(forum,opr:"down"), method: :post, remote: true %>
<% end %>
<% if forum&.position.to_i != @max_position %>
<%= link_to "上移",move_admins_forum_section_path(forum,opr:"up"), method: :post, remote: true %>
<% end %>
</div>
</span>
</div>
<div id="children-forum-section-<%= forum.id %>">
<%= render partial: "admins/forum_sections/children_forum_sections", locals: {children_forums: forum.get_children_section("desc")} %>
</div>
</div>
</td>
<td id="forum-section-recommend-<%= forum.id %>">
<%= render partial: "admins/forum_sections/recommend_forum_sections", locals: {forum: forum} %>
</td>
<td>
<div class="grid-item pbt5">
<div class="grid-item-1">
<%= link_to "<i class='fa fa-plus-square-o'></i>".html_safe,new_admins_forum_section_forum_moderator_path(forum), class: "font-20 color-blue mr10", title: "添加版主", remote: true %>
</div>
<div class="width100 inline-block edu-txt-left" id="forum_sections_moderators_<%= forum.id %>">
<%= render partial: "admins/forum_moderators/forum_moderator_item", locals: {users: forum.forum_moderators, forum: forum} %>
</div>
</div>
</td>

View File

@ -0,0 +1,27 @@
<%= file_field_tag 'attachments[dummy][file]',
:id => "_file_section_picture",
:class => 'file_selector',
:onchange => "addInputFiles_board()",
:style =>'display:none',
accept: 'image/png,image/gif,image/jpeg,image/jpg,image/bmp',
:data => {
:max_file_size => 5120.kilobytes,
:max_concurrent_uploads => 1,
:upload_path => attachments_upload_images_path(:format => 'js'),
} %>
<script>
function addInputFiles_board() {
var formData = new FormData();
formData.append('file', $('input[name="attachments[dummy][file]"]')[0].files[0]);
$.ajax({
url: "<%= attachments_upload_images_path %>",
type: 'POST',
data: formData,
processData: false,
contentType: false,
})
}
</script>

View File

@ -0,0 +1,12 @@
<% if @forum_status[:status] == 0 %>
$("#add-section-forum").removeClass("none").html("<%= j render partial: "admins/forum_sections/shared/error_section", locals: {error_messages: @forum_status[:msg] } %>")
<% else %>
$("#add-section-forum").addClass("none")
<% if @forum_section.parent_id.present? %>
$("#forum-section-detail-<%= @forum_section.parent_id %>").html("<%= j render partial: "admins/forum_sections/td_forum_section", locals: {forum: @parent_forum} %>")
<% else %>
$("#forum-section-contents").prepend("<%= j render partial: "admins/forum_sections/forum_section_detail", locals: {forum: @forum_section} %>")
<% end %>
$('#admin-forum-section-modal').modal("hide")
<% end %>

View File

@ -0,0 +1,7 @@
<% if @delete_status[:status] > 0 %>
<% if params[:children_forum] %>
$("#children-forum-detail-<%= @forum_section.id %>").remove()
<% else %>
$("#forum-section-detail-<%= @forum_section.id %>").remove()
<% end %>
<% end %>

Some files were not shown because too many files have changed in this diff Show More