Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_cs_new
caishi 6 years ago
commit 3b97dd75ad

@ -2,7 +2,8 @@ class LibrariesController < ApplicationController
include PaginateHelper include PaginateHelper
before_action :require_login, :check_auth, except: %i[index show] before_action :require_login, :check_auth, except: %i[index show]
before_action :check_account, except: %i[index show]
after_action :increment_visit_count, only: [:show, :edit, :update]
helper_method :current_library, :library_manageable? helper_method :current_library, :library_manageable?
def index def index
@ -80,6 +81,10 @@ class LibrariesController < ApplicationController
current_user&.id == library.user_id || admin_or_business? current_user&.id == library.user_id || admin_or_business?
end end
def increment_visit_count
current_library.increment_visited_count! if current_library && current_library.id
end
def save_params def save_params
params.permit(:title, :content, :author_name, :author_school_name, params.permit(:title, :content, :author_name, :author_school_name,
:cover_id, :publish, attachment_ids: [], tag_ids: []) :cover_id, :publish, attachment_ids: [], tag_ids: [])

@ -5,7 +5,6 @@ class ShixunsController < ApplicationController
before_action :require_login, :check_auth, except: [:download_file, :index, :menus] before_action :require_login, :check_auth, except: [:download_file, :index, :menus]
before_action :check_account, only: [:new, :create, :shixun_exec] before_action :check_account, only: [:new, :create, :shixun_exec]
before_action :check_auth, except: [:download_file, :index, :menus]
before_action :find_shixun, :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns, before_action :find_shixun, :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
:propaedeutics, :departments, :apply_shixun_mirror, :propaedeutics, :departments, :apply_shixun_mirror,

@ -34,6 +34,10 @@ class Library < ApplicationRecord
end end
end end
def increment_visited_count!(num = 1)
increment_column!(:visited_count, num)
end
def generate_uuid def generate_uuid
uuid = Util::UUID.time_uuid uuid = Util::UUID.time_uuid
while Library.exists?(uuid: uuid) while Library.exists?(uuid: uuid)
@ -42,4 +46,10 @@ class Library < ApplicationRecord
self.uuid = uuid self.uuid = uuid
end end
private
def increment_column!(column, num = 1)
self.class.connection.execute("update #{self.class.table_name} set #{column} = COALESCE(#{column}, 0) + #{num} where id = #{id}")
end
end end

@ -1,13 +1,13 @@
class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2] class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
include ActionView::Helpers::SanitizeHelper include ActionView::Helpers::SanitizeHelper
def change def change
def ke_transform_to_md content # def ke_transform_to_md content
return content if content.blank? # return content if content.blank?
s_contents = sanitize(content, tags: %w(img a table td tr tbody pre), attributes: %w(src href target style)) # s_contents = sanitize(content, tags: %w(img a table td tr tbody pre), attributes: %w(src href target style))
s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", "").gsub(/(\n)+/, "<br />") # s_contents.gsub(">\n<", "><").gsub(/^\n/, "").gsub(" ", "").gsub(/(\n)+/, "<br />")
.gsub("\t", "").gsub(" ", "&nbsp;&nbsp;&nbsp;&nbsp;").gsub("\n", "<br />") # .gsub("\t", "").gsub("\n", "").gsub(" ", "&nbsp;&nbsp;&nbsp;&nbsp;").gsub(/(<br\s?\/?>)+/, "<br />")
.gsub(/(<br\s?\/?>)+/, "<br />") # s_contents.gsub("\n", "<br />").gsub(/(<br\s?\/?>)+/, "<br />")
end # end
# #
# # 课程讨论区 # # 课程讨论区
# MessageDetail.find_each do |m| # MessageDetail.find_each do |m|
@ -16,12 +16,12 @@ class ModifyKeContentsForMarkdown < ActiveRecord::Migration[5.2]
# end # end
#试卷的标题 #试卷的标题
ExerciseQuestion.where(:exercise_id => 1890).find_each do |eq| # ExerciseQuestion.where(:exercise_id => 1892).find_each do |eq|
puts("#eq.question_title: #{eq.question_title}") # puts("#eq.question_title: #{eq.question_title}")
question_title = ke_transform_to_md eq.question_title # question_title = ke_transform_to_md eq.question_title
puts("#question_title: #{question_title}") # puts("#question_title: #{question_title}")
eq.update_column(:question_title, question_title) # eq.update_column(:question_title, question_title)
end # end
# # 试卷的答案 # # 试卷的答案
# ExerciseStandardAnswer.find_each do |esa| # ExerciseStandardAnswer.find_each do |esa|

File diff suppressed because one or more lines are too long

@ -498,7 +498,7 @@ pop_box_new(htmlvalue, 480, 182);
return resData return resData
} }
fetchAll(stageId) { fetchAll(stageId, noTimeout) {
if (window.__fetchAllFlag == true ) { if (window.__fetchAllFlag == true ) {
console.log('TPIContextProvider call fetchAll repeatly!') console.log('TPIContextProvider call fetchAll repeatly!')
@ -544,6 +544,13 @@ pop_box_new(htmlvalue, 480, 182);
return; return;
} }
if (response.data.status == 404) { if (response.data.status == 404) {
// 如果第一次发生404则隔1s后再调用一次本接口因为ucloud主从同步可能有延迟
if (!noTimeout) {
setTimeout(() => {
this.fetchAll(stageId, true)
}, 1000)
return;
}
window.location.href = '/myshixuns/not_found' window.location.href = '/myshixuns/not_found'
return; return;
} }

@ -248,7 +248,7 @@ class Addcourses extends Component{
}else{ }else{
notification.open({ response.data.message && notification.open({
message:"提示", message:"提示",
description:response.data.message description:response.data.message
}); });

@ -659,8 +659,8 @@ submittojoinclass=(value)=>{
{AccountProfiletype===true?<AccountProfile {AccountProfiletype===true?<AccountProfile
hideAccountProfile={()=>this.hideAccountProfile()} hideAccountProfile={()=>this.hideAccountProfile()}
{...this.state}
{...this.props} {...this.props}
{...this.state}
/>:""} />:""}
<a href="/" className={"fl mr60 ml25"}> <a href="/" className={"fl mr60 ml25"}>
<img alt="高校智能化教学与实训平台" className="logoimg" src={getImageUrl("images/educoder/headNavLogo.png?1526520218")}></img> <img alt="高校智能化教学与实训平台" className="logoimg" src={getImageUrl("images/educoder/headNavLogo.png?1526520218")}></img>

@ -10,6 +10,8 @@ import axios from 'axios';
import './TPMIndex.css' import './TPMIndex.css'
import LoginDialog from '../login/LoginDialog'; import LoginDialog from '../login/LoginDialog';
import AccountProfile from '../user/AccountProfile';
import Trialapplication from "../login/Trialapplication"; import Trialapplication from "../login/Trialapplication";
// import "antd/dist/antd.css"; // import "antd/dist/antd.css";
// import '../../css/educoder/edu-common.css' // import '../../css/educoder/edu-common.css'
@ -76,7 +78,8 @@ export function TPMIndexHOC(WrappedComponent) {
Footerdown:undefined, Footerdown:undefined,
coursedata: {}, coursedata: {},
isRender: false isRender: false,
AccountProfiletype: false
} }
} }
@ -300,11 +303,26 @@ export function TPMIndexHOC(WrappedComponent) {
isRender: true isRender: true
}) })
} }
checkIfLogin = () => { checkIfLogin = () => {
return this.state.current_user && this.state.current_user.login != '' return this.state.current_user && this.state.current_user.login != ''
} }
hideAccountProfile = () => {
this.setState({
hideAccountProfile: false
})
}
showProfileCompleteDialog = () => {
this.setState({
hideAccountProfile: true
})
}
checkIfProfileCompleted = () => {
return this.state.current_user && this.state.current_user.profile_completed
}
render() { render() {
let{Headertop,Footerdown, isRender}=this.state; let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state;
const common = { const common = {
isSuperAdmin:this.isSuperAdmin, isSuperAdmin:this.isSuperAdmin,
isAdminOrCreator:this.isAdminOrCreator, isAdminOrCreator:this.isAdminOrCreator,
@ -319,6 +337,8 @@ export function TPMIndexHOC(WrappedComponent) {
showLoginDialog: this.showLoginDialog, showLoginDialog: this.showLoginDialog,
checkIfLogin: this.checkIfLogin, checkIfLogin: this.checkIfLogin,
showProfileCompleteDialog: this.showProfileCompleteDialog,
checkIfProfileCompleted: this.checkIfProfileCompleted,
} }
return ( return (
<div> <div>
@ -327,6 +347,11 @@ export function TPMIndexHOC(WrappedComponent) {
{...this.state} {...this.state}
{...this.props} {...this.props}
/> : ""} /> : ""}
{AccountProfiletype===true ? <AccountProfile
hideAccountProfile={()=>this.hideAccountProfile()}
{...this.state}
{...this.props}
/>:""}
<SiderBar Headertop={Headertop}/> <SiderBar Headertop={Headertop}/>
{/* 注释掉了1440 影响到了手机屏幕的展示 */} {/* 注释掉了1440 影响到了手机屏幕的展示 */}
<style>{ <style>{

Loading…
Cancel
Save