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

dev_cs
杨树明 5 years ago
commit 664777d571

@ -0,0 +1,2 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.

@ -0,0 +1,3 @@
// Place all the styles related to the subject_lists controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

@ -19,7 +19,7 @@ class Ecs::RequirementSupportObjectivesController < Ecs::BaseController
end
def create
record = EcRequirementVsObjective.find_by_or_initialize(permit_params)
record = EcRequirementVsObjective.find_or_initialize_by(permit_params)
record.status = true
record.save!
@ -36,18 +36,20 @@ class Ecs::RequirementSupportObjectivesController < Ecs::BaseController
private
def check_record_exists!
unless current_year.ec_graduation_requirements.exists?(id: params[:graduation_requirement_id])
unless current_year.ec_graduation_requirements.exists?(id: params[:ec_graduation_requirement_id])
render_not_found
return
end
unless current_year.ec_training_subitems.exists?(id: params[:training_subitem_id])
unless current_year.ec_training_subitems.exists?(id: params[:ec_training_subitem_id])
render_not_found
return
end
end
def permit_params
params.require(%i[graduation_requirement_id training_subitem_id])
hash = params.permit(%i[ec_graduation_requirement_id ec_training_subitem_id])
hash[:ec_training_objective_id] = hash.delete(:ec_training_subitem_id)
hash
end
end

@ -19,7 +19,7 @@ class Ecs::SubitemSupportStandardsController < Ecs::BaseController
end
def create
record = EcRequireSubVsStandard.find_by_or_initialize(permit_params)
record = EcRequireSubVsStandard.find_or_initialize_by(permit_params)
record.status = true
record.save!

@ -0,0 +1,6 @@
class LibraryTagsController < ApplicationController
def index
library_tags = LibraryTag.all
render_ok(library_tags: library_tags.as_json(only: %i[id name]), count: library_tags.size)
end
end

@ -5,6 +5,6 @@ class ShixunListsController < ApplicationController
private
def search_params
params.permit(:keyword, :type, :page, :limit, :order, :type, :status, :diff)
params.permit(:keyword, :type, :page, :limit, :order, :status, :diff)
end
end

@ -0,0 +1,10 @@
class SubjectListsController < ApplicationController
def index
@results = SubjectSearchService.call(search_params)
end
private
def search_params
params.permit(:keyword, :type, :page, :limit, :order, :sort)
end
end

@ -0,0 +1,2 @@
module SubjectListsHelper
end

@ -18,7 +18,9 @@ module Searchable::Subject
def search_data
{
name: name,
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH]
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH],
shixuns_count: shixuns_count,
myshixuns_count: member_count,
}.merge!(searchable_user_data)
.merge!(searchable_stages_data)
end
@ -45,7 +47,8 @@ module Searchable::Subject
visits_count: visits,
stage_count: stages_count,
stage_shixuns_count: stage_shixuns_count,
shixuns_count: shixuns_count
shixuns_count: shixuns_count,
myshixuns_count: member_count
}
end

@ -0,0 +1,42 @@
class SubjectSearchService < ApplicationService
include ElasticsearchAble
attr_reader :params
def initialize(params)
@params = params
end
def call
# 全部实训/我的实训
type = params[:type] || "all"
if type == "mine"
@subjects = User.current.shixuns.visible.unhidden
else
@subjects = Subject.visible.unhidden
end
Subject.search(keyword, search_options)
end
private
def search_options
model_options = {
includes: [ user: { user_extension: :school } ]
}
model_options.merge!(where: { id: @subjects.pluck(:id) })
model_options.merge!(order: {sort_type => sort_str})
model_options.merge!(default_options)
model_options
end
def sort_str
params[:order] || "desc"
end
def sort_type
params[:sort] || "myshixuns_count"
end
end

@ -1,4 +1,4 @@
json.graduation_requirements @graduation_requirements, partial: 'ecs/ec_graduation_requirements/shared/ec_graduation_requirement', as: :ec_graduation_requirement
json.training_subitems @training_subitems, partial: 'ecs/ec_training_subitems/shared/ec_training_subitem', as: :ec_training_subitem
json.training_subitems @training_subitems, partial: 'ecs/ec_training_objectives/shared/ec_training_subitem', as: :ec_training_subitem
json.requirement_support_objectives @requirement_support_objectives, partial: 'ecs/requirement_support_objectives/shared/requirement_support_objective', as: :requirement_support_objective

@ -11,6 +11,7 @@ json.tasks @tasks.each do |task|
task_curr_status = task_curr_status(task, @course)
json.status task_curr_status[:status]
json.status_time task_curr_status[:time]
json.author task.user.real_name
unless task_curr_status[:status].include?("未发布")
json.commit_count grduationwork_count task, 1

@ -0,0 +1,22 @@
json.subjects_count @results.total_count
json.subject_list do
json.array! @results.with_highlights(multiple: true) do |obj, highlights|
json.merge! obj.to_searchable_json
# 去除开头标点符号
reg = /^[,。?:;‘’!“”—……、]/
# 附件的替换
atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '')
highlights[:description]&.map{|des| des.gsub!(atta_reg, '')}
highlights[:content]&.first&.sub!(reg, '')
highlights[:content]&.map{|des| des.gsub!(atta_reg, '')}
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.sub!(atta_reg, '')
json.content highlights
end
end

@ -174,6 +174,7 @@ Rails.application.routes.draw do
end
end
resources :subject_lists
resources :shixun_lists
resources :shixuns, param: :identifier do
@ -791,6 +792,7 @@ Rails.application.routes.draw do
end
resources :libraries, only: [:index, :show, :create, :update, :destroy]
resources :library_tags, only: [:index]
scope module: :projects do
resources :project_applies, only: [:create]

@ -0,0 +1,9 @@
class AddLibraryTagData < ActiveRecord::Migration[5.2]
def up
execute 'INSERT INTO library_tags(id, name) VALUES(4, "高校案例")'
end
def down
execute 'DELETE FROM library_tags WHERE id = 4 and name = "高校案例"'
end
end

@ -63,10 +63,10 @@ class BoardsListItem extends Component{
<div className="clearfix ds pr pt5 contentSection" onClick={() => onItemClick(discussMessage)}>
<h6>
<Tooltip title={canNotLink?"私有属性,非课堂成员不能访问":`${discussMessage.subject.length > 40 ? discussMessage.subject : ''}`} placement="bottom">
<a className="panel-list-title hide fl mt5 color-dark font-bd pointer"
style={{ fontWeight: 'bold', cursor: (canNotLink ? 'poninter' : 'poninter'), maxWidth: '700px' }}
{canNotLink?<span className="fl mt3 font-16 font-bd color-dark maxwidth580 pointer">{discussMessage.subject}</span>:<a className="panel-list-title hide fl mt5 color-dark font-bd pointer"
style={{ fontWeight: 'bold', maxWidth: '700px' }}
onClick={canNotLink ? () => {} : () => this.onTitleClick(discussMessage)}
>{discussMessage.subject}</a>
>{discussMessage.subject}</a>}
</Tooltip>
{ !!discussMessage.sticky && <span className="btn-cir btn-cir-red fl mt5 ml5">置顶</span> }
{

@ -144,6 +144,9 @@ class CommonWorkItem extends Component{
text-overflow: ellipsis;
white-space: nowrap;
}
a:hover{
color: #4cacff;
}
`
}
</style>
@ -158,12 +161,15 @@ class CommonWorkItem extends Component{
mainList && isAdmin &&
<span className="fl mr12"><Checkbox value={item.homework_id} key={item.homework_id}></Checkbox></span>
}
<div className="flex1" onClick={() => this.props.onItemClick(Object.assign({}, item, {id: item.homework_id})) }>
<p className="clearfix mb20">
<Tooltip title={ canNotLink ? "私有属性,非课堂成员不能访问" : item.name} placement="bottom" >
<span className="fl font-16 font-bd mt2 comnonwidth580 pointer" style={{cursor: canNotLink ? 'poninter' : 'poninter'}}
{canNotLink?<span className={"fl font-16 font-bd mt2 comnonwidth580 pointer color-grey-name"}>
{item.name}
</span>:<a className={"fl font-16 font-bd mt2 comnonwidth580 pointer"}
onClick={ canNotLink ? () => {} : () => this.onItemClick(item)}
>{item.name}</span>
>{item.name}</a>}
</Tooltip>
{/* 只有非课堂成员且作业是私有的情况下才会为true */}
{

@ -274,7 +274,7 @@ class GraduateTaskItem extends Component{
<p className="color-grey mt16 fl">
<span className="mr50">
{/* <a href="/users/innov" className="panel-name-small hide fl mr15 mr30 color-grey3">{discussMessage.author.name}</a> */}
{ discussMessage.author && <span className="mr15 color-grey-3">{discussMessage.author}</span> }
{discussMessage.commit_count===undefined?"":<span className="mr15 color-grey9 font-14">{discussMessage.commit_count} 已交</span>}
{discussMessage.uncommit_count===undefined?"":<span className="mr15 color-grey9 font-14">{discussMessage.uncommit_count} 未交</span>}
{/*<span className="mr15 color-grey9">{discussMessage.replies_count} 3 未评</span>*/}

@ -83,12 +83,16 @@ class GraduateTopicItem extends Component{
text-overflow:ellipsis;
white-space:nowrap
}
a:hover{
color: #4cacff;
}
`}</style>
<h6>
{
isNotMember?
<Tooltip title={ discussMessage.private_icon===true?"私有属性,非课堂成员不能访问":discussMessage.name} placement="bottom">
<span className="fl mt3 font-16 font-bd color-dark maxwidth580 pointer">{discussMessage.name}</span>
{discussMessage.private_icon===true?<span className="fl mt3 font-16 font-bd color-dark maxwidth580 pointer">{discussMessage.name}</span>:
<a className="fl mt3 font-16 font-bd color-dark maxwidth580 pointer">{discussMessage.name}</a>}
</Tooltip>:""
}

@ -41,7 +41,8 @@ class CaseNew extends Component{
loading: false,
checkTag:false,
checkFile:false,
coverID:undefined
coverID:undefined,
library_tags:undefined
}
}
@ -132,6 +133,17 @@ class CaseNew extends Component{
if(this.props.match.params.caseID){
this.InitEditData();
}
let url=`/library_tags.json`;
axios.get(url).then((result) => {
console.log(result)
if(result.data.status===0){
this.setState({
library_tags:result.data.library_tags
})
}
}).catch((error) => {
console.log(error);
})
}
componentDidUpdate=(prevState)=>{
@ -263,7 +275,7 @@ class CaseNew extends Component{
render(){
let { caseID } = this.props.match.params;
let { CaseDetail } = this.props;
let { casesTags , contentFileList , imageUrl , checkTag , checkFile } = this.state;
let { casesTags , contentFileList , imageUrl , checkTag , checkFile,library_tags } = this.state;
const {getFieldDecorator} = this.props.form;
@ -301,8 +313,8 @@ class CaseNew extends Component{
action:`${getUploadActionUrl()}`,
onChange:this.handleChange,
}
console.log('111');
console.log(!caseID || (CaseDetail && CaseDetail.status == "pending"));
// console.log('111');
// console.log(!caseID || (CaseDetail && CaseDetail.status == "pending"));
return(
<div className="educontent mt10 mb50">
<style>
@ -380,9 +392,11 @@ class CaseNew extends Component{
<div className={checkTag==true ? "clearfix mb20 pr has-error" : "clearfix mb20"} id="tagFormItem">
<span className="upload_Title must">标签</span>
<ul className="fl libraries_tab">
<li className={ casesTags.indexOf(1) > -1 ? "active" :"" } onClick={()=>this.changeType(1)}>获奖案例</li>
<li className={ casesTags.indexOf(2) > -1 ? "active" :"" } onClick={()=>this.changeType(2)}>入库案例</li>
<li className={ casesTags.indexOf(3) > -1 ? "active" :"" } onClick={()=>this.changeType(3)}>企业案例</li>
{library_tags&&library_tags.map((item,key)=>{
return(
<li key={key} className={ casesTags.indexOf(item.id) > -1 ? "active" :"" } onClick={()=>this.changeType(item.id)}>{item.name}</li>
)
})}
</ul>
{
checkTag && <div class="ant-form-explain">请选择标签</div>

@ -1,36 +1,37 @@
import React,{ Component } from "react";
import './css/moopCases.css'
import '../courses/css/Courses.css'
class CaseTags extends Component{
constructor(props){
super(props);
}
render(){
let { tags } = this.props;
return(
<React.Fragment>
{
tags && tags.map((item,key)=>{
return(
<React.Fragment>
{
item.name == "获奖案例" ?
<span key={key} className="edu-filter-btn fl cdefault edu-activity-red ml10">{item.name}</span>
:
item.name == "入库案例" ?
<span key={key} className="edu-filter-btn fl cdefault edu-activity-blue ml10">{item.name}</span>
:
<span key={key} className="edu-filter-btn fl cdefault edu-activity-orange-sub ml10">{item.name}</span>
}
</React.Fragment>
)
})
}
</React.Fragment>
)
}
}
import React,{ Component } from "react";
import './css/moopCases.css'
import '../courses/css/Courses.css'
class CaseTags extends Component{
constructor(props){
super(props);
}
render(){
let { tags } = this.props;
return(
<React.Fragment>
{
tags && tags.map((item,key)=>{
return(
<React.Fragment>
{
item.name == "获奖案例" ?
<span key={key} className="edu-filter-btn fl cdefault edu-activity-red ml10">{item.name}</span>
:
item.name == "入库案例" ?
<span key={key} className="edu-filter-btn fl cdefault edu-activity-blue ml10">{item.name}</span>
:item.name =='企业案例'?
<span key={key} className="edu-filter-btn fl cdefault edu-activity-orange-sub ml10">{item.name}</span>
: <span key={key} className="edu-filter-btn fl cdefault edu-activity-36c53c-sub ml10">{item.name}</span>
}
</React.Fragment>
)
})
}
</React.Fragment>
)
}
}
export default CaseTags;

@ -69,7 +69,13 @@
border: 1px solid #ff6800;
line-height: 17px;
}
.edu-activity-36c53c-sub {
background-color: #36c53c;
color: #fff!important;
cursor: pointer;
border: 1px solid #36c53c;
line-height: 17px;
}
.pointsBtn {
width: 70px;
height: 70px;

@ -489,6 +489,9 @@ class PathDetailIndex extends Component{
.padding40-20-30{
padding:40px 20px 30px;
}
.pathDetailIndex .markdown-body > p {
line-height: 28px;
}
`
}
</style>
@ -501,7 +504,7 @@ class PathDetailIndex extends Component{
loadtype={loadtype}
>
</Modals>
<div className="newMain clearfix">
<div className="newMain clearfix pathDetailIndex">
<DetailTop {...this.state} {...this.props} getdatasindex={(key)=>this.getdatasindex(key)} getMenuItemsindex={(key,status)=>this.getMenuItemsindex(key,status)} getlistdatas={()=>this.getlistdatas()}></DetailTop>
<div className="educontent clearfix mb80">
<div className="with65 fl">

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe SubjectListsController, type: :controller do
end

@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the SubjectListsHelper. For example:
#
# describe SubjectListsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe SubjectListsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save