diff --git a/app/controllers/discusses_controller.rb b/app/controllers/discusses_controller.rb index 6a270f619..4af27b919 100644 --- a/app/controllers/discusses_controller.rb +++ b/app/controllers/discusses_controller.rb @@ -1,7 +1,7 @@ class DiscussesController < ApplicationController LIMIT = 10 before_action :find_container, only: [:index, :hidden] - before_action :find_discuss, except: [:create, :index, :new_message, :reward_code, :forum_discusses] + before_action :find_discuss, except: [:create, :index, :new_message, :reward_code, :forum_discusses, :plus] def index page = params[:page].to_i diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index c7d914089..30a325cd3 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -30,6 +30,7 @@ module TidingDecorator end def strip_html(text, len = 0, suffix = "...") + text = text.to_s str = "" if !text.nil? && text.length > 0 str = text.gsub(/<\/?.*?>/, '').strip diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7e9fd652b..5040acec0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -130,15 +130,15 @@ module ApplicationHelper if source.class.to_s == 'User' File.join(relative_path, ["#{source.class}", "#{source.id}"]) else - File.join("images/avatars", ["#{source.class}", "#{source.id}"]) + File.join("avatars", ["#{source.class}", "#{source.id}"]) end elsif source.class.to_s == 'User' str = source.user_extension.try(:gender).to_i == 0 ? "b" : "g" File.join(relative_path, "#{source.class}", str) elsif source.class.to_s == 'Subject' - File.join("images","educoder", "index", "subject", "subject#{rand(17)}.jpg") + File.join("educoder", "index", "subject", "subject#{rand(17)}.jpg") elsif source.class.to_s == 'Shixun' - File.join("images","educoder", "index", "shixun", "shixun#{rand(23)}.jpg") + File.join("educoder","index", "shixun", "shixun#{rand(23)}.jpg") end end diff --git a/app/models/apply_add_school.rb b/app/models/apply_add_school.rb index bae65d24f..c303283ca 100644 --- a/app/models/apply_add_school.rb +++ b/app/models/apply_add_school.rb @@ -9,6 +9,7 @@ class ApplyAddSchool < ApplicationRecord private def send_notify - tidings.create!(user_id: 1, status: 0, trigger_user_id: user_id, belong_container: school, tiding_type: 'Apply') + Tiding.create!(user_id: 1, status: 0, container_id: id, container_type: 'ApplyAddSchools', + trigger_user_id: user_id, belong_container: school, tiding_type: 'Apply') end end \ No newline at end of file diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 1da26fd22..d5697d87f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -25,6 +25,8 @@ class JournalsForMessage < ApplicationRecord # "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 # "hidden", 隐藏 + after_create :send_tiding + # course_identity 课堂用户身份 def contents_show course_identity @@ -47,4 +49,29 @@ class JournalsForMessage < ApplicationRecord JournalsForMessage.includes(:user).where(m_parent_id: self.id).page(page).per(limit).reorder("created_on asc") end + + def send_tiding + # 回复和@同一个人时:只发@的消息(因@的消息先创建) + case self.jour_type + # 用户留言当做私信处理 不发消息 + when "Principal" +=begin + user_id = self.m_parent_id.present? ? JournalsForMessage.find(self.m_parent_id).user_id : self.jour_id + if user_id != self.user_id && !self.tidings.where(:user_id => user_id, :trigger_user_id => self.user_id, :tiding_type => "Mentioned").first.present? + self.tidings << Tiding.new(:trigger_user_id => self.user_id, :user_id => user_id, :parent_container_id => self.jour_id, :parent_container_type => self.jour_type, :belong_container_id => self.jour_id, :belong_container_type => "User", :viewed => 0, :tiding_type => self.m_parent_id.present? ? "Comment" : "Journal") + end +=end + when "HomeworkCommon", "GraduationTopic" + user_id = self.m_parent_id.present? ? JournalsForMessage.find(self.m_parent_id).user_id : (self.jour_type == "HomeworkCommon" ? self.jour.user_id : self.jour.tea_id) + if user_id != self.user_id && !self.tidings.where(:user_id => user_id, :trigger_user_id => self.user_id, :tiding_type => "Mentioned").first.present? + self.tidings << Tiding.new(:trigger_user_id => self.user_id, :user_id => user_id, :parent_container_id => self.jour_id, :parent_container_type => self.jour_type, :belong_container_id => self.jour.course_id, :belong_container_type => "Course", :viewed => 0, :tiding_type => "Comment") + end + when "StudentWorksScore" + course_id = self.jour.try(:student_work).try(:homework_common).try(:course_id) + user_id = self.m_parent_id.present? ? JournalsForMessage.find(self.m_parent_id).user_id : self.jour.user_id + if user_id != self.user_id && !self.tidings.where(:user_id => user_id, :trigger_user_id => self.user_id, :tiding_type => "Mentioned").first.present? + self.tidings << Tiding.new(:trigger_user_id => self.user_id, :user_id => user_id, :parent_container_id => self.jour_id, :parent_container_type => self.jour_type, :belong_container_id => course_id, :belong_container_type => "Course", :viewed => 0, :tiding_type => "Comment") + end + end + end end diff --git a/app/views/memos/_memo.json.jbuilder b/app/views/memos/_memo.json.jbuilder index a33de2492..f0ac5cd3d 100644 --- a/app/views/memos/_memo.json.jbuilder +++ b/app/views/memos/_memo.json.jbuilder @@ -9,6 +9,6 @@ json.memo do json.tag memo.tag_repertoires.map(&:name) json.time memo.created_at json.replies_count memo.all_replies_count - json.user_praise memo.praise_treads.user_liker(@user.try(:id)).count > 1 ? true : false + json.user_praise memo.praise_treads.user_liker(@user.try(:id)).count > 0 ? true : false json.memo_praise_count memo.praise_treads.liker.count end diff --git a/db/migrate/20190802105008_tranfer_tiding_data.rb b/db/migrate/20190802105008_tranfer_tiding_data.rb new file mode 100644 index 000000000..ef7682530 --- /dev/null +++ b/db/migrate/20190802105008_tranfer_tiding_data.rb @@ -0,0 +1,5 @@ +class TranferTidingData < ActiveRecord::Migration[5.2] + def change + Tiding.where(container_type: 'ApplyAddSchool').update_all(container_type: 'ApplyAddSchools') + end +end diff --git a/public/react/src/modules/courses/coursesPublic/Addcourses.js b/public/react/src/modules/courses/coursesPublic/Addcourses.js index 8225907b8..a9d30f2b6 100644 --- a/public/react/src/modules/courses/coursesPublic/Addcourses.js +++ b/public/react/src/modules/courses/coursesPublic/Addcourses.js @@ -75,6 +75,7 @@ class Addcourses extends Component{ if(e.target.checked===true){ this.setState({ assistant_professor:1, + professor:null, Checkboxteachingchecked:e.target.checked, Checkboxteachertype:true }) @@ -95,6 +96,7 @@ class Addcourses extends Component{ if(e.target.checked===true){ this.setState({ professor:1, + assistant_professor:null, Checkboxteacherchecked:e.target.checked, Checkboxteachingtype:true }) diff --git a/public/react/src/modules/courses/new/CoursesNew.js b/public/react/src/modules/courses/new/CoursesNew.js index f37f1a1db..fc4719013 100644 --- a/public/react/src/modules/courses/new/CoursesNew.js +++ b/public/react/src/modules/courses/new/CoursesNew.js @@ -203,7 +203,7 @@ class CoursesNew extends Component { // debugger if (response.data.status === 0) { // this.goback() - this.props.history.push(first_category_url); + window.location.href=first_category_url; } }).catch((error) => { console.log(error) @@ -247,7 +247,7 @@ class CoursesNew extends Component { ).then((response) => { if (response.status === 200) { // this.goback - this.props.history.push(response.data.first_category_url); + window.location.href=response.data.first_category_url; } }).catch((error) => { console.log(error) diff --git a/public/react/src/modules/forums/PostPaginationHOC.js b/public/react/src/modules/forums/PostPaginationHOC.js index 3922eae41..cdba0a35a 100644 --- a/public/react/src/modules/forums/PostPaginationHOC.js +++ b/public/react/src/modules/forums/PostPaginationHOC.js @@ -136,7 +136,7 @@ return function wrap(WrappedComponent) { const params = { // replies_count最热 created_at 最新 // s_order: 'replies_count', - page: currentPage - 1, + page: currentPage, // forum: // forum_id // user_id @@ -267,7 +267,7 @@ return function wrap(WrappedComponent) { this.setTop(memo); } onMemoDelete(memo) { - const deleteUrl = `/api/v1/memos/${memo.id}`; + const deleteUrl = `/memos/${memo.id}.json`; // 获取memo list axios.delete(deleteUrl, { // withCredentials: true, diff --git a/public/react/src/modules/forums/RecommendShixun.js b/public/react/src/modules/forums/RecommendShixun.js index aa9dec952..af0ca0007 100644 --- a/public/react/src/modules/forums/RecommendShixun.js +++ b/public/react/src/modules/forums/RecommendShixun.js @@ -28,7 +28,7 @@ class RecommendShixun extends Component {
- {`${_shixun.id}`} + {`${_shixun.id}`}
diff --git a/public/react/src/modules/projectPackages/PackageIndexNEITaskDetails/PackageIndexNEITaskDetails.js b/public/react/src/modules/projectPackages/PackageIndexNEITaskDetails/PackageIndexNEITaskDetails.js index 1f7851303..ac498b4ee 100644 --- a/public/react/src/modules/projectPackages/PackageIndexNEITaskDetails/PackageIndexNEITaskDetails.js +++ b/public/react/src/modules/projectPackages/PackageIndexNEITaskDetails/PackageIndexNEITaskDetails.js @@ -297,8 +297,8 @@ class PackageIndexNEITaskDetails extends Component { onMouseOver={this.setover} onMouseOut={this.setout} > - {overtype===false? 头像联系TA: - 头像 头像联系TA: + 头像联系TA}
}
@@ -411,7 +411,7 @@ class PackageIndexNEITaskDetails extends Component { {item.status==="bidding_won"?:""}

{item.name}

- {this.props.current_user&&this.props.current_user.login!=item.login? + {this.props.current_user&&this.props.current_user.login!=item.login? 头像联系TA :""} diff --git a/public/react/src/modules/user/usersInfo/InfosPackage.js b/public/react/src/modules/user/usersInfo/InfosPackage.js index 36175295b..0355e2d76 100644 --- a/public/react/src/modules/user/usersInfo/InfosPackage.js +++ b/public/react/src/modules/user/usersInfo/InfosPackage.js @@ -132,18 +132,19 @@ class InfosPackage extends Component{ delectproject=(id)=>{ - let {cate,status}=this.state; + let {category,status}=this.state; + debugger let url=`/project_packages/${id}.json` axios.delete(url).then((response) => { if (response.data.status == 0) { - this.getCourses(cate,status,1); + this.getCourses(category,status,1); } }) .catch(function (error) { console.log(error); }); - this.cancelProject; + this.cancelProject(); } render(){ let{