Merge branches 'dev_Ysl' and 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_admin
杨树林 6 years ago
commit 3b882b4080

@ -1,7 +1,7 @@
class DiscussesController < ApplicationController class DiscussesController < ApplicationController
LIMIT = 10 LIMIT = 10
before_action :find_container, only: [:index, :hidden] 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 def index
page = params[:page].to_i page = params[:page].to_i

@ -30,6 +30,7 @@ module TidingDecorator
end end
def strip_html(text, len = 0, suffix = "...") def strip_html(text, len = 0, suffix = "...")
text = text.to_s
str = "" str = ""
if !text.nil? && text.length > 0 if !text.nil? && text.length > 0
str = text.gsub(/<\/?.*?>/, '').strip str = text.gsub(/<\/?.*?>/, '').strip

@ -130,15 +130,15 @@ module ApplicationHelper
if source.class.to_s == 'User' if source.class.to_s == 'User'
File.join(relative_path, ["#{source.class}", "#{source.id}"]) File.join(relative_path, ["#{source.class}", "#{source.id}"])
else else
File.join("images/avatars", ["#{source.class}", "#{source.id}"]) File.join("avatars", ["#{source.class}", "#{source.id}"])
end end
elsif source.class.to_s == 'User' elsif source.class.to_s == 'User'
str = source.user_extension.try(:gender).to_i == 0 ? "b" : "g" str = source.user_extension.try(:gender).to_i == 0 ? "b" : "g"
File.join(relative_path, "#{source.class}", str) File.join(relative_path, "#{source.class}", str)
elsif source.class.to_s == 'Subject' 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' 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
end end

@ -9,6 +9,7 @@ class ApplyAddSchool < ApplicationRecord
private private
def send_notify 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
end end

@ -25,6 +25,8 @@ class JournalsForMessage < ApplicationRecord
# "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言 # "is_comprehensive_evaluation", # 1 教师评论、2 匿评、3 留言
# "hidden", 隐藏 # "hidden", 隐藏
after_create :send_tiding
# course_identity 课堂用户身份 # course_identity 课堂用户身份
def contents_show 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") JournalsForMessage.includes(:user).where(m_parent_id: self.id).page(page).per(limit).reorder("created_on asc")
end 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 end

@ -9,6 +9,6 @@ json.memo do
json.tag memo.tag_repertoires.map(&:name) json.tag memo.tag_repertoires.map(&:name)
json.time memo.created_at json.time memo.created_at
json.replies_count memo.all_replies_count 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 json.memo_praise_count memo.praise_treads.liker.count
end end

@ -0,0 +1,5 @@
class TranferTidingData < ActiveRecord::Migration[5.2]
def change
Tiding.where(container_type: 'ApplyAddSchool').update_all(container_type: 'ApplyAddSchools')
end
end

@ -75,6 +75,7 @@ class Addcourses extends Component{
if(e.target.checked===true){ if(e.target.checked===true){
this.setState({ this.setState({
assistant_professor:1, assistant_professor:1,
professor:null,
Checkboxteachingchecked:e.target.checked, Checkboxteachingchecked:e.target.checked,
Checkboxteachertype:true Checkboxteachertype:true
}) })
@ -95,6 +96,7 @@ class Addcourses extends Component{
if(e.target.checked===true){ if(e.target.checked===true){
this.setState({ this.setState({
professor:1, professor:1,
assistant_professor:null,
Checkboxteacherchecked:e.target.checked, Checkboxteacherchecked:e.target.checked,
Checkboxteachingtype:true Checkboxteachingtype:true
}) })

@ -203,7 +203,7 @@ class CoursesNew extends Component {
// debugger // debugger
if (response.data.status === 0) { if (response.data.status === 0) {
// this.goback() // this.goback()
this.props.history.push(first_category_url); window.location.href=first_category_url;
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)
@ -247,7 +247,7 @@ class CoursesNew extends Component {
).then((response) => { ).then((response) => {
if (response.status === 200) { if (response.status === 200) {
// this.goback // this.goback
this.props.history.push(response.data.first_category_url); window.location.href=response.data.first_category_url;
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)

@ -136,7 +136,7 @@ return function wrap(WrappedComponent) {
const params = { const params = {
// replies_count最热 created_at 最新 // replies_count最热 created_at 最新
// s_order: 'replies_count', // s_order: 'replies_count',
page: currentPage - 1, page: currentPage,
// forum: // forum_id // forum: // forum_id
// user_id // user_id
@ -267,7 +267,7 @@ return function wrap(WrappedComponent) {
this.setTop(memo); this.setTop(memo);
} }
onMemoDelete(memo) { onMemoDelete(memo) {
const deleteUrl = `/api/v1/memos/${memo.id}`; const deleteUrl = `/memos/${memo.id}.json`;
// 获取memo list // 获取memo list
axios.delete(deleteUrl, { axios.delete(deleteUrl, {
// withCredentials: true, // withCredentials: true,

@ -28,7 +28,7 @@ class RecommendShixun extends Component {
<div className="recomments clearfix df" key={index}> <div className="recomments clearfix df" key={index}>
<a href={`/shixuns/${_shixun.identifier}/challenges`} style={{height:'76px'}} target="_blank"> <a href={`/shixuns/${_shixun.identifier}/challenges`} style={{height:'76px'}} target="_blank">
<img alt={`${_shixun.id}`} style={{maxHeight:'76px'}} src={`/images/${_shixun.image_url}`} width="100" > <img alt={`${_shixun.id}`} style={{maxHeight:'76px'}} src={`/${_shixun.image_url}`} width="100" >
</img> </img>
</a> </a>
<div className="ml10 flex1"> <div className="ml10 flex1">

@ -297,8 +297,8 @@ class PackageIndexNEITaskDetails extends Component {
onMouseOver={this.setover} onMouseOver={this.setover}
onMouseOut={this.setout} onMouseOut={this.setout}
> >
{overtype===false?<a className="ContacttheTA fl" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${data&&data.creator.login}`}> <img alt="头像" class="mr5" src={require('./newsone.png')} />联系TA</a>: {overtype===false?<a className="ContacttheTA fl" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${data&&data.creator.id}`}> <img alt="头像" class="mr5" src={require('./newsone.png')} />联系TA</a>:
<a className="ContacttheTAs fl" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${data&&data.creator.login}`}> <img alt="头像" className="mr5" <a className="ContacttheTAs fl" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${data&&data.creator.id}`}> <img alt="头像" className="mr5"
src={require('./newstwo.png')}/>联系TA</a>} src={require('./newstwo.png')}/>联系TA</a>}
</div>} </div>}
</div> </div>
@ -411,7 +411,7 @@ class PackageIndexNEITaskDetails extends Component {
{item.status==="bidding_won"?<img src={gouxuan} className="yslgouxuanimg"/>:""} {item.status==="bidding_won"?<img src={gouxuan} className="yslgouxuanimg"/>:""}
<a href={`/users/${item.login}`}><img className="div1imgs" src={getImageUrl("images/"+item.image_url)}/></a> <a href={`/users/${item.login}`}><img className="div1imgs" src={getImageUrl("images/"+item.image_url)}/></a>
<div className="textall mt10" title={item.name}> <p className="ptext">{item.name}</p></div> <div className="textall mt10" title={item.name}> <p className="ptext">{item.name}</p></div>
{this.props.current_user&&this.props.current_user.login!=item.login?<a className="ContacttheTAs fl none" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${item.login}`}> {this.props.current_user&&this.props.current_user.login!=item.login?<a className="ContacttheTAs fl none" target="_blank" href={`/messages/${this.props.current_user&&this.props.current_user.login}/message_detail?target_ids=${item.id}`}>
<img alt="头像" className="mr5" src={require('./newstwo.png')}/>联系TA <img alt="头像" className="mr5" src={require('./newstwo.png')}/>联系TA
</a>:""} </a>:""}
</div> </div>

@ -132,18 +132,19 @@ class InfosPackage extends Component{
delectproject=(id)=>{ delectproject=(id)=>{
let {cate,status}=this.state; let {category,status}=this.state;
debugger
let url=`/project_packages/${id}.json` let url=`/project_packages/${id}.json`
axios.delete(url).then((response) => { axios.delete(url).then((response) => {
if (response.data.status == 0) { if (response.data.status == 0) {
this.getCourses(cate,status,1); this.getCourses(category,status,1);
} }
}) })
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
this.cancelProject; this.cancelProject();
} }
render(){ render(){
let{ let{

Loading…
Cancel
Save