This commit is contained in:
guange 2016-06-27 11:09:25 +08:00
parent 7df9fe7d60
commit c501af70ba
13 changed files with 140 additions and 82 deletions

1
.access_token Normal file
View File

@ -0,0 +1 @@
{"access_token":"_-LoF1vaOEfUwHI2E5iF7IOIyhvTQAhdkyrwp0ISL0q2Nqb8QMcO9K4Z_kNXxporFsN3xJxOdd8EcCPLVxxzqbBm02m9gmGdp_ENBf9K5nHcneKNTpdoIII7B-9FXHRwCYPaADAJFW","expires_in":7200,"got_token_at":1466770839}

View File

@ -1,9 +1,9 @@
source 'https://ruby.taobao.org/'
### <20><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>bundle config mirror.https://rubygems.org https://gems.ruby-china.org <20>л<EFBFBD><D0BB><EFBFBD>ruby-chinaԴ
unless RUBY_PLATFORM =~ /w32/
# unix-like only
gem 'iconv'
gem "rmagick", ">= 2.0.0"
end
gem 'certified'
@ -31,7 +31,6 @@ gem 'acts-as-taggable-on', '2.4.1'
gem 'spreadsheet'
gem 'ruby-ole'
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
#gem "rmagick", ">= 2.0.0"
gem 'binding_of_caller'
gem 'chinese_pinyin'
# gem 'sunspot_rails', '~> 1.3.3'

View File

@ -14,8 +14,9 @@ module Mobile
optional :token, type: String
end
get do
authenticate!
cs = CoursesService.new
courses = cs.course_list(params,current_user.nil? ? User.find(2):current_user)
courses = cs.course_list(params,current_user)
present :data, courses, with: Mobile::Entities::Course
present :status, 0
end

View File

@ -100,8 +100,8 @@ class ProjectsController < ApplicationController
render_404
end
def course
render_404
def courserender_404
end
# Time 2015-01-29 11:19:11
@ -299,6 +299,8 @@ class ProjectsController < ApplicationController
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
end
logger.debug "111111111"*100
# over
@author = params[:user_id].blank? ? nil : User.active.find(params[:user_id])
@page = params[:page] ? params[:page].to_i + 1 : 0
@ -319,6 +321,7 @@ class ProjectsController < ApplicationController
else
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc").page(params['page'|| 1]).per(10);
end
logger.debug "2"*100
# g = Gitlab.client
unless @project.gpid.nil? || @project.project_score.changeset_num == 0
# rep_statics_commit = @project.rep_statics.order("commits_num desc")
@ -332,12 +335,20 @@ class ProjectsController < ApplicationController
@a_commits_del = rep_statics_code.map {|s| s.del.to_i }
@a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i }
g = Gitlab.client
logger.debug "3"*100
begin
g_branch = g.project(@project.gpid).default_branch.to_s
rescue
logger.error("get gitlab project failed!")
gid = @project.gpid
logger.debug "31"*100
g_branch = g.project(gid)
logger.debug "4"*100
g_branch = g_branch.default_branch.to_s
logger.debug "5"*100
rescue =>e
logger.error("get gitlab project failed: " + e)
end
logger.debug "6"*100
@rev = g_branch.nil? ? "master" : g_branch
logger.debug "7"*100
end
# 根据对应的请求,返回对应的数据
respond_to do |format|

View File

@ -65,7 +65,7 @@ class WechatsController < ActionController::Base
end
on :click, with: 'DEV' do |request, key|
request.reply.text "此功能正在开发中,请耐心等待。"
request.reply.text "此功能正在开发中,很快就会上线,谢谢!"
end
# When user view URL in the menu button
on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view|
@ -138,7 +138,7 @@ class WechatsController < ActionController::Base
unless uw
sendBind(request)
else
request.reply.text "请直接回复6位班级邀请码\n(不区分大小写):"
request.reply.text "请直接回复5位班级邀请码\n(不区分大小写):"
end
end
@ -163,7 +163,6 @@ class WechatsController < ActionController::Base
if uw && uw.user
request.reply.text "欢迎回来, #{uw.user.show_name}"
else
request.reply.text "欢迎关注Trustie创新实践社区"
sendBind(request)
end
end
@ -188,7 +187,7 @@ class WechatsController < ActionController::Base
course = nil
course = Course.where(qrcode: params[:ticket]).first if params[:ticket]
course = Course.where(invite_code: params[:invite_code]).first if params[:invite_code]
raise "课程不存在" unless course
raise "班级不存在,请确认您的邀请码是否输入正确,谢谢!" unless course
cs = CoursesService.new
status = cs.join_course({invite_code: course.invite_code}, user)
@ -239,14 +238,14 @@ class WechatsController < ActionController::Base
code = params[:code] || session[:wechat_code]
openid = get_openid_from_code(code)
raise "无法获取到openid,请在微信中打开本页面" unless openid
raise "此微信号已绑定用户, 不能重复绑定" if user_binded?(openid)
raise "无法获取到openid请在微信中打开本页面" unless openid
raise "此微信号已绑定用户不能重复绑定" if user_binded?(openid)
user, last_login_on = User.try_to_login(params[:username], params[:password])
raise "用户名或密码错误,请重新输入" unless user
raise "用户名或密码错误请重新输入" unless user
#补全用户信息
raise "此用户已经绑定过公众号, 请换一个帐户试试" if user.user_wechat
raise "此用户已经绑定过公众号请换一个帐户试试" if user.user_wechat
UserWechat.create!(
openid: openid,

View File

@ -44,9 +44,9 @@ module CoursesHelper
def visible_excellent_course obj
# if course.is_pu
end
# 返回x项目成员数量即roles表中定义的所有成员
def projectCount project
def projectCount project
#searchCountByRoles project, AllPeople
project.members.count
end
@ -147,10 +147,10 @@ module CoursesHelper
# 返回学生数量即roles表中定义的Reporter
#def studentCount project
# searchStudent(project).count
# or
# searchStudent(project).count
# end
# searchStudent(project).count
# or
# searchStudent(project).count
# end
# 判断用户是否是课程的管理员
# add by nwb
@ -225,11 +225,11 @@ module CoursesHelper
#end
# 注意:此方法有问题,速度慢且结果不准
# alias studentCountOrigin studentCount
# alias studentCountOrigin studentCount
#def studentCount course
# count = studentCountOrigin course
#garble count
# end
# count = studentCountOrigin course
#garble count
# end
#获取课程所有成员
def course_all_member course
@ -265,27 +265,18 @@ module CoursesHelper
def garble count
count = count.round( 1-count.to_s.size ).to_i
return count.to_s if count.to_s.size.eql?(1)
count.to_s << '+'
count.to_s << '+'
end
# =====================================================================================
# return people list
def searchPeopleByName(course, role_name)
course.members.select{|m|
m.roles.any?{|r|r.name == role_name}
}
end
def searchTeacherAndAssistant project
searchPeopleByName(project, 'Manager').concat(
searchPeopleByName(project, 'Teacher')
).concat(
searchPeopleByName(project, 'TeachingAsistant')
)
end
def searchStudent project
searchPeopleByName(project, 'Student')
#searchPeopleByRoles(project, TeacherRoles)
members = []
project.members.includes(:user).each do |m|
members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
end
members
end
def TeacherAndAssistantCount course
@ -302,6 +293,19 @@ module CoursesHelper
members
end
def searchStudent project
#searchPeopleByRoles(project, StudentRoles)
members = []
project.members.each do |m|
if m && m.user && m.user.allowed_to?(:as_student,project)
members << m
end
end
members
end
def searchStudent_by_name project, name
#searchPeopleByRoles(project, StudentRoles)
members = []
@ -320,29 +324,29 @@ module CoursesHelper
mems = []
if name != ""
name = name.to_s.downcase
members.each do |m|
members.each do |m|
username = m.user[:lastname].to_s.downcase + m.user[:firstname].to_s.downcase
if(m.user[:login].to_s.downcase.include?(name) || m.user.user_extensions[:student_id].to_s.downcase.include?(name) || username.include?(name))
mems << m
end
end
else
mems = members
end
mems = members
end
mems
end
def searchgroupmember_by_name members, name, group
#searchPeopleByRoles(project, StudentRoles)
mems = []
if name != ""
members.each do |m|
if m.course_group_id == group.id
username = m.user[:lastname].to_s + m.user[:firstname].to_s
if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name))
mems << m
members.each do |m|
if m.course_group_id == group.id
username = m.user[:lastname].to_s + m.user[:firstname].to_s
if(m.user[:login].to_s.include?(name) || m.user.user_extensions[:student_id].to_s.include?(name) || username.include?(name))
mems << m
end
end
end
end
end
else
mems = members
end
@ -454,7 +458,7 @@ module CoursesHelper
content = content_tag('ul', content)
content_tag('div', content, :class => "tabs")
end
def findCourseTime project
str = ""
begin
@ -679,9 +683,9 @@ module CoursesHelper
#file_count
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
if attachment.is_public? || User.current.member_of_course?(@course) || User.current.admin?
activities[attachment.container_id]+=1
activities[attachment.container_id]+=1
else
activities[attachment.container_id]
activities[attachment.container_id]
end
end
@ -700,8 +704,8 @@ module CoursesHelper
#news
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
if news.author.member_of_course?(@course)
activities[news.course_id]+=1
end
activities[news.course_id]+=1
end
end
#homework_count

View File

@ -457,6 +457,15 @@ class Course < ActiveRecord::Base
end
end
# 延迟生成邀请码
def invite_code
code = read_attribute[:invite_code]
if !code || code.size < 5
code = generate_invite_code
end
return code
end
# 生成邀请码
CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z)
def generate_invite_code

View File

@ -28,27 +28,28 @@
<script src="https://dn-demotest.qbox.me/angular.all.min.js"></script>
<!--<script src="/javascripts/wechat/build/angular.all.min.js"></script>-->
<script src="/javascripts/wechat/build/app.min.js"></script>
<!--<script src="/javascripts/wechat/app.js"></script>-->
<!--<script src="/javascripts/wechat/others/factory.js"></script>-->
<!--<script src="/javascripts/wechat/others/filter.js"></script>-->
<!--<script src="/javascripts/wechat/directives/alert.js"></script>-->
<!--<script src="/javascripts/wechat/directives/form_validate.js"></script>-->
<!--<script src="/javascripts/wechat/directives/input_auto.js"></script>-->
<!--<script src="/javascripts/wechat/directives/loading_spinner.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/reg.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/invite_code.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/login.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/activity.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/add_class.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/blog.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/course_notice.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/discussion.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/homework.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/issue.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/journals.js"></script>-->
<!--<script src="/javascripts/wechat/controllers/myclass.js"></script>-->
<!--<script src="/javascripts/wechat/others/routes.js"></script>-->
<!--<script src="/javascripts/wechat/build/app.min.js"></script>-->
<script src="/javascripts/wechat/app.js"></script>
<script src="/javascripts/wechat/others/factory.js"></script>
<script src="/javascripts/wechat/others/filter.js"></script>
<script src="/javascripts/wechat/directives/alert.js"></script>
<script src="/javascripts/wechat/directives/form_validate.js"></script>
<script src="/javascripts/wechat/directives/input_auto.js"></script>
<script src="/javascripts/wechat/directives/loading_spinner.js"></script>
<script src="/javascripts/wechat/controllers/reg.js"></script>
<script src="/javascripts/wechat/controllers/invite_code.js"></script>
<script src="/javascripts/wechat/controllers/login.js"></script>
<script src="/javascripts/wechat/controllers/activity.js"></script>
<script src="/javascripts/wechat/controllers/add_class.js"></script>
<script src="/javascripts/wechat/controllers/blog.js"></script>
<script src="/javascripts/wechat/controllers/course_notice.js"></script>
<script src="/javascripts/wechat/controllers/discussion.js"></script>
<script src="/javascripts/wechat/controllers/homework.js"></script>
<script src="/javascripts/wechat/controllers/issue.js"></script>
<script src="/javascripts/wechat/controllers/journals.js"></script>
<script src="/javascripts/wechat/controllers/myclass.js"></script>
<script src="/javascripts/wechat/controllers/class_list.js"></script>
<script src="/javascripts/wechat/others/routes.js"></script>
</body>
</html>

View File

@ -2,7 +2,7 @@ button:
-
type: "view"
name: "我的动态"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf694495398c7d470&redirect_uri=http://wechat.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=http://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=123#wechat_redirect"
-
name: "我的课程"
sub_button:
@ -19,9 +19,13 @@ button:
name: "更多"
sub_button:
-
type: "view"
type: "click"
name: "加入班级"
url: "https://www.trustie.net/"
key: "JOIN_CLASS"
-
type: "click"
name: "反馈"
key: "FEEDBACK"
-
type: "view"
name: "历史推文"

View File

@ -15,7 +15,7 @@ default: &default
access_token: ".access_token"
encrypt_mode: false # if true must fill encoding_aes_key
encoding_aes_key: "QGfP13YP4BbQGkkrlYuxpn4ZIDXpBJww4fxl8CObvNw"
jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket"
jsapi_ticket: "tmp/wechat_jsapi_ticket"
#template
binding_succ_notice: "jjpDrgFErnmkrE9tf2M3o0t31ZrJ7mr0YtuE_wyLaMc"

View File

@ -0,0 +1,10 @@
<div class="post-container">
<div class="blue-title">课程列表</div>
<div class="course-list-row f13 c-grey3 mt10"><img src="/images/wechat/plus.png" width="15" class="fl ml10 mt11 spread-btn" /><img src="/images/wechat/minus.png" width="15" class="fl ml10 mt11 retract-btn undis" /><span class="fl ml10">未命名课程</span><img src="/images/wechat/setting.png" width="15" class="fr mr10 mt10" /></div>
<ul class="class-list f13 c-grey3">
<li ng-repeat="course in courses" ng-class="{'border-bottom-none': $last}"><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">{{course.name}}</span><span class="fr c-grey4">&gt;</span><span class="students-amount f12 fr mt10">10人</span></li>
<!--<li><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">分布式计算环境B班</span><span class="fr c-grey4">&gt;</span><span class="students-amount f12 fr mt10">10人</span></li>-->
<!--<li class="border-bottom-none"><img src="/images/wechat/dot.png" width="15px" class="class-list-dot" /><span class="fl ml10 class-list-name hidden">分布式计算环境C班</span><span class="fr c-grey4">&gt;</span><span class="students-amount f12 fr mt10">10人</span></li>-->
</ul>
</div>

View File

@ -0,0 +1,18 @@
/**
* Created by guange on 16/6/27.
*/
app.controller('ClassListController', ['$scope','config','auth','$http', function($scope, config, auth, $http){
var vm = $scope;
vm.courses = [];
$http.get(config.apiUrl + "courses?token="+ auth.token() + "&per_page_count=10&page=1").then(
function(response){
console.log(response.data);
vm.courses = response.data.data;
}
);
}]);

View File

@ -32,6 +32,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func
.when('/blog_comment/:id', makeRoute('blog_detail.html', 'BlogController'))
.when('/add_class', makeRoute('add_class.html', 'AddClassController'))
.when('/myclass', makeRoute('myclass.html', 'MyClassController'))
.when('/class_list', makeRoute('class_list.html', 'ClassListController'))
.when('/invite_code', makeRoute('invite_code.html', 'InviteCodeController'))
.otherwise({
redirectTo: '/activites'