Merge remote-tracking branch 'origin/topic_bank' into topic_bank

dev_aliyun_beta
杨树明 5 years ago
commit 383c2f33c1

@ -83,4 +83,4 @@ $(document).on("turbolinks:before-cache", function () {
// });
$(function () {
});
});

@ -0,0 +1,8 @@
class Wechats::JsSdkSignaturesController < ApplicationController
def create
signature = Util::Wechat.js_sdk_signature(params[:url], params[:noncestr], params[:timestamp])
render_ok(signature: signature)
rescue Util::Wechat::Error => ex
render_error(ex.message)
end
end

@ -0,0 +1,74 @@
module Util::Wechat
BASE_SITE = 'https://api.weixin.qq.com'.freeze
Error = Class.new(StandardError)
class << self
attr_accessor :appid, :secret
def js_sdk_signature(url, noncestr, timestamp)
str = { jsapi_ticket: jsapi_ticket, noncestr: noncestr, timestamp: timestamp, url: url }.to_query
Digest::SHA1.hexdigest(str)
end
def access_token
# 7200s 有效时间
Rails.cache.fetch(access_token_cache_key, expires_in: 100.minutes) do
result = request(:get, '/cgi-bin/token', appid: appid, secret: secret, grant_type: 'client_credential')
result['access_token']
end
end
def refresh_access_token
Rails.cache.delete(access_token_cache_key)
access_token
end
def jsapi_ticket
# 7200s 有效时间
Rails.cache.fetch(jsapi_ticket_cache_key, expires_in: 100.minutes) do
result = request(:get, '/cgi-bin/ticket/getticket', access_token: access_token, type: 'jsapi')
result['ticket']
end
end
def refresh_jsapi_ticket
Rails.cache.delete(jsapi_ticket_cache_key)
jsapi_ticket
end
def access_token_cache_key
"#{base_cache_key}/access_token"
end
def jsapi_ticket_cache_key
"#{base_cache_key}/jsapi_ticket"
end
def base_cache_key
"wechat/#{appid}"
end
private
def request(method, url, **params)
Rails.logger.error("[wechat] request: #{method} #{url} #{params.inspect}")
client = Faraday.new(url: BASE_SITE)
response = client.public_send(method, url, params)
result = JSON.parse(response.body)
Rails.logger.error("[wechat] response:#{response.status} #{result.inspect}")
if response.status != 200
raise Error, result.inspect
end
if result['errcode'].present? && result['errcode'].to_i.nonzero?
raise Error, result.inspect
end
result
end
end
end

@ -6,6 +6,9 @@ defaults: &defaults
cate_id: '-1'
callback_url: 'http://47.96.87.25:48080/api/callbacks/aliyun_vod.json'
signature_key: 'test12345678'
wechat:
appid: 'test'
secret: 'test'
development:
<<: *defaults

@ -4,7 +4,7 @@ aliyun_vod_config = {}
begin
config = Rails.application.config_for(:configuration)
aliyun_vod_config = config['aliyun_vod']
raise 'oauth wechat config missing' if aliyun_vod_config.blank?
raise 'aliyun vod config missing' if aliyun_vod_config.blank?
rescue => ex
raise ex if Rails.env.production?

@ -0,0 +1,16 @@
wechat_config = {}
begin
config = Rails.application.config_for(:configuration)
wechat_config = config['wechat']
raise 'wechat config missing' if wechat_config.blank?
rescue => ex
raise ex if Rails.env.production?
puts %Q{\033[33m [warning] wechat config or configuration.yml missing,
please add it or execute 'cp config/configuration.yml.example config/configuration.yml' \033[0m}
wechat_config = {}
end
Util::Wechat.appid = wechat_config['appid']
Util::Wechat.secret = wechat_config['secret']

@ -880,6 +880,10 @@ Rails.application.routes.draw do
end
end
namespace :wechats do
resource :js_sdk_signature, only: [:create]
end
#git 认证回调
match 'gitauth/*url', to: 'gits#auth', via: :all

@ -186,7 +186,7 @@ class BoardsNew extends Component{
});
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
// title: '确定要删除这个附件吗?',
title: '是否确认删除?',

@ -218,7 +218,8 @@ class CommonWorkAppraise extends Component{
</a>
<span className="color656565 mt2 color-grey-6 font-12 mr8">{item.filesize}</span>
{/*{item.delete===true?<i className="font-14 iconfont icon-guanbi " id={item.id} aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.id)}></i>:""}*/}
{item.delete===true?<i className="font-14 iconfont icon-guanbi " style={{display: 'none'}} id={item.id} aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.id)}></i>:""}
{item.delete===true?<i className="font-14 iconfont icon-guanbi " id={item.id} aria-hidden="true" onClick={()=>this.onAttachmentRemove(item.id)}></i>:""}
{/* style={{display: 'none'}} */}
</div>
)
})}

@ -320,11 +320,19 @@ class CommonWorkPost extends Component{
// ModalSave: ()=>this.deleteAttachment(file),
// ModalCancel:this.cancelAttachment
// })
if(file.response!=undefined){
this.deleteAttachment(file)
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '是否确认删除?',
onOk: () => {
this.deleteAttachment(file)
},
onCancel() {
console.log('Cancel');
},
});
return false;
}
}
cancelAttachment=()=>{

@ -3,7 +3,8 @@ import { Input, InputNumber, Form, Button, Checkbox, Upload, Icon, message, Moda
import axios from 'axios'
import '../css/busyWork.css'
import '../css/Courses.css'
import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll } from 'educoder'
import { WordsBtn, getUrl, ConditionToolTip, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll
, getUploadActionUrl } from 'educoder'
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import CBreadcrumb from '../common/CBreadcrumb'
@ -243,7 +244,7 @@ class NewWork extends Component{
}
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '是否确认删除?',
@ -331,7 +332,7 @@ class NewWork extends Component{
// https://github.com/ant-design/ant-design/issues/15505
// showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。
// showUploadList: false,
action: `${getUrl()}/api/attachments.json`,
action: `${getUploadActionUrl()}`,
onChange: this.handleContentUploadChange,
onRemove: (file) => this.onAttachmentRemove(file, 'contentFileList'),
beforeUpload: (file) => {

@ -73,7 +73,7 @@ class AccessoryModal extends Component{
// ModalCancel:this.cancelAttachment
// })
// return false;
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.deleteAttachment(file);
}
}

@ -64,7 +64,7 @@ class AccessoryModal2 extends Component{
// ModalCancel:this.cancelAttachment
// })
// return false;
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.deleteAttachment(file);
}

@ -296,7 +296,7 @@ class Selectsetting extends Component{
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})

@ -132,7 +132,7 @@ class Sendresource extends Component{
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
axios.delete(url, {
})

@ -53,11 +53,15 @@ class ExerciseDisplay extends Component{
componentDidMount = () => {
const Id = this.props.match.params.Id
if (Id) {
const url = `/exercises/${Id}.json`
const url = `/${this.props.urlPath || 'exercises'}/${Id}.json`
axios.get(url)
.then((response) => {
if (response.data.status == 0) {
this.setState({...response.data})
if (response.data.exercise) {
response.data.exercise.exercise_description = response.data.exercise.exercise_description || response.data.exercise.description
response.data.exercise.exercise_name = response.data.exercise.exercise_name || response.data.exercise.name
response.data.exercise.exercise_status = response.data.exercise.exercise_status == undefined ? 1 : response.data.exercise.exercise_status
this.setState({...response.data})
this.props.detailFetchCallback && this.props.detailFetchCallback(response);
}
})
.catch(function (error) {

@ -157,7 +157,7 @@ class GraduationTasksSubmitedit extends Component{
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
let {attachments,fileList}=this.state;
const url = `/attachments/${file}.json`
axios.delete(url, {

@ -146,7 +146,7 @@ class GraduationTasksSubmitnew extends Component{
// },
// });
// return false;
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.setState({
Modalstype:true,
Modalstopval:'确定要删除这个附件吗?',

@ -88,7 +88,7 @@ class GraduationTasksappraiseMainEditor extends Component{
this.setState({ fileList });
}
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '确定要删除这个附件吗?',
okText: '确定',

@ -150,7 +150,7 @@ class GraduationTasksedit extends Component{
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
// debugger
this.cancelAttachment();
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`

@ -173,7 +173,7 @@ class GraduationTasksnew extends Component {
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
const url = `/attachments/${file.response ? file.response.id : file.uid}.json`
// const url = `/attachments/${file}.json`
axios.delete(url, {})

@ -216,7 +216,7 @@ class GraduateTopicNew extends Component{
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',

@ -163,7 +163,7 @@ class GraduateTopicPostWorksNew extends Component{
this.setState({ fileList });
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',

@ -73,7 +73,7 @@ class CreateGroupByImportModal extends Component{
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '是否确认删除?',

@ -2499,6 +2499,8 @@ class Listofworksstudentone extends Component {
// console.log(data);
// console.log(datas);
// console.log(this.props.isAdmin());
console.log("学生老师列表");
return (
this.props.isAdmin() === true ?
(

@ -561,7 +561,7 @@ class MemoNew extends Component {
}
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
// title: '确定要删除这个附件吗?',
content: '是否确认删除?',

@ -47,7 +47,7 @@ class CaseNew extends Component{
// 上传附件-删除确认框
onAttachmentRemove = (file, stateName) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
this.props.confirm({
content: '是否确认删除?',
onOk: () => {

@ -1384,7 +1384,7 @@ export default class TPMsettings extends Component {
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',

@ -772,7 +772,7 @@ class Newshixuns extends Component {
}
onAttachmentRemove = (file) => {
if(file.response!=undefined){
if(!file.percent || file.percent == 100){
confirm({
title: '确定要删除这个附件吗?',
okText: '确定',

@ -149,6 +149,13 @@ class BanksIndex extends Component{
/>)
}
}></Route>
<Route path='/banks/exercise/:Id'
render={
(props) => {
return (<BanksTabIndex {...this.props} {...props} {...this.state} {...common}
/>)
}
}></Route>
<Route path='/banks/gtopic/:bankId/edit'
render={

@ -17,6 +17,11 @@ const PollBanks = Loadable({
loader: () => import('./PollBanksContent'),
loading: Loading,
})
// 试卷详情
const ExerciseBanksDetail = Loadable({
loader: () => import('./ExerciseBanksDetail'),
loading: Loading,
});
class BanksTabIndex extends Component{
constructor(props){
@ -53,7 +58,13 @@ class BanksTabIndex extends Component{
></BanksMenu>
}
<Switch {...this.props}>
<Route path='/banks/exercise/:Id'
render={
(props) => {
return (<ExerciseBanksDetail {...this.props} {...props} {...this.state} {...common}
/>)
}
}></Route>
<Route path='/banks/gtopic/:bankId'
render={

@ -0,0 +1,54 @@
import React, { Component } from 'react';
import axios from 'axios'
import ExerciseDisplay from '../../../courses/exercise/ExerciseDisplay'
class ExerciseBanksDetail extends Component{
constructor(props){
super(props);
this.state={
}
}
componentDidMount = () =>{
}
detailFetchCallback = (result) => {
let Id=this.props.match.params.Id;
const crumbData={
title: result.data.exercise && result.data.exercise.name,
is_public: result.data.exercise && result.data.exercise.is_public,
crumbArray:[
{content:'详情'},
]
}
const menuData={
tab:'0',//tab选中的index
menuArray:[//tab以及tab路由
{to:`/banks/exercise/${Id}`,content:'内容详情'}
],
category:'exercise',//
tos: `/banks/exercise/${Id}/edit`,
id: Id,
}
this.props.initPublic(crumbData,menuData);
}
render(){
let { pollDetail } = this.state
return(
<div>
<ExerciseDisplay {...this.props} {...this.state}
urlPath = {'exercise_banks'}
detailFetchCallback={this.detailFetchCallback}
>
</ExerciseDisplay>
</div>
)
}
}
export default ExerciseBanksDetail

@ -126,7 +126,7 @@ class BanksMenu extends Component{
<span className="fr mt18">
<WordsBtn onClick={()=>this.deletecheckBoxValues(banksMenu&&banksMenu.id,banksMenu&&banksMenu.category)}style="blue" className="ml20 font-16">删除</WordsBtn>
<WordsBtn to={banksMenu&&banksMenu.category==='poll'?banksMenu.tos:""} style="blue" className="ml20 font-16">编辑</WordsBtn>
<WordsBtn to={ banksMenu.tos ? banksMenu.tos:""} style="blue" className="ml20 font-16">编辑</WordsBtn>
<WordsBtn onClick={()=>this.sendTopics()} style="blue" className="ml20 font-16">发送</WordsBtn>
</span>
</div>

Loading…
Cancel
Save