diff --git a/Gemfile b/Gemfile index 80c0e1c2a..1305320cf 100644 --- a/Gemfile +++ b/Gemfile @@ -50,10 +50,10 @@ gem 'elasticsearch-model' gem 'elasticsearch-rails' #rails 3.2.22.2 bug - gem "test-unit", "~>3.0" + # gem "test-unit", "~>3.0" ### profile - gem 'oneapm_rpm' + # gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 6d46b2f59..e72daae6d 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -89,11 +89,15 @@ module Mobile tip = 0 #0班级1项目 type = params[:type] result = 1 + + #0回复 1回复的回复 + reply_type = params[:reply_type] + + update_id = 0 + if params[:content]!="" && current_user case type when "HomeworkCommon" - homework_common = HomeworkCommon.find(params[:id]) - #如果是私有的 并且不是成员则不能回复 # is_public = homework_common.course.is_public # if is_public == 0 && !current_user.member_of_course?(homework_common.course) @@ -106,15 +110,29 @@ module Mobile # result = 2 # end # end - feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id]) - if (feedback.errors.empty?) - homework_common.update_column(:updated_at, Time.now) - result = 2 + if reply_type == nil || reply_type == 0 + homework_common = HomeworkCommon.find(params[:id]) + feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id]) + if (feedback.errors.empty?) + homework_common.update_column(:updated_at, Time.now) + result = 2 + update_id = homework_common.id + end + else + #二级回复 + reply = JournalsForMessage.find params[:id].to_i + homework_common = HomeworkCommon.find reply.jour_id + + options = {:notes => params[:content], :reply_id => reply.user_id,:user_id => current_user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i} + feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], reply.jour_id, options) + if (feedback.errors.empty?) + homework_common.update_column(:updated_at, Time.now) + result = 2 + update_id = homework_common.id + end end when "News" - news = News.find(params[:id]) - # if news.project # if news.project.is_public == false && !current_user.member_of?(news.project) # status = -1 @@ -126,19 +144,28 @@ module Mobile # tip = 0 # end # end - if status == 0 - comment = Comment.new - comment.comments = params[:content] - comment.author = current_user - if news.comments << comment - result = 2 + if reply_type == nil || reply_type == 0 + news = News.find(params[:id]) + comment = Comment.new + comment.comments = params[:content] + comment.author = current_user + if news.comments << comment + result = 2 + update_id = news.id + end + else + #二级回复 + comment = Comment.find(params[:id]) + news = News.find comment.commented_id + new_comment = news.comments.build(:author_id => current_user.id, :reply_id => params[:id], :comments => params[:content], :parent_id => comment.id) + if new_comment.save + result = 2 + update_id = news.id + end end end when "Message" - message = Message.find(params[:id]) - board = Board.find(message.board_id) - # if message.project # if message.project.is_public == false && !current_user.member_of?(message.project) # status = -1 @@ -152,20 +179,26 @@ module Mobile # end if status == 0 - topic = message.root - reply = Message.new - reply.author = current_user - reply.board = board - reply.content = params[:content] - reply.parent_id = params[:id] - reply.subject = "RE: #{topic.subject}" - if topic.children << reply - result = 2 - end + # if reply_type == nil || reply_type == 0 + message = Message.find(params[:id]) + board = Board.find(message.board_id) + topic = message.root + reply = Message.new + reply.author = current_user + reply.board = board + reply.content = params[:content] + reply.parent_id = params[:id] + reply.subject = "RE: #{topic.subject}" + if message.children << reply + result = 2 + update_id = topic.id + end + # else + #二级回复 + + # end end when "JournalsForMessage" - jour = JournalsForMessage.find params[:id] - # if jour.jour_type == "Project" # if jour.project.is_public == false && !current_user.member_of?(jour.project) # status = -1 @@ -179,64 +212,108 @@ module Mobile # end if status == 0 - parent_id = params[:id] - author_id = current_user.id - reply_user_id = jour.user_id - reply_id = params[:id] - content = params[:content] - options = {:user_id => author_id, - :status => true, - :m_parent_id => parent_id, - :m_reply_id => reply_id, - :reply_id => reply_user_id, - :notes => content, - :is_readed => false} - jfm = jour.user.add_jour(nil, nil, nil, options) - if jfm.errors.empty? - (JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now) - result = 2 - end + # if reply_type == nil || reply_type == 0 + jour = JournalsForMessage.find(params[:id]).root + parent_id = params[:id] + author_id = current_user.id + reply_user_id = jour.user_id + reply_id = params[:id] + content = params[:content] + options = {:user_id => author_id, + :status => true, + :m_parent_id => parent_id, + :m_reply_id => reply_id, + :reply_id => reply_user_id, + :notes => content, + :is_readed => false} + jfm = jour.user.add_jour(nil, nil, nil, options) + if jfm.errors.empty? + (JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now) + result = 2 + update_id = jour.id + end + # else + #二级回复 + + # end end when 'Issue' - issue = Issue.find params[:id] - # if issue.project.is_public == false && !current_user.member_of?(issue.project) # status = -1 # tip = 1 # end if status == 0 - is_jour = Journal.new - is_jour.user_id = current_user.id - is_jour.notes = params[:content] - is_jour.journalized = issue - if is_jour.save - result = 2 + if reply_type == nil || reply_type == 0 + issue = Issue.find params[:id] + is_jour = Journal.new + is_jour.user_id = current_user.id + is_jour.notes = params[:content] + is_jour.journalized = issue + if is_jour.save + result = 2 + update_id = issue.id + end + else + #二级回复 + jour = Journal.find(params[:id]) + issue = jour.journalized + is_jour = Journal.new + is_jour.user_id = current_user.id + is_jour.notes = params[:content] + is_jour.reply_id = params[:id] + is_jour.parent_id = params[:id] + is_jour.journalized = issue + if is_jour.save + result = 2 + update_id = issue.id + end end end when 'BlogComment' - blog = BlogComment.find(params[:id]).root - blogComment = BlogComment.new - blogComment.author = current_user - blogComment.blog = blog.blog - blogComment.content = params[:content] - blogComment.title = "RE: #{blog.title}" - if blog.children << blogComment - result = 2 + if reply_type == nil || reply_type == 0 + blog = BlogComment.find(params[:id]).root + blogComment = BlogComment.new + blogComment.author = current_user + blogComment.blog = blog.blog + blogComment.content = params[:content] + blogComment.title = "RE: #{blog.title}" + if blog.children << blogComment + result = 2 + update_id = blog.id + end + else + #二级回复 + blog = BlogComment.find(params[:id]).root + blogComment = BlogComment.new + blogComment.author = current_user + blogComment.blog = blog.blog + blogComment.content = params[:content] + blogComment.title = "RE: #{blog.title}" + parent = BlogComment.find params[:id] + blogComment.parent_id = params[:id] #被回复的回复 + blogComment.reply_id = parent.author.id #被回复者id + + if parent.children << blogComment + result = 2 + update_id = blog.id + end + end end if result == 2 - update_course_activity_api(type,params[:id]) - update_user_activity_api(type,params[:id]) - update_org_activity_api(type,params[:id]) - update_forge_activity_api(type,params[:id]) - update_principal_activity_api(type,params[:id]) + update_course_activity_api(type,update_id) + update_user_activity_api(type,update_id) + update_org_activity_api(type,update_id) + update_forge_activity_api(type,update_id) + update_principal_activity_api(type,update_id) end else result = 3 end present :result, result present :status, status + present :act_id, update_id present :tip, tip present :subscribe,subscribe end diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb index 764dc957f..557b06cea 100644 --- a/app/api/mobile/apis/users.rb +++ b/app/api/mobile/apis/users.rb @@ -4,6 +4,61 @@ module Mobile class Users < Grape::API resource :users do + desc "我的资料" + params do + requires :token, type: String + end + + get 'get_userinfo' do + authenticate! + present :data, current_user, with: Mobile::Entities::User + present :status, 0 + end + + desc "上传头像" + params do + requires :token, type: String + requires :imgdata, type: String + end + + post 'upload_head' do + authenticate! + #直接生成头像 + dirPath = "public/images/avatars/User" + + fileDir = dirPath + "/"+current_user.id.to_s + imgdata = Base64.decode64(params[:imgdata].split(",")[1]) + if imgdata.length > 1024*1024 + present :message,"上传图片不能超过1M" + present :status, -1 + else + begin + File.open(fileDir,'wb'){ |f| f.write(imgdata) } + present :status, 0 + rescue + present :message,"上传失败" + present :status, -1 + end + end + end + + desc "解除绑定" + params do + requires :token, type: String + end + + post 'user_unbind' do + authenticate! + + user = current_user + uw = user.user_wechat + + us = UsersService.new + us.wechat_unbind user.user_wechat + + present :status, 0 + end + desc "查询是否已绑定" params do requires :openid, type: String, desc: 'wechat openid' @@ -221,6 +276,73 @@ module Mobile present :data,my_jours,with:Mobile::Entities::Jours present :status,0 end + + desc "修改我的资料" + + params do + requires :token, type: String + requires :lastname, type: String + requires :sex, type: Integer + requires :mail, type: String + end + + post 'edit_userinfo' do + authenticate! + user = current_user + status = 0 + message = "" + + #昵称 不能超过30个字符 + if params[:lastname].length > 30 then + message = "姓名不能超过30个字符!" + status = -1 + end + + if params[:mail].length > 60 then + message = "邮箱地址不能超过60个字符!" + status = -1 + end + + if !(params[:mail].match(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i)) + message = "请输入正确的邮箱地址!" + status = -1 + end + + if status == 0 + # 修改邮箱的时候同步修改到gitlab + if user.mail != params[:mail] + g = Gitlab.client + begin + g.edit_user(user.gid, :email => params[:mail]) + rescue + Rails.logger.error "sync user's email of gitlab failed!" + end + end + + user.mail = params[:mail] + + user.lastname = params[:lastname] + + se = user.extensions + + se.gender = params[:sex] + + if user.save && se.save + status = 0 + else + message = "该邮箱地址已被使用!" + status = -1 + end + end + + if status == 0 + present :data, current_user, with: Mobile::Entities::User + present :status, 0 + else + present :status, -1 + present :message, message + end + end end end end diff --git a/app/api/mobile/entities/user.rb b/app/api/mobile/entities/user.rb index dcdf48d3b..30a2a7edd 100644 --- a/app/api/mobile/entities/user.rb +++ b/app/api/mobile/entities/user.rb @@ -30,15 +30,24 @@ module Mobile u.nil? ? "" : u.show_name when :roles_id u[:roles_id].nil? ? nil : u.roles_id + when :login + u.login + when :lastname + u.lastname + when :mail + u.mail end end end - end end expose :id #头像 + user_expose :login + user_expose :lastname + #邮箱地址 + user_expose :mail expose :nickname #真名 user_expose :img_url @@ -51,8 +60,6 @@ module Mobile #我的二维码 #工作单位 user_expose :work_unit - #邮箱地址 - user_expose :mail #地区 user_expose :location #签名 diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 03f9c2f7c..6fb2868bc 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -180,6 +180,7 @@ class IssuesController < ApplicationController end end + # 用户发布新issue def create call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue }) @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) @@ -222,6 +223,7 @@ class IssuesController < ApplicationController end def edit + # 修改实例变量的值 return unless update_issue_from_params respond_to do |format| @@ -230,6 +232,7 @@ class IssuesController < ApplicationController end end + # 用户编辑更改issue def update if params[:issue_detail] issue = Issue.find(params[:id]) @@ -237,6 +240,7 @@ class IssuesController < ApplicationController @saved = update_user_issue_detail(issue, params) return else + # 修改实例变量的值 return unless update_issue_from_params @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads])) saved = false @@ -572,6 +576,7 @@ class IssuesController < ApplicationController @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) @time_entry.attributes = params[:time_entry] + # 更新issue状态时,journal表产生记录,返回@current_journal @issue.init_journal(User.current) issue_attributes = params[:issue] diff --git a/app/controllers/org_member_controller.rb b/app/controllers/org_member_controller.rb index 2eaa790cd..a01956f56 100644 --- a/app/controllers/org_member_controller.rb +++ b/app/controllers/org_member_controller.rb @@ -8,18 +8,33 @@ class OrgMemberController < ApplicationController end end + # 组织子成员,及其分页 + def org_member_paging + @organization = Organization.find(params[:org]) + + if User.current.admin? || User.current.admin_of_org?(@organization) + @members = OrgMember.where(:organization_id => @organization.id).all.sort + @members = paginateHelper @members, 20 + respond_to do |format| + format.js + end + end + end + def create - @org = Organization.find(params[:org]) + @organization = Organization.find(params[:org]) if params[:membership].nil? @fail_hint = l(:label_blank_user_lists_for_org) else member_ids = params[:membership][:user_ids] role_id = params[:orgRole] member_ids.each do |user_id| - member = OrgMember.create(:user_id=>user_id, :created_at => Time.now) - @org.org_members << member + member = OrgMember.create(:user_id => user_id, :created_at => Time.now) + @organization.org_members << member OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id) end + @members = (@organization.org_members).sort + @members = paginateHelper @members, 20 end respond_to do |format| format.js @@ -32,7 +47,11 @@ class OrgMemberController < ApplicationController @member_role = @member.org_member_roles[0] @member_role.role_id = params[:org_member][:role_ids][0] @member_role.save - @org = @member.organization + @organization = @member.organization + # 成员编辑角色后分页 + @members = (@organization.org_members).sort + @members = paginateHelper @members, 20 + respond_to do |format| format.js end @@ -44,8 +63,10 @@ class OrgMemberController < ApplicationController def destroy member = OrgMember.find(params[:id]) - @org = member.organization + @organization = member.organization member.destroy + @members = (@organization.org_members).sort + @members = paginateHelper @members, 20 respond_to do |format| format.js end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b36ef592d..56ffc77e2 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -421,6 +421,8 @@ class OrganizationsController < ApplicationController @organization = Organization.find(params[:id]) if User.current.admin? || User.current.admin_of_org?(@organization) + @members = OrgMember.where(:organization_id => @organization.id).all.sort + @members = paginateHelper @members, 20 else render_403 end @@ -451,10 +453,11 @@ class OrganizationsController < ApplicationController def members if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) - @members = OrgMember.where("organization_id =?", @organization.id) + @members = OrgMember.where(:organization_id => @organization.id).all.sort else render_403 end + @members = paginateHelper @members, 20 end def more_org_projects diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 5dcf493ee..8d4c09ded 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -580,6 +580,7 @@ class ProjectsController < ApplicationController end end @members = paginateHelper @members + end def update_message_status(user, project) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5aab1df49..e0fa253b3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2677,7 +2677,8 @@ class UsersController < ApplicationController project_ids.each do |project_id| project = Project.find(project_id) if project.news.map(&:id).exclude?(news.id) - message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id) + # message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id) + message = News.create(:project_id => project.id, :title => news.title, :summary => news.summary, :description => news.description, :author_id => User.current.id, :created_on => Time.now ) # record forward to table forwards if new record is valid if message.valid? news.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id) @@ -3515,11 +3516,15 @@ class UsersController < ApplicationController @order, @c_sort, @type, @list_type = 1, 2, 1, 1 #limit = 5 - @my_projects = @user.projects.visible.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") + # 用户的所有项目 + # @my_projects = @user.projects.visible.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") + @my_projects = @user.projects.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") @my_projects_count = @my_projects.count - @my_joined_projects = @user.projects.visible.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") + #@my_joined_projects = @user.projects.visible.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") + @my_joined_projects = @user.projects.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") @my_joined_projects_count = @my_joined_projects.count + respond_to do |format| format.html {render :layout => 'new_base_user'} end diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb index 54486221e..0c6eb0910 100644 --- a/app/controllers/wechats_controller.rb +++ b/app/controllers/wechats_controller.rb @@ -167,6 +167,27 @@ class WechatsController < ActionController::Base end end + on :click, with: 'UNBIND' do |request, key| + uw = user_binded?(request[:FromUserName]) + unless uw + request.reply.text "您还未绑定帐号" + else + #解除绑定 + us = UsersService.new + us.wechat_unbind uw + + tmpurl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{ROOT_URL+'/wechat/user_activities'}&response_type=code&scope=snsapi_base&state=login&connect_redirect=1#wechat_redirect" + news = (1..1).each_with_object([]) { |n, memo| memo << { title: '重新绑定提醒', + content: "尊敬的用户,您已解除绑定。\n解除时间:#{format_time(Time.now)}\n点击进入重新绑定!"} } + request.reply.news(news) do |article, n, index| # article is return object + url = tmpurl + article.item title: "#{n[:title]}", + description: n[:content], + url: url + end + end + end + def join_class_request(request) openid = request[:FromUserName] wl = WechatLog.where("openid = '#{openid}' and request_raw like '%\"Event\":\"click\"%'").order('id desc').first diff --git a/app/helpers/org_member_helper.rb b/app/helpers/org_member_helper.rb index 8e7d1e2ef..e9fbd3967 100644 --- a/app/helpers/org_member_helper.rb +++ b/app/helpers/org_member_helper.rb @@ -1,5 +1,6 @@ module OrgMemberHelper include ApplicationHelper + def find_user_not_in_current_org_by_name org if params[:q] && params[:q].lstrip.rstrip != "" scope = Principal.active.sorted.not_member_of_org(org).like(params[:q]) diff --git a/app/models/issue.rb b/app/models/issue.rb index 4cfea1f43..222a4f4e2 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -757,6 +757,7 @@ class Issue < ActiveRecord::Base end end +# 更新issue时,判断更新之前当前是否有自动更新的评论 def init_journal(user, notes = "") @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes) if new_record? @@ -1454,8 +1455,18 @@ class Issue < ActiveRecord::Base end # Callback on file attachment + # 在执行issue模块前 执行:当附件被添加时,产生评论 + # 第一次创建issue时,@current_journal为nil,评论不产生 + # 当附件名称重名时,也不产生评论 + # 当更新isuue时,第一次上传的附件的已经存在,则不更新次附件评论 def attachment_added(obj) - if @current_journal && @current_journal.user_id == obj.author_id && JournalDetail.find_all_by_value(obj.filename).count == 0 + + # 找出该issue评论表中,附件重名的个数 + jor = Journal.where(:journalized_id => self.id) + jor_ids = jor.empty? ? "(-1)" : "(" + jor.map{|detail| detail.id}.join(",") + ")" + jor_details_count = JournalDetail.where("journal_id in #{jor_ids} and value = '#{obj.filename}'").count + + if @current_journal && @current_journal.user_id == obj.author_id && jor_details_count == 0 && self.attachments.find_all_by_filename(obj.filename).count == 0 @current_journal.details << JournalDetail.new(:property => 'attachment', :prop_key => obj.id, :value => obj.filename) end diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb index f184fa923..24e15f369 100644 --- a/app/services/courses_service.rb +++ b/app/services/courses_service.rb @@ -941,46 +941,36 @@ class CoursesService :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation} end - - def student_homework_score(groupid,course_id, nums, score_sort_by) - #teachers = find_course_teachers(@course) - #start_from = start_from * nums + def student_homework_score(groupid,course_id, nums, score_sort_by, sort_type = 'score') sql_select = "" if groupid == 0 - if nums == 0 - sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{course_id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{course_id}) AND members.user_id = homework_attaches.user_id - AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id}) GROUP BY members.user_id - UNION all - SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{course_id} AND - students_for_courses.course_id = #{course_id} and members.user_id = students_for_courses.student_id AND - members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id} ) - ) - GROUP BY members.user_id ORDER BY score #{score_sort_by}" - else - sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{course_id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{course_id}) AND members.user_id = homework_attaches.user_id - AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id}) GROUP BY members.user_id - UNION all - SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{course_id} AND - students_for_courses.course_id = #{course_id} and members.user_id = students_for_courses.student_id AND - members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id} ) - ) - GROUP BY members.user_id ORDER BY score #{score_sort_by} " #limit #{start_from}, #{nums}" - - end + sql_select = "SELECT members.*,( + SELECT SUM(student_works.work_score) + FROM student_works,homework_commons + WHERE student_works.homework_common_id = homework_commons.id + AND homework_commons.course_id = course_id + AND student_works.user_id = members.user_id + ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{course_id} AND ccs.user_id = members.user_id + ) AS act_score + FROM members + JOIN students_for_courses + ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id + WHERE members.course_id = #{course_id} ORDER BY #{sort_type} #{score_sort_by}" else - sql_select = "SELECT members.*, SUM(homework_attaches.score) as score FROM members, homework_attaches - WHERE members.course_id = #{course_id} AND members.user_id in (SELECT students_for_courses.student_id FROM students_for_courses WHERE course_id = #{course_id}) AND members.user_id = homework_attaches.user_id - and members.course_group_id = #{groupid} AND homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id}) - GROUP BY members.user_id - UNION all - SELECT members.*, 0 as score FROM members,homework_attaches,students_for_courses WHERE members.course_id = #{course_id} - and members.course_group_id = #{groupid} AND - students_for_courses.course_id = #{course_id} and members.user_id = students_for_courses.student_id AND - members.user_id NOT IN (SELECT homework_attaches.user_id FROM homework_attaches WHERE homework_attaches.bid_id in (SELECT bid_id FROM homework_for_courses WHERE course_id = #{course_id} ) - ) - GROUP BY members.user_id ORDER BY score #{score_sort_by}" + sql_select = "SELECT members.*,( + SELECT SUM(student_works.work_score) + FROM student_works,homework_commons + WHERE student_works.homework_common_id = homework_commons.id + AND homework_commons.course_id = #{course_id} + AND student_works.user_id = members.user_id + ) AS score,(SELECT (message_num*2 + message_reply_num*1 + news_reply_num*1 + news_num*1 + + resource_num*5 + journal_num*1 + homework_journal_num*1 ) FROM `course_contributor_scores` AS ccs WHERE ccs.course_id = #{course_id} AND ccs.user_id = members.user_id + ) AS act_score + FROM members + JOIN students_for_courses + ON students_for_courses.student_id = members.user_id AND students_for_courses.course_id = members.course_id + WHERE members.course_id = #{course_id} AND members.course_group_id = #{groupid} ORDER BY #{sort_type} #{score_sort_by}" end sql = ActiveRecord::Base.connection() homework_scores = Member.find_by_sql(sql_select) diff --git a/app/services/users_service.rb b/app/services/users_service.rb index 5789befe5..540e1bbff 100644 --- a/app/services/users_service.rb +++ b/app/services/users_service.rb @@ -1,3 +1,4 @@ +#coding=utf-8 class UsersService include ApplicationHelper include AccountHelper @@ -319,8 +320,22 @@ class UsersService my_jours_arr end + def wechat_unbind uw + user = uw.user + #发重新绑定的微信模版消息 + type = "login" + title = "尊敬的用户,您已解除绑定。" + key1 = "个人原因" + remark = "点击进入重新绑定。" + ws = WechatService.new + ws.rebind_notice user.id, type, user.id, title, key1,format_time(Time.now), remark + + uw.user_id = nil + uw.delete + + end end diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb index 8adc1392f..c11826896 100644 --- a/app/services/wechat_service.rb +++ b/app/services/wechat_service.rb @@ -445,4 +445,41 @@ class WechatService end end + def rebind_notice(user_id, type, id, first, key1, key2,remark="") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = { + touser:uw.openid, + template_id:Wechat.config.rebind_notice, + url:Wechat.config.auto_openid_url_1+Wechat.config.auto_openid_url_2+"login"+Wechat.config.auto_openid_url_3, + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#707070" + }, + keyword1:{ + value:key1, + color:"#707070" + }, + keyword2:{ + value:key2, + color:"#707070" + }, + remark:{ + value:remark, + color:"#707070" + } + } + } + #data = three_keys_template uw.openid,Wechat.config.create_class_notice, type, id, first, key1, key2, key3, remark + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[rebind_notice] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + end + end \ No newline at end of file diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 889def55e..376ca420a 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -74,7 +74,6 @@ }); function check_and_submit(doc){ $("#error").html('').hide(); - check_forum_name(); if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){ $("#error").html("名称不能为空").show(); return; @@ -98,7 +97,6 @@ '<%= check_forum_name_forums_path %>', {"forum_name":encodeURIComponent(name)}, function(data){ - if( data == 'true'){ $("#error").html("贴吧名称已经存在").show(); check_pass = false; diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index 51a6c3b9e..1be21cbc1 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -78,7 +78,7 @@
<%= call_hook(:view_issues_form_details_bottom, {:issue => @issue, :form => f}) %> <% end %> - 确定 + 确定 <% if params[:action] == "new" %> <% if @copy_from %> <%= link_to "取消", issue_path(@copy_from), :class => "grey_btn fl mr50 ml10" %> diff --git a/app/views/issues/update.js.erb b/app/views/issues/update.js.erb index bd4385340..733066d38 100644 --- a/app/views/issues/update.js.erb +++ b/app/views/issues/update.js.erb @@ -1,12 +1,5 @@ <% if @saved %> -$("#issue_detail").replaceWith('<%= escape_javascript(render :partial => 'issues/detail') %>') -$("#issue_edit").replaceWith('<%= escape_javascript(render :partial => 'issues/edit') %>') - -$("#issue_detail").show(); -$("#issue_edit").hide(); -$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue,:replies_all_i=>0}) %>"); -sd_create_editor_from_data(<%= @issue.id%>, null, "100%","<%=@issue.class.name%>"); -$(".homepagePostReplyBannerCount").html('<%= escape_javascript(render :partial => 'issues/issue_reply_banner') %>'); +location.reload(); //edit里的编辑器貌似显示不出来,所以手动js生成。 issue_desc_editor = KindEditor.create('#issue_description', {"width":"85%", @@ -31,6 +24,7 @@ issue_desc_editor = KindEditor.create('#issue_description', // "allowFileManager":true, // "uploadJson":"/kindeditor/upload", // "fileManagerJson":"/kindeditor/filemanager"}); + <%else%> alert('<%= @issue.errors.full_messages[0].to_s%>') <%end %> diff --git a/app/views/layouts/_logined_header_show.html.erb b/app/views/layouts/_logined_header_show.html.erb index c593c3e8c..f8db441de 100644 --- a/app/views/layouts/_logined_header_show.html.erb +++ b/app/views/layouts/_logined_header_show.html.erb @@ -38,7 +38,7 @@ <%= image_tag(url_to_avatar(User.current),:width =>"40",:height => "40",:alt=>"头像", :id => "nh_user_logo", :class => "portraitRadius") %> diff --git a/app/views/layouts/new_base_user_show.html.erb b/app/views/layouts/new_base_user_show.html.erb index a0e335938..b92218241 100644 --- a/app/views/layouts/new_base_user_show.html.erb +++ b/app/views/layouts/new_base_user_show.html.erb @@ -103,7 +103,7 @@
<% if User.current.logged?%> - <%= image_tag(url_to_avatar(@user),width:"74", height: "74", :id=>'nh_user_tx')%> + <%= image_tag(url_to_avatar(@user), width:"74", height: "74", :id=>'nh_user_tx')%> <% else %> <% end %> @@ -112,7 +112,7 @@ <% end %> - +
<%= reply.author.name%><%= format_date(reply.created_at) %>
-
<%= h reply.content%>
+
<%= h reply.content.html_safe%>
\ No newline at end of file + + diff --git a/app/views/projects/_project_create.html.erb b/app/views/projects/_project_create.html.erb index 2e7a919d1..0d24c4f6b 100644 --- a/app/views/projects/_project_create.html.erb +++ b/app/views/projects/_project_create.html.erb @@ -7,7 +7,7 @@ <%= render :partial => 'users/show_detail_info', :locals => {:user => user} %>
-
+
<% if user.try(:realname) == ' ' %> <%= link_to user, user_path(user), :class => "newsBlue mr15" %> <% else %> diff --git a/app/views/projects/_project_member_list.html.erb b/app/views/projects/_project_member_list.html.erb index fbaa837ac..71ea21322 100644 --- a/app/views/projects/_project_member_list.html.erb +++ b/app/views/projects/_project_member_list.html.erb @@ -24,4 +24,7 @@
-
\ No newline at end of file +
+ + + diff --git a/app/views/projects/_project_news.html.erb b/app/views/projects/_project_news.html.erb index 6b3e8e43c..092e47329 100644 --- a/app/views/projects/_project_news.html.erb +++ b/app/views/projects/_project_news.html.erb @@ -5,7 +5,7 @@ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
+
<%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> TO <%= link_to activity.project.name.to_s+" | 项目新闻", project_news_index_path(activity.project), :class => "newsBlue ml15" %> diff --git a/app/views/projects/member.html.erb b/app/views/projects/member.html.erb index eb2dcacbc..1f3f76ea3 100644 --- a/app/views/projects/member.html.erb +++ b/app/views/projects/member.html.erb @@ -1,5 +1,5 @@
-

<%= @subPage_title%>

+

<%= @subPage_title %>

<% if is_project_manager?(User.current, @project) %> <%=link_to "成员管理", :controller => 'projects', :action => 'settings', :id => @project.id, :tab => 'members' %> diff --git a/app/views/users/_project_attachment.html.erb b/app/views/users/_project_attachment.html.erb index ed4f8cfb8..960036ece 100644 --- a/app/views/users/_project_attachment.html.erb +++ b/app/views/users/_project_attachment.html.erb @@ -5,7 +5,7 @@ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
+
<% if activity.try(:author).try(:realname) == ' ' %> <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> <% else %> @@ -43,4 +43,4 @@ $(function(){ user_card_show_hide(); }); - + diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 131354df0..e1c9038d5 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -5,7 +5,7 @@ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
+
<% if activity.try(:author).try(:realname) == ' ' %> <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> <% else %> diff --git a/app/views/users/_project_list.html.erb b/app/views/users/_project_list.html.erb index 77f9aaf5b..828f4f7ac 100644 --- a/app/views/users/_project_list.html.erb +++ b/app/views/users/_project_list.html.erb @@ -1,19 +1,25 @@
<% unless projects.empty? %> <% if @type.to_i == 2 %> - <%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %> + <%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, + :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :style => "margin-right: 5px;", :remote => true %> <% else %> - <%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortdownbtn sort_no fr", :style => "margin-right: 5px;", :remote => true %> + <%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, + :class => "sortdownbtn sort_no fr", :style => "margin-right: 5px;", :remote => true %> <% end %> - <%= link_to "人气", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, :class => "sortTxt fr", :remote => true %> + <%= link_to "人气", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 2 }, + :class => "sortTxt fr", :remote => true %> <% if @type.to_i == 1 %> - <%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %> + <%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, + :class => "#{@c_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} fr", :remote => true %> <% else %> - <%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortdownbtn sort_no fr", :remote => true %> + <%= link_to "", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, + :class => "sortdownbtn sort_no fr", :remote => true %> <% end %> - <%= link_to "时间", {:controller => 'users', :action => 'sort_project_list', :id =>@user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, :class => "sortTxt fr", :remote => true %> + <%= link_to "时间", {:controller => 'users', :action => 'sort_project_list', :id => @user,:list_type => list_type, :type => @type, :sort => @c_sort, :order => 1 }, + :class => "sortTxt fr", :remote => true %> <% end %> -<%=@user == User.current ? "我" : "他" %><%= list_type == 1 ? "创建" : "参与"%>的项目 +<%= @user == User.current ? "我" : "他" %><%= list_type == 1 ? "创建" : "参与"%>的项目
@@ -21,7 +27,7 @@
<% if list_type == 1 %>

<%=@user == User.current ? "您" : "他" %>还没有创建项目~~
- <%= link_to "创建项目", new_project_path(:host=> Setting.host_name), :target => "_blank", :class => "sy_btn_green ml5 mt5" if @user == User.current %> + <%= link_to "创建项目", new_project_path(:host => Setting.host_name), :target => "_blank", :class => "sy_btn_green ml5 mt5" if @user == User.current %>

<% else %>

<%=@user == User.current ? "您" : "他" %>还没有加入项目~~
@@ -31,16 +37,18 @@ <% else %> <% projects.each_with_index do |project, i| %>

+ <% allow_visit = User.current.member_of?(project) || User.current.admin? || project.is_public? %>
- + <%=render :partial => 'collect_project', :locals => {:project => project} %> -

<%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :target => '_blank', :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (project.is_public? ? "公开项目:":"私有项目:") + project.name%>

+

<%= link_to project.name, allow_visit ? project_path(project.id,:host=>Setting.host_name) : 'javascript:void(0)', :target => '_blank', + :class => "new_project_title fl",:id => "show_project_#{project.id}", :title => (allow_visit ? "#{project.name}" : "私有项目不可访问") %>

<% unless project.is_public? %> 私有 <% end %> <% projectUser = User.where("id=?",project.user_id).first %> - <%=link_to "创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}".html_safe, user_path(projectUser) %> + <%= link_to "创建者:#{projectUser.try(:realname) != " " ? projectUser.lastname + projectUser.firstname : projectUser.try(:login)}".html_safe, user_path(projectUser) %>
@@ -58,7 +66,8 @@ <% end %> <% if count > 5 %> <% end %> <% end %> diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index 5ee3ff0ba..d590b9a66 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -5,7 +5,7 @@ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
+
<%= link_to activity.author.show_name, user_path(activity.author_id), :class => "newsBlue mr15" %> TO <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%> diff --git a/app/views/users/_share_news_to_course.html.erb b/app/views/users/_share_news_to_course.html.erb index 0e88c164e..03b5ff08b 100644 --- a/app/views/users/_share_news_to_course.html.erb +++ b/app/views/users/_share_news_to_course.html.erb @@ -20,7 +20,7 @@ <%= hidden_field_tag(:send_ids, send_ids) %> <%= submit_tag '',:class=>'searchIcon2',:onfocus=>"this.blur();",:style=>'border-style:none' %> diff --git a/config/menu.yml.production b/config/menu.yml.production index 8929d002e..0b8cd5b37 100644 --- a/config/menu.yml.production +++ b/config/menu.yml.production @@ -30,3 +30,7 @@ button: type: "click" name: "联系我们" key: "FEEDBACK" + - + type: "view" + name: "个人资料" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=edit_userinfo#wechat_redirect" diff --git a/config/menu.yml.test b/config/menu.yml.test index 303b30c26..5888996cf 100644 --- a/config/menu.yml.test +++ b/config/menu.yml.test @@ -30,3 +30,7 @@ button: type: "click" name: "联系我们" key: "FEEDBACK" + - + type: "view" + name: "个人资料" + url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities&response_type=code&scope=snsapi_base&state=edit_userinfo#wechat_redirect" diff --git a/config/routes.rb b/config/routes.rb index 89ebf1064..afe30d4de 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -116,6 +116,7 @@ RedmineApp::Application.routes.draw do end collection do get 'org_member_autocomplete' + get 'org_member_paging' get 'deleteOrgMember' end end diff --git a/config/wechat.yml.template b/config/wechat.yml.template index 8ca6ac237..734ed0e51 100644 --- a/config/wechat.yml.template +++ b/config/wechat.yml.template @@ -26,6 +26,7 @@ default: &default join_project_notice: "TtXvy0XMIQyCgpnXHhoB8t-x0QIfy-78gAJXsGf9afg" project_issue_notice: "HP8JejOnkzmvFopTarc0l1Tp4bU9qnxzdH27x3186lI" at_notice: "U3kqzgriCaqkPI9qX0NDQOInJ5hiwHCz6wgTsPysSx4" + rebind_notice: "OYsiECfqUlHKlzF_X-pz_xsGh_vAAUunX0jYRdHlyFU" auto_openid_url_1: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8e1ab05163a28e37&redirect_uri=https://www.trustie.net/wechat/user_activities" auto_openid_url_2: "&response_type=code&scope=snsapi_base&state=" diff --git a/config/wechat.yml.test b/config/wechat.yml.test index 12cee4751..28c9d974e 100644 --- a/config/wechat.yml.test +++ b/config/wechat.yml.test @@ -26,6 +26,7 @@ default: &default join_project_notice: "3KnMQEMUCmQWkB5JvzrpmguEwnN8bvUHUdpOTudxv_M" project_issue_notice: "HAF2aCta7BtnaOd_cotGvU4tErGWwCd9I9aiClFN7w8" at_notice: "p4HfyZQuF8O5bP_44RbbJS30SGojLJAuZEqp34iB4JU" + rebind_notice: "B97nOiW9cscB_d078I3k0jaPLHeJThTKUuxMoUnWZ2U" auto_openid_url_1: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://test.forge.trustie.net/wechat/user_activities" auto_openid_url_2: "&response_type=code&scope=snsapi_base&state=" diff --git a/public/assets/wechat/app.html b/public/assets/wechat/app.html index fdd4d3276..099384593 100644 --- a/public/assets/wechat/app.html +++ b/public/assets/wechat/app.html @@ -40,7 +40,7 @@ - + diff --git a/public/assets/wechat/blog_detail.html b/public/assets/wechat/blog_detail.html index 570bfb797..7aa629bb7 100644 --- a/public/assets/wechat/blog_detail.html +++ b/public/assets/wechat/blog_detail.html @@ -73,7 +73,17 @@
{{journal.praise_count}}
{{journal.praise_count}}
+
+ 回复 +
+
+
+ + + +
+
@@ -82,13 +92,13 @@
-
+
- - - + + +
diff --git a/public/assets/wechat/course_discussion.html b/public/assets/wechat/course_discussion.html index a3f6ae496..91aa58fcf 100644 --- a/public/assets/wechat/course_discussion.html +++ b/public/assets/wechat/course_discussion.html @@ -71,7 +71,17 @@
{{journal.praise_count}}
{{journal.praise_count}}
+
+ 回复 +
+
+
+ + + +
+
@@ -79,13 +89,13 @@
-
+
- - - + + +
diff --git a/public/assets/wechat/course_notice.html b/public/assets/wechat/course_notice.html index 33e8e77be..247cd1fd0 100644 --- a/public/assets/wechat/course_notice.html +++ b/public/assets/wechat/course_notice.html @@ -86,7 +86,17 @@
{{journal.praise_count}}
{{journal.praise_count}}
+
+ 回复 +
+
+
+ + + +
+
@@ -94,13 +104,13 @@
-
+
- - - + + +
diff --git a/public/assets/wechat/edit_userinfo.html b/public/assets/wechat/edit_userinfo.html new file mode 100644 index 000000000..e299b8feb --- /dev/null +++ b/public/assets/wechat/edit_userinfo.html @@ -0,0 +1,44 @@ +
+
+
编辑资料
+
+
+ + + +
+ {{user.login}}解除绑定
+ +
+ +
姓名
+
+
+ 性别 + + +
+
+ + + +
+
+ +
+ 邮箱 + +
+ 电子邮箱地址不能为空 + 电子邮箱地址不合法 +
+
+
+ 取消 + 确定 +
+
+ + + +
\ No newline at end of file diff --git a/public/assets/wechat/homework_detail.html b/public/assets/wechat/homework_detail.html index bf2a89f35..e5f73faa9 100644 --- a/public/assets/wechat/homework_detail.html +++ b/public/assets/wechat/homework_detail.html @@ -75,7 +75,17 @@
{{journal.praise_count}}
{{journal.praise_count}}
+
+ 回复 +
+
+
+ + + +
+
@@ -83,13 +93,13 @@
-
+
- - - + + +
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 5b55ebba0..f4eed4bd9 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -92,7 +92,17 @@
{{journal.praise_count}}
{{journal.praise_count}}
+
+ 回复 +
+
+
+ + + +
+
@@ -100,13 +110,13 @@
-
+
- - - + + +
diff --git a/public/assets/wechat/jour_message_detail.html b/public/assets/wechat/jour_message_detail.html index 5b06a22aa..a1db224a6 100644 --- a/public/assets/wechat/jour_message_detail.html +++ b/public/assets/wechat/jour_message_detail.html @@ -70,7 +70,17 @@
{{journal.praise_count}}
{{journal.praise_count}}
+
+ 回复 +
+
+
+ + + +
+
@@ -78,13 +88,13 @@
-
+
- - - + + +
diff --git a/public/assets/wechat/project_discussion.html b/public/assets/wechat/project_discussion.html index e0ee87d78..dcb5a68a6 100644 --- a/public/assets/wechat/project_discussion.html +++ b/public/assets/wechat/project_discussion.html @@ -71,20 +71,30 @@
{{journal.praise_count}}
{{journal.praise_count}}
+
+ 回复 +
+
+
+ + + +
+
更多
-
+
- - - + + +
diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 5f1194273..aeb9e645a 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -550,8 +550,8 @@ function observeSearchfield(fieldId, targetId, url) { dataType: 'jsonp', data: {q: $this.val()}, success: function(data){ if(targetId) $('#'+targetId).html(data); }, - beforeSend: function(){ $this.addClass('ajax-loading'); }, - complete: function(){ $this.removeClass('ajax-loading'); } + beforeSend: function(){ $this.addClass('ajax-loading'); }, // 添加成员加载完成前,显示载入中 + complete: function(){ $this.removeClass('ajax-loading'); } // 完成后,移除 }); } }; diff --git a/public/javascripts/org.js b/public/javascripts/org.js index a2b2bd361..f1520a0ec 100644 --- a/public/javascripts/org.js +++ b/public/javascripts/org.js @@ -1,4 +1,5 @@ //�����֯��Ա���ύ���� +// 组织:新增成员 function submit_add_org_members(){ $("#org_member_add_form").submit(); } diff --git a/public/javascripts/wechat/controllers/edit_userinfo.js b/public/javascripts/wechat/controllers/edit_userinfo.js new file mode 100644 index 000000000..94722398d --- /dev/null +++ b/public/javascripts/wechat/controllers/edit_userinfo.js @@ -0,0 +1,92 @@ +app.controller('EditUserInfoController', ['$scope', 'config','$http', 'auth','$location','$routeParams','alertService','rms','common','$timeout','wx', function($scope, config, $http, auth, $location, $routeParams,alertService,rms,common,$timeout,wx){ +// common.checkLogin(); + + $scope.replaceUrl = function(url){ + return url; + }; + + var vm = $scope; + + //单弹框 + vm.alertService_1 = alertService.create(); + + //双弹框 + vm.alertService_2 = alertService.create(); + + vm.getuserinfo = function(){ + $http.get(config.apiUrl + 'users/get_userinfo?token='+auth.token()).then( + function(response) { + console.log(response.data); + vm.user = response.data.data; + vm.lastname = vm.user.lastname; + vm.mail = vm.user.mail; + vm.sex = vm.user.gender; + } + ); + }; + + vm.getuserinfo(); + + vm.unbind = function(){ + vm.alertService_2.showMessage('提示', '是否确认解除绑定', function() { + $http.post(config.apiUrl + "users/user_unbind", + {token: auth.token()} + ).then(function (response) { + if (response.data.status == 0) { + vm.alertService_1.showMessage('提示', '解除绑定成功', function () { + wx.closeWindow(); + }); + } + else { + vm.alertService_1.showMessage('提示', response.data.message); + } + }); + }); + }; + + vm.cancel = function(){ + vm.alertService_2.showMessage('提示', '是否确认取消', function() { + wx.closeWindow(); + }); + }; + + vm.confirm = function(frm){ + frm.$setSubmitted(); + + console.log(frm); + if (!frm.$valid) { + console.log(frm.$error); + return; + } + + if(vm.lastname == ""){ + vm.alertService_1.showMessage('提示', '姓名不能为空'); + return; + } + + if(vm.mail == ""){ + vm.alertService_1.showMessage('提示', '邮箱不能为空'); + return; + } + +// if(!(/\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i.test(vm.mail))){ +// vm.alertService_1.showMessage('提示', '邮箱不合法'); +// return; +// } + + $http.post(config.apiUrl + "users/edit_userinfo", + {token: auth.token(),lastname: vm.lastname, sex: vm.sex, mail: vm.mail} + ).then(function(response){ + if(response.data.status == 0) + { + vm.alertService_1.showMessage('提示', '修改成功',function(){ + wx.closeWindow(); + }); + } + else{ + vm.alertService_1.showMessage('提示', response.data.message); + } + }); + }; + +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/input_auto.js b/public/javascripts/wechat/directives/input_auto.js index 9cd77188b..ea0a6bf1a 100644 --- a/public/javascripts/wechat/directives/input_auto.js +++ b/public/javascripts/wechat/directives/input_auto.js @@ -1,19 +1,40 @@ -app.directive('inputAuto',function(){ - return{ - restrict: 'A', - scope: {}, - link: function(scope, element){ - var copyContainer = element.parent().children().children().eq(0); - var sendButton = element.next(); - element.on('input',function(){ - //console.log(sendButton); - copyContainer.html(element[0].value); - var textHeight = copyContainer[0].scrollHeight-10; - element.css('height', textHeight + 'px'); - }); - sendButton.on('click',function(){ - element.css('height','18px'); - }); - } - } -}); \ No newline at end of file +//app.directive('inputAuto',function(){ +// return{ +// restrict: 'A', +// scope: {}, +// link: function(scope, element){ +// var copyContainer = element.parent().children().children().eq(0); +// var sendButton = element.next(); +// element.on('input',function(){ +// //console.log(sendButton); +// copyContainer.html(element[0].value); +// var textHeight = copyContainer[0].scrollHeight-10; +// element.css('height', textHeight + 'px'); +// }); +// sendButton.on('click',function(){ +// element.css('height','18px'); +// }); +// } +// } +//}); + +app.directive('inputAuto',["$timeout",function(timer){ + return{ + restrict: 'A', + scope: {}, + link: function(scope, element){ + timer(function(){ + $(".post-reply-input").bind("input",function(){ + var copyInput = $(this).prev().children(); + var sendButton = $(this).next(); + copyInput.html($(this).val()); + var textHeight = copyInput[0].scrollHeight-10; + $(this).css("height",textHeight + "px"); + sendButton.click(function(){ + $(this).prev().css("height","18px"); + }) + }); + }); + } + } +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/load_head.js b/public/javascripts/wechat/directives/load_head.js new file mode 100644 index 000000000..47862f0b7 --- /dev/null +++ b/public/javascripts/wechat/directives/load_head.js @@ -0,0 +1,35 @@ +app.directive('loadHead',['$http','config','auth','$location','alertService',function($http,config,auth,$location,alertService){ + return{ + restrict: 'A', + scope: {}, + link: function (scope, element, attrs) { + element.bind('change', function(){ + var file = event.target.files[0]; + //判断类型是不是图片 + if (!/image\/\w+/.test(file.type)) { + alert("非图片"); + return; + } + + var reader = new FileReader(); + reader.readAsDataURL(file); + reader.onload = function (e) { +// alert(this.result);//base64 + + $http.post(config.apiUrl + "users/upload_head", + {token: auth.token(),imgdata:this.result} + ).then(function (response) { + if(response.data.status == 0){ + scope.$parent.alertService_1.showMessage('提示',"上传成功",function(){ + scope.$parent.getuserinfo(); + }); + } + else{ + scope.$parent.alertService_1.showMessage('提示',response.data.message); + } + }); + } + }); + } + } +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/multi_reply.js b/public/javascripts/wechat/directives/multi_reply.js new file mode 100644 index 000000000..5b1e2b483 --- /dev/null +++ b/public/javascripts/wechat/directives/multi_reply.js @@ -0,0 +1,42 @@ +/** + * Created by ttang on 2016/9/5. + */ +app.directive('multiReply',["$timeout",function(timer){ + return{ + restrict: 'A', + scope: {}, + link: function(scope, element){ + timer(function(){ + $(".reply-icons").each(function(){ + $(this).toggle(function(){ + $(this).next().next().removeClass("undis"); + $(this).next().next().focus(); + },function(){ + $(this).next().next().addClass("undis"); + }); + }); +// $(".reply-icons").live("click",function(){ +// if($(this).hasClass("multi-hide")){ +// $(".multi-input-container").addClass("undis"); +// $(".reply-icons").addClass("multi-hide"); +// $(this).next().next().removeClass("undis"); +// $(this).next().next().focus(); +// $(this).removeClass("multi-hide"); +// $(".post-reply-input").val(""); +// } +// else{ +// $(this).addClass("multi-hide"); +// $(".post-input-container").addClass("undis"); +// $(".post-reply-input").val(""); +// $("#post_input_1, #post_input_1 .post-input-container").show(); +// } +// }); +// $(".post-reply-submit,#more_reply").click(function(){ +// $(".reply-icons").addClass("multi-hide"); +// $(".post-input-container").addClass("undis"); +// $("#post_input_1, #post_input_1 .post-input-container").show(); +// }); + }) + } + } +}]); \ No newline at end of file diff --git a/public/javascripts/wechat/directives/submit_start.js b/public/javascripts/wechat/directives/submit_start.js deleted file mode 100644 index cbdc469ab..000000000 --- a/public/javascripts/wechat/directives/submit_start.js +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Created by ttang on 2016/8/31. - */ -app.directive('submitStart',["$timeout",function(timer){ - return{ - restrict: 'A', - scope: {}, - link: function(scope, element){ - timer(function(){ - $("#manageDelete,.login-box").click(function(){ - element.removeClass("bg-grey c-white"); - element.addClass("link-blue2"); - }); - }) - } - } -}]); diff --git a/public/javascripts/wechat/others/factory.js b/public/javascripts/wechat/others/factory.js index d4e365321..190dd36b4 100644 --- a/public/javascripts/wechat/others/factory.js +++ b/public/javascripts/wechat/others/factory.js @@ -94,7 +94,7 @@ app.factory('rms', function(){ }); app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$location', function($http, auth, $routeParams,rms,config,wx,$location){ - var addCommonReply = function(id, type, data,args, cb){ + var addCommonReply = function(id, type, data,args,reply_type, cb){ //先判断有没有绑定 // $http.post( // '/wechat/is_bind', @@ -111,12 +111,12 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc } var temp = data.comment.replace(/\n/g,'
'); - temp = temp.replace(/^\:[a-z0-9_]+\:$/g, "[表情]"); var userInfo = { type: type, content: temp, - token: auth.token() + token: auth.token(), + reply_type:reply_type }; //回复按钮禁用 data.disabled = true; @@ -146,24 +146,26 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc cb(response.data.subscribe); } + var act_id = response.data.act_id; + //保证内外回复数一致 activities = rms.get("activities") || []; course_activities = rms.get("course_activities") || []; project_activities = rms.get("project_activities") || []; for(var i in activities){ - if(activities[i].act_id == id){ + if(activities[i].act_id == act_id){ activities[i].reply_count += 1; break; } } for(var i in course_activities){ - if(course_activities[i].act_id == id){ + if(course_activities[i].act_id == act_id){ course_activities[i].reply_count += 1; break; } } for(var i in project_activities){ - if(project_activities[i].act_id == id){ + if(project_activities[i].act_id == act_id){ project_activities[i].reply_count += 1; break; } @@ -222,7 +224,7 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc var init = function(args){ args.scope.replytip = "输入回复内容~"; - args.scope.formData = {comment: ''}; +// args.scope.formData = {comment: ''}; var loadData = function(id,replytype,page){ loadCommonData(id, args.type,replytype,page).then(function successCallback(response) { console.log(response.data); @@ -304,10 +306,10 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc }; loadData(args.id,0,0); - args.scope.addReply = function(data){ + args.scope.addReply = function(data,reply_type){ console.log(data.comment); - addCommonReply(args.id, args.replyType, data,args, function(subscribe){ - args.scope.formData = {comment: ''}; + addCommonReply(data.act_id, args.replyType, data,args,reply_type, function(subscribe){ +// args.scope.formData = {comment: ''}; if(subscribe == 0){ $location.path("/login_tip"); return; @@ -322,6 +324,27 @@ app.factory('common', ['$http', 'auth', '$routeParams','rms','config','wx','$loc }); }; + args.scope.inputfocus = function(data){ + data.notshow = true; + }; + + args.scope.inputblur = function(data){ + data.notshow = false; + }; + + args.scope.clickReply = function(act_id,data) { + allchidren = data.all_children; + for(var i in allchidren){ + if(allchidren[i].act_id != act_id ){ + allchidren[i].showinput = false; + } + else{ + allchidren[i].showinput = !allchidren[i].showinput; + data.notshow = allchidren[i].showinput; + } + } + }; + // 动态详情界面点赞与动态界面的数据要同步 保证进入详情点赞后出来显示一致 args.scope.addPraise = function(act){ activities = rms.get("activities") || []; diff --git a/public/javascripts/wechat/others/routes.js b/public/javascripts/wechat/others/routes.js index 2182e16ee..e5c87d1ab 100644 --- a/public/javascripts/wechat/others/routes.js +++ b/public/javascripts/wechat/others/routes.js @@ -51,6 +51,7 @@ app.config(['$routeProvider',"$httpProvider", "$locationProvider",'config', func .when('/review_project_member', makeRoute('review_project_member.html', 'ReviewProjectMemberController')) .when('/project_publishnote', makeRoute('project_publishnote.html', 'ProjectPublishNoteController')) .when('/login_tip', makeRoute('login_tip.html', 'LoginTipController')) + .when('/edit_userinfo', makeRoute('edit_userinfo.html', 'EditUserInfoController')) .otherwise({ redirectTo: '/activites' }); diff --git a/public/stylesheets/weui/weixin.css b/public/stylesheets/weui/weixin.css index 3d960b4ad..cf44a3814 100644 --- a/public/stylesheets/weui/weixin.css +++ b/public/stylesheets/weui/weixin.css @@ -257,4 +257,9 @@ a.underline {text-decoration:underline;} /*发布帖子,通知*/ .full-width-wrap {padding:5px 15px; background-color:#fff; border-top:1px solid #ddd; border-bottom:1px solid #ddd;} -.full-width-textarea {width:100%; height:180px; line-height:18px; max-height:180px; border:none; resize:none; font-size:13px; color:#555; overflow-y:auto;} \ No newline at end of file +.full-width-textarea {width:100%; height:180px; line-height:18px; max-height:180px; border:none; resize:none; font-size:13px; color:#555; overflow-y:auto;} + +/*资料修改*/ +.blank-row {width:100%; height:38px; line-height:38px; vertical-align:middle;} +.upload-input-container {width:30px; height:30px; border:1px solid #ddd; position:relative;} +.upload-input {width:30px; height:30px; position:absolute; z-index:1; opacity:0;} \ No newline at end of file