diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c80ca2348..bf8a0651e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -229,7 +229,7 @@ class ApplicationController < ActionController::Base uid_logger("user_setup: " + (User.current.logged? ? "#{User.current.try(:login)} (id=#{User.current.try(:id)})" : "anonymous")) if !User.current.logged? && Rails.env.development? - User.current = User.find 12 + User.current = User.find 57703 end if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 diff --git a/app/controllers/concerns/controller_rescue_handler.rb b/app/controllers/concerns/controller_rescue_handler.rb index bacd6a793..101b72f5c 100644 --- a/app/controllers/concerns/controller_rescue_handler.rb +++ b/app/controllers/concerns/controller_rescue_handler.rb @@ -3,7 +3,7 @@ module ControllerRescueHandler included do rescue_from Exception do |e| - logger.error e + Util.logger_error e render json: {status: -1, message: e.message} end # rescue_from ActionView::MissingTemplate, with: :object_not_found diff --git a/app/controllers/concerns/paginate_helper.rb b/app/controllers/concerns/paginate_helper.rb index 13148bf42..34740eb5d 100644 --- a/app/controllers/concerns/paginate_helper.rb +++ b/app/controllers/concerns/paginate_helper.rb @@ -1,7 +1,7 @@ module PaginateHelper def paginate(objs, **opts) page = params[:page].to_i <= 0 ? 1 : params[:page].to_i - per_page = params[:per_page].to_i > 0 ? params[:per_page].to_i : 20 + per_page = params[:per_page].to_i > 0 ? params[:per_page].to_i : opts[:per_page] || 20 Kaminari.paginate_array(objs).page(page).per(per_page) end diff --git a/app/controllers/departments_controller.rb b/app/controllers/departments_controller.rb index b6ebcb2ef..5e82b2c51 100644 --- a/app/controllers/departments_controller.rb +++ b/app/controllers/departments_controller.rb @@ -1,6 +1,6 @@ class DepartmentsController < ApplicationController def for_option - render_ok(departments: current_school.departments.select(:id, :name).as_json) + render_ok(departments: current_school.departments.without_deleted.select(:id, :name).as_json) end private diff --git a/app/controllers/tidings_controller.rb b/app/controllers/tidings_controller.rb index 686f457f0..795010b3f 100644 --- a/app/controllers/tidings_controller.rb +++ b/app/controllers/tidings_controller.rb @@ -1,19 +1,32 @@ class TidingsController < ApplicationController + include PaginateHelper + + after_action :update_onclick_time!, only: [:index] + def index - tidings = current_user.tidings.order(created_at: :desc) + tidings = current_user.tidings tiding_types = case params[:type] when 'notice' then 'System' when 'apply' then 'Apply' - when 'course' then %w(HomeworkCommon Exercise Poll) + when 'course' then %w(HomeworkCommon Exercise Poll GraduationTask GraduationTopic) when 'project' then 'Project' when 'interaction' then %w(Comment Mentioned Praise Fan) + when 'project_package' then %w(Created Destroyed Bidding BiddingEnd BiddingWon BiddingLost) end - tidings = tidings.where(tiding_type: tiding_types) if tiding_types.present? + tidings = tidings.where(container_type: 'ProjectPackage') if params[:type] == 'project_package' + @count = tidings.count - @tidings = paginate tidings + @tidings = paginate(tidings.order(created_at: :desc), per_page: 10) + @onclick_time = current_user.click_time + end + + private + + def update_onclick_time! + current_user.onclick_time.touch(:onclick_time) end end \ No newline at end of file diff --git a/app/decorators/tiding_decorator.rb b/app/decorators/tiding_decorator.rb index a9faeae84..8d383dadf 100644 --- a/app/decorators/tiding_decorator.rb +++ b/app/decorators/tiding_decorator.rb @@ -8,6 +8,10 @@ module TidingDecorator time_from_now(created_at) end + def unread?(time) + created_at > time + end + # 组装国际化路径:locale_format('Apply', 1) ==> tiding.ApplyUserAuthentication.Apply.1_end def locale_format(*arr) arr.unshift("tiding.#{container_type}").join('.') << '_end' @@ -340,4 +344,20 @@ module TidingDecorator def department_content I18n.t(locale_format) % [container.try(:name), container.try(:school)&.name] end + + def library_content + if tiding_type == 'System' + I18n.t(locale_format(tiding_type, status), reason: extra) % container.try(:title) + else + I18n.t(locale_format) % container.try(:title) + end + end + + def project_package_content + if tiding_type == 'System' + I18n.t(locale_format(tiding_type, status), reason: extra) % container.try(:title) + else + I18n.t(locale_format(tiding_type)) % [container.try(:title) || extra] + end + end end diff --git a/app/models/department.rb b/app/models/department.rb index 15a8a7c1b..9c4a0908b 100644 --- a/app/models/department.rb +++ b/app/models/department.rb @@ -2,4 +2,6 @@ class Department < ApplicationRecord belongs_to :school has_many :department_members, dependent: :destroy + + scope :without_deleted, -> { where(is_delete: false) } end diff --git a/app/views/tidings/_tiding.json.jbuilder b/app/views/tidings/_tiding.json.jbuilder index 7a7168d38..d26d37b7b 100644 --- a/app/views/tidings/_tiding.json.jbuilder +++ b/app/views/tidings/_tiding.json.jbuilder @@ -1,9 +1,11 @@ -json.extract! tiding, :id, :status, :viewed, :user_id, :tiding_type, :container_type, :parent_container_type +json.extract! tiding, :id, :status, :viewed, :user_id, :tiding_type, :container_id, :container_type, :parent_container_id, :parent_container_type json.content tiding.content +json.identifier tiding.try(:container).try(:identifier) rescue nil json.time tiding.how_long_time +json.new_tiding tiding.unread?(@onclick_time) json.trigger_user do - json.partial! 'users/user_simple', user: tiding.trigger_user + json.partial! 'users/user_simple', user: tiding.trigger_user_id.zero? ? User.find(1) : tiding.trigger_user end json.attachments tiding.attachments, partial: 'attachments/attachment_small', as: :attachment diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index fbb9778e2..164c943d0 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -14,6 +14,7 @@ if @course if params[:group_info] json.group_info @course.teacher_group(@user.id) if @course_identity < Course::STUDENT end + json.first_category_url module_url(@course.none_hidden_course_modules.first, @course) end if params[:school] diff --git a/config/locales/tidings/zh-CN.yml b/config/locales/tidings/zh-CN.yml index 66262588c..07e3c2f6d 100644 --- a/config/locales/tidings/zh-CN.yml +++ b/config/locales/tidings/zh-CN.yml @@ -199,3 +199,19 @@ Apply_end: "发起了匿评申诉申请:%s" HomeworkCommon_end: "有人对你的匿评发起了申诉:%s" Department_end: "你选填的二级单位:%s(%s)因不符合规范,已被系统删除.请重新选择" + Library: + Apply_end: "申请发布教学案例:%s" + System: + 1_end: "你提交的发布教学案例申请:%s,审核已通过" + 2_end: "你提交的发布教学案例申请:%s,审核未通过,原因:%{reason}" + ProjectPackage: + Apply_end: "申请发布众包需求:%s" + System: + 1_end: "你提交的众包需求申请:%s,审核已通过" + 2_end: "你提交的众包需求申请:%s,审核未通过,原因:%{reason}" + Created_end: "你创建了众包需求:%s" + Destroyed_end: "你删除了众包需求:%s" + Bidding_end: "应征了你发布的众包任务:%s" + BiddingEnd_end: "你发布的众包任务:%s,已进入选标阶段,请尽快进行选择确认!" + BiddingWon_end: "恭喜,你应征的众包任务:%s,在评选环节中标了" + BiddingLost_end: "很遗憾,你应征投稿的众包任务:%s,未中标" diff --git a/db/migrate/20190725024516_modify_attachment_url_for_challenge_answer.rb b/db/migrate/20190725024516_modify_attachment_url_for_challenge_answer.rb new file mode 100644 index 000000000..41840bac1 --- /dev/null +++ b/db/migrate/20190725024516_modify_attachment_url_for_challenge_answer.rb @@ -0,0 +1,7 @@ +class ModifyAttachmentUrlForChallengeAnswer < ActiveRecord::Migration[5.2] + def change + ChallengeChoose.find_each do |cc| + cc.update_column(:subject, cc.subject.gsub("(/attachments/download", "(/api/attachments")) if cc.subject.present? + end + end +end diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js index 044d0a3ae..fbaa5b7c3 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js @@ -78,12 +78,12 @@ class GraduationTasksSubmitedit extends Component{ } setedit=()=>{ - let coursesId=this.props.match.params.coursesId; - let workId=this.props.match.params.work_Id; - let {workslist}=this.state - let task_id=workslist&&workslist.task_id; + // let coursesId=this.props.match.params.coursesId; + // let workId=this.props.match.params.work_Id; + // let {workslist}=this.state + // let task_id=workslist&&workslist.task_id; // window.location.href="/courses/"+coursesId+"/graduation_tasks/"+task_id+"/"+workId+"/works/edit"; - window.location.href="/courses/"+coursesId+"/graduation_tasks/"+workId+"/appraise"; + this.goback() } @@ -96,11 +96,13 @@ class GraduationTasksSubmitedit extends Component{ } goback=()=>{ - let courseId=this.props.match.params.coursesId; - let work_Id=this.props.match.params.work_Id; - // window.location.href="/courses/"+courseId+"/graduation/graduation_tasks/"+category_id; - window.location.href="/courses/"+courseId+"/graduation_tasks/"+work_Id+"/appraise"; + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } @@ -568,7 +570,7 @@ class GraduationTasksSubmitedit extends Component{

{/* {workslist&&workslist.course_name}*/} {/*>*/} - 毕设任务 + 毕设任务 > 任务详情 > @@ -825,7 +827,7 @@ class GraduationTasksSubmitedit extends Component{

- 取消 + 取消
{/**/} diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js index 50f2a4fde..dddb11e53 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js @@ -100,9 +100,12 @@ class GraduationTasksSubmitnew extends Component{ goback=()=>{ let courseId=this.props.match.params.coursesId; - let category_id=this.props.match.params.category_id; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } - window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; } @@ -438,7 +441,7 @@ class GraduationTasksSubmitnew extends Component{ spinnings:false }) if(response!==undefined){ - this.setedit(response.data.work_id) + this.goback() } // if(response.status===200) { // GraduationTasksnewtype=false; @@ -567,7 +570,7 @@ render(){

{/* {workslist&&workslist.course_name}*/} {/*>*/} - 毕设任务 + 毕设任务 > 任务详情 > @@ -802,7 +805,7 @@ render(){

- 取消 + 取消
{/**/} diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksappraise.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksappraise.js index 971152781..7aa1530af 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksappraise.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksappraise.js @@ -70,7 +70,13 @@ class GraduationTasksappraise extends Component{ // let category_id=this.props.match.params.category_id; // // window.location.href="/courses/"+courseId+"/graduation_tasks/"+datalist.graduation_id; - window.history.go(-1) + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } + } Cancelvisible=()=>{ diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js index 2e9efba0c..2b55e0737 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js @@ -81,10 +81,13 @@ class GraduationTasksedit extends Component{ goback=()=>{ - // let courseId=this.props.match.params.coursesId; - // window.location.href="/courses/"+courseId+"/graduation_tasks/"+this.state.data.graduation_id; - // goback = () => { - window.history.go(-1) + + let courseId = this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } @@ -233,8 +236,8 @@ class GraduationTasksedit extends Component{ // console.log(response) // GraduationTasksedittype=false; // window.location.href="/courses/"+course_id+"/graduation/"+graduationId+"/graduation_tasks/"+category_id+"/questions"; - // this.goback() - this.props.history.push("/courses/"+this.props.match.params.coursesId+"/graduation_tasks/"+graduation_id+"/"+this.props.match.params.category_id +"/setting"); + this.goback() + //this.props.history.push("/courses/"+this.props.match.params.coursesId+"/graduation_tasks/"+graduation_id+"/"+this.props.match.params.category_id +"/setting"); } }).catch((error) => { console.log(error) @@ -333,7 +336,7 @@ class GraduationTasksedit extends Component{

- {this.props.current_user&&this.props.current_user.course_name} + {this.props.current_user&&this.props.current_user.course_name} > 毕设任务 > diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js index 90f67a984..e27d8382b 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js @@ -91,7 +91,7 @@ class GraduationTasksnew extends Component { // GraduationTasksnewtype = false; // this.goback(); if(response!==undefined){ - this.props.history.push("/courses/" + this.props.match.params.coursesId + "/graduation_tasks/" + this.props.match.params.category_id + "/" + response.data.task_id + "/setting"); + this.goback() } // } }).catch((error) => { @@ -108,9 +108,11 @@ class GraduationTasksnew extends Component { goback = () => { let courseId = this.props.match.params.coursesId; - let category_id = this.props.match.params.category_id; - - window.location.href = "/courses/" + courseId + "/graduation_tasks/" + category_id; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } @@ -307,8 +309,7 @@ class GraduationTasksnew extends Component {

- {this.props.current_user && this.props.current_user.course_name} + {this.props.current_user && this.props.current_user.course_name} > 毕设任务 diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js index 983231167..5bbbe1a14 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js @@ -761,9 +761,11 @@ class GraduationTaskssettingapp extends Component{ goback=()=>{ let courseId=this.props.match.params.coursesId; - let category_id=this.props.match.params.category_id; - - window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } isgoback=()=>{ @@ -1046,7 +1048,7 @@ class GraduationTaskssettingapp extends Component{

- {coursename} + {coursename} > 毕设任务 > diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js index 291095008..d773d8411 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js @@ -57,11 +57,15 @@ class GraduationTaskssettinglist extends Component{ let{teacher_comment,task_status,course_group,cross_comment,order,b_order,search}=this.state; this.seacthdata(teacher_comment,task_status,course_group,cross_comment,order,b_order,search,this.state.page); } + goback=()=>{ // window.history.back(-1) let courseId=this.props.match.params.coursesId; - let category_id=this.props.match.params.category_id; - window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } @@ -1058,7 +1062,7 @@ class GraduationTaskssettinglist extends Component{

- {taskslistdata.course_name} + {taskslistdata.course_name} > {taskslistdata.graduation_name} > diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingquestions.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingquestions.js index dee8f0c91..1bf6eb962 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingquestions.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingquestions.js @@ -55,7 +55,12 @@ class GraduationTasksquestions extends Component{ // let courseId=this.props.match.params.coursesId; // let category_id=this.props.match.params.category_id; // window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; - window.history.go(-1) + let courseId = this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } end=()=>{ @@ -300,7 +305,7 @@ class GraduationTasksquestions extends Component{

- {questionslist.course_name} + {questionslist.course_name} > {questionslist.graduation_name} > diff --git a/public/react/src/modules/courses/new/CoursesNew.js b/public/react/src/modules/courses/new/CoursesNew.js index 6e996297b..fce6cd732 100644 --- a/public/react/src/modules/courses/new/CoursesNew.js +++ b/public/react/src/modules/courses/new/CoursesNew.js @@ -28,6 +28,7 @@ function disabledDateTime() { }; } + class CoursesNew extends Component { constructor(props) { @@ -191,17 +192,7 @@ class CoursesNew extends Component { ).then((response) => { // debugger if (response.data.status === 0) { - // this.setState({ - // Modalstype: true, - // Modalstopval: response.data.message, - // ModalSave: this.cancelmodel, - // Loadtype: true, - // checkBoxValues: [], - // checkAllValue: false, - // // Realnamecertification : authentication, - // // professional_certification: values.Professionalcertification - // }) - window.location.href = "/courses/" + coursesId+"/students"; + this.goback } }).catch((error) => { console.log(error) @@ -262,7 +253,7 @@ class CoursesNew extends Component { if(this.props.match.params.coursesId===undefined){ this.props.history.push("/courses"); }else{ - this.props.history.push(`/courses/${this.props.match.params.coursesId}`); + this.props.history.push(this.props.current_user.first_category_url); } // window.history.go(-1) } @@ -390,7 +381,7 @@ class CoursesNew extends Component { const optionschool = this.state.searchlistscholl&&this.state.searchlistscholl.map(z => ); // console.log(this.props.current_user.user_school) // form合并了 - console.log(options) + return ( diff --git a/public/react/src/modules/home/shixunsHome.js b/public/react/src/modules/home/shixunsHome.js index 92f3c9f44..9c166f43f 100644 --- a/public/react/src/modules/home/shixunsHome.js +++ b/public/react/src/modules/home/shixunsHome.js @@ -93,7 +93,7 @@ class ShixunsHome extends Component { const CustomNextArrow = props => { return (

- +
); }; @@ -101,7 +101,7 @@ class ShixunsHome extends Component { const CustomPrevArrow = props => { return (
- +
); }; @@ -374,7 +374,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -388,7 +388,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -402,7 +402,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -418,7 +418,7 @@ class ShixunsHome extends Component { return (
  • - + {item.username}
  • @@ -450,7 +450,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -464,7 +464,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -478,7 +478,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -494,7 +494,7 @@ class ShixunsHome extends Component { return (
  • - + {item.username}
  • diff --git a/public/react/src/modules/paths/ShixunPathCard.js b/public/react/src/modules/paths/ShixunPathCard.js index 9260b9f46..1b0759d1f 100644 --- a/public/react/src/modules/paths/ShixunPathCard.js +++ b/public/react/src/modules/paths/ShixunPathCard.js @@ -38,7 +38,7 @@ class ShixunPathCard extends Component{
    {/*target="_blank"*/} - 13?1543211263 + 13?1543211263