From 141bf1a4883222a62c6eedd83873372c7a07a10c Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Tue, 13 Oct 2020 14:35:18 +0800 Subject: [PATCH 1/6] Add Memo API --- Gemfile | 2 +- Gemfile.lock | 30 --- app/api/mobile/api.rb | 107 -------- app/api/mobile/apis/auth.rb | 60 ----- app/api/mobile/apis/forum_sections.rb | 199 --------------- app/api/mobile/apis/memos.rb | 241 ------------------ app/api/mobile/apis/my_memos.rb | 32 --- app/api/mobile/exceptions/auth_exception.rb | 13 - app/api/mobile/middleware/error_handler.rb | 26 -- .../admins/forum_moderators_controller.rb | 2 +- app/controllers/forum_sections_controller.rb | 101 ++++++++ app/controllers/memos_controller.rb | 109 ++++++++ app/controllers/my_memos_controller.rb | 22 ++ app/helpers/api_helper.rb | 6 +- app/helpers/api_index_helper.rb | 15 +- app/models/block_user.rb | 4 + app/models/concerns/watchable.rb | 6 +- app/models/forum_section.rb | 1 + app/models/memo.rb | 113 +------- app/models/memo_message.rb | 2 + app/models/praise_tread.rb | 4 + app/models/user.rb | 11 +- .../banned_users/_banned_user_item.html.erb | 8 +- .../admins/forum_applies/_item_list.html.erb | 4 +- .../_forum_moderator_item.html.erb | 2 +- .../admins/memos/_my_count_message.html.erb | 2 +- .../memos/_my_show_count_message.html.erb | 2 +- app/services/admins/memos/edit.html.erb | 2 +- app/services/admins/memos/new.html.erb | 2 +- app/services/admins/memos/show.html.erb | 6 +- app/services/forum_sections_service.rb | 17 +- app/services/memos_service.rb | 92 ++++--- app/services/my_memos_service.rb | 2 +- app/services/projects/apply_join_service.rb | 2 +- .../admins/memos/_memo_reply_list.html.erb | 2 +- app/views/admins/memos/_message_list.html.erb | 2 +- config/application.rb | 7 - config/initializers/autoreload_grape.rb | 26 -- config/routes.rb | 47 +++- .../20201013023832_change_memo_null_true.rb | 5 + ...1013030153_add_memo_image_to_attachment.rb | 6 + .../20201013032846_create_block_users.rb | 11 + .../20201013035058_create_memo_messages.rb | 12 + spec/models/block_user_spec.rb | 5 + spec/models/memo_message_spec.rb | 5 + 45 files changed, 452 insertions(+), 923 deletions(-) delete mode 100644 app/api/mobile/api.rb delete mode 100644 app/api/mobile/apis/auth.rb delete mode 100644 app/api/mobile/apis/forum_sections.rb delete mode 100644 app/api/mobile/apis/memos.rb delete mode 100644 app/api/mobile/apis/my_memos.rb delete mode 100644 app/api/mobile/exceptions/auth_exception.rb delete mode 100644 app/api/mobile/middleware/error_handler.rb create mode 100644 app/controllers/forum_sections_controller.rb create mode 100644 app/controllers/memos_controller.rb create mode 100644 app/controllers/my_memos_controller.rb create mode 100644 app/models/block_user.rb create mode 100644 app/models/memo_message.rb delete mode 100644 config/initializers/autoreload_grape.rb create mode 100644 db/migrate/20201013023832_change_memo_null_true.rb create mode 100644 db/migrate/20201013030153_add_memo_image_to_attachment.rb create mode 100644 db/migrate/20201013032846_create_block_users.rb create mode 100644 db/migrate/20201013035058_create_memo_messages.rb create mode 100644 spec/models/block_user_spec.rb create mode 100644 spec/models/memo_message_spec.rb diff --git a/Gemfile b/Gemfile index 989571b6..83963a31 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 58b9a89f..9190d340 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb deleted file mode 100644 index 7a3586bd..00000000 --- a/app/api/mobile/api.rb +++ /dev/null @@ -1,107 +0,0 @@ -#coding=utf-8 -# status值 -# 0:成功;-1:500错误;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 - - diff --git a/app/api/mobile/apis/auth.rb b/app/api/mobile/apis/auth.rb deleted file mode 100644 index 9f89d56d..00000000 --- a/app/api/mobile/apis/auth.rb +++ /dev/null @@ -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 - - diff --git a/app/api/mobile/apis/forum_sections.rb b/app/api/mobile/apis/forum_sections.rb deleted file mode 100644 index a5ffc682..00000000 --- a/app/api/mobile/apis/forum_sections.rb +++ /dev/null @@ -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 diff --git a/app/api/mobile/apis/memos.rb b/app/api/mobile/apis/memos.rb deleted file mode 100644 index 8e4b82dc..00000000 --- a/app/api/mobile/apis/memos.rb +++ /dev/null @@ -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 \ No newline at end of file diff --git a/app/api/mobile/apis/my_memos.rb b/app/api/mobile/apis/my_memos.rb deleted file mode 100644 index 921e7700..00000000 --- a/app/api/mobile/apis/my_memos.rb +++ /dev/null @@ -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 diff --git a/app/api/mobile/exceptions/auth_exception.rb b/app/api/mobile/exceptions/auth_exception.rb deleted file mode 100644 index 5dceab57..00000000 --- a/app/api/mobile/exceptions/auth_exception.rb +++ /dev/null @@ -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 diff --git a/app/api/mobile/middleware/error_handler.rb b/app/api/mobile/middleware/error_handler.rb deleted file mode 100644 index 40eaa581..00000000 --- a/app/api/mobile/middleware/error_handler.rb +++ /dev/null @@ -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 diff --git a/app/controllers/admins/forum_moderators_controller.rb b/app/controllers/admins/forum_moderators_controller.rb index e028890b..0356952b 100644 --- a/app/controllers/admins/forum_moderators_controller.rb +++ b/app/controllers/admins/forum_moderators_controller.rb @@ -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 = "" + check_html = "" return_html << check_html end end diff --git a/app/controllers/forum_sections_controller.rb b/app/controllers/forum_sections_controller.rb new file mode 100644 index 00000000..30209574 --- /dev/null +++ b/app/controllers/forum_sections_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb new file mode 100644 index 00000000..0b84acfe --- /dev/null +++ b/app/controllers/memos_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/my_memos_controller.rb b/app/controllers/my_memos_controller.rb new file mode 100644 index 00000000..b3758601 --- /dev/null +++ b/app/controllers/my_memos_controller.rb @@ -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 \ No newline at end of file diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index c03f7e05..fdbe0cf9 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -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 diff --git a/app/helpers/api_index_helper.rb b/app/helpers/api_index_helper.rb index 47f26813..2010f99a 100644 --- a/app/helpers/api_index_helper.rb +++ b/app/helpers/api_index_helper.rb @@ -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), diff --git a/app/models/block_user.rb b/app/models/block_user.rb new file mode 100644 index 00000000..1386f6b4 --- /dev/null +++ b/app/models/block_user.rb @@ -0,0 +1,4 @@ +class BlockUser < ApplicationRecord + belongs_to :user + scope :block_user_present, ->(target_id){where(block_user_id: target_id)} +end diff --git a/app/models/concerns/watchable.rb b/app/models/concerns/watchable.rb index 4c52cf99..7d45d6ef 100644 --- a/app/models/concerns/watchable.rb +++ b/app/models/concerns/watchable.rb @@ -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 diff --git a/app/models/forum_section.rb b/app/models/forum_section.rb index 35d36b5d..5ea76832 100644 --- a/app/models/forum_section.rb +++ b/app/models/forum_section.rb @@ -1,4 +1,5 @@ class ForumSection < ApplicationRecord + include Watchable has_ancestry #论坛板块的表 # attr_accessible :title, :body diff --git a/app/models/memo.rb b/app/models/memo.rb index f4c1bc76..f74f4c39 100644 --- a/app/models/memo.rb +++ b/app/models/memo.rb @@ -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: [''], - # post_tags: [''], - # 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 diff --git a/app/models/memo_message.rb b/app/models/memo_message.rb new file mode 100644 index 00000000..80e6d442 --- /dev/null +++ b/app/models/memo_message.rb @@ -0,0 +1,2 @@ +class MemoMessage < ApplicationRecord +end diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb index cdfdbea2..cb6afa78 100644 --- a/app/models/praise_tread.rb +++ b/app/models/praise_tread.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index beb0810d..6a9678f6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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}") diff --git a/app/services/admins/banned_users/_banned_user_item.html.erb b/app/services/admins/banned_users/_banned_user_item.html.erb index de661c7d..6fd44065 100644 --- a/app/services/admins/banned_users/_banned_user_item.html.erb +++ b/app/services/admins/banned_users/_banned_user_item.html.erb @@ -13,15 +13,15 @@ <%= image_tag(url_to_avatar(user),width:"50px",height:"50px",class:"radius mr15") %>
  • - <%= 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" %> <%= time_from_now(ban.updated_at) %> <%= ban.banned_count %>次 被禁言 <% 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: "" %> <%= time_from_now(ban.updated_at) %> @@ -29,7 +29,7 @@
  • - 在【<%= link_to memo.subject.truncate(50), "forums/#{memo.id}", class: "color-blue_4C" %>】被<%= author_type %>:<%= link_to author.try(:show_name), user_path(author), class: "" %> 禁言 + 在【<%= link_to memo.subject.truncate(50), "forums/#{memo.id}", class: "color-blue_4C" %>】被<%= author_type %>:<%= link_to author.try(:show_real_name), user_path(author), class: "" %> 禁言
    diff --git a/app/services/admins/forum_applies/_item_list.html.erb b/app/services/admins/forum_applies/_item_list.html.erb index f78f50ee..c9863079 100644 --- a/app/services/admins/forum_applies/_item_list.html.erb +++ b/app/services/admins/forum_applies/_item_list.html.erb @@ -1,7 +1,7 @@ <%= image_tag(url_to_avatar(user),width:"50px",height:"50px",class:"radius mr15") %>
  • - <%= 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" %> <%= time_from_now(apply.updated_at) %> IP:<%= user_ip_addr apply.user_ip %> @@ -9,7 +9,7 @@ <% apply_user = apply&.reviews&.acted_forum&.last&.user %> <% if apply_user.present? %> - <%= link_to apply_user.try(:show_name), user_path(apply_user) %> + <%= link_to apply_user.try(:show_real_name), user_path(apply_user) %> <% end %> <% if apply.is_confirm == 2 %> diff --git a/app/services/admins/forum_moderators/_forum_moderator_item.html.erb b/app/services/admins/forum_moderators/_forum_moderator_item.html.erb index a432bc45..79764db7 100644 --- a/app/services/admins/forum_moderators/_forum_moderator_item.html.erb +++ b/app/services/admins/forum_moderators/_forum_moderator_item.html.erb @@ -2,7 +2,7 @@ <% users.each do |u| %> <% user = u.user %> - <%= link_to user.try(:show_name), user_path(user) %> + <%= link_to user.try(:show_real_name), user_path(user) %> <%= link_to "".html_safe,admin_forum_section_forum_moderator_path(forum, u), method: :delete, data:{confirm: "确认删除吗?"}, remote: true, class: "color-grey-9" %> <% end %> diff --git a/app/services/admins/memos/_my_count_message.html.erb b/app/services/admins/memos/_my_count_message.html.erb index d8b8708b..8ba6b7e0 100644 --- a/app/services/admins/memos/_my_count_message.html.erb +++ b/app/services/admins/memos/_my_count_message.html.erb @@ -4,7 +4,7 @@
  • - <% 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 %>
    吧主:
    <%= user_name %>
    回答:<%= @my_replies_count %> diff --git a/app/services/admins/memos/_my_show_count_message.html.erb b/app/services/admins/memos/_my_show_count_message.html.erb index e1fa37a7..73eb9f25 100644 --- a/app/services/admins/memos/_my_show_count_message.html.erb +++ b/app/services/admins/memos/_my_show_count_message.html.erb @@ -4,7 +4,7 @@
    - <% 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 %>
    吧主:
    <%= user_name %>
    回答:<%= @my_replies_count %> diff --git a/app/services/admins/memos/edit.html.erb b/app/services/admins/memos/edit.html.erb index 96f503fb..ae60f48d 100644 --- a/app/services/admins/memos/edit.html.erb +++ b/app/services/admins/memos/edit.html.erb @@ -1,7 +1,7 @@

    - <%= @user.show_name %> > 讨论 > 编辑 + <%= @user.show_real_name %> > 讨论 > 编辑

    编辑话题

    diff --git a/app/services/admins/memos/new.html.erb b/app/services/admins/memos/new.html.erb index 325febcc..86f40e20 100644 --- a/app/services/admins/memos/new.html.erb +++ b/app/services/admins/memos/new.html.erb @@ -1,7 +1,7 @@

    - <%= @user.show_name %> > 讨论区 > 新建 + <%= @user.show_real_name %> > 讨论区 > 新建

    新建话题

    diff --git a/app/services/admins/memos/show.html.erb b/app/services/admins/memos/show.html.erb index 2cb6d732..84a0fb67 100644 --- a/app/services/admins/memos/show.html.erb +++ b/app/services/admins/memos/show.html.erb @@ -5,7 +5,7 @@

    - <%= @user.show_name %> > 讨论区 + <%= @user.show_real_name %> > 讨论区

    @@ -32,7 +32,7 @@

    - <%= @memo.author.show_name %>更新于<%= time_from_now @memo.updated_at %> + <%= @memo.author.show_real_name %>更新于<%= time_from_now @memo.updated_at %> <% if @memo.try(:reward).present? %> <%= @memo.try(:reward) %> @@ -156,7 +156,7 @@

    - <%= link_to @memo.author.show_name, user_path(@memo.author), :class => "linkBlue2", :target=> "_blank"%>
    + <%= link_to @memo.author.show_real_name, user_path(@memo.author), :class => "linkBlue2", :target=> "_blank"%>
    <%= format_date( @memo.created_at)%>
    diff --git a/app/services/forum_sections_service.rb b/app/services/forum_sections_service.rb index 5146593c..a8bb4a7d 100644 --- a/app/services/forum_sections_service.rb +++ b/app/services/forum_sections_service.rb @@ -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)}", diff --git a/app/services/memos_service.rb b/app/services/memos_service.rb index eafd38ba..59322237 100644 --- a/app/services/memos_service.rb +++ b/app/services/memos_service.rb @@ -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}) diff --git a/app/services/my_memos_service.rb b/app/services/my_memos_service.rb index fcdb68b1..9a98fd32 100644 --- a/app/services/my_memos_service.rb +++ b/app/services/my_memos_service.rb @@ -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) diff --git a/app/services/projects/apply_join_service.rb b/app/services/projects/apply_join_service.rb index 0b57712d..2383b0ca 100644 --- a/app/services/projects/apply_join_service.rb +++ b/app/services/projects/apply_join_service.rb @@ -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 diff --git a/app/views/admins/memos/_memo_reply_list.html.erb b/app/views/admins/memos/_memo_reply_list.html.erb index 15cd94c5..0f74ca9d 100644 --- a/app/views/admins/memos/_memo_reply_list.html.erb +++ b/app/views/admins/memos/_memo_reply_list.html.erb @@ -38,7 +38,7 @@ =end%> - <%= link_to(memo.try(:author).try(:show_name), user_path(memo.author)) %> + <%= link_to(memo.try(:author).try(:show_real_name), user_path(memo.author)) %> <%# if memo.try(:author).try(:realname) == ' '%> <%#= link_to(memo.try(:author), user_path(memo.author)) %> <%# else %> diff --git a/app/views/admins/memos/_message_list.html.erb b/app/views/admins/memos/_message_list.html.erb index d0b74ad9..c7c49009 100644 --- a/app/views/admins/memos/_message_list.html.erb +++ b/app/views/admins/memos/_message_list.html.erb @@ -27,7 +27,7 @@ <%= (@obj_pages.page - 1) * @obj_pages.per_page + index + 1 %> - <%= link_to(memo.try(:author).try(:show_name), user_path(memo.author)) %> + <%= link_to(memo.try(:author).try(:show_real_name), user_path(memo.author)) %> <% if memo.parent_id.nil? || memo.subject.starts_with?('RE:')%> diff --git a/config/application.rb b/config/application.rb index 9aaa900b..fece76eb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -43,12 +43,5 @@ module Educoderplus resource '/*', :headers => :any, :methods => [:get, :post, :delete, :options, :put] end end - config.middleware.use Rack::Cors do - allow do - origins '*' - # location of your API - resource '/api/*', :headers => :any, :methods => [:get, :post, :delete, :options, :put] - end - end end end diff --git a/config/initializers/autoreload_grape.rb b/config/initializers/autoreload_grape.rb deleted file mode 100644 index 5cbfa509..00000000 --- a/config/initializers/autoreload_grape.rb +++ /dev/null @@ -1,26 +0,0 @@ -# if Rails.env.development? -# lib_ruby_files = Dir.glob(File.join("app/api/**", "*.rb")) -# lib_reloader ||= ActiveSupport::FileUpdateChecker.new(lib_ruby_files) do -# # lib_ruby_files.each do |lib_file| -# # puts "start require #{lib_file}" -# # require_dependency(lib_file) -# # end -# # - -# # binding.pry -# # if Object.const_defined?(:Mobile) -# # Object.send(:remove_const, :Mobile) -# # end -# # -# # $".delete_if {|s| s.include?('api/mobile') } -# # require File.join(Rails.root,"app/api/mobile/api.rb") -# Rails.application.reload_routes! -# end - -# ActionDispatch::Callbacks.to_prepare do -# lib_reloader.execute_if_updated -# end - -# end - - diff --git a/config/routes.rb b/config/routes.rb index fe62b0a8..48666388 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,7 +2,7 @@ Rails.application.routes.draw do require 'sidekiq/web' require 'admin_constraint' - mount Mobile::API => '/api' + # mount Mobile::API => '/api' # mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new # Serve websocket cable requests in-process @@ -45,6 +45,51 @@ Rails.application.routes.draw do resources :edu_settings scope '/api' do + get 'my_memos/:login/memos', to: 'my_memos#index' + get 'my_memos/:login/my_interested', to: 'my_memos#my_interested' + get 'my_memos/:login/replies_memos', to: 'my_memos#replies_memos' + get 'my_memos/:login/recommend_memos', to: 'my_memos#recommend_memos' + get 'forum_sections/:id/deal_applies/:apply_id', to: 'forum_sections#deal_applies' + get 'forum_sections/:id/destroy_moderator/:moderator_id', to: 'forum_sections#destroy_moderator' + resources :forum_sections, only: [:index, :create, :destroy] do + collection do + get :select_sections + end + member do + post :user_apply + post :edit_notice + get :forum_section_header + post :rename + get :order_forums + get :search_users + post :add_users + get :managements + get :applied_forums + get :unchecked_memos + get :unchecked_replies + get :checked_memos + end + end + get 'memos/forum_memos/:id', to: 'memos#forum_memos' + get 'memos/forum_memos_head/:id', to: 'memos#forum_memos_head' + get 'memos/forum_memos_right/:id', to: 'memos#forum_memos_right' + post 'forum_memos/:id/is_watch', to: 'memos#is_watch' + resources :memos, only: [:index, :create, :edit, :update, :show, :destroy] do + member do + get :related_memos + post :watch_memo + get :hidden + post :watch_memo + post :memo_hidden + post :reply + get :set_top_or_down + post :is_fine + post :banned_user + get :more_reply + post :confirm_delete + post :plus + end + end resources :sync_forge, only: [:create] do collection do post :sync_users diff --git a/db/migrate/20201013023832_change_memo_null_true.rb b/db/migrate/20201013023832_change_memo_null_true.rb new file mode 100644 index 00000000..a27d6490 --- /dev/null +++ b/db/migrate/20201013023832_change_memo_null_true.rb @@ -0,0 +1,5 @@ +class ChangeMemoNullTrue < ActiveRecord::Migration[5.2] + def change + change_column_null(:memos, :forum_id, true) + end +end diff --git a/db/migrate/20201013030153_add_memo_image_to_attachment.rb b/db/migrate/20201013030153_add_memo_image_to_attachment.rb new file mode 100644 index 00000000..bd19ef2f --- /dev/null +++ b/db/migrate/20201013030153_add_memo_image_to_attachment.rb @@ -0,0 +1,6 @@ +class AddMemoImageToAttachment < ActiveRecord::Migration[5.2] + def change + add_column :attachments, :memo_image, :boolean, default: false + add_column :attachments, :extra_type, :integer, default: 0 + end +end diff --git a/db/migrate/20201013032846_create_block_users.rb b/db/migrate/20201013032846_create_block_users.rb new file mode 100644 index 00000000..cd187efd --- /dev/null +++ b/db/migrate/20201013032846_create_block_users.rb @@ -0,0 +1,11 @@ +class CreateBlockUsers < ActiveRecord::Migration[5.2] + def change + create_table :block_users do |t| + t.integer "user_id" + t.integer "block_user_id" + t.timestamps + end + add_index :block_users, :user_id + add_index :block_users, :block_user_id + end +end diff --git a/db/migrate/20201013035058_create_memo_messages.rb b/db/migrate/20201013035058_create_memo_messages.rb new file mode 100644 index 00000000..38668f5d --- /dev/null +++ b/db/migrate/20201013035058_create_memo_messages.rb @@ -0,0 +1,12 @@ +class CreateMemoMessages < ActiveRecord::Migration[5.2] + def change + create_table :memo_messages do |t| + t.integer "user_id" + t.integer "forum_id" + t.integer "memo_id" + t.string "memo_type" + t.integer "viewed" + t.timestamps + end + end +end diff --git a/spec/models/block_user_spec.rb b/spec/models/block_user_spec.rb new file mode 100644 index 00000000..de136f6f --- /dev/null +++ b/spec/models/block_user_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe BlockUser, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/memo_message_spec.rb b/spec/models/memo_message_spec.rb new file mode 100644 index 00000000..af4831c9 --- /dev/null +++ b/spec/models/memo_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe MemoMessage, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 5639a69f78be12af6f562c838354bd8e80b1bc61 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Tue, 13 Oct 2020 19:25:17 +0800 Subject: [PATCH 2/6] Change Forum --- .../admins/forum_sections/index.js | 4 + .../stylesheets/admins/banned_users.scss | 7 ++ app/assets/stylesheets/admins/common.scss | 31 +++++++ .../stylesheets/admins/forum_sections.scss | 24 +++++ app/assets/stylesheets/admins/memos.scss | 5 ++ .../admins/apply_destroy_controller.rb | 31 +++++++ .../admins/banned_users_controller.rb | 13 +-- .../admins/forum_applies_controller.rb | 13 +-- .../admins/forum_sections_controller.rb | 15 ++-- .../admins/memo_reply_lists_controller.rb | 16 ++++ app/controllers/admins/memos_controller.rb | 68 ++++---------- .../admins/upload_images_controller.rb | 15 ++++ app/models/checked_action.rb | 2 + .../banned_users/_banned_users_items.html.erb | 31 ------- .../admins/banned_users/index.html.erb | 3 - app/services/admins/banned_users/index.js.erb | 1 - .../_forum_applies_items.html.erb | 33 ------- .../admins/forum_applies/index.html.erb | 3 - .../_forum_section_detail.html.erb | 3 - .../admins/forum_sections/_new_forum.html.erb | 49 ---------- .../forum_sections/_upload_logo.html.erb | 19 ---- .../admins/forum_sections/edit.js.erb | 2 - .../admins/forum_sections/index.html.erb | 3 - app/services/admins/forum_sections/new.js.erb | 2 - .../admins/forum_sections/order_forums.js.erb | 1 - .../forum_sections/recommend_forums.js.erb | 1 - .../_apply_destroy_memos_list.html.erb | 71 +++++++++++++++ .../confirm_apply_destroy.js.erb | 1 + app/views/admins/apply_destroy/index.html.erb | 9 ++ app/views/admins/apply_destroy/index.js.erb | 1 + .../banned_users/_banned_user_item.html.erb | 13 +-- .../banned_users/_banned_users_items.html.erb | 32 +++++++ .../admins/banned_users/confirm_banned.js.erb | 0 app/views/admins/banned_users/index.html.erb | 6 ++ app/views/admins/banned_users/index.js.erb | 1 + .../_forum_applies_items.html.erb | 33 +++++++ .../forum_applies/_forum_apply_item.html.erb | 14 +-- .../admins/forum_applies/_item_list.html.erb | 5 +- .../admins/forum_applies/confirm_apply.js.erb | 2 +- app/views/admins/forum_applies/index.html.erb | 7 ++ .../admins/forum_applies/index.js.erb | 2 +- .../_forum_moderator_item.html.erb | 0 .../_new_forum_moderators.html.erb | 0 .../admins/forum_moderators/create.js.erb | 2 +- .../admins/forum_moderators/destroy.js.erb | 0 .../admins/forum_moderators/new.js.erb | 2 +- .../forum_moderators/search_user.js.erb | 0 .../_children_forum_detail.html.erb | 4 +- .../_children_forum_sections.html.erb | 2 +- .../forum_sections/_edit_forum.html.erb | 6 +- .../_forum_section_detail.html.erb | 3 + .../_forums_plateSetting.html.erb | 73 +++++++++++++++ .../_forums_plateSetting_add.html.erb | 29 ++++++ .../admins/forum_sections/_new_forum.html.erb | 45 ++++++++++ .../_recommend_forum_sections.html.erb | 2 +- .../forum_sections/_show_image_forum.html.erb | 0 .../forum_sections/_td_forum_section.html.erb | 14 +-- .../forum_sections/_upload_logo.html.erb | 20 +++++ .../admins/forum_sections/create.js.erb | 4 +- .../admins/forum_sections/destroy.js.erb | 0 app/views/admins/forum_sections/edit.js.erb | 2 + .../admins/forum_sections/index.html.erb | 11 +++ .../admins/forum_sections/index.js.erb | 0 .../admins/forum_sections/move.js.erb | 0 app/views/admins/forum_sections/new.js.erb | 2 + .../admins/forum_sections/order_forums.js.erb | 1 + .../forum_sections/recommend_forums.js.erb | 1 + .../shared/_add_section.html.erb | 54 +++++++++++ .../shared/_error_section.html.erb | 6 ++ .../admins/forum_sections/update.js.erb | 4 +- .../memo_reply_lists/_message_list.html.erb | 89 +++++++++++++++++++ .../admins/memo_reply_lists/index.html.erb | 9 ++ .../admins/memo_reply_lists/index.js.erb | 1 + .../admins/memos/_memo_reply_list.html.erb | 17 +--- app/views/admins/memos/_message_list.html.erb | 30 ++++--- app/views/admins/memos/index.html.erb | 5 +- app/views/admins/memos/index.js.erb | 1 + app/views/admins/shared/_sidebar.html.erb | 6 +- app/views/admins/upload_images/create.js.erb | 3 + config/routes.rb | 17 +++- .../20201013071302_create_checked_actions.rb | 14 +++ spec/models/checked_action_spec.rb | 5 ++ 82 files changed, 775 insertions(+), 301 deletions(-) create mode 100644 app/assets/javascripts/admins/forum_sections/index.js create mode 100644 app/assets/stylesheets/admins/banned_users.scss create mode 100644 app/assets/stylesheets/admins/forum_sections.scss create mode 100644 app/assets/stylesheets/admins/memos.scss create mode 100644 app/controllers/admins/apply_destroy_controller.rb create mode 100644 app/controllers/admins/memo_reply_lists_controller.rb create mode 100644 app/controllers/admins/upload_images_controller.rb create mode 100644 app/models/checked_action.rb delete mode 100644 app/services/admins/banned_users/_banned_users_items.html.erb delete mode 100644 app/services/admins/banned_users/index.html.erb delete mode 100644 app/services/admins/banned_users/index.js.erb delete mode 100644 app/services/admins/forum_applies/_forum_applies_items.html.erb delete mode 100644 app/services/admins/forum_applies/index.html.erb delete mode 100644 app/services/admins/forum_sections/_forum_section_detail.html.erb delete mode 100644 app/services/admins/forum_sections/_new_forum.html.erb delete mode 100644 app/services/admins/forum_sections/_upload_logo.html.erb delete mode 100644 app/services/admins/forum_sections/edit.js.erb delete mode 100644 app/services/admins/forum_sections/index.html.erb delete mode 100644 app/services/admins/forum_sections/new.js.erb delete mode 100644 app/services/admins/forum_sections/order_forums.js.erb delete mode 100644 app/services/admins/forum_sections/recommend_forums.js.erb create mode 100644 app/views/admins/apply_destroy/_apply_destroy_memos_list.html.erb create mode 100644 app/views/admins/apply_destroy/confirm_apply_destroy.js.erb create mode 100644 app/views/admins/apply_destroy/index.html.erb create mode 100644 app/views/admins/apply_destroy/index.js.erb rename app/{services => views}/admins/banned_users/_banned_user_item.html.erb (79%) create mode 100644 app/views/admins/banned_users/_banned_users_items.html.erb rename app/{services => views}/admins/banned_users/confirm_banned.js.erb (100%) create mode 100644 app/views/admins/banned_users/index.html.erb create mode 100644 app/views/admins/banned_users/index.js.erb create mode 100644 app/views/admins/forum_applies/_forum_applies_items.html.erb rename app/{services => views}/admins/forum_applies/_forum_apply_item.html.erb (55%) rename app/{services => views}/admins/forum_applies/_item_list.html.erb (79%) rename app/{services => views}/admins/forum_applies/confirm_apply.js.erb (68%) create mode 100644 app/views/admins/forum_applies/index.html.erb rename app/{services => views}/admins/forum_applies/index.js.erb (60%) rename app/{services => views}/admins/forum_moderators/_forum_moderator_item.html.erb (100%) rename app/{services => views}/admins/forum_moderators/_new_forum_moderators.html.erb (100%) rename app/{services => views}/admins/forum_moderators/create.js.erb (55%) rename app/{services => views}/admins/forum_moderators/destroy.js.erb (100%) rename app/{services => views}/admins/forum_moderators/new.js.erb (85%) rename app/{services => views}/admins/forum_moderators/search_user.js.erb (100%) rename app/{services => views}/admins/forum_sections/_children_forum_detail.html.erb (50%) rename app/{services => views}/admins/forum_sections/_children_forum_sections.html.erb (66%) rename app/{services => views}/admins/forum_sections/_edit_forum.html.erb (83%) create mode 100644 app/views/admins/forum_sections/_forum_section_detail.html.erb create mode 100644 app/views/admins/forum_sections/_forums_plateSetting.html.erb create mode 100644 app/views/admins/forum_sections/_forums_plateSetting_add.html.erb create mode 100644 app/views/admins/forum_sections/_new_forum.html.erb rename app/{services => views}/admins/forum_sections/_recommend_forum_sections.html.erb (91%) rename app/{services => views}/admins/forum_sections/_show_image_forum.html.erb (100%) rename app/{services => views}/admins/forum_sections/_td_forum_section.html.erb (60%) create mode 100644 app/views/admins/forum_sections/_upload_logo.html.erb rename app/{services => views}/admins/forum_sections/create.js.erb (74%) rename app/{services => views}/admins/forum_sections/destroy.js.erb (100%) create mode 100644 app/views/admins/forum_sections/edit.js.erb create mode 100644 app/views/admins/forum_sections/index.html.erb rename app/{services => views}/admins/forum_sections/index.js.erb (100%) rename app/{services => views}/admins/forum_sections/move.js.erb (100%) create mode 100644 app/views/admins/forum_sections/new.js.erb create mode 100644 app/views/admins/forum_sections/order_forums.js.erb create mode 100644 app/views/admins/forum_sections/recommend_forums.js.erb create mode 100644 app/views/admins/forum_sections/shared/_add_section.html.erb create mode 100644 app/views/admins/forum_sections/shared/_error_section.html.erb rename app/{services => views}/admins/forum_sections/update.js.erb (72%) create mode 100644 app/views/admins/memo_reply_lists/_message_list.html.erb create mode 100644 app/views/admins/memo_reply_lists/index.html.erb create mode 100644 app/views/admins/memo_reply_lists/index.js.erb create mode 100644 app/views/admins/memos/index.js.erb create mode 100644 app/views/admins/upload_images/create.js.erb create mode 100644 db/migrate/20201013071302_create_checked_actions.rb create mode 100644 spec/models/checked_action_spec.rb diff --git a/app/assets/javascripts/admins/forum_sections/index.js b/app/assets/javascripts/admins/forum_sections/index.js new file mode 100644 index 00000000..444ee1cf --- /dev/null +++ b/app/assets/javascripts/admins/forum_sections/index.js @@ -0,0 +1,4 @@ +$(document).on('turbolinks:load', function() { + var $addSectionModal = $('.admin-import-user-modal'); + +}); \ No newline at end of file diff --git a/app/assets/stylesheets/admins/banned_users.scss b/app/assets/stylesheets/admins/banned_users.scss new file mode 100644 index 00000000..cc8927bd --- /dev/null +++ b/app/assets/stylesheets/admins/banned_users.scss @@ -0,0 +1,7 @@ +// .admins-banned-users-index-page { +// .width240 { +// width: 240px; +// } +// .mr15{margin-right: 15px;} +// .mt2{margin-top: 2px;} +// } \ No newline at end of file diff --git a/app/assets/stylesheets/admins/common.scss b/app/assets/stylesheets/admins/common.scss index 8d48a67e..7a346464 100644 --- a/app/assets/stylesheets/admins/common.scss +++ b/app/assets/stylesheets/admins/common.scss @@ -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;} } + diff --git a/app/assets/stylesheets/admins/forum_sections.scss b/app/assets/stylesheets/admins/forum_sections.scss new file mode 100644 index 00000000..61ec5cce --- /dev/null +++ b/app/assets/stylesheets/admins/forum_sections.scss @@ -0,0 +1,24 @@ +.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; + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/admins/memos.scss b/app/assets/stylesheets/admins/memos.scss new file mode 100644 index 00000000..159a31d6 --- /dev/null +++ b/app/assets/stylesheets/admins/memos.scss @@ -0,0 +1,5 @@ +.admins-memos-index-page { + .users-list-container { + text-align: center; + } +} \ No newline at end of file diff --git a/app/controllers/admins/apply_destroy_controller.rb b/app/controllers/admins/apply_destroy_controller.rb new file mode 100644 index 00000000..2391014b --- /dev/null +++ b/app/controllers/admins/apply_destroy_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/admins/banned_users_controller.rb b/app/controllers/admins/banned_users_controller.rb index 95ea0f70..7e338d6c 100644 --- a/app/controllers/admins/banned_users_controller.rb +++ b/app/controllers/admins/banned_users_controller.rb @@ -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 diff --git a/app/controllers/admins/forum_applies_controller.rb b/app/controllers/admins/forum_applies_controller.rb index 26afc8f4..7c21bba8 100644 --- a/app/controllers/admins/forum_applies_controller.rb +++ b/app/controllers/admins/forum_applies_controller.rb @@ -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 diff --git a/app/controllers/admins/forum_sections_controller.rb b/app/controllers/admins/forum_sections_controller.rb index ac1933bc..fe55db52 100644 --- a/app/controllers/admins/forum_sections_controller.rb +++ b/app/controllers/admins/forum_sections_controller.rb @@ -9,11 +9,16 @@ 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 diff --git a/app/controllers/admins/memo_reply_lists_controller.rb b/app/controllers/admins/memo_reply_lists_controller.rb new file mode 100644 index 00000000..7878c2e1 --- /dev/null +++ b/app/controllers/admins/memo_reply_lists_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/admins/memos_controller.rb b/app/controllers/admins/memos_controller.rb index d61b906b..bca22de7 100644 --- a/app/controllers/admins/memos_controller.rb +++ b/app/controllers/admins/memos_controller.rb @@ -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 \ No newline at end of file diff --git a/app/controllers/admins/upload_images_controller.rb b/app/controllers/admins/upload_images_controller.rb new file mode 100644 index 00000000..802ea306 --- /dev/null +++ b/app/controllers/admins/upload_images_controller.rb @@ -0,0 +1,15 @@ +class Admins::UploadImagesController < Admins::BaseController + def create + @attachment = Attachment.new(:file => request.raw_post) + @attachment.author = User.current + @attachment.filename = params[:filename].presence || Redmine::Utils.random_hex(16) + if @attachment.save + @status = 1 + else + @status = -1 + end + respond_to do |format| + format.js + end + end +end \ No newline at end of file diff --git a/app/models/checked_action.rb b/app/models/checked_action.rb new file mode 100644 index 00000000..69e8655c --- /dev/null +++ b/app/models/checked_action.rb @@ -0,0 +1,2 @@ +class CheckedAction < ApplicationRecord +end diff --git a/app/services/admins/banned_users/_banned_users_items.html.erb b/app/services/admins/banned_users/_banned_users_items.html.erb deleted file mode 100644 index a95a5272..00000000 --- a/app/services/admins/banned_users/_banned_users_items.html.erb +++ /dev/null @@ -1,31 +0,0 @@ -
    - -
      - - 搜索 - <%= link_to "清除", admin_banned_users_path(search: nil, banned_type: @banned_type),remote: true, class: "edu-default-btn edu-greyback-btn fl mt2 mr15" %> -
    -
    -
    - <%= render partial: "admin/banned_users/banned_user_item" %> -
    - - \ No newline at end of file diff --git a/app/services/admins/banned_users/index.html.erb b/app/services/admins/banned_users/index.html.erb deleted file mode 100644 index 125f526d..00000000 --- a/app/services/admins/banned_users/index.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
    - <%= render partial: "admin/banned_users/banned_users_items" %> -
    diff --git a/app/services/admins/banned_users/index.js.erb b/app/services/admins/banned_users/index.js.erb deleted file mode 100644 index 281629fb..00000000 --- a/app/services/admins/banned_users/index.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#banned-users-container").html("<%= j render partial: "admin/banned_users/banned_users_items" %>") \ No newline at end of file diff --git a/app/services/admins/forum_applies/_forum_applies_items.html.erb b/app/services/admins/forum_applies/_forum_applies_items.html.erb deleted file mode 100644 index 0e6343a5..00000000 --- a/app/services/admins/forum_applies/_forum_applies_items.html.erb +++ /dev/null @@ -1,33 +0,0 @@ -
    - -
      - - - 搜索 - <%= 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" %> -
    -
    -
    - <%= render partial: "admin/forum_applies/forum_apply_item" %> -
    - - \ No newline at end of file diff --git a/app/services/admins/forum_applies/index.html.erb b/app/services/admins/forum_applies/index.html.erb deleted file mode 100644 index a56be3dc..00000000 --- a/app/services/admins/forum_applies/index.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
    - <%= render partial: "admin/forum_applies/forum_applies_items" %> -
    diff --git a/app/services/admins/forum_sections/_forum_section_detail.html.erb b/app/services/admins/forum_sections/_forum_section_detail.html.erb deleted file mode 100644 index 15c85195..00000000 --- a/app/services/admins/forum_sections/_forum_section_detail.html.erb +++ /dev/null @@ -1,3 +0,0 @@ - - <%= render partial: "admin/forum_sections/td_forum_section", locals: {forum: forum} %> - diff --git a/app/services/admins/forum_sections/_new_forum.html.erb b/app/services/admins/forum_sections/_new_forum.html.erb deleted file mode 100644 index 9c105ae5..00000000 --- a/app/services/admins/forum_sections/_new_forum.html.erb +++ /dev/null @@ -1,49 +0,0 @@ -<%=javascript_include_tag '../javascripts/attachments.js' %> -
    -
    - <%= parent_id.present? ? "新建二级版块" : "新建一级版块" %> -
    - <%= form_tag(admin_forum_sections_path, method: :post, class: "", remote: true) do %> - <%= hidden_field_tag :parent_id,parent_id %> -
    -
    - 名称: -
    - <%= text_field_tag :title, nil,class: "winput-300-35", placeholder: "请输入名称,最大限制20个字符", maxlength: 20 %> -
    不能重名
    -
    -
    -
    - 描述: -
    - - <%= text_area_tag :description,nil,class: "width300", placeholder: "请输入描述", maxlength: 200, rows: 4 %> -
    不能超过200字
    -
    -
    -
    - 封面: -
    -
    -
    上传封面
    -
    -
    - <%=render partial: "admin/forum_sections/upload_logo" %> -
    -
    - 尺寸 100*100,支持.jpg .jpeg .bmp .gif .png格式照片。 -
    -
    - -
    - -
    -
    -
    -
  • - 取消 - <%= submit_tag "确定", class: "edu-default-btn edu-blueback-btn" %> -
  • -
    - <% end %> -
    \ No newline at end of file diff --git a/app/services/admins/forum_sections/_upload_logo.html.erb b/app/services/admins/forum_sections/_upload_logo.html.erb deleted file mode 100644 index 5798bb81..00000000 --- a/app/services/admins/forum_sections/_upload_logo.html.erb +++ /dev/null @@ -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 => "" - } %> \ No newline at end of file diff --git a/app/services/admins/forum_sections/edit.js.erb b/app/services/admins/forum_sections/edit.js.erb deleted file mode 100644 index b71ae586..00000000 --- a/app/services/admins/forum_sections/edit.js.erb +++ /dev/null @@ -1,2 +0,0 @@ -var htmlvalue = "<%= j render :partial => 'admin/forum_sections/edit_forum' %>"; -pop_box_new(htmlvalue, 520, 400); \ No newline at end of file diff --git a/app/services/admins/forum_sections/index.html.erb b/app/services/admins/forum_sections/index.html.erb deleted file mode 100644 index 68395932..00000000 --- a/app/services/admins/forum_sections/index.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
    - <%= render partial: "managements/forums_plateSetting.html.erb" %> -
    \ No newline at end of file diff --git a/app/services/admins/forum_sections/new.js.erb b/app/services/admins/forum_sections/new.js.erb deleted file mode 100644 index 2b950c3f..00000000 --- a/app/services/admins/forum_sections/new.js.erb +++ /dev/null @@ -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); \ No newline at end of file diff --git a/app/services/admins/forum_sections/order_forums.js.erb b/app/services/admins/forum_sections/order_forums.js.erb deleted file mode 100644 index 7d361ddb..00000000 --- a/app/services/admins/forum_sections/order_forums.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#children-forum-section-<%= @forum_section.id %>").html("<%= j render partial: "admin/forum_sections/children_forum_sections", locals: {children_forums: @children_forums} %>") \ No newline at end of file diff --git a/app/services/admins/forum_sections/recommend_forums.js.erb b/app/services/admins/forum_sections/recommend_forums.js.erb deleted file mode 100644 index 199010ef..00000000 --- a/app/services/admins/forum_sections/recommend_forums.js.erb +++ /dev/null @@ -1 +0,0 @@ -$("#forum-section-recommend-<%= @forum_section.id %>").html("<%= j render partial: "admin/forum_sections/recommend_forum_sections", locals: {forum: @forum_section} %>") \ No newline at end of file diff --git a/app/views/admins/apply_destroy/_apply_destroy_memos_list.html.erb b/app/views/admins/apply_destroy/_apply_destroy_memos_list.html.erb new file mode 100644 index 00000000..0cb71e95 --- /dev/null +++ b/app/views/admins/apply_destroy/_apply_destroy_memos_list.html.erb @@ -0,0 +1,71 @@ +
    + + + + + + + + + + + + + <% @memos.each_with_index do |memo,index| %> + + + + + + + + + <% end %> + +
    序号作者标题发布时间回复数操作
    <%= list_index_no((params[:page] || 1).to_i, index) %> + <%= link_to(memo.try(:author).try(:show_real_name), "/users/#{memo.author.login}", target: "_blank") %> + + <%= link_to(memo.subject, "/forums/#{memo.id}/detail", target: "_blank") %> + <%= format_time(memo.created_at) %> + <%= link_to(memo.replies_count, "/forums/#{memo.id}/detail", target: "_blank") %> + + <%= 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: "确认删除该帖子吗?"} %> +
    +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: @memos } %> + \ No newline at end of file diff --git a/app/views/admins/apply_destroy/confirm_apply_destroy.js.erb b/app/views/admins/apply_destroy/confirm_apply_destroy.js.erb new file mode 100644 index 00000000..8032771f --- /dev/null +++ b/app/views/admins/apply_destroy/confirm_apply_destroy.js.erb @@ -0,0 +1 @@ +$("#apply_destroy_memo_<%= params[:id] %>").remove() \ No newline at end of file diff --git a/app/views/admins/apply_destroy/index.html.erb b/app/views/admins/apply_destroy/index.html.erb new file mode 100644 index 00000000..0a62a38d --- /dev/null +++ b/app/views/admins/apply_destroy/index.html.erb @@ -0,0 +1,9 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('申请删帖', admins_apply_destroy_index_path) %> +<% end %> + +
    +
    + <%= render :partial => "admins/apply_destroy/apply_destroy_memos_list" %> +
    +
    \ No newline at end of file diff --git a/app/views/admins/apply_destroy/index.js.erb b/app/views/admins/apply_destroy/index.js.erb new file mode 100644 index 00000000..04cde46d --- /dev/null +++ b/app/views/admins/apply_destroy/index.js.erb @@ -0,0 +1 @@ +$("#apply_destory_memos").html('<%= escape_javascript( render :partial => 'admins/apply_destroy/apply_destroy_memos_list') %>'); \ No newline at end of file diff --git a/app/services/admins/banned_users/_banned_user_item.html.erb b/app/views/admins/banned_users/_banned_user_item.html.erb similarity index 79% rename from app/services/admins/banned_users/_banned_user_item.html.erb rename to app/views/admins/banned_users/_banned_user_item.html.erb index 6fd44065..abb7f7fd 100644 --- a/app/services/admins/banned_users/_banned_user_item.html.erb +++ b/app/views/admins/banned_users/_banned_user_item.html.erb @@ -1,9 +1,7 @@
    - <% 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 %> @@ -36,12 +34,5 @@ <% end %> <% end %> -
    -
    -
      - <%= pagination_links_full @banned_users_pages, @banned_users_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %> -
    -
    -
    -
    + <%= render partial: 'admins/shared/paginate', locals: { objects: @banned_users } %>
    \ No newline at end of file diff --git a/app/views/admins/banned_users/_banned_users_items.html.erb b/app/views/admins/banned_users/_banned_users_items.html.erb new file mode 100644 index 00000000..9641015c --- /dev/null +++ b/app/views/admins/banned_users/_banned_users_items.html.erb @@ -0,0 +1,32 @@ +
    + +
      + + 搜索 + <%= link_to "清除", admins_banned_users_path(search: nil, banned_type: @banned_type),remote: true, class: "btn btn-secondary fl btn-sm" %> +
    +
    + +
    + <%= render partial: "admins/banned_users/banned_user_item" %> +
    + + \ No newline at end of file diff --git a/app/services/admins/banned_users/confirm_banned.js.erb b/app/views/admins/banned_users/confirm_banned.js.erb similarity index 100% rename from app/services/admins/banned_users/confirm_banned.js.erb rename to app/views/admins/banned_users/confirm_banned.js.erb diff --git a/app/views/admins/banned_users/index.html.erb b/app/views/admins/banned_users/index.html.erb new file mode 100644 index 00000000..4f4fe763 --- /dev/null +++ b/app/views/admins/banned_users/index.html.erb @@ -0,0 +1,6 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('禁言列表', admins_banned_users_path) %> +<% end %> +
    + <%= render partial: "admins/banned_users/banned_users_items" %> +
    diff --git a/app/views/admins/banned_users/index.js.erb b/app/views/admins/banned_users/index.js.erb new file mode 100644 index 00000000..73d311a0 --- /dev/null +++ b/app/views/admins/banned_users/index.js.erb @@ -0,0 +1 @@ +$("#banned-users-container").html("<%= j render partial: "admins/banned_users/banned_users_items" %>") \ No newline at end of file diff --git a/app/views/admins/forum_applies/_forum_applies_items.html.erb b/app/views/admins/forum_applies/_forum_applies_items.html.erb new file mode 100644 index 00000000..4dd93909 --- /dev/null +++ b/app/views/admins/forum_applies/_forum_applies_items.html.erb @@ -0,0 +1,33 @@ +
    + +
      + + + 搜索 + <%= 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" %> +
    +
    +
    + <%= render partial: "admins/forum_applies/forum_apply_item" %> +
    + + \ No newline at end of file diff --git a/app/services/admins/forum_applies/_forum_apply_item.html.erb b/app/views/admins/forum_applies/_forum_apply_item.html.erb similarity index 55% rename from app/services/admins/forum_applies/_forum_apply_item.html.erb rename to app/views/admins/forum_applies/_forum_apply_item.html.erb index 32649077..eaec8b60 100644 --- a/app/services/admins/forum_applies/_forum_apply_item.html.erb +++ b/app/views/admins/forum_applies/_forum_apply_item.html.erb @@ -1,8 +1,6 @@
    - <% 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 %> -
    -
    -
      - <%= pagination_links_full @forum_applies_pages, @forum_applies_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %> -
    -
    -
    -
    + <%= render partial: 'admins/shared/paginate', locals: { objects: @forum_applies } %> +
    \ No newline at end of file diff --git a/app/views/admins/forum_sections/_forums_plateSetting_add.html.erb b/app/views/admins/forum_sections/_forums_plateSetting_add.html.erb new file mode 100644 index 00000000..760d40ee --- /dev/null +++ b/app/views/admins/forum_sections/_forums_plateSetting_add.html.erb @@ -0,0 +1,29 @@ +
    提示
    +
    +
    + 名称: +
    + +

    请输入名称

    +
    +
    +
    +
    + 取消 + 确定 +
    +
    + \ No newline at end of file diff --git a/app/views/admins/forum_sections/_new_forum.html.erb b/app/views/admins/forum_sections/_new_forum.html.erb new file mode 100644 index 00000000..ad0804dc --- /dev/null +++ b/app/views/admins/forum_sections/_new_forum.html.erb @@ -0,0 +1,45 @@ +
    +
    + <%= parent_id.present? ? "新建二级版块" : "新建一级版块" %> +
    + <%= form_tag(admins_forum_sections_path, method: :post, class: "", remote: true) do %> + <%= hidden_field_tag :parent_id,parent_id %> +
    +
    + 名称: +
    + <%= text_field_tag :title, nil,class: "form-control input-lg", placeholder: "请输入名称,最大限制20个字符", maxlength: 20 %> +
    不能重名
    +
    +
    +
    + 描述: +
    + <%= text_area_tag :description,nil,class: "width300", placeholder: "请输入描述", maxlength: 200, rows: 4 %> +
    不能超过200字
    +
    +
    +
    + 封面: +
    +
    +
    上传封面
    +
    +
    + <%= render partial: "admins/forum_sections/upload_logo" %> +
    +
    + 尺寸 100*100,支持.jpg .jpeg .bmp .gif .png格式照片。 +
    +
    +
    +
    +
    +
    +
  • + 取消 + <%= submit_tag "确定", class: "edu-default-btn edu-blueback-btn" %> +
  • +
    + <% end %> +
    diff --git a/app/services/admins/forum_sections/_recommend_forum_sections.html.erb b/app/views/admins/forum_sections/_recommend_forum_sections.html.erb similarity index 91% rename from app/services/admins/forum_sections/_recommend_forum_sections.html.erb rename to app/views/admins/forum_sections/_recommend_forum_sections.html.erb index b0600006..84089ba4 100644 --- a/app/services/admins/forum_sections/_recommend_forum_sections.html.erb +++ b/app/views/admins/forum_sections/_recommend_forum_sections.html.erb @@ -1,5 +1,5 @@

    - <%= 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 %> <%= 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}')" %> diff --git a/app/services/admins/forum_sections/_show_image_forum.html.erb b/app/views/admins/forum_sections/_show_image_forum.html.erb similarity index 100% rename from app/services/admins/forum_sections/_show_image_forum.html.erb rename to app/views/admins/forum_sections/_show_image_forum.html.erb diff --git a/app/services/admins/forum_sections/_td_forum_section.html.erb b/app/views/admins/forum_sections/_td_forum_section.html.erb similarity index 60% rename from app/services/admins/forum_sections/_td_forum_section.html.erb rename to app/views/admins/forum_sections/_td_forum_section.html.erb index 05ff9ba5..b4d67d74 100644 --- a/app/services/admins/forum_sections/_td_forum_section.html.erb +++ b/app/views/admins/forum_sections/_td_forum_section.html.erb @@ -9,9 +9,9 @@

    - <%= 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 %> + <%= 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_admin_forum_section_path(forum,opr:"down"), method: :post, remote: true %> <% end %> @@ -22,20 +22,20 @@
    - <%= render partial: "admin/forum_sections/children_forum_sections", locals: {children_forums: forum.get_children_section("desc")} %> + <%= render partial: "admins/forum_sections/children_forum_sections", locals: {children_forums: forum.get_children_section("desc")} %>
    - <%= render partial: "admin/forum_sections/recommend_forum_sections", locals: {forum: forum} %> + <%= render partial: "admins/forum_sections/recommend_forum_sections", locals: {forum: forum} %>
    - <%= link_to "".html_safe,new_admin_forum_section_forum_moderator_path(forum), class: "font-20 color-blue mr10", title: "添加版主", remote: true %> + <%= link_to "".html_safe,new_admins_forum_section_forum_moderator_path(forum), class: "font-20 color-blue mr10", title: "添加版主", remote: true %>
    - <%= render partial: "admin/forum_moderators/forum_moderator_item", locals: {users: forum.forum_moderators, forum: forum} %> + <%= render partial: "admins/forum_moderators/forum_moderator_item", locals: {users: forum.forum_moderators, forum: forum} %>
    diff --git a/app/views/admins/forum_sections/_upload_logo.html.erb b/app/views/admins/forum_sections/_upload_logo.html.erb new file mode 100644 index 00000000..ea6b8d25 --- /dev/null +++ b/app/views/admins/forum_sections/_upload_logo.html.erb @@ -0,0 +1,20 @@ +<%= file_field_tag 'attachments[dummy][file]', + :id => "_file_section_picture", + :class => 'file_selector', + :onchange => "addInputFiles_board(this);", + :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 => admins_upload_images_path(:format => 'js'), + } %> + + + \ No newline at end of file diff --git a/app/services/admins/forum_sections/create.js.erb b/app/views/admins/forum_sections/create.js.erb similarity index 74% rename from app/services/admins/forum_sections/create.js.erb rename to app/views/admins/forum_sections/create.js.erb index 3188d4ec..a4c94579 100644 --- a/app/services/admins/forum_sections/create.js.erb +++ b/app/views/admins/forum_sections/create.js.erb @@ -4,9 +4,9 @@ <% 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} %>") + $("#forum-section-detail-<%= params[:parent_id] %>").html("<%= j render partial: "admins/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} %>") + $("#forum-section-contents").prepend("<%= j render partial: "admins/forum_sections/forum_section_detail", locals: {forum: @forum_section} %>") <% end %> <% else %> diff --git a/app/services/admins/forum_sections/destroy.js.erb b/app/views/admins/forum_sections/destroy.js.erb similarity index 100% rename from app/services/admins/forum_sections/destroy.js.erb rename to app/views/admins/forum_sections/destroy.js.erb diff --git a/app/views/admins/forum_sections/edit.js.erb b/app/views/admins/forum_sections/edit.js.erb new file mode 100644 index 00000000..27f507a3 --- /dev/null +++ b/app/views/admins/forum_sections/edit.js.erb @@ -0,0 +1,2 @@ +var htmlvalue = "<%= j render :partial => 'admins/forum_sections/edit_forum' %>"; +pop_box_new(htmlvalue, 520, 400); \ No newline at end of file diff --git a/app/views/admins/forum_sections/index.html.erb b/app/views/admins/forum_sections/index.html.erb new file mode 100644 index 00000000..90633f9d --- /dev/null +++ b/app/views/admins/forum_sections/index.html.erb @@ -0,0 +1,11 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('版块管理', admins_forum_sections_path) %> +<% end %> + +
    +
    + <%= render partial: "admins/forum_sections/forums_plateSetting.html.erb" %> +
    +
    + +<%= render partial: 'admins/forum_sections/shared/add_section' %> \ No newline at end of file diff --git a/app/services/admins/forum_sections/index.js.erb b/app/views/admins/forum_sections/index.js.erb similarity index 100% rename from app/services/admins/forum_sections/index.js.erb rename to app/views/admins/forum_sections/index.js.erb diff --git a/app/services/admins/forum_sections/move.js.erb b/app/views/admins/forum_sections/move.js.erb similarity index 100% rename from app/services/admins/forum_sections/move.js.erb rename to app/views/admins/forum_sections/move.js.erb diff --git a/app/views/admins/forum_sections/new.js.erb b/app/views/admins/forum_sections/new.js.erb new file mode 100644 index 00000000..1410a7ee --- /dev/null +++ b/app/views/admins/forum_sections/new.js.erb @@ -0,0 +1,2 @@ +var htmlvalue = "<%= j render :partial => 'admins/forum_sections/new_forum', locals: {parent_id: @parent_id} %>"; +pop_box_new(htmlvalue, 520, 400); \ No newline at end of file diff --git a/app/views/admins/forum_sections/order_forums.js.erb b/app/views/admins/forum_sections/order_forums.js.erb new file mode 100644 index 00000000..0ebfedc9 --- /dev/null +++ b/app/views/admins/forum_sections/order_forums.js.erb @@ -0,0 +1 @@ +$("#children-forum-section-<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_sections/children_forum_sections", locals: {children_forums: @children_forums} %>") \ No newline at end of file diff --git a/app/views/admins/forum_sections/recommend_forums.js.erb b/app/views/admins/forum_sections/recommend_forums.js.erb new file mode 100644 index 00000000..100abe11 --- /dev/null +++ b/app/views/admins/forum_sections/recommend_forums.js.erb @@ -0,0 +1 @@ +$("#forum-section-recommend-<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_sections/recommend_forum_sections", locals: {forum: @forum_section} %>") \ No newline at end of file diff --git a/app/views/admins/forum_sections/shared/_add_section.html.erb b/app/views/admins/forum_sections/shared/_add_section.html.erb new file mode 100644 index 00000000..58b3f735 --- /dev/null +++ b/app/views/admins/forum_sections/shared/_add_section.html.erb @@ -0,0 +1,54 @@ +<% parent_id = params[:parent_id] %> + diff --git a/app/views/admins/forum_sections/shared/_error_section.html.erb b/app/views/admins/forum_sections/shared/_error_section.html.erb new file mode 100644 index 00000000..7a293c9f --- /dev/null +++ b/app/views/admins/forum_sections/shared/_error_section.html.erb @@ -0,0 +1,6 @@ + + +错误: +
    + <%= error_messages %> +
    \ No newline at end of file diff --git a/app/services/admins/forum_sections/update.js.erb b/app/views/admins/forum_sections/update.js.erb similarity index 72% rename from app/services/admins/forum_sections/update.js.erb rename to app/views/admins/forum_sections/update.js.erb index 27e73c86..f38a7962 100644 --- a/app/services/admins/forum_sections/update.js.erb +++ b/app/views/admins/forum_sections/update.js.erb @@ -4,9 +4,9 @@ $("#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} %>") + $("#children-forum-detail-<%= @forum_section.id %>").html("<%= j render partial: "admins/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} %>") + $("#forum-section-detail-<%= @forum_section.id %>").html("<%= j render partial: "admins/forum_sections/td_forum_section", locals: {forum: @forum_section} %>") <% end %> <% else %> op_know("<%= @edit_forum_status[:msg] %>") diff --git a/app/views/admins/memo_reply_lists/_message_list.html.erb b/app/views/admins/memo_reply_lists/_message_list.html.erb new file mode 100644 index 00000000..5bf890b0 --- /dev/null +++ b/app/views/admins/memo_reply_lists/_message_list.html.erb @@ -0,0 +1,89 @@ + +
    + +
    +
    + + + + + + + + + + + + + + <% @memos.each_with_index do |memo,index| %> + + + + + + + + + + <% end %> + +
    序号来源评论内容评论者评论时间审核操作
    <%= list_index_no((params[:page] || 1).to_i, index) %> + <%= link_to(memo.root.subject, forum_path(memo.root)+"/detail", :target => "_blank") %> + + <%= sanitize memo.content %> + + <%= link_to(memo.try(:author).try(:show_real_name), "/users/#{memo.author.login}", target: "_blank") %> + <%= format_time(memo.created_at) %> + <%= check_box_tag(:hidden, 1, !memo.hidden?, id: "hidden-check-box-#{memo.id}", class: 'magic-checkbox', data: { id: memo.id, url: memo_hidden_admins_memos_path, type: 'hidden' }) %> + + 通过 + + <%= link_to '查看', forum_path(memo.root)+"/detail?reply_id=#{memo.id}", target: '_blank' %> + <%= link_to '删除', delete_memo_admins_memos_path(id: memo.id), method: :delete, class: "delete-link-#{memo.id}", data: { confirm: '确认删除该帖子吗?' }, style: memo.hidden? ? '' : 'display: none' %> +
    +
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: @memos } %> + + \ No newline at end of file diff --git a/app/views/admins/memo_reply_lists/index.html.erb b/app/views/admins/memo_reply_lists/index.html.erb new file mode 100644 index 00000000..bd5356b1 --- /dev/null +++ b/app/views/admins/memo_reply_lists/index.html.erb @@ -0,0 +1,9 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('帖子管理', admins_memos_path) %> +<% end %> + +
    +
    + <%= render :partial => "admins/memo_reply_lists/message_list" %> +
    +
    \ No newline at end of file diff --git a/app/views/admins/memo_reply_lists/index.js.erb b/app/views/admins/memo_reply_lists/index.js.erb new file mode 100644 index 00000000..dcc4d5ce --- /dev/null +++ b/app/views/admins/memo_reply_lists/index.js.erb @@ -0,0 +1 @@ +$("#leave_message").html('<%= escape_javascript( render :partial => 'admins/memo_reply_lists/message_list') %>'); \ No newline at end of file diff --git a/app/views/admins/memos/_memo_reply_list.html.erb b/app/views/admins/memos/_memo_reply_list.html.erb index 0f74ca9d..6168df7f 100644 --- a/app/views/admins/memos/_memo_reply_list.html.erb +++ b/app/views/admins/memos/_memo_reply_list.html.erb @@ -29,13 +29,6 @@ <%= sanitize memo.content %> - <% -=begin%> - <%= link_to(forum_path(memo.parent, reply_id: memo.id)+"/detail", :target => "_blank") do %> - <%= sanitize memo.content %> - <% end %> -<% -=end%> <%= link_to(memo.try(:author).try(:show_real_name), user_path(memo.author)) %> @@ -59,14 +52,8 @@ <% end %> -
    -
    -
      - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %> -
    -
    -
    -
    + +<%= render partial: 'admins/shared/paginate', locals: { objects: @memos } %> \ No newline at end of file + }); + diff --git a/app/views/admins/forum_sections/index.html.erb b/app/views/admins/forum_sections/index.html.erb index 90633f9d..d9ce73c8 100644 --- a/app/views/admins/forum_sections/index.html.erb +++ b/app/views/admins/forum_sections/index.html.erb @@ -4,7 +4,7 @@
    - <%= render partial: "admins/forum_sections/forums_plateSetting.html.erb" %> + <%= render partial: "admins/forum_sections/forums_plateSetting" %>
    diff --git a/app/views/admins/forum_sections/new.js.erb b/app/views/admins/forum_sections/new.js.erb index 41128ebb..4a2ebef4 100644 --- a/app/views/admins/forum_sections/new.js.erb +++ b/app/views/admins/forum_sections/new.js.erb @@ -1,2 +1,3 @@ -var htmlvalue = "<%= j render :partial => 'admins/forum_sections/new_forum', locals: {parent_id: @parent_id, is_create: "1", forum_section: @forum_section} %>"; -$('#identifier').modal('show') \ No newline at end of file +var htmlvalue = "<%= j render :partial => 'admins/forum_sections/shared/new_forum', locals: {parent_id: @parent_id, is_create: "1", forum_section: @forum_section} %>"; +$("#admin-forum-section-content").html(htmlvalue) +$('#admin-forum-section-modal').modal('show') \ No newline at end of file diff --git a/app/views/admins/forum_sections/shared/_add_section.html.erb b/app/views/admins/forum_sections/shared/_add_section.html.erb index 58b3f735..87e46487 100644 --- a/app/views/admins/forum_sections/shared/_add_section.html.erb +++ b/app/views/admins/forum_sections/shared/_add_section.html.erb @@ -1,54 +1,7 @@ -<% parent_id = params[:parent_id] %> -
    -<%= render partial: 'admins/forum_sections/shared/add_section' %> \ No newline at end of file +<%= render partial: 'admins/forum_sections/shared/add_section' %> +<%= render partial: 'admins/forum_sections/shared/add_managers' %> \ No newline at end of file diff --git a/app/views/admins/forum_sections/shared/_add_managers.html.erb b/app/views/admins/forum_sections/shared/_add_managers.html.erb new file mode 100644 index 00000000..6a3e316a --- /dev/null +++ b/app/views/admins/forum_sections/shared/_add_managers.html.erb @@ -0,0 +1,7 @@ + + \ No newline at end of file diff --git a/app/views/admins/forum_sections/shared/_new_forum.html.erb b/app/views/admins/forum_sections/shared/_new_forum.html.erb index b985b5a1..a41ea823 100644 --- a/app/views/admins/forum_sections/shared/_new_forum.html.erb +++ b/app/views/admins/forum_sections/shared/_new_forum.html.erb @@ -1,5 +1,5 @@ -<%= form_tag(admins_forum_sections_path, method: :post, class: "", remote: true) do %> +<%= simple_form_for(forum_section, url: forum_section.id.present? ? admins_forum_section_path(forum_section.id) : admins_forum_sections_path,method: forum_section.id.present? ? "put" : "post", html: { remote: true}) do |f|%> + <%= f.hidden_field :parent_id, value: parent_id %>