Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
commit
ea3ba1f71e
@ -1,6 +1,26 @@
|
||||
class UserWechat < ActiveRecord::Base
|
||||
attr_accessible :subscribe, :openid, :nickname, :sex, :language, :city, :province, :country,
|
||||
:headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user, :user_id
|
||||
:headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user, :user_id, :bindtype
|
||||
|
||||
belongs_to :user
|
||||
|
||||
def real?
|
||||
bindtype == 0
|
||||
end
|
||||
|
||||
def migrate_user(u)
|
||||
self.bindtype = 0
|
||||
old_user = user.id
|
||||
self.user = u
|
||||
self.save
|
||||
|
||||
## 主要是将comment 迁移
|
||||
User.delete(old_user)
|
||||
|
||||
JournalsForMessage.where(user_id: old_user).update_all(user_id: u.id)
|
||||
Journal.where(user_id: old_user).update_all(user_id: u.id)
|
||||
Comment.where(author_id: old_user).update_all(author_id: u.id)
|
||||
Message.where(author_id: old_user).update_all(author_id: u.id)
|
||||
BlogComment.where(author_id: old_user).update_all(author_id: u.id)
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddBindtypeToUserWechats < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :user_wechats, :bindtype, :integer, :default => 0
|
||||
end
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
require 'wechat/token/access_token_base'
|
||||
|
||||
module Wechat
|
||||
module Token
|
||||
class AuthAccessToken < AccessTokenBase
|
||||
|
||||
# def refresh
|
||||
# params = {
|
||||
# appid: access_token.appid,
|
||||
# grant_type: 'refresh_token',
|
||||
# refresh_token: user_refresh_token
|
||||
# }
|
||||
# data = client.get 'oauth2/refresh_token', params: params, base: OAUTH2_BASE
|
||||
# write_token_to_file(data)
|
||||
# read_token_from_file
|
||||
# end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,13 @@
|
||||
<div class="post-container">
|
||||
<div loading-spinner></div>
|
||||
|
||||
<div class="blue-title">提示</div>
|
||||
<div class="ac-wrap">
|
||||
<ul class="ac-content f13 c-grey3">
|
||||
<li class="mt30 mb15"><span class="project-intro-dot">•</span>您的回复内容已提交</li>
|
||||
<li class="mb15"><span class="project-intro-dot">•</span>想要实时接收动态、加入社区?<br/>长按二维码,关注公众号</li>
|
||||
<li class="mb20" style="text-align:center;"><img src="/images/wechat/trustie_QR.jpg" width="150" class="inline-block" /></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
After Width: | Height: | Size: 156 KiB |
After Width: | Height: | Size: 31 KiB |
@ -1,181 +1,185 @@
|
||||
app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms', function($scope, config, $http, auth, $location, $routeParams,alertService,rms){
|
||||
|
||||
var vm = $scope;
|
||||
var courseid = $routeParams.id;
|
||||
var tag = $routeParams.tag;
|
||||
|
||||
|
||||
var getUsers = function(){
|
||||
if(vm.teachers.length<=0){
|
||||
$http.get(config.apiUrl + 'courses/teachers?token='+auth.token()+'&course_id='+courseid).then(
|
||||
function(response) {
|
||||
console.log(response.data);
|
||||
vm.teachers = response.data.data;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if(vm.course.is_creator){
|
||||
if(vm.reviewers.length<=0){
|
||||
$http.get(config.apiUrl + 'courses/reviewers?token='+auth.token()+'&course_id='+courseid).then(
|
||||
function(response) {
|
||||
console.log(response.data);
|
||||
vm.reviewers = response.data.data;
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if(vm.students.length<=0){
|
||||
$http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then(
|
||||
function(response) {
|
||||
console.log(response.data);
|
||||
vm.students = response.data.data;
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var getResources = function(){
|
||||
if(vm.resources.length<=0){
|
||||
$http.post(config.apiUrl + "courses/"+courseid+"/attachments",
|
||||
{token: auth.token(), name: ''}
|
||||
).then(function(response){
|
||||
vm.resources = response.data.data;
|
||||
vm.resources_tag = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var getHomeworks = function(){
|
||||
if(vm.homeworks.length <=0){
|
||||
$http.get(config.apiUrl + "courses/homeworks/"+courseid+"?token="+auth.token()).then(function(response){
|
||||
vm.homeworks = response.data.data;
|
||||
console.log(response.data);
|
||||
vm.homeworks_tag = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var getExercises = function(){
|
||||
if(vm.exercises.length <=0){
|
||||
$http.get(config.apiUrl + "courses/"+courseid+"/exercises?token="+auth.token()).then(function(response){
|
||||
vm.exercises = response.data.data;
|
||||
console.log(response.data);
|
||||
vm.exercises_tag = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vm.isTeacher = false;
|
||||
vm.currentTab = 1;
|
||||
vm.tab = function(index){
|
||||
vm.currentTab = index;
|
||||
vm.searchText = '';
|
||||
|
||||
vm.showClassMate = false;
|
||||
vm.showResources = false;
|
||||
vm.showHomework = false;
|
||||
vm.showTestcase = false;
|
||||
vm.resources_tag = false;
|
||||
vm.homeworks_tag = false;
|
||||
vm.exercises_tag = false;
|
||||
|
||||
if(vm.isTeacher){
|
||||
if(index == 1){ //课件
|
||||
getResources();
|
||||
vm.showResources = true;
|
||||
} else if(index==2){ //作业
|
||||
getHomeworks();
|
||||
vm.showHomework = true;
|
||||
} else if(index==3){ //小测验
|
||||
getExercises();
|
||||
vm.showTestcase = true;
|
||||
} else if(index==4){ //学生管理
|
||||
getUsers();
|
||||
vm.showClassMate = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
if(index == 2){
|
||||
getUsers();
|
||||
vm.showClassMate = true;
|
||||
} else if(index==1){
|
||||
getResources();
|
||||
vm.showResources = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vm.course = {};
|
||||
vm.students = [];
|
||||
vm.teachers = [];
|
||||
vm.reviewers = []; //待审批
|
||||
vm.resources = [];
|
||||
vm.homeworks = [];
|
||||
vm.exercises = [];
|
||||
|
||||
//发送类别 1课件 2作业 3测验
|
||||
vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1;
|
||||
|
||||
vm.alertService = alertService.create();
|
||||
|
||||
vm.invite = function(){
|
||||
$location.path("/invite_code").search({id: courseid});
|
||||
};
|
||||
|
||||
vm.sendFile = function(r,index){
|
||||
vm.myresource_sendIndex = index;
|
||||
rms.save('myresource_sendIndex',index);
|
||||
$location.path("/send_class_list").search({id: r.id});
|
||||
}
|
||||
|
||||
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
|
||||
function(response) {
|
||||
console.log(response.data);
|
||||
|
||||
if (response.data.status == 0){
|
||||
vm.course = response.data.data;
|
||||
resetMenu(vm.course.current_user_is_teacher);
|
||||
if(tag){
|
||||
vm.tab(4);
|
||||
tag = null;
|
||||
}
|
||||
else{
|
||||
vm.tab(1);
|
||||
}
|
||||
}
|
||||
else{
|
||||
vm.alertService.showMessage('提示', response.data.message);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
var resetMenu = function(is_teacher){
|
||||
vm.isTeacher = is_teacher;
|
||||
if(is_teacher){
|
||||
vm.menus = ["课件", "作业", "测验", "成员管理"];
|
||||
} else {
|
||||
vm.menus = ['课件', "我的同学"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vm.onSetting = function(user){
|
||||
rms.save('current_edit_member', user);
|
||||
$location.path("/edit_class_member").search({id: courseid,user_id: user.id});
|
||||
};
|
||||
|
||||
vm.review = function(user){
|
||||
rms.save('current_review_member', user);
|
||||
rms.save('current_course', vm.course);
|
||||
|
||||
$location.path("/review_class_member").search({id: courseid,user_id: user.id});
|
||||
}
|
||||
|
||||
|
||||
|
||||
app.controller('ClassController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms','common', function($scope, config, $http, auth, $location, $routeParams,alertService,rms,common){
|
||||
common.checkLogin();
|
||||
|
||||
var vm = $scope;
|
||||
var courseid = $routeParams.id;
|
||||
var tag = $routeParams.tag;
|
||||
|
||||
|
||||
var getUsers = function(){
|
||||
if(vm.teachers.length<=0){
|
||||
$http.get(config.apiUrl + 'courses/teachers?token='+auth.token()+'&course_id='+courseid).then(
|
||||
function(response) {
|
||||
console.log(response.data);
|
||||
vm.teachers = response.data.data;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if(vm.course.is_creator){
|
||||
if(vm.reviewers.length<=0){
|
||||
$http.get(config.apiUrl + 'courses/reviewers?token='+auth.token()+'&course_id='+courseid).then(
|
||||
function(response) {
|
||||
console.log(response.data);
|
||||
vm.reviewers = response.data.data;
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if(vm.students.length<=0){
|
||||
$http.get(config.apiUrl + 'courses/students?token='+auth.token()+'&course_id='+courseid).then(
|
||||
function(response) {
|
||||
console.log(response.data);
|
||||
vm.students = response.data.data;
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var getResources = function(){
|
||||
if(vm.resources.length<=0){
|
||||
$http.post(config.apiUrl + "courses/"+courseid+"/attachments",
|
||||
{token: auth.token(), name: ''}
|
||||
).then(function(response){
|
||||
vm.resources = response.data.data;
|
||||
vm.resources_tag = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var getHomeworks = function(){
|
||||
if(vm.homeworks.length <=0){
|
||||
$http.get(config.apiUrl + "courses/homeworks/"+courseid+"?token="+auth.token()).then(function(response){
|
||||
vm.homeworks = response.data.data;
|
||||
console.log(response.data);
|
||||
vm.homeworks_tag = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var getExercises = function(){
|
||||
if(vm.exercises.length <=0){
|
||||
$http.get(config.apiUrl + "courses/"+courseid+"/exercises?token="+auth.token()).then(function(response){
|
||||
vm.exercises = response.data.data;
|
||||
console.log(response.data);
|
||||
vm.exercises_tag = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vm.isTeacher = false;
|
||||
vm.currentTab = 1;
|
||||
vm.tab = function(index){
|
||||
vm.currentTab = index;
|
||||
vm.searchText = '';
|
||||
|
||||
vm.showClassMate = false;
|
||||
vm.showResources = false;
|
||||
vm.showHomework = false;
|
||||
vm.showTestcase = false;
|
||||
vm.resources_tag = false;
|
||||
vm.homeworks_tag = false;
|
||||
vm.exercises_tag = false;
|
||||
|
||||
if(vm.isTeacher){
|
||||
if(index == 1){ //课件
|
||||
getResources();
|
||||
vm.showResources = true;
|
||||
} else if(index==2){ //作业
|
||||
getHomeworks();
|
||||
vm.showHomework = true;
|
||||
} else if(index==3){ //小测验
|
||||
getExercises();
|
||||
vm.showTestcase = true;
|
||||
} else if(index==4){ //学生管理
|
||||
getUsers();
|
||||
vm.showClassMate = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
if(index == 2){
|
||||
getUsers();
|
||||
vm.showClassMate = true;
|
||||
} else if(index==1){
|
||||
getResources();
|
||||
vm.showResources = true;
|
||||
}
|
||||
}
|
||||
rms.save("tab_num",index);
|
||||
}
|
||||
|
||||
vm.tabRecord = rms.get('tab_num') || 1;
|
||||
|
||||
vm.course = {};
|
||||
vm.students = [];
|
||||
vm.teachers = [];
|
||||
vm.reviewers = []; //待审批
|
||||
vm.resources = [];
|
||||
vm.homeworks = [];
|
||||
vm.exercises = [];
|
||||
|
||||
//发送类别 1课件 2作业 3测验
|
||||
vm.myresource_sendIndex = rms.get('myresource_sendIndex') || 1;
|
||||
|
||||
vm.alertService = alertService.create();
|
||||
|
||||
vm.invite = function(){
|
||||
$location.path("/invite_code").search({id: courseid});
|
||||
};
|
||||
|
||||
vm.sendFile = function(r,index){
|
||||
vm.myresource_sendIndex = index;
|
||||
rms.save('myresource_sendIndex',index);
|
||||
$location.path("/send_class_list").search({id: r.id});
|
||||
}
|
||||
|
||||
$http.get(config.apiUrl+ 'courses/'+courseid+"?token="+auth.token()).then(
|
||||
function(response) {
|
||||
console.log(response.data);
|
||||
|
||||
if (response.data.status == 0){
|
||||
vm.course = response.data.data;
|
||||
resetMenu(vm.course.current_user_is_teacher,vm.tabRecord);
|
||||
if(tag){
|
||||
vm.tab(4);
|
||||
tag = null;
|
||||
}
|
||||
else{
|
||||
vm.tab(vm.tabRecord);
|
||||
}
|
||||
}
|
||||
else{
|
||||
vm.alertService.showMessage('提示', response.data.message);
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
var resetMenu = function(is_teacher){
|
||||
vm.isTeacher = is_teacher;
|
||||
if(is_teacher){
|
||||
vm.menus = ["课件", "作业", "测验", "成员管理"];
|
||||
} else {
|
||||
vm.menus = ['课件', "我的同学"];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vm.onSetting = function(user){
|
||||
rms.save('current_edit_member', user);
|
||||
$location.path("/edit_class_member").search({id: courseid,user_id: user.id});
|
||||
};
|
||||
|
||||
vm.review = function(user){
|
||||
rms.save('current_review_member', user);
|
||||
rms.save('current_course', vm.course);
|
||||
|
||||
$location.path("/review_class_member").search({id: courseid,user_id: user.id});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}]);
|
@ -0,0 +1,7 @@
|
||||
app.controller('LoginTipController', ['$scope', '$http', '$location', 'alertService','$location',
|
||||
function ($scope, $http, $location, alertService, $location) {
|
||||
$scope.bindWx = function(){
|
||||
$location.path("/login").search({tag:1});
|
||||
};
|
||||
|
||||
}]);
|
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Created by ttang on 2016/8/10.
|
||||
*/
|
||||
app.directive('atDeleteLink',["$timeout",function(timer){
|
||||
return{
|
||||
restrict: 'A',
|
||||
scope: {},
|
||||
link: function(scope, element){
|
||||
timer(function(){
|
||||
$(".at a").each(function(){
|
||||
var atText = $(this).text();
|
||||
$(this).parent().html(atText);
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
}]);
|
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Created by ttang on 2016/8/10.
|
||||
*/
|
||||
app.directive('inputFocus',function(){
|
||||
return{
|
||||
restrict: 'A',
|
||||
scope: {},
|
||||
link: function(scope, element){
|
||||
element.on('click',function(){
|
||||
$("#postInput1").focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
Loading…
Reference in new issue