diff --git a/.gitignore b/.gitignore index 22d9e17e6..0727a920a 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ vendor/cache /public/files /tags /config/initializers/gitlab_config.rb +1234567 diff --git a/1234567 b/1234567 new file mode 100644 index 000000000..08de77ab4 --- /dev/null +++ b/1234567 @@ -0,0 +1 @@ +{"access_token":"bFlabz0uBcoIBfWL7nBJkgpl26aOWDy-dyCOvH_MjUo_hMOOKG83WV1cCL1MG6H-AE-6eMI0iyLoOoAMv9Y3pFFsLYD-GAGr3UH9fT8OqeHMDlFhXyRTvHv9l2QPHGpcARUcCGANEH","expires_in":7200,"got_token_at":1462934760} \ No newline at end of file diff --git a/Gemfile b/Gemfile index fbfd4c100..9f31edad1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org/' -#source 'http://ruby.sdutlinux.org/' +### 这里执行bundle config mirror.https://rubygems.org https://gems.ruby-china.org 切换到ruby-china源 unless RUBY_PLATFORM =~ /w32/ # unix-like only @@ -7,6 +7,8 @@ unless RUBY_PLATFORM =~ /w32/ end gem 'certified' + +gem 'wechat',path: 'lib/wechat' gem 'grack', path:'lib/grack' gem 'gitlab', path: 'lib/gitlab-cli' gem 'rest-client' @@ -17,8 +19,9 @@ gem 'delayed_job_active_record'#, :group => :production gem 'daemons' gem 'grape', '~> 0.9.0' gem 'grape-entity' +gem 'rack-cors', :require => 'rack/cors' gem 'seems_rateable', '~> 1.0.13' -gem "rails", "~> 3.2.13" +gem 'rails', '~> 3.2' gem "jquery-rails", "~> 2.0.2" gem "i18n", "~> 0.6.0" gem 'coderay', '~> 1.1.0' @@ -41,10 +44,15 @@ gem 'kaminari' gem 'elasticsearch-model' gem 'elasticsearch-rails' + +### profile +#gem 'oneapm_rpm' + group :development do gem 'grape-swagger' gem 'better_errors', '~> 1.1.0' - gem 'rack-mini-profiler', '~> 0.9.3' + # gem "query_reviewer" + # gem 'rack-mini-profiler', '~> 0.9.3' if RUBY_PLATFORM =~ /w32/ gem 'win32console' end diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb index a59b01776..23014b0c1 100644 --- a/app/api/mobile/api.rb +++ b/app/api/mobile/api.rb @@ -7,6 +7,16 @@ module Mobile require_relative 'apis/upgrade' require_relative 'apis/homeworks' require_relative 'apis/comments' + require_relative 'apis/issues' + require_relative 'apis/activities' + require_relative 'apis/whomeworks' + require_relative 'apis/newss' + require_relative 'apis/journal_for_messages' + require_relative 'apis/messages' + require_relative 'apis/blog_comments' + require_relative 'apis/new_comment' + require_relative 'apis/praise' + class API < Grape::API version 'v1', using: :path format :json @@ -39,6 +49,15 @@ module Mobile mount Apis::Upgrade mount Apis::Homeworks mount Apis::Comments + mount Apis::Issues + mount Apis::Activities + mount Apis::Whomeworks + mount Apis::Newss + mount Apis::JournalForMessages + mount Apis::Messages + mount Apis::BlogComments + mount Apis::NewComment + mount Apis::Praise #add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'}) #add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? diff --git a/app/api/mobile/apis/activities.rb b/app/api/mobile/apis/activities.rb new file mode 100644 index 000000000..94ee14a56 --- /dev/null +++ b/app/api/mobile/apis/activities.rb @@ -0,0 +1,63 @@ +#coding=utf-8 + +module Mobile + module Apis + class Activities< Grape::API + resources :activities do + + desc "get user activities" + + params do + requires :page, type: Integer + requires :openid, type: String + end + post do + user = UserWechat.find_by_openid(params[:openid]).user +=begin + shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) + page = params[:page] ? params[:page] : 0 + user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + project_types = "('Message','Issue','ProjectCreateInfo')" + principal_types = "JournalsForMessage" + + blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")" + activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc') +=end + + shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) + page = params[:page] ? params[:page] : 0 + user_project_ids = (user.projects.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (user.courses.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")" + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + project_types = "('Message','Issue','ProjectCreateInfo')" + principal_types = "JournalsForMessage" + watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(',')) + user_ids = "(" + user.id.to_s + watched_user_ids + ")" + watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",") + blog_ids = "(" + watched_user_blog_ids + ")" + + activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc') + + all_count = activities.count + activities = activities.limit(10).offset(page * 10) + count = activities.count + present :data, activities, with: Mobile::Entities::Activity,user: user + present :all_count, all_count + present :count, count + present :page, page + present :status, 0 + end + end + end + end +end \ No newline at end of file diff --git a/app/api/mobile/apis/blog_comments.rb b/app/api/mobile/apis/blog_comments.rb new file mode 100644 index 000000000..5a064245a --- /dev/null +++ b/app/api/mobile/apis/blog_comments.rb @@ -0,0 +1,19 @@ +#coding=utf-8 + +module Mobile + module Apis + class BlogComments< Grape::API + resources :blog_comments do + + desc "get special topic" + get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user + blog = BlogComment.find params[:id] + present :data, blog, with: Mobile::Entities::BlogComment,user: user + present :status, 0 + end + end + end + end +end + diff --git a/app/api/mobile/apis/comments.rb b/app/api/mobile/apis/comments.rb index 7fa676161..15f020bc2 100644 --- a/app/api/mobile/apis/comments.rb +++ b/app/api/mobile/apis/comments.rb @@ -115,7 +115,7 @@ module Mobile desc '閫氱煡璇勮鍒楄〃' params do - requires :token, type: String + #requires :token, type: String requires :notice_id,type:Integer,desc:'閫氱煡id' optional :page,type:Integer,desc:'椤电爜' end diff --git a/app/api/mobile/apis/issues.rb b/app/api/mobile/apis/issues.rb new file mode 100644 index 000000000..b767bd768 --- /dev/null +++ b/app/api/mobile/apis/issues.rb @@ -0,0 +1,19 @@ +#coding=utf-8 + +module Mobile + module Apis + class Issues< Grape::API + resources :issues do + include IssuesHelper + + desc "get special issuse" + get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user + issue = Issue.find params[:id] + present :data, issue, with: Mobile::Entities::Issue,user: user + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/journal_for_messages.rb b/app/api/mobile/apis/journal_for_messages.rb new file mode 100644 index 000000000..15a571a82 --- /dev/null +++ b/app/api/mobile/apis/journal_for_messages.rb @@ -0,0 +1,18 @@ +#coding=utf-8 + +module Mobile + module Apis + class JournalForMessages< Grape::API + resources :journal_for_messages do + + desc "get special journal" + get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user + jour = JournalsForMessage.find params[:id] + present :data, jour, with: Mobile::Entities::Jours,user: user + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/messages.rb b/app/api/mobile/apis/messages.rb new file mode 100644 index 000000000..ae2f9a39c --- /dev/null +++ b/app/api/mobile/apis/messages.rb @@ -0,0 +1,18 @@ +#coding=utf-8 + +module Mobile + module Apis + class Messages< Grape::API + resources :messages do + + desc "get special topic" + get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user + message = Message.find params[:id] + present :data, message, with: Mobile::Entities::Message,user: user + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb new file mode 100644 index 000000000..694ec0613 --- /dev/null +++ b/app/api/mobile/apis/new_comment.rb @@ -0,0 +1,105 @@ +#coding=utf-8 + +module Mobile + module Apis + class NewComment< Grape::API + include ApplicationHelper + include ApiHelper + resources :new_comment do + + desc "add a new comment" + params do + requires :type, type: String + requires :content, type: String + requires :openid, type: String + end + post ':id' do + type = params[:type] + result = 1 + current_user = UserWechat.find_by_openid(params[:openid]).user + if params[:content]!="" && current_user + case type + when "HomeworkCommon" + 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 + end + when "News" + news = News.find(params[:id]) + comment = Comment.new + comment.comments = params[:content] + comment.author = current_user + if news.comments << comment + result = 2 + end + when "Message" + 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 topic.children << reply + result = 2 + end + when "JournalsForMessage" + jour = JournalsForMessage.find params[:id] + 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 + when 'Issue' + 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 + 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 + 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]) + end + else + result = 3 + end + present :result, result + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/newss.rb b/app/api/mobile/apis/newss.rb new file mode 100644 index 000000000..8bdd460cc --- /dev/null +++ b/app/api/mobile/apis/newss.rb @@ -0,0 +1,18 @@ +#coding=utf-8 + +module Mobile + module Apis + class Newss< Grape::API + resources :newss do + + desc "get special news" + get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user + news = News.find params[:id] + present :data, news, with: Mobile::Entities::News,user: user + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/apis/praise.rb b/app/api/mobile/apis/praise.rb new file mode 100644 index 000000000..57dbd0729 --- /dev/null +++ b/app/api/mobile/apis/praise.rb @@ -0,0 +1,41 @@ +#coding=utf-8 + +module Mobile + module Apis + class Praise< Grape::API + include ApiHelper + resources :praise do + desc "praise an activity" + + params do + requires :type, type: String + requires :openid, type: String + end + post ':id' do + obj_id = params[:id] + obj_type = params[:type] + user = UserWechat.find_by_openid(params[:openid]).user + pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id).first + if pts.blank? + praise_or_cancel(obj_type,obj_id,user,1) + obj = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first + num = get_activity_praise_num(obj) if !obj.blank? + else + pts.destroy if !pts.blank? + #鍐嶆洿鏂皃raise_tread_cache琛 浣跨浉搴旂殑璁板綍鍑1 褰撲负0鏃跺垹闄 + ptc = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first + ptc.praise_minus(1) if !ptc.blank? + if ptc.praise_num == 0 + ptc.delete + end + obj = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first + num = !obj.blank? ? get_activity_praise_num(obj) : 0 + end + + present :data, num + present :status, 0 + end + end + end + end +end \ No newline at end of file diff --git a/app/api/mobile/apis/whomeworks.rb b/app/api/mobile/apis/whomeworks.rb new file mode 100644 index 000000000..a88d509a3 --- /dev/null +++ b/app/api/mobile/apis/whomeworks.rb @@ -0,0 +1,18 @@ +#coding=utf-8 + +module Mobile + module Apis + class Whomeworks< Grape::API + resources :whomeworks do + + desc "get one homework" + get ':id' do + user = UserWechat.find_by_openid(params[:openid]).user + homework = HomeworkCommon.find params[:id] + present :data, homework, with: Mobile::Entities::Whomework,user: user + present :status, 0 + end + end + end + end +end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb new file mode 100644 index 000000000..20876bf69 --- /dev/null +++ b/app/api/mobile/entities/activity.rb @@ -0,0 +1,146 @@ +# encoding: utf-8 +module Mobile + module Entities + class Activity e message = {status: 1, message: e.message }.to_json - puts(e.backtrace.join("\n")) if Rails.env.development? + Rails.logger.error e.inspect + Rails.logger.error e.backtrace.join("\n") status = 200 headers = { 'Content-Type' => content_type } Rack::Response.new([message], status, headers).finish diff --git a/app/assets/javascripts/shield_wechat_messages.js.coffee b/app/assets/javascripts/shield_wechat_messages.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/shield_wechat_messages.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/sub_document_comments.js.coffee b/app/assets/javascripts/sub_document_comments.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/sub_document_comments.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/javascripts/sub_domains.js.coffee b/app/assets/javascripts/sub_domains.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/sub_domains.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/shield_wechat_messages.css.scss b/app/assets/stylesheets/shield_wechat_messages.css.scss new file mode 100644 index 000000000..770d71351 --- /dev/null +++ b/app/assets/stylesheets/shield_wechat_messages.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the ShieldWechatMessages controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sub_document_comments.css.scss b/app/assets/stylesheets/sub_document_comments.css.scss new file mode 100644 index 000000000..c88f77750 --- /dev/null +++ b/app/assets/stylesheets/sub_document_comments.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the sub_document_comments controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/sub_domains.css.scss b/app/assets/stylesheets/sub_domains.css.scss new file mode 100644 index 000000000..7a751c0d9 --- /dev/null +++ b/app/assets/stylesheets/sub_domains.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the sub_domains controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index 8ae20972c..d3f681a06 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -593,7 +593,7 @@ class AdminController < ApplicationController end end - #浠g爜娴嬭瘯鍒楄〃 +#浠g爜娴嬭瘯鍒楄〃 def code_work_tests #姹傚嚭鎵鏈夋潯鏁 tCount = CodeTests.count() @@ -644,4 +644,13 @@ class AdminController < ApplicationController format.html end end + #鍒嗕韩浣滀笟鐢宠 + def apply_for_homework + homeworks = ApplyHomework.where("user_id != 0") + @homework = paginateHelper homeworks,30 + @page = (params['page'] || 1).to_i - 1 + respond_to do |format| + format.html + end + end end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 1dacffb6f..fe3c3272a 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -660,8 +660,8 @@ class AttachmentsController < ApplicationController end def has_login - unless @attachment && @attachment.container_type == "Organization" - unless @attachment && @attachment.container_type == "PhoneAppVersion" + unless (@attachment && @attachment.container_type == "Organization").nil? + unless (@attachment && @attachment.container_type == "PhoneAppVersion").nil? render_403 if !User.current.logged? && !(@attachment.container_type == 'OrgSubfield' && @attachment.container.organization.allow_guest_download) && !(@attachment.container_type == 'OrgDocumentComment' && @attachment.container.organization.allow_guest_download) end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 7320820bd..0fd4cc2c9 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -187,7 +187,7 @@ class CoursesController < ApplicationController end @canShowCode = User.current.allowed_to?(:as_teacher,@course) && params[:role] != '1' @is_remote = true - + @members = student_homework_score(0,0, 10,"desc") @course_groups = @course.course_groups end @@ -209,7 +209,7 @@ class CoursesController < ApplicationController end @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1' @is_remote = true - + @members = student_homework_score(0,0, 10,"desc") @course_groups = @course.course_groups end @@ -956,6 +956,7 @@ class CoursesController < ApplicationController @student_works.each do |tmpwork| @works_hash[tmpwork.id] = tmpwork + puts tmpwork.id end #respond_to do |format| diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 49e6ec290..689ef2bd7 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -11,6 +11,9 @@ class HomeworkCommonController < ApplicationController before_filter :member_of_course, :only => [:index] def index + #unless params[:page] + # update_homework_time(@course.homework_commons) + #end @new_homework = HomeworkCommon.new @new_homework.homework_detail_manual = HomeworkDetailManual.new @new_homework.course = @course @@ -73,16 +76,23 @@ class HomeworkCommonController < ApplicationController else @homework.publish_time = params[:homework_common][:publish_time] end + homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new @homework.end_time = params[:homework_common][:end_time] || Time.now @homework.course_id = params[:course_id] - @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment] : 0 + anonymous = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0 + if anonymous != @homework.anonymous_comment + if anonymous == 1 + homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 1.0 : 0.4 + else + homework_detail_manual.ta_proportion = @homework.homework_type == 1 ? 0.6 : 0.3 + end + end - homework_detail_manual = @homework.homework_detail_manual || HomeworkDetailManual.new if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 homework_detail_manual.comment_status = 1 end eval_start = homework_detail_manual.evaluation_start - if eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1 + if eval_start.nil? || (eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1) homework_detail_manual.evaluation_start = @homework.end_time + 7 homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7 end @@ -94,6 +104,13 @@ class HomeworkCommonController < ApplicationController @homework.homework_detail_programing ||= HomeworkDetailPrograming.new @homework_detail_programing = @homework.homework_detail_programing @homework_detail_programing.language = params[:language_type].to_i + if anonymous != @homework.anonymous_comment + if anonymous == 1 + @homework_detail_programing.ta_proportion = 0.6 + else + @homework_detail_programing.ta_proportion = 0.5 + end + end @homework.homework_tests.delete_all inputs = params[:program][:input] @@ -116,8 +133,9 @@ class HomeworkCommonController < ApplicationController @homework_detail_group.base_on_project = params[:base_on_project].to_i end + @homework.anonymous_comment = params[:homework_common][:anonymous_comment] ? params[:homework_common][:anonymous_comment].to_i : 0 if @homework.save - @homework_detail_manual.save if @homework_detail_manual + homework_detail_manual.save if homework_detail_manual @homework_detail_programing.save if @homework_detail_programing @homework_detail_group.save if @homework_detail_group @@ -385,4 +403,47 @@ class HomeworkCommonController < ApplicationController student_works += student_works student_works[index + 1 .. index + n] end + + def update_homework_time homeworks + unless homeworks.nil? + homeworks.each do |h| + if h.homework_type == 3 + student_works = h.student_work_projects.where("is_leader = 1") + time = h.updated_at + unless student_works.nil? + student_works.each do |s| + project = Project.find s.project_id + unless project.nil? && project.gpid.nil? + project_time=project.updated_on + project_time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last + if format_time(time) < format_time(project_time) + time = project_time + end + begin + # gitlab绔幏鍙栭粯璁ゅ垎鏀 + g = Gitlab.client + default_branch = g.project(project.gpid).default_branch + changesets = g.commits(project.gpid, :ref_name => default_branch) + changesets_latest_coimmit = changesets[0] + unless changesets[0].blank? + if format_time(time) < format_time(changesets_latest_coimmit.created_at) + time = changesets_latest_coimmit.created_at + end + end + rescue + logger.error("############## ==> update homework project time") + end + end + end + end + puts h.updated_at + puts time + s_time = time + if format_time(time) > format_time(h.updated_at) + h.update_attribute(:updated_at, s_time) + end + end + end + end + end end diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index d1a8b23dd..c6047d227 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -79,7 +79,7 @@ class OrgDocumentCommentsController < ApplicationController def add_reply @document = OrgDocumentComment.find(params[:id]).root - @act = OrgActivity.find(params[:id]) + @act = OrgActivity.find(params[:act_id]) @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id]) @comment.content = params[:org_content] @document.children << @comment diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 661073cdc..c628b25fc 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -15,6 +15,12 @@ class OrgSubfieldsController < ApplicationController end end @subfield.update_attributes(:field_type => params[:field_type]) + # 濡傛灉鏍忕洰鏄暀甯堬紝涓嶅弬鍏ョ被鍨嬬殑閰嶇疆锛屽畾涔変负鍙充笁妯″紡 + # 鏂板妯″潡鍛藉悕瑙勫垯锛屽乏杈1寮澶达紝鍙宠竟2寮澶达紝浠ュ墠鐨勪笉鍙 + # eg锛23 鍙充笁 + if params[:field_type] == "Comptec" + @subfield.update_attributes(:status => 23) + end else @res = false end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 75ca3e1ab..c94f734e1 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -28,7 +28,7 @@ class OrganizationsController < ApplicationController helper :project_score helper :issues include UsersHelper - before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout] + before_filter :find_organization, :only => [:show, :members, :apply_subdomain, :select_org_layout, :teachers] layout 'base_org' def index @@ -76,18 +76,14 @@ class OrganizationsController < ApplicationController def show # 缁勭粐鏂扮被鍨 show_mode锛氬垽鏂爣鍑 1涓烘柊绫诲瀷锛0涓烘棫 - if @organization.show_mode == 1 && params[:org_subfield_id].nil? && params[:list] .nil? + if @organization.show_mode.to_i == 1 && params[:org_subfield_id].nil? && params[:list] .nil? if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) # REDO:鏃堕棿绱э紝鏆傛椂鍏堣繖鏍 - @org_logo_attchment = Attachment.where("container_id =? and container_type =? and attachtype =?", @organization, "Organization", 0).order("created_on desc").first - @org_banner_attchment = Attachment.where("container_id =? and container_type =? and attachtype =?", @organization, "Organization", 1).order("created_on desc").first + @org_logo_attchment = Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 0 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first + @org_banner_attchment = Attachment.find_by_sql("SELECT * from attachments WHERE container_id = #{@organization.id} and container_type = 'Organization' and attachtype = 1 and filename REGEXP '(.jpg|.png|.bmp|.gif|.jpeg)' ORDER BY created_on desc limit 1").first @subfield_content = @organization.org_subfields.order("priority") @organization = Organization.find(params[:id]) - # @org_subfield = OrgSubfield.find(params[:org_subfield_id]) - # @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 - # @org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) - shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) project_ids = (@organization.projects.map(&:id)-shield_project_ids) << 0 @@ -95,35 +91,33 @@ class OrganizationsController < ApplicationController course_types = "('Message','News','HomeworkCommon','Poll','Course')" @project_acts = get_project_activities_org @organization, project_ids @course_acts = get_course_activities_org @organization, course_ids - #@org_acts = OrgActivity.where("container_id =? and container_type =?",@organization.id, 'Organization').order('updated_at desc') - #@project_acts = OrgActivity.where("(container_id =? and container_type =?) " + - # "or (container_type ='Project' and org_act_type in ('Issue','Message') and container_id in (#{project_ids.join(',')})) ", - # @organization.id, 'Organization').order('updated_at desc').limit(8) - - #@course_acts = OrgActivity.where("(container_id =? and container_type =?) " + - # "or (container_type ='Course' and org_act_type in #{course_types} and container_id in (#{course_ids.join(',')}))", - # @organization.id, 'Organization').order('updated_at desc').limit(8) - - - - # 椤圭洰涓ょ鍔ㄦ - #@project_acts = get_project_activities_org @organization - - # 璇剧▼鍔ㄦ - #@project_acts_issues = get_project_activities_org @organization - #@course_acts = get_course_activities_org @organization - - render :layout => 'base_org_newstyle' + render :layout => 'base_org2' else render_403 end else if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) @organization = Organization.find(params[:id]) + # params[:org_subfield_id] 瀛樺湪鍗冲搴旂殑鏍忕洰锛屽惁鍒欒繘鍏ョ粍缁囧姩鎬 if params[:org_subfield_id] @org_subfield = OrgSubfield.find(params[:org_subfield_id]) - @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 - @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) + if @org_subfield.field_type == "Comptec" || @org_subfield.field_type == "Compstu" + + # @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,( SELECT `courses`.* FROM `courses` INNER JOIN `members` ON `courses`.`id` = `members`.`course_id` WHERE `members`.`user_id` = u.id AND (courses.status<>9)) as course_count + # from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 order by course_count desc") + # @org_count = @org_teachers.count + # @limit = 25 + # @is_remote = true + # @atta_count = @attachments.count + # @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + # @offset ||= @atta_pages.offset + # #@curse_attachments_all = @all_attachments[@offset, @limit] + # @attachments = paginateHelper @attachments,25 + else + @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 + @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) + end else shield_project_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Project'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='Organization' and container_id=#{@organization.id} and shield_type='Course'").map(&:shield_id) @@ -164,6 +158,57 @@ class OrganizationsController < ApplicationController end + def teachers + unless @organization.allow_set_teachers + render_403 + return + end + q = params[:search].nil? ? "" : "#{params[:search].strip}" + @field = OrgSubfield.find(params[:org_subfield_id]) + @type = params[:type] + if @type == "courses" || @type.nil? + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + elsif @type == "students" + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + elsif @type == "resources" + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from attachments where attachments.author_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + elsif @type == "famous" + @org_teachers = User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 and concat(lastname,firstname,login) like '%#{q}%' order by course_count desc") + end + limit = 10 + # @is_remote = true + @teachers_count = @org_teachers.count + @atta_pages = Paginator.new @teachers_count, limit, params['page'] || 1 + @offset ||= @atta_pages.offset + #@curse_attachments_all = @all_attachments[@offset, @limit] + @org_teachers = paginateHelper @org_teachers, limit + respond_to do |format| + format.html + format.js + end + end + + def searchmember_by_name members, name + #searchPeopleByRoles(project, StudentRoles) + mems = [] + if name != "" + name = name.to_s.downcase + 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 + end + def get_project_message_activities_org org project_ids = org.projects.map{|project| project.id}.join(",") unless project_ids.blank? @@ -187,7 +232,7 @@ class OrganizationsController < ApplicationController def get_project_activities_org org, project_ids unless project_ids.blank? project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{project_ids.join(',')}) and container_type = 'project' - and org_act_type in ('Message', 'Issue') order by updated_at desc limit 8;") + and org_act_type in ('Message', 'Issue') order by updated_at desc limit 5;") else project_acts = nil end @@ -198,7 +243,7 @@ class OrganizationsController < ApplicationController def get_course_activities_org org, course_ids unless course_ids.blank? project_acts = OrgActivity.find_by_sql("SELECT * FROM org_activities where container_id in (#{course_ids.join(',')}) and container_type = 'course' - and org_act_type in ('HomeworkCommon', 'Poll', 'Message', 'News', 'Course') order by updated_at desc limit 8;") + and org_act_type in ('HomeworkCommon', 'Poll', 'Message', 'News', 'Course') order by updated_at desc limit 5;") else project_acts = nil end @@ -243,6 +288,7 @@ class OrganizationsController < ApplicationController # @organization.domain = params[:organization][:domain] @organization.is_public = params[:organization][:is_public] == 'on' ? 1 : 0 @organization.allow_guest_download = params[:organization][:allow_guest_download] == 'on' ? 1 : 0 + @organization.allow_teacher = params[:organization][:allow_teacher] == 'on' ? 1 : 0 @organization.show_mode = params[:show_mode] #@organization.name = params[:organization][:name] @organization.save @@ -425,6 +471,18 @@ class OrganizationsController < ApplicationController end end + # 璁剧疆涓哄悕甯 + def set_excellent_teacher + @ex_teacher = User.find(params[:user]) + @ex_teacher.update_column(:excellent_teacher, 1) + end + + # 鍙栨秷鍚嶅笀 + def reset_excellent_teacher + @ex_teacher = User.find(params[:user]) + @ex_teacher.update_column(:excellent_teacher, 0) + end + def hide_org_subfield @org_subfield = OrgSubfield.find(params[:org_subfield_id]) @org_subfield.update_attribute(:hide, 1) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index b73ecf9b9..4a148bb8b 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -32,9 +32,9 @@ class RepositoriesController < ApplicationController before_filter :find_project_by_project_id, :only => [:new, :create, :newrepo, :stats] before_filter :find_repository, :only => [:edit, :update, :destroy, :committers] - before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked] + before_filter :find_project_repository, :except => [:new, :create, :newcreate, :edit, :update, :destroy, :committers, :newrepo, :to_gitlab, :forked, :project_archive] before_filter :find_changeset, :only => [:revision, :add_related_issue, :remove_related_issue] - before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff] + before_filter :authorize , :except => [:newrepo,:newcreate,:fork, :to_gitlab, :forked, :commit_diff, :project_archive] accept_rss_auth :revisions # hidden repositories filter // 闅愯棌浠g爜杩囨护鍣 before_filter :check_hidden_repo, :only => [:show, :stats, :revisions, :revision, :diff ] @@ -95,6 +95,13 @@ class RepositoriesController < ApplicationController end + # 涓閿甖IP涓嬭浇 + def project_archive + g = Gitlab.client + g.get() + # g.project_archive(params[:gpid].to_i, params[:rev]) + end + # 鍒ゆ柇鐢ㄦ埛鏄惁宸茬粡fork杩囪椤圭洰 def has_forked?(project, user) projects = Project.where("user_id =?", user) diff --git a/app/controllers/shield_wechat_messages_controller.rb b/app/controllers/shield_wechat_messages_controller.rb new file mode 100644 index 000000000..f2e9e4ff2 --- /dev/null +++ b/app/controllers/shield_wechat_messages_controller.rb @@ -0,0 +1,36 @@ +class ShieldWechatMessagesController < ApplicationController + def create + if params[:user_id] + @user = User.find params[:user_id] + if params[:project_id] + ShieldWechatMessage.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i) + #@cp = 1 + #@projects = @user.projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5) + elsif params[:course_id] + ShieldWechatMessage.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Course', :shield_id => params[:course_id].to_i) + #@cp = 0 + #@courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) + end + end + end + + def show_messages + if params[:user_id] + @user = User.find params[:user_id] + if params[:project_id] + ShieldWechatMessage.where("container_type='User' and container_id=#{params[:user_id].to_i} and shield_type='Project' and shield_id=#{params[:project_id]}").each do |act| + act.destroy + end + #@cp = 1 + #@projects = @user.projects.visible.select("projects.*, (SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5) + # ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i) + elsif params[:course_id] + ShieldWechatMessage.where("container_type='User' and container_id=#{params[:user_id].to_i} and shield_type='Course' and shield_id=#{params[:course_id]}").each do |act| + act.destroy + end + #@cp = 0 + #@courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) + end + end + end +end diff --git a/app/controllers/ssos_controller.rb b/app/controllers/ssos_controller.rb new file mode 100644 index 000000000..1e1bd932b --- /dev/null +++ b/app/controllers/ssos_controller.rb @@ -0,0 +1,71 @@ +#coding=utf-8 + +require 'base64' +require 'json' +require 'openssl' + +## 鍗曠偣鐧诲綍 <=> 鍖楁枟 +class SsosController < ApplicationController + + skip_before_filter :check_if_login_required + layout false + + def show + begin + # suRh2nFEJd0Ai_TFbqZ-1yQXnGfIB-YD_f4KTA3O4dQGSBMiXfOMt-0mzizgXekWTjHKfn62nJ60iHM3_eY_KS0Qn8SF8vANfa46GhzZRt4T0iC5ZOSs4cWeK43OU0RoekQLZZAo5OyOVibxabmiPGzEFCnVVtdmRk9d7X_B0Is= + @auth = params[:auth] + @options = parse(params[:auth]) + + if params[:login].present? + @options["name"] = params[:login] + end + + logger.debug @options + ## 璁よ瘉 + sso = login(@options) + + ## 鍔犲叆缁勭粐 + @organization = Organization.find(82) + unless @organization.org_members.exists?(user_id: sso.user_id) + member = OrgMember.new(:user_id => sso.user_id) + @organization.org_members << member + end + + ## 閫夋嫨鎬ц烦杞 + redirect_to @organization + rescue => e + logger.error e + if e.message == "exist user" + render 'ssos/show', :layout => false + else + raise e + end + end + end + + ## 鏀圭敤鎴峰悕 + def create + show and return + end + + private + def base64_safe(content) + content = content.gsub('-', '+') + content.gsub('_', '/') + end + + def parse(auth) + crypted_str = Base64.decode64(base64_safe(auth)) + pkey = OpenSSL::PKey::RSA.new(File.new(File.join(Rails.root,"config/private.key"))) + content = pkey.private_decrypt(crypted_str,OpenSSL::PKey::RSA::PKCS1_PADDING) + # content = pkey.private_decrypt(crypted_str) + ActiveSupport::JSON.decode(content) + end + + def login(opt) + sso = Sso.sync_user(opt) + start_user_session(sso.user) + sso + end + +end diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index 19fe8de9e..b71c5a6e3 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -519,8 +519,8 @@ class StudentWorkController < ApplicationController return end @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name).count - end + end @score = @b_sort == "desc" ? "asc" : "desc" @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0 # 娑堟伅浼犺繃鏉ョ殑ID @@ -618,7 +618,7 @@ class StudentWorkController < ApplicationController stu_project.save end end - @homework.update_attributes(:updated_at => Time.now) + @homework.update_column(:updated_at, Time.now) update_course_activity(@homework.class,@homework.id) update_user_activity(@homework.class,@homework.id) update_org_activity(@homework.class,@homework.id) @@ -780,49 +780,64 @@ class StudentWorkController < ApplicationController #鑰佸笀銆佹暀杈呭彲浠ラ殢鏃惰瘎鍒嗭紝瀛︾敓鍙兘鍦ㄥ尶璇勪綔涓氱殑鍖胯瘎闃舵杩涜璇勫垎 render_403 and return unless @is_teacher || @homework.homework_detail_manual.comment_status == 2 @score = student_work_score @work,User.current + #@score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" + #@score.score = params[:score] if params[:score] + #if User.current.admin? + # @score.reviewer_role = 1 + #else + # role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name + # @score.reviewer_role = get_role_by_name(role) + #end + #@is_new = false + @is_last_a = @work.student_works_scores.empty? + @new_score = StudentWorksScore.new + if @score && params[:score] + @new_score.score = params[:score].to_i == -1 ? @score.score : params[:score] + elsif @score.nil? && params[:score] + @new_score.score = params[:score].to_i == -1 ? nil : params[:score] + end + @new_score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" + @new_score.user_id = User.current.id + @new_score.student_work_id = @work.id + if User.current.admin? + @new_score.reviewer_role = 1 + else + role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name + @new_score.reviewer_role = get_role_by_name(role) + end if @score - @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" - @score.score = params[:score] if params[:score] - if User.current.admin? - @score.reviewer_role = 1 + if @is_teacher + @is_new = true + @is_last_a = false else - role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name - @score.reviewer_role = get_role_by_name(role) + @is_new = false end - @is_new = false else - @is_last_a = @work.student_works_scores.empty? - @score = StudentWorksScore.new - @score.score = params[:score] if params[:score] - @score.comment = params[:new_form][:user_message] if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" - @score.user_id = User.current.id - @score.student_work_id = @work.id - if User.current.admin? - @score.reviewer_role = 1 - else - role = User.current.members.where("course_id = ?",@course.id).first.roles.first.name - @score.reviewer_role = get_role_by_name(role) - end @is_new = true end - @score.save_attachments(params[:attachments]) - render_attachment_warning_if_needed(@score) + @new_score.save_attachments(params[:attachments]) + render_attachment_warning_if_needed(@new_score) - if @score.save - case @score.reviewer_role + if @new_score.save + case @new_score.reviewer_role when 1 #鏁欏笀璇勫垎锛氭渶鍚庝竴涓暀甯堣瘎鍒嗕负鏈缁堣瘎鍒 - @work.teacher_score = @score.score + @work.teacher_score = @new_score.score when 2 #鏁欒緟璇勫垎 鏁欒緟璇勫垎鏄剧ず骞冲潎鍒 - @work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f + #@work.teaching_asistant_score = @work.student_works_scores.where(:reviewer_role => 2).average(:score).try(:round, 2).to_f + ts_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 2 AND score IS NOT NULL ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") + @work.teaching_asistant_score = ts_score.first.score.nil? ? nil : ts_score.first.score.try(:round, 2).to_f when 3 #瀛︾敓璇勫垎 瀛︾敓璇勫垎鏄剧ず骞冲潎鍒 - @work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f + #@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f + stu_score = StudentWorksScore.find_by_sql("SELECT AVG(score) AS score FROM (SELECT * FROM (SELECT * FROM student_works_scores WHERE student_work_id = #{@work.id} AND reviewer_role = 3 ORDER BY created_at DESC) AS t GROUP BY user_id) AS a") + @work.student_score = stu_score.first.score.try(:round, 2).to_f end @homework.update_attributes(:updated_at => Time.now) update_course_activity(@homework.class,@homework.id) update_user_activity(@homework.class,@homework.id) update_org_activity(@homework.class,@homework.id) if @work.save + @work = @homework.student_works.select("student_works.*,student_works.work_score as score").where(:id => @work.id).first respond_to do |format| format.js end @@ -855,6 +870,14 @@ class StudentWorkController < ApplicationController end end + #鎻愪氦鏈瘎鍒嗙殑璇勮 + def add_comments_to_work + @work = StudentWork.find params[:id] + respond_to do |format| + format.js + end + end + #涓轰綔鍝佺偣璧 def praise_student_work pt = PraiseTread.new @@ -959,7 +982,7 @@ class StudentWorkController < ApplicationController if homework_detail_manual.ta_proportion.to_s != params[:ta_proportion].to_s || @homework.teacher_priority.to_s != teacher_priority.to_s || (homework_detail_programing && homework_detail_programing.ta_proportion.to_s != params[:sy_proportion].to_s) homework_detail_manual.ta_proportion = params[:ta_proportion] homework_detail_programing.ta_proportion = params[:sy_proportion] if homework_detail_programing - @homework.teacher_priority = teacher_priority + @homework.update_column('teacher_priority', teacher_priority) homework_detail_manual.save if homework_detail_manual homework_detail_programing.save if homework_detail_programing @@ -1010,6 +1033,10 @@ class StudentWorkController < ApplicationController end attachment = @work.attachments.where("attachtype = 7").first attachment.update_attributes(:description => params[:description]) + if attachment.attachtype == 7 + student_work = StudentWork.find attachment.container_id + CourseMessage.create(:user_id => student_work.homework_common.user_id, :course_id => student_work.homework_common.course_id, :viewed => false,:course_message_id=>attachment.container_id,:course_message_type=>'StudentWork',:status=>2) + end respond_to do |format| format.js end @@ -1167,7 +1194,7 @@ class StudentWorkController < ApplicationController blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 sheet1.row(0).default_format = blue if @homework.homework_type == 1 #鍖胯瘎浣滀笟 - sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name), + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), l(:excel_t_score),l(:excel_ta_score), l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)]) count_row = 1 items.each do |homework| @@ -1177,15 +1204,16 @@ class StudentWorkController < ApplicationController sheet1[count_row,3] = homework.user.user_extensions.student_id sheet1[count_row,4] = homework.user.mail sheet1[count_row,5] = homework.name - sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score) - sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score) - sheet1[count_row,8] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score) - sheet1[count_row,9] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score) - sheet1[count_row,10] = format_time(homework.created_at) + sheet1[count_row,6] = strip_html homework.description + sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2) + sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) + sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) + sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,11] = format_time(homework.created_at) count_row += 1 end elsif @homework.homework_type == 2 #缂栫▼浣滀笟 - sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name), + sheet1.row(0).concat([l(:excel_user_id),l(:excel_user_name),l(:excel_nickname),l(:excel_student_id),l(:excel_mail),l(:excel_homework_name),l(:excel_homework_des), l(:excel_t_score),l(:excel_ta_score), l(:excel_s_score),l(:excel_n_score),l(:excel_f_score),l(:excel_commit_time)]) count_row = 1 items.each do |homework| @@ -1195,12 +1223,13 @@ class StudentWorkController < ApplicationController sheet1[count_row,3] = homework.user.user_extensions.student_id sheet1[count_row,4] = homework.user.mail sheet1[count_row,5] = homework.name - sheet1[count_row,6] = homework.teacher_score.nil? ? l(:label_without_score) : format("%.2f",homework.teacher_score) - sheet1[count_row,7] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : format("%.2f",homework.teaching_asistant_score) - sheet1[count_row,8] = homework.system_score.nil? ? l(:label_without_score) : format("%.2f",homework.system_score) - sheet1[count_row,9] = homework.student_score.nil? ? l(:label_without_score) : format("%.2f",homework.student_score) - sheet1[count_row,10] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : format("%.2f",homework.score) : l(:label_without_score) - sheet1[count_row,11] = format_time(homework.created_at) + sheet1[count_row,6] = homework.description + sheet1[count_row,7] = homework.teacher_score.nil? ? l(:label_without_score) : homework.teacher_score.round(2) + sheet1[count_row,8] = homework.teaching_asistant_score.nil? ? l(:label_without_score) : homework.teaching_asistant_score.round(2) + sheet1[count_row,9] = homework.system_score.nil? ? l(:label_without_score) : homework.system_score.round(2) + sheet1[count_row,10] = homework.student_score.nil? ? l(:label_without_score) : homework.student_score.round(2) + sheet1[count_row,11] = homework.respond_to?("score") ? homework.score.nil? ? l(:label_without_score) : homework.score.round(2) : l(:label_without_score) + sheet1[count_row,12] = format_time(homework.created_at) count_row += 1 end end @@ -1342,8 +1371,12 @@ class StudentWorkController < ApplicationController final_score = final_ta_score + final_s_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end else #涓嶈冭檻鏁欏笀璇勫垎 if student_work.teaching_asistant_score.nil? @@ -1357,8 +1390,12 @@ class StudentWorkController < ApplicationController final_score = final_ta_score + final_s_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end elsif homework.homework_type == 2 && homework.homework_detail_programing #缂栫▼浣滀笟-----璁惧畾锛氱郴缁熻瘎鍒嗗繀瀹氫笉涓虹┖ if homework.teacher_priority == 1 #鏁欏笀浼樺厛 @@ -1393,8 +1430,12 @@ class StudentWorkController < ApplicationController final_score = final_sy_score + final_ts_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end else #涓嶈冭檻鏁欏笀璇勫垎 if student_work.teaching_asistant_score.nil? #鏁欒緟鏈瘎鍒 @@ -1424,8 +1465,12 @@ class StudentWorkController < ApplicationController final_score = final_sy_score + final_ts_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end end end diff --git a/app/controllers/sub_document_comments_controller.rb b/app/controllers/sub_document_comments_controller.rb new file mode 100644 index 000000000..767e1ba29 --- /dev/null +++ b/app/controllers/sub_document_comments_controller.rb @@ -0,0 +1,208 @@ +class SubDocumentCommentsController < ApplicationController + before_filter :find_subdomain_and_subfield, :only => [:new, :create, :show, :index, :destroy, :edit] + before_filter :find_subfield_content, :only => [:show, :index] + helper :attachments,:organizations + layout 'base_sub_domain' + + def new + @sub_document_comment = SubDocumentComment.new + end + + + def create + @sub_document_comment = SubDocumentComment.new(:sub_domain_id => params[:sub_domain_id], :creator_id => User.current.id, :org_subfield_id => params[:org_subfield_id]) + @sub_document_comment.title = params[:sub_document_comment][:title] + @sub_document_comment.content = params[:sub_document_comment][:content] + # @sub_document_comment.save_attachments(params[:attachments]) + if params[:field_id] + @sub_document_comment.org_subfield_id = params[:field_id].to_i + end + if @sub_document_comment.save + flash.keep[:notice] = l(:notice_successful_create) + redirect_to org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id) + # EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @sub_document_comment.id, :created_at => @sub_document_comment.updated_at) + # if params[:field_id] + # @org_subfield = OrgSubfield.find(params[:field_id]) + # if @org_subfield.subfield_subdomain_dir.nil? + # redirect_to organization_path(@organization, :org_subfield_id => params[:field_id]) + # else + # redirect_to show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => @org_subfield.subfield_subdomain_dir.name) + # end + # else + # redirect_to organization_org_document_comments_path(@organization) + # end + else + redirect_to new_org_document_comment_path(:organization_id => @organization.id) + end + end + + def show + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @document = SubDocumentComment.find(params[:id]) + respond_to do |format| + format.html {render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'} + end + else + render_403 + end + end + + def index + if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization) + @documents = @subdomain.sub_document_comments.where("parent_id is null").order("created_at desc") + @is_remote = true + @limit = 20 + @atta_count = @documents.count + @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 + @offset ||= @atta_pages.offset + @documents = paginateHelper @documents,20 + respond_to do |format| + format.html {render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org'} + end + else + render_403 + end + end + + def update + @sub_document = SubDocumentComment.find(params[:id]) + @sub_document.update_attributes(:title => params[:sub_document_comment][:title], :content => params[:sub_document_comment][:content]) + @organization = OrgSubfield.find(params[:org_subfield_id]).organization + # Attachment.attach_files(@org_document, params[:attachments]) + # @org_document.save_attachments(params[:attachments]) + if @sub_document.parent.nil? + act = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", @sub_document.id).first + act.update_attributes(:updated_at => @sub_document.updated_at) + # EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now) + end + respond_to do |format| + format.html { + if params[:flag].to_i == 0 + + # render :action => 'index', :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' + redirect_to org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => params[:org_subfield_id], :sub_domain_id => params[:sub_domain_id]) + # render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' + # redirect_to organization_path(@organization) + else + redirect_to org_subfield_sub_domain_sub_document_comment_path(:org_subfield_id => params[:org_subfield_id], :sub_domain_id => params[:sub_domain_id]) + end + } + end + end + + def edit + @sub_document = SubDocumentComment.find(params[:id]) + @flag = params[:flag] + render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' + end + + def add_reply + @document = SubDocumentComment.find(params[:id]).root + @subdomain = @document.sub_domain + @org_subfield = @subdomain.org_subfield + @organization = @org_subfield.organization + @act = OrgActivity.find(params[:id]) + @comment = SubDocumentComment.new(:sub_domain_id => @document.sub_domain, :creator_id => User.current.id, :reply_id => params[:id]) + @comment.content = params[:sub_content] + @document.children << @comment + @document.save + end + + def add_reply_in_doc + @document = SubDocumentComment.find(params[:id]).root + @subdomain = @document.sub_domain + @org_subfield = @subdomain.org_subfield + @organization = @org_subfield.organization + @comment = SubDocumentComment.new(:sub_domain_id => @document.sub_domain_id, :creator_id => User.current.id, :reply_id => params[:id]) + @comment.content = params[:flag] ? params[:sub_content] : params[:org_comment][:sub_content] + @document.children << @comment + @document.save + respond_to do |format| + format.html {redirect_to org_subfield_sub_domain_sub_document_comment_path(:id => @document.id, :org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id)} + end + end + + def destroy + @sub_document_comment = SubDocumentComment.find(params[:id]) + @sub_document_comment.destroy + rescue ActiveRecord::RecordNotFound + respond_to do |format| + # format.html{ + # redirect_to org_subfield_sub_domain_sub_document_comments_path(:id => params[:sub_domain_id], :org_subfield_id => params[:org_subfield_id]) + # } + format.js + end + end + + def delete_reply + @sub_document_comment = OrgDocumentComment.find(params[:id]) + @document = @sub_document_comment.root + org = @sub_document_comment.organization + @sub_document_comment.destroy + respond_to do |format| + format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)} + end + end + def quote + @org_comment = OrgDocumentComment.find(params[:id]) + @subject = @org_comment.content + @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') + + @content = "> #{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}\n> " + @temp = OrgDocumentComment.new + #@course_id = params[:course_id] + @temp.content = "
#{ll(Setting.default_language, :text_user_wrote, User.find(@org_comment.creator_id).realname)}
#{@org_comment.content.html_safe}
".html_safe + respond_to do | format| + format.js + end + end + + def reply + @document = OrgDocumentComment.find(params[:id]).root + @quote = params[:quote][:quote] + @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id]) + + # params[:blog_comment][:sticky] = params[:blog_comment][:sticky] || 0 + # params[:blog_comment][:locked] = params[:blog_comment][:locked] || 0 + @org_document.title = params[:org_document_comment][:title] + @org_document.content = params[:org_document_comment][:content] + @org_document.content = @quote + @org_document.content + #@org_document.title = "RE: #{@article.title}" unless params[:blog_comment][:title] + @document.children << @org_document + # @user_activity_id = params[:user_activity_id] + # user_activity = UserActivity.where("act_type='BlogComment' and act_id =#{@article.id}").first + # if user_activity + # user_activity.updated_at = Time.now + # user_activity.save + # end + # attachments = Attachment.attach_files(@org_document, params[:attachments]) + # render_attachment_warning_if_needed(@org_document) + #@article.save + # redirect_to user_blogs_path(:user_id=>params[:user_id]) + respond_to do |format| + format.html { + # if params[:course_id] #濡傛灉鍛嗕簡course_id杩囨潵浜嗭紝閭d箞杩欐槸瑕佽烦鍒拌绋嬪ぇ绾插幓鐨 + # redirect_to syllabus_course_path(:id=>params[:course_id]) + # else + redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id) + # end + + } + format.js + end + end + + private + def find_subdomain_and_subfield + @subdomain = SubDomain.find(params[:sub_domain_id]) + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @organization = @org_subfield.organization + rescue ActiveRecord::RecordNotFound + # source_subdomain_subfield not found + render_404 + end + + def find_subfield_content + @subfield_content = @organization.org_subfields.order("priority") + end +end diff --git a/app/controllers/sub_domains_controller.rb b/app/controllers/sub_domains_controller.rb new file mode 100644 index 000000000..e32935789 --- /dev/null +++ b/app/controllers/sub_domains_controller.rb @@ -0,0 +1,63 @@ +class SubDomainsController < ApplicationController + layout 'base_org' + before_filter :find_org_subfield_and_subdomain, :only => [:show, :index, :domain_update_priority, :destroy, :update, :hide_sub_domain, :show_sub_domain] + + def new + @subdomain = SubDomain.new + @org_subfield = OrgSubfield.find(params[:org_subfield_id]) + @organization = @org_subfield.organization + end + + def create + if SubDomain.where("org_subfield_id=#{params[:org_subfield_id]} and name=?",params[:name]).count == 0 + @res = true + @subfield = OrgSubfield.find(params[:org_subfield_id]) + @organization = @subfield.organization + @subdomain = SubDomain.create(:name => params[:name], :org_subfield_id => params[:org_subfield_id], :priority => @subfield.sub_domains.blank? ? 1 : @subfield.sub_domains.order("priority").last.priority + 1) + @subdomain.update_column(:field_type, params[:field_type]) + else + @res = false + end + end + + def update + @subdomain.update_column(:name, params[:name]) + end + + def domain_update_priority + @subdomain.update_attribute(:priority, params[:priority].to_i) + end + + def destroy + @subdomain.destroy + end + + def show + render_404 + # @subfield_content = @organization.org_subfields.order("priority") + # render layout: @organization.switch_type ? 'base_sub_domain' : 'base_org' + end + + def index + + end + + def hide_sub_domain + @subdomain.update_attribute(:hide, 1) + end + + def show_sub_domain + @subdomain.update_attribute(:hide, 0) + end + + + private + def find_org_subfield_and_subdomain + @subfield = OrgSubfield.find(params[:org_subfield_id]) + @subdomain = SubDomain.find(params[:id]) + @organization = @subfield.organization + rescue ActiveRecord::RecordNotFound + # source_subdomain not found + render_404 + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ce54496a0..a81ade3fa 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -85,6 +85,29 @@ class UsersController < ApplicationController helper :issues include UsersHelper + #灞曞紑鎵鏈夊洖澶 + def show_all_replies + @comment = JournalsForMessage.find params[:comment].to_i + end + + #浜岀骇鍥炲 + def reply_to + case params[:type] + when 'HomeworkCommon' + @reply = JournalsForMessage.find params[:reply_id] + if params[:user_activity_id] + @user_activity_id = params[:user_activity_id] + else + @user_activity_id = -1 + end + @is_in_course = params[:is_in_course] + @course_activity = params[:course_activity].to_i + end + respond_to do |format| + format.js + end + end + def refresh_changests if !(@user.nil?) && !(@user.memberships.nil?) @user.memberships.each do |member| @@ -288,6 +311,30 @@ class UsersController < ApplicationController end end + #澶勭悊寮曠敤浣滀笟鐨勮姹 + #status 1 鍚屾剰 2 鎷掔粷 + def dealwith_apply_homework + @msg = CourseMessage.find(params[:msg_id]) + ah = ApplyHomework.where("user_id = ? and homework_common_id = ?",@msg.apply_user_id, @msg.course_message_id) + case params[:agree] + when 'Y' + unless ah.empty? + ah.first.update_column('status', 2) + CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>1) + @msg.update_attributes(:apply_result=>1,:viewed=>1) + end + when 'N' + unless ah.empty? + ah.first.update_column('status', 3) + CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>2) + @msg.update_attributes(:apply_result=>2,:viewed=>1) + end + end + respond_to do |format| + format.js + end + end + # added by bai def show_score @@ -372,13 +419,51 @@ class UsersController < ApplicationController end # end + #寮曠敤浣滀笟璇锋眰寮规 + def apply_homework + if User.current.logged? + @homework = HomeworkCommon.find params[:homework_id] + @state = 2 + else + @state = 1 + end + respond_to do |format| + format.js + end + end + + #鐢宠寮曠敤闈炲叕寮浣滀笟 + def apply_for_homework + if User.current.logged? + homework = HomeworkCommon.find params[:homework_id] + unless homework.nil? + ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework_id].to_i) + if ah.empty? + ApplyHomework.create(:user_id => params[:id].to_i, :homework_common_id => params[:homework_id].to_i, :status => 1) + Mailer.run.apply_for_homework_request(homework, User.current) + CourseMessage.create(:user_id => homework.user_id, :course_id => homework.course.id, :viewed => false,:course_message_id=>params[:homework_id].to_i,:course_message_type=>'HomeworkCommon',:status=>5,:apply_user_id=>params[:id].to_i,:content=>params[:content]) + @state = 2 + @ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", params[:id].to_i, params[:homework_id].to_i).first + @homework = homework + else + @state = 3 + end + end + else + @state = 1 + end + respond_to do |format| + format.js + end + end + #鐢ㄦ埛浣滀笟鍒楄〃 def user_homeworks @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc" @user = User.current @r_sort = @b_sort == "desc" ? "asc" : "desc" - if(params[:type].blank? || params[:type] == "1") #鍏叡棰樺簱 - visible_course = Course.where("is_public = 1 && is_delete = 0") + if(params[:type].blank? || params[:type] == "1") #棰樺簱 + visible_course = Course.where("is_delete = 0") visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") elsif params[:type] == "2" #鎴戠殑棰樺簱 @@ -403,7 +488,7 @@ class UsersController < ApplicationController user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" #鍒ゆ柇褰撳墠鐢ㄦ埛鍦ㄥ綋鍓嶈绋嬬殑韬唤 - visibleCourse = @user.courses.empty? ? [] : @user.courses.visible + visibleCourse = @user.courses.empty? ? [] : @user.courses.where("is_delete = 0").visible homework_ids = [] visibleCourse.each do |course| homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'") @@ -424,6 +509,14 @@ class UsersController < ApplicationController def choose_user_course homework = HomeworkCommon.find params[:send_id].to_i + if homework.user != User.current && homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) + ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:send_id].to_i) + if ah.empty? + @status = 2 + elsif ah.first.status != 2 + @status = ah.first.status + end + end if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" @course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search).select { |course| @user.allowed_to?(:as_teacher,course)} @@ -528,19 +621,40 @@ class UsersController < ApplicationController @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc" @r_sort = @b_sort == "desc" ? "asc" : "desc" @user = User.current - if(params[:type].blank? || params[:type] == "1") #鍏叡棰樺簱 - visible_course = Course.where("is_public = 1 && is_delete = 0") + if(params[:type].blank? || params[:type] == "1") #棰樺簱 + if params[:is_import].to_i == 1 + visible_course = Course.where("is_public = 1 && is_delete = 0") + elsif params[:is_import].to_i == 0 + visible_course = Course.where("is_delete = 0") + end visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") elsif params[:type] == "2" #鎴戠殑棰樺簱 - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") - end - if params[:property] && params[:property] == "1" - @homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}") - elsif params[:property] && params[:property] == "2" - @homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}") - elsif params[:property] && params[:property] == "3" - @homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}") + courses = @user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and course_id not in #{course_ids}").order("#{@order} #{@b_sort}") + elsif params[:type] == "3" #鐢宠棰樺簱 + none_visible_course = Course.where("is_delete = 1") + none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")" + #apply_homeworks = ApplyHomework.where("user_id = ?",@user.id).order('created_at desc') + #homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")" + #@homeworks = HomeworkCommon.where("id in #{homework_ids} and course_id not in #{none_visible_course_ids}") + + sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN apply_homeworks as ah ON homework_commons.id = ah.homework_common_id where ah.user_id = #{@user.id} and homework_commons.course_id not in #{none_visible_course_ids} order by ah.created_at desc" + @homeworks = HomeworkCommon.find_by_sql(sql) + end + if params[:property] + all_homework_ids = @homeworks.empty? ? "(-1)" : "(" + @homeworks.map{|h| h.id}.join(",") + ")" + if params[:property] == "1" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 1") + #@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}") + elsif params[:property] == "2" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 2") + #@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}") + elsif params[:property] == "3" + @homeworks = HomeworkCommon.find_by_sql("select * from homework_commons where id in #{all_homework_ids} and homework_type = 3") + #@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}") + end end @type = params[:type] @property = params[:property] @@ -557,7 +671,21 @@ class UsersController < ApplicationController end def show_homework_detail - @homework = HomeworkCommon.find params[:homework].to_i + homework = HomeworkCommon.find params[:homework].to_i + if homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course) && User.current != homework.user + ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, params[:homework].to_i) + if ah.empty? + @status = 2 + @homework = nil + elsif ah.first.status != 2 + @status = ah.first.status + @homework = nil + elsif ah.first.status == 2 + @homework = homework + end + else + @homework = homework + end @is_import = params[:is_import] respond_to do |format| format.js @@ -571,8 +699,12 @@ class UsersController < ApplicationController @user = User.current search = params[:name].to_s.strip.downcase type_ids = params[:property]=="" || params[:property].nil? ? "(1, 2, 3)" : "(" + params[:property] + ")" - if(params[:type].blank? || params[:type] == "1") #鍏ㄩ儴 - visible_course = Course.where("is_public = 1 && is_delete = 0") + if(params[:type].blank? || params[:type] == "1") #鍏ㄩ儴 + if params[:is_import].to_i == 1 + visible_course = Course.where("is_public = 1 && is_delete = 0") + elsif params[:is_import].to_i == 0 + visible_course = Course.where("is_delete = 0") + end visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'") all_user_ids = all_homeworks.map{|hw| hw.user_id} @@ -586,14 +718,29 @@ class UsersController < ApplicationController else @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}") end - elsif params[:type] == "2" #璇剧▼璧勬簮 + elsif params[:type] == "2" #鎴戠殑棰樺簱 + courses = @user.courses.where("is_delete = 1") + course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" + if @order == "course_name" + sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.course_id not in #{course_ids} and homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" + @homeworks = HomeworkCommon.find_by_sql(sql) + elsif @order == "user_name" + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") + else + @homeworks = HomeworkCommon.where("user_id = #{@user.id} and course_id not in #{course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}") + end + elsif params[:type] == "3" #鐢宠棰樺簱 + apply_homeworks = ApplyHomework.where("user_id = ?",@user.id) + homework_ids = apply_homeworks.empty? ? "(-1)" : "(" + apply_homeworks.map{|ah| ah.homework_common_id}.join(",") + ")" + none_visible_course = Course.where("is_delete = 1") + none_visible_course_ids = none_visible_course.empty? ? "(-1)" : "(" + none_visible_course.map{|course| course.id}.join(",") + ")" if @order == "course_name" - sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" + sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where courses.is_delete = 0 and homework_commons.id in #{homework_ids} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}" @homeworks = HomeworkCommon.find_by_sql(sql) elsif @order == "user_name" - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") + @homeworks = HomeworkCommon.where("homework_commons.id in #{homework_ids} and course_id not in #{none_visible_course_ids} and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}") else - @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}") + @homeworks = HomeworkCommon.where("id in #{homework_ids} and (name like '%#{search}%') and course_id not in #{none_visible_course_ids} and homework_type in #{type_ids}").order("#{@order} #{@b_sort}") end end =begin @@ -750,7 +897,11 @@ class UsersController < ApplicationController render_attachment_warning_if_needed(homework) homework_detail_manual = HomeworkDetailManual.new - homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 + if homework.anonymous_comment == 1 + homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 1.0 : 0.4 + else + homework_detail_manual.ta_proportion = homework.homework_type == 1 ? 0.6 : 0.3 + end if homework.publish_time > Date.today homework_detail_manual.comment_status = 0 else @@ -766,7 +917,11 @@ class UsersController < ApplicationController if homework.homework_type == 2 homework_detail_programing = HomeworkDetailPrograming.new homework.homework_detail_programing = homework_detail_programing - homework_detail_programing.ta_proportion = 0.5 + if homework.anonymous_comment == 1 + homework_detail_programing.ta_proportion = 0.6 + else + homework_detail_programing.ta_proportion = 0.5 + end homework_detail_programing.language = params[:language_type].to_i inputs = params[:program][:input] @@ -1216,7 +1371,7 @@ class UsersController < ApplicationController shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id) @page = params[:page] ? params[:page].to_i + 1 : 0 user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" - user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" + user_course_ids = (@user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")" course_types = "('Message','News','HomeworkCommon','Poll','Course','JournalsForMessage')" project_types = "('Message','Issue','ProjectCreateInfo')" principal_types = "JournalsForMessage" @@ -2463,6 +2618,9 @@ class UsersController < ApplicationController # 鑾峰彇鎴戠殑璧勬簮 def get_my_resources author_id, user_course_ids, user_project_ids, order, score + unless author_id.to_i.to_s == author_id + author_id = User.find_by_login(author_id).id + end attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('OrgSubfield','Principal','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2470,6 +2628,7 @@ class UsersController < ApplicationController # 鑾峰彇鎴戠殑璧勬簮鏌ヨ缁撴灉 def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search) + author_id = User.find_by_login(author_id).id @attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2477,6 +2636,7 @@ class UsersController < ApplicationController # 鑾峰彇鎴戠殑璇剧▼璧勬簮 def get_course_resources author_id, user_course_ids, order, score + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2484,6 +2644,7 @@ class UsersController < ApplicationController # 鑾峰彇鎴戠殑璇剧▼璧勬簮涓悳绱㈢粨鏋 def get_course_resources_search author_id, user_course_ids, order, score, search + author_id = User.find_by_login(author_id).id attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2501,6 +2662,7 @@ class UsersController < ApplicationController # 鑾峰彇鎴戠殑椤圭洰璧勬簮 def get_project_resources author_id, user_project_ids, order, score + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2508,6 +2670,7 @@ class UsersController < ApplicationController # 鑾峰彇鎴戠殑椤圭洰璧勬簮鎼滅储 def get_project_resources_search author_id, user_project_ids, order, score, search + author_id = User.find_by_login(author_id).id attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") @@ -2525,12 +2688,14 @@ class UsersController < ApplicationController # 鑾峰彇鎴戜笂浼犵殑闄勪欢 def get_attch_resources author_id, order, score + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', 'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}") end # 鑾峰彇鎴戜笂浼犵殑闄勪欢鎼滅储缁撴灉 def get_attch_resources_search author_id, order, score, search + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', 'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") end @@ -2549,11 +2714,13 @@ class UsersController < ApplicationController # 鑾峰彇鎴戠殑鐢ㄦ埛绫诲瀷璧勬簮 def get_principal_resources author_id, order, score + author_id = User.find_by_login(author_id).id attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") end # 鑾峰彇鎴戠殑鐢ㄦ埛绫诲瀷璧勬簮鎼滅储 def get_principal_resources_search author_id, order, score, search + author_id = User.find_by_login(author_id).id attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end @@ -2570,7 +2737,7 @@ class UsersController < ApplicationController # 璧勬簮搴 鍒嗕负鍏ㄩ儴 璇剧▼璧勬簮 椤圭洰璧勬簮 闄勪欢 def user_resource # 鍒汉鐨勮祫婧愬簱鏄病鏈夋潈闄愬幓鐪嬬殑 - if User.current.id.to_i != params[:id].to_i + if User.current.id.to_i != @user.id.to_i render_403 return end @@ -2625,13 +2792,13 @@ class UsersController < ApplicationController # 瀵煎叆璧勬簮 def import_resources # 鍒汉鐨勮祫婧愬簱鏄病鏈夋潈闄愬幓鐪嬬殑 - if User.current.id.to_i != params[:id].to_i + @user = User.find_by_login(params[:id]) + if User.current != @user render_403 return end @resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id] @resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project" - @user = User.find(params[:id]) @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" @score = @b_sort == "desc" ? "asc" : "desc" user_course_ids = User.current.courses.map { |c| c.is_delete == 0 && c.id} @@ -2731,6 +2898,10 @@ class UsersController < ApplicationController attach_copied_obj.attachtype = 4 end attach_copied_obj.save + # 闄勪欢淇濆瓨鎴愬姛鍚庢洿鏂伴」鐩拰璇剧▼鐨勭粺璁℃暟 + if params[:mul_type] == "Project" + mul_container.project_score.update_attribute(:attach_num, mul_container.project_score.attach_num + 1) unless mul_container.project_score.nil? + end @save_message = attach_copied_obj.errors.full_messages end end diff --git a/app/controllers/wechats_controller.rb b/app/controllers/wechats_controller.rb new file mode 100644 index 000000000..0d75636f7 --- /dev/null +++ b/app/controllers/wechats_controller.rb @@ -0,0 +1,237 @@ +#coding=utf-8 +class WechatsController < ActionController::Base + wechat_responder + + include ApplicationHelper + + # default text responder when no other match + on :text do |request, content| + request.reply.text "鎮ㄧ殑鎰忚宸叉敹鍒" # Just echo + end + + # When receive 'help', will trigger this responder + on :text, with: 'help' do |request| + request.reply.text 'help content' + end + + # When receive 'news', will match and will got count as as parameter + on :text, with: /^(\d+) news$/ do |request, count| + # Wechat article can only contain max 10 items, large than 10 will dropped. + news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } } + request.reply.news(news) do |article, n, index| # article is return object + article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/' + end + end + + on :event, with: 'subscribe' do |request| + default_msg(request) + end + + # When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account + # notice user will subscribe public account at same time, so wechat won't trigger subscribe event any more + on :scan, with: 'qrscene_xxxxxx' do |request, ticket| + request.reply.text "Unsubscribe user #{request[:FromUserName]} Ticket #{ticket}" + end + + # When subscribe user scan scene_id in public account + on :scan, with: 'scene_id' do |request, ticket| + request.reply.text "Subscribe user #{request[:FromUserName]} Ticket #{ticket}" + end + + # When no any on :scan responder can match subscribe user scaned scene_id + on :event, with: 'scan' do |request| + if request[:EventKey].present? + request.reply.text "event scan got EventKey #{request[:EventKey]} Ticket #{request[:Ticket]}" + end + end + + # When enterprise user press menu BINDING_QR_CODE and success to scan bar code + on :scan, with: 'BINDING_QR_CODE' do |request, scan_result, scan_type| + request.reply.text "User #{request[:FromUserName]} ScanResult #{scan_result} ScanType #{scan_type}" + end + + # Except QR code, wechat can also scan CODE_39 bar code in enterprise account + on :scan, with: 'BINDING_BARCODE' do |message, scan_result| + if scan_result.start_with? 'CODE_39,' + message.reply.text "User: #{message[:FromUserName]} scan barcode, result is #{scan_result.split(',')[1]}" + end + end + + # When user click the menu button + on :click, with: 'BOOK_LUNCH' do |request, key| + request.reply.text "User: #{request[:FromUserName]} click #{key}" + end + + # When user view URL in the menu button + on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view| + request.reply.text "#{request[:FromUserName]} view #{view}" + end + + # When user sent the imsage + on :image do |request| + request.reply.image(request[:MediaId]) # Echo the sent image to user + end + + # When user sent the voice + on :voice do |request| + request.reply.voice(request[:MediaId]) # Echo the sent voice to user + end + + # When user sent the video + on :video do |request| + nickname = wechat.user(request[:FromUserName])['nickname'] # Call wechat api to get sender nickname + request.reply.video(request[:MediaId], title: 'Echo', description: "Got #{nickname} sent video") # Echo the sent video to user + end + + # When user sent location + on :location do |request| + request.reply.text("Latitude: #{message[:Latitude]} Longitude: #{message[:Longitude]} Precision: #{message[:Precision]}") + end + + on :event, with: 'unsubscribe' do |request| + request.reply.success # user can not receive this message + end + + # When user enter the app / agent app + on :event, with: 'enter_agent' do |request| + request.reply.text "#{request[:FromUserName]} enter agent app now" + end + + # When batch job create/update user (incremental) finished. + on :batch_job, with: 'sync_user' do |request, batch_job| + request.reply.text "sync_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}" + end + + # When batch job replace user (full sync) finished. + on :batch_job, with: 'replace_user' do |request, batch_job| + request.reply.text "replace_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}" + end + + # When batch job invent user finished. + on :batch_job, with: 'invite_user' do |request, batch_job| + request.reply.text "invite_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}" + end + + # When batch job replace department (full sync) finished. + on :batch_job, with: 'replace_party' do |request, batch_job| + request.reply.text "replace_party job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}" + end + + # Any not match above will fail to below + on :fallback, respond: 'fallback message' + + on :click, with: 'FEEDBACK' do |request, key| + request.reply.text "濡傛湁鍙嶉闂,璇风洿鎺ュ垏鍏ヨ嚦杈撳叆妗,鍙戝井淇$粰鎴戜滑鍗冲彲" + end + + on :click, with: 'MY_NEWS' do |request, key| + default_msg(request) + end + + def default_msg(request) + uw = user_binded?(request[:FromUserName]) + if uw && uw.user + request.reply.text "娆㈣繋鍥炴潵, #{uw.user.show_name}" + else + request.reply.text "娆㈣繋鍏虫敞Trustie鍒涙柊瀹炶返绀惧尯" + sendBind(request) + end + end + + def sendBind(request) + news = (1..1).each_with_object([]) { |n, memo| memo << { title: '缁戝畾鐧诲綍', content: "鎮ㄨ繕鏈粦瀹氱‘瀹炵殑鐢ㄦ埛,璇峰厛缁戝畾." } } + request.reply.news(news) do |article, n, index| # article is return object + url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect" + article.item title: "#{n[:title]}", + description: n[:content], + pic_url: 'https://www.trustie.net/images/trustie_logo2.png', + url: url + end + end + + + def get_open_id + begin + raise "闈炴硶鎿嶄綔, code涓嶅瓨鍦" unless params[:code] + openid = get_openid_from_code(params[:code]) + raise "鏃犳硶鑾峰彇鍒皁penid" unless openid + render :json => {status:0, openid: openid} + rescue Exception=>e + render :json => {status: -1, msg: e.message} + end + end + + def bind + begin + raise "闈炴硶鎿嶄綔, code涓嶅瓨鍦" unless params[:code] + openid = get_openid_from_code(params[:code]) + raise "鏃犳硶鑾峰彇鍒皁penid" unless openid + raise "姝ゅ井淇″彿宸茬粦瀹氱敤鎴, 涓嶈兘寰楀缁戝畾" if user_binded?(openid) + + user, last_login_on = User.try_to_login(params[:username], params[:password]) + raise "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒,璇烽噸鏂扮櫥褰" unless user + #琛ュ叏鐢ㄦ埛淇℃伅 + + raise "姝ょ敤鎴峰凡缁忕粦瀹氫簡鍏紬鍙" if user.user_wechat + + UserWechat.create!( + openid: openid, + user: user + ) + request.reply.text "娆㈣繋鍔犲叆Trustie鍒涙柊瀹炶返绀惧尯" + render :json => {status:0, msg: "缁戝畾鎴愬姛"} + rescue Exception=>e + render :json => {status: -1, msg: e.message} + end + end + + def login + @code = params[:code] #TODO 瀹夊叏鎬 + render 'wechats/login', layout: 'base_wechat' + end + + private + def get_openid_from_code(code) + url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code" + logger.debug url + body = URI.parse(url).read + logger.debug body + JSON.parse(body)["openid"] + end + + def user_binded?(openid) + uw = UserWechat.where(openid: openid).first + end + + def user_activity(user) + @user = user + shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id) + shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id) + @page = params[:page] ? params[:page].to_i + 1 : 0 + user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" + user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" + course_types = "('Message','News','HomeworkCommon','Poll','Course')" + project_types = "('Message','Issue','ProjectCreateInfo')" + principal_types = "JournalsForMessage" + + blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + + "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + + "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10) + + + end + + def process_activity(user_activity) + act= user_activity.act + case user_activity.container_type.to_s + when 'Course' + when 'Project' + case user_activity.act_type.to_s + when 'Issue' + [act.project.name.to_s+" | 椤圭洰闂", act.subject.to_s, url_to_avatar(act.author),"http://wechat.trustie.net/app.html#/issue/#{act.id}"] + end + end + end +end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index e6d1d9117..fa084e349 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -276,7 +276,7 @@ class WordsController < ApplicationController ids = params[:asset_id].split(',') update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE end - @homework_common.update_attributes(:updated_at => Time.now) + @homework_common.update_column('updated_at', Time.now) update_course_activity(@homework_common.class,@homework_common.id) update_user_activity(@homework_common.class,@homework_common.id) update_org_activity(@homework_common.class,@homework_common.id) @@ -296,6 +296,40 @@ class WordsController < ApplicationController render_403 end end + + #浣滀笟鐨勪簩绾у洖澶 + def reply_to_homework + if User.current.logged? + @user = User.current + reply = JournalsForMessage.find params[:id].to_i + @homework_common = HomeworkCommon.find reply.jour_id + if params[:reply_message].size>0 && User.current.logged? && @user + options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i} + feedback = HomeworkCommon.add_homework_jour(@user, params[:reply_message], reply.jour_id, options) + if (feedback.errors.empty?) + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE + end + @homework_common.update_column('updated_at', Time.now) + update_course_activity(@homework_common.class,@homework_common.id) + update_user_activity(@homework_common.class,@homework_common.id) + update_org_activity(@homework_common.class,@homework_common.id) + respond_to do |format| + format.js{ + @user_activity_id = params[:user_activity_id].to_i + @is_in_course = params[:is_in_course].to_i + @course_activity = params[:course_activity].to_i + } + end + else + flash[:error] = feedback.errors.full_messages[0] + end + end + else + render_403 + end + end def add_brief_introdution user = User.current diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb index 8324951f9..49640d889 100644 --- a/app/helpers/api_helper.rb +++ b/app/helpers/api_helper.rb @@ -27,6 +27,10 @@ module ApiHelper location end + def get_user_realname user + name = user.lastname + user.firstname + name.empty? || name.nil? || name == " " ? user.login : name + end def get_assigned_homeworks(homeworks, n, index) homeworks += homeworks @@ -201,5 +205,288 @@ module ApiHelper end + #鏃ユ湡杞崲涓烘椂闂 + def convert_to_time date, num + if num == 0 + date = date.to_s + " 00:00" + elsif num == 1 + date = date.to_s + " 23:59" + end + return date + end + + #鑾峰彇鐢ㄦ埛 + def get_user user_id + user = User.find user_id + user + end + + #鑾峰彇椤圭洰 + def get_project project_id + project = Project.find project_id + project + end + + #鑾峰彇璇剧▼ + def get_course course_id + course = Course.find course_id + course + end + + #鑾峰彇鐐硅禐鏁 + def get_activity_praise_num(object) + obj_type = object.class + obj_id = object.id + record = PraiseTreadCache.find_by_object_id_and_object_type(obj_id,obj_type) + if record + return ((record.praise_num.nil? ? 0 : record.praise_num.to_i)-(record.tread_num.nil? ? 0 : record.tread_num.to_i)) + else + return 0 + end + end + + #鑾峰彇缂洪櫡鐨勪紭鍏堢骇 + def get_issue_priority_api value + issuetype = "" + if value == 4 + issuetype = "绱ф" + elsif value == 2 + issuetype = "姝e父" + elsif value == 3 + issuetype = "楂" + elsif value == 1 + issuetype = "浣" + else + issuetype = "绔嬪埢" + end + end + + def jdetails_to_strings(details, no_html=false, options={}) + options[:only_path] = (options[:only_path] == false ? false : true) + options[:token] = options[:token] if options[:token] + strings = [] + values_by_field = {} + details.each do |detail| + + if detail.property == 'cf' + field_id = detail.prop_key + field = CustomField.find_by_id(field_id) + if field && field.multiple? + values_by_field[field_id] ||= {:added => [], :deleted => []} + if detail.old_value + values_by_field[field_id][:deleted] << detail.old_value + end + if detail.value + values_by_field[field_id][:added] << detail.value + end + next + end + end + strings << jshow_detail(detail, no_html, options) + + end + values_by_field.each do |field_id, changes| + detail = JournalDetail.new(:property => 'cf', :prop_key => field_id) + if changes[:added].any? + detail.value = changes[:added] + strings << jshow_detail(detail, no_html, options) + elsif changes[:deleted].any? + detail.old_value = changes[:deleted] + strings << jshow_detail(detail, no_html, options) + end + end + strings + end + + # Returns the textual representation of a single journal detail + def jshow_detail(detail, no_html=false, options={}) + multiple = false + case detail.property + when 'attr' + field = detail.prop_key.to_s.gsub(/\_id$/, "") + label = l(("field_" + field).to_sym) + case detail.prop_key + when 'due_date', 'start_date' + value = format_date(detail.value.to_date) if detail.value + old_value = format_date(detail.old_value.to_date) if detail.old_value + + when 'project_id', 'status_id', 'tracker_id', 'assigned_to_id', + 'priority_id', 'category_id', 'fixed_version_id' + value = find_name_by_reflection(field, detail.value) + old_value = find_name_by_reflection(field, detail.old_value) + + when 'estimated_hours' + value = "%0.02f" % detail.value.to_f unless detail.value.blank? + old_value = "%0.02f" % detail.old_value.to_f unless detail.old_value.blank? + + when 'parent_id' + label = l(:field_parent_issue) + value = "##{detail.value}" unless detail.value.blank? + old_value = "##{detail.old_value}" unless detail.old_value.blank? + + when 'is_private' + value = l(detail.value == "0" ? :general_text_No : :general_text_Yes) unless detail.value.blank? + old_value = l(detail.old_value == "0" ? :general_text_No : :general_text_Yes) unless detail.old_value.blank? + end + when 'cf' + custom_field = CustomField.find_by_id(detail.prop_key) + if custom_field + multiple = custom_field.multiple? + label = custom_field.name + value = format_value(detail.value, custom_field.field_format) if detail.value + old_value = format_value(detail.old_value, custom_field.field_format) if detail.old_value + end + when 'attachment' + label = l(:label_attachment) + end + call_hook(:helper_issues_show_detail_after_setting, + {:detail => detail, :label => label, :value => value, :old_value => old_value }) + + label ||= detail.prop_key + value ||= detail.value + old_value ||= detail.old_value + + unless no_html + label = content_tag('strong', label) + old_value = content_tag("i", old_value) if detail.old_value + old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank? + if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key) + # Link to the attachment if it has not been removed + if options[:token].nil? + value = atta.filename + else + value = atta.filename + end + # 鏀惧ぇ闀滄悳绱㈠姛鑳 + # if options[:only_path] != false && atta.is_text? + # value += link_to( + # image_tag('magnifier.png'), + # :controller => 'attachments', :action => 'show', + # :id => atta, :filename => atta.filename + # ) + # end + else + value = content_tag("i", value) if value + end + end + # 缂洪櫡鏇存柊缁撴灉鍦ㄦ秷鎭腑鏄剧ず鏍峰紡 + if no_html == "message" + label = content_tag(:span, label, :class => "issue_update_message") + old_value = content_tag("span", old_value) if detail.old_value + old_value = content_tag("del", old_value) if detail.old_value and detail.value.blank? + if detail.property == 'attachment' && !value.blank? && atta = Attachment.find_by_id(detail.prop_key) + # Link to the attachment if it has not been removed + if options[:token].nil? + value = atta.filename + else + value = atta.filename + end + else + value = content_tag(:span, value, :class => "issue_update_message_value") if value + end + end + + if detail.property == 'attr' && detail.prop_key == 'description' + s = l(:text_journal_changed_no_detail, :label => label) + unless no_html + diff_link = link_to l(:label_diff), + {:controller => 'journals', :action => 'diff', :id => detail.journal_id, + :detail_id => detail.id, :only_path => options[:only_path]}, + :title => l(:label_view_diff) + s << " (#{ diff_link })" + end + s.html_safe + elsif detail.value.present? + case detail.property + when 'attr', 'cf' + if detail.old_value.present? + l(:text_journal_changed, :label => label, :old => old_value, :new => value).html_safe + elsif multiple + l(:text_journal_added, :label => label, :value => value).html_safe + else + l(:text_journal_set_to, :label => label, :value => value).html_safe + end + when 'attachment' + l(:text_journal_added, :label => label, :value => value).html_safe + end + else + l(:text_journal_deleted, :label => label, :old => old_value).html_safe + end + end + + #璇剧▼鍔ㄦ佺殑鏇存柊 + def update_course_activity_api type, id + course_activity = CourseActivity.where("course_act_type=? and course_act_id =?", type.to_s, id.to_i).first + if course_activity + course_activity.updated_at = Time.now + course_activity.save + end + end + #棣栭〉鍔ㄦ佹洿鏂 + def update_user_activity_api type, id + user_activity = UserActivity.where("act_type=? and act_id =?", type.to_s, id.to_i).first + if user_activity + user_activity.updated_at = Time.now + user_activity.save + end + end + #椤圭洰鍔ㄦ佹洿鏂 + def update_forge_activity_api type, id + forge_activity = ForgeActivity.where("forge_act_type=? and forge_act_id=?", type.to_s, id.to_i).first + if forge_activity + forge_activity.updated_at = Time.now + forge_activity.save + end + end + #缁勭粐鍔ㄦ佹洿鏂 + def update_org_activity_api type , id + org_activity = OrgActivity.where("org_act_type=? and org_act_id =?", type.to_s, id.to_i).first + if org_activity + org_activity.updated_at = Time.now + org_activity.save + end + end + #涓汉鍔ㄦ佹洿鏂 + def update_principal_activity_api type, id + principal_activity = PrincipalActivity.where("principal_act_type=? and principal_act_id =?", type.to_s, id.to_i).first + if principal_activity + principal_activity.updated_at = Time.now + principal_activity.save + end + end + + #璧/鍙栨秷璧 + def praise_or_cancel(type,id,user,flag) + unless id.nil? and type.nil? + #棣栧厛鍒涘缓鎴栨洿鏂皃raise_tread 琛 + pt = PraiseTread.new + pt.user_id = user.id + pt.praise_tread_object_id = id.to_i + pt.praise_tread_object_type = type + pt.praise_or_tread = flag + pt.save + # end + + #鍐嶅垱寤烘垨鏇存柊praise_tread_cache琛 + #@ptc = PraiseTreadCache.find_by_object_id_and_object_type(id,type) + ptc = PraiseTreadCache.where("object_id = ? and object_type = ?",id.to_i,type).first + ptc = ptc.nil? ? PraiseTreadCache.new : ptc + ptc.object_id = id.to_i + ptc.object_type = type + ptc.save + ptc.praise_plus(flag,1) + end + end + + def praise_plus(flag,num) + case flag + when 1 + self.update_attribute(:praise_num, self.praise_num.to_i + num) + end + end + + def praise_minus(num) + self.update_attribute(:praise_num, self.praise_num.to_i - num) + end end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index fb8da4dae..229aceb1c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,10 +33,29 @@ module ApplicationHelper extend Forwardable def_delegators :wiki_helper, :wikitoolbar_for, :heads_for_wiki_formatter + + def user_path(resource, parameters = {}) + if Fixnum === resource + resource = User.find(resource) + end + super + end + + # def user_blogs_path(resource,parameters={}) + # super + # end + + def update_visiti_count container container.update_column(:visits, container.visits + 1) end + def if_hidden_subdomain field + domains = field.sub_domains.select{|domain| domain.hide.to_i == 0} + result = domains.length > 0 ? true : false + return result + end + # Time 2015-03-24 15:27:29 # Author lizanle # Description 浠庣‖鐩樹笂鍒犻櫎瀵瑰簲鐨勮祫婧愭枃浠 @@ -2953,6 +2972,14 @@ int main(int argc, char** argv){ return sort_projects end end + + def project_sort_first projects + unless projects.empty? + project_ids = '('+projects.map{|pro|pro.project_id}.join(',')+')' + sort_projects = ForgeActivity.find_by_sql("SELECT updated_at,user_id, project_id FROM forge_activities WHERE project_id IN #{project_ids} ORDER BY updated_at DESC limit 1") + return sort_projects + end + end end def user_url_in_org(user_id) @@ -2983,9 +3010,11 @@ def homework_common_index_url_in_org(course_id) Setting.protocol + "://" + Setting.host_name + "/homework_common?course=" + course_id.to_s end -def student_work_index_url_in_org(homework_id, is_focus = '') +def student_work_index_url_in_org(homework_id, is_focus = '', show_work_id = '') if is_focus != '' Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&is_focus=" + is_focus.to_s + elsif show_work_id != '' + Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s + "&show_work_id=" + show_work_id.to_s else Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s end @@ -3065,6 +3094,16 @@ def host_with_protocol return Setting.protocol + "://" + Setting.host_name end + +#鑾峰彇鍥炲鐨勬墍鏈夌埗鑺傜偣 +def get_reply_parents parents_rely, comment + unless comment.parent.nil? + parents_rely << comment.parent + get_reply_parents parents_rely, comment.parent + end + parents_rely +end + #灏嗘湁缃《灞炴х殑鎻愬埌鏁扮粍鍓嶉潰 def sort_by_sticky topics tmpTopics = [] @@ -3195,3 +3234,17 @@ def sortby_time_countcommon_nosticky topics,sortstr return tmpTopics end +def strip_html(text,len=0,endss="...") + ss = "" + if text.length>0 + ss=text.gsub(/<\/?.*?>/, '').strip + + if len > 0 && ss.length > len + ss = ss[0, len] + endss + elsif len > 0 && ss.length <= len + ss = ss + #ss = truncate(ss, :length => len) + end + end + return ss +end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 1cd22558b..b161e29e9 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -19,7 +19,7 @@ module IssuesHelper include ApplicationHelper - + include TagsHelper def issue_list(issues, &block) ancestors = [] issues.each do |issue| diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index b3b014de1..cba4fa210 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -5,17 +5,17 @@ module OrganizationsHelper 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]) - else - scope = [] - end - principals = paginateHelper scope,10 - s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') - links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| - link_to text, org_member_autocomplete_org_member_index_path( parameters.merge(:q => params[:q],:flag => true,:org=>org, :format => 'js')), :remote => true - } - s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) + if params[:q] && params[:q].lstrip.rstrip != "" + scope = Principal.active.sorted.not_member_of_org(org).like(params[:q]) + else + scope = [] + end + principals = paginateHelper scope,10 + s = content_tag('ul', project_member_check_box_tags_ex('membership[user_ids][]', principals), :class => 'mb5', :id => 'principals') + links = pagination_links_full(@obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true){|text, parameters, options| + link_to text, org_member_autocomplete_org_member_index_path( parameters.merge(:q => params[:q],:flag => true,:org=>org, :format => 'js')), :remote => true + } + s + content_tag('ul', links,:class => 'wlist',:style=>'float:left !important', :id => "org_member_pagination_links" ) end def get_default_name field @@ -63,14 +63,128 @@ module OrganizationsHelper def subfield_status_option type = [] option1 = [] - option1 << "鍒楄〃" + option1 << "宸︿竴" + option1 << "1" + type << option1 + # option2 = [] + # option2 << "涓竴" + # option2 << "2" + # type << option2 + option3 = [] + option3 << "宸︿簩" + option3 << "3" + type << option3 + option4 = [] + option4 << "宸︿笁" + option4 << "4" + type << option4 + option5 = [] + option5 << "宸﹀洓" + option5 << "5" + type << option5 + option6 = [] + option6 << "鍙充竴" + option6 << "6" + type << option6 + option7 = [] + option7 << "鍙充簩" + option7 << "7" + type << option7 + option8 = [] + option8 << "鍙充笁" + option8 << "8" + type << option8 + type + end + + # 璇剧▼鍜岄」鐩笉鍙備笌鏌愪簺妯″潡鐨勬帓鍒 + def subfield_status_option_default + type = [] + option1 = [] + option1 << "宸︿竴" option1 << "1" type << option1 - option2 = [] - option2 << "鍥剧墖" - option2 << "0" - type << option2 + option3 = [] + option3 << "宸︿簩" + option3 << "3" + type << option3 + option4 = [] + option4 << "宸︿笁" + option4 << "4" + type << option4 + option6 = [] + option6 << "鍙充竴" + option6 << "6" + type << option6 type end + def subfield_list_type subfield + case subfield.to_i + when 1 + resulet = "宸︿竴" + when 2 + resulet = "宸︿簩" + when 3 + resulet = "宸︿簩" + when 4 + resulet = "宸︿笁" + when 5 + resulet = "宸﹀洓" + when 6 + resulet = "鍙充竴" + when 7 + resulet = "鍙充簩" + when 8 + resulet = "鍙充笁" + end + end + + + def get_subfield_acts field + org_subfield = OrgSubfield.find(field.id) + org_subfield_ids = org_subfield.org_document_comments.map(&:id) << 0 + org_acts = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{org_subfield.id})").order('updated_at desc') + org_acts + end + + def org_subfield_had_created?(org, type) + sub_field = org.org_subfields.select{|subfield| subfield.field_type == type} + result = sub_field.length > 0 ? true : false + result + end + + def org_subfield_type(field) + case field.field_type + when "Post" + result = "甯栧瓙" + when "Resource" + result = "璧勬簮" + when "Compstu" + result = "瀛︾敓" + when "Comptec" + result = "鏁欏笀" + when "Complex" + result = "缁煎悎" + end + end + + def org_teacher_resource_count user + results = Attachment.find_by_sql("SELECT * FROM attachments where author_id = #{user.id};").count + end + + def org_teacher_course_count user + results = Course.find_by_sql("select * from courses where courses.tea_id = #{user.id}").count + end + + def org_student_course_count user + course_ids = user.courses.map { |c| c.is_delete == 0 && c.id} + results = Member.find_by_sql("select id from courses where courses.tea_id = #{user.id}").count + end + + def excellent_teachers + User.find_by_sql("select u.*, ue.technical_title, ue.school_id,(select count(*) from courses where courses.tea_id = u.id) as course_count + from users u, user_extensions ue where u.id = ue.user_id and ue.identity=0 and u.excellent_teacher =1 order by course_count desc").first(5) + end + end diff --git a/app/helpers/shield_wechat_messages_helper.rb b/app/helpers/shield_wechat_messages_helper.rb new file mode 100644 index 000000000..0c605db1b --- /dev/null +++ b/app/helpers/shield_wechat_messages_helper.rb @@ -0,0 +1,2 @@ +module ShieldWechatMessagesHelper +end diff --git a/app/helpers/student_work_helper.rb b/app/helpers/student_work_helper.rb index 4e11e153e..74788751b 100644 --- a/app/helpers/student_work_helper.rb +++ b/app/helpers/student_work_helper.rb @@ -23,7 +23,7 @@ module StudentWorkHelper #鑾峰彇鎸囧畾鐢ㄦ埛瀵规煇涓浣滀笟鐨勮瘎鍒嗙粨鏋 def student_work_score work,user - StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).first + StudentWorksScore.where(:user_id => user.id,:student_work_id => work.id).last end #鑾峰彇鎸囧畾璇勫垎鐨勮鑹 diff --git a/app/helpers/sub_document_comments_helper.rb b/app/helpers/sub_document_comments_helper.rb new file mode 100644 index 000000000..c1f2a4de1 --- /dev/null +++ b/app/helpers/sub_document_comments_helper.rb @@ -0,0 +1,2 @@ +module SubDocumentCommentsHelper +end diff --git a/app/helpers/sub_domains_helper.rb b/app/helpers/sub_domains_helper.rb new file mode 100644 index 000000000..ee1c18e71 --- /dev/null +++ b/app/helpers/sub_domains_helper.rb @@ -0,0 +1,5 @@ +module SubDomainsHelper + include OrganizationsHelper + + +end diff --git a/app/models/apply_homework.rb b/app/models/apply_homework.rb new file mode 100644 index 000000000..f4ded9733 --- /dev/null +++ b/app/models/apply_homework.rb @@ -0,0 +1,6 @@ +class ApplyHomework < ActiveRecord::Base + #status锛1. 绛夊緟鍥炲 2.瀹℃牳閫氳繃 3.宸叉嫆缁 + belongs_to :user + belongs_to :homework_common + attr_accessible :status, :user_id, :homework_common_id +end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 754bd4dee..b3f5ce4ed 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -301,7 +301,7 @@ class Attachment < ActiveRecord::Base nil end - def filename=(arg) + def filename=(arg) write_attribute :filename, sanitize_filename(arg.to_s) filename end diff --git a/app/models/blog_comment.rb b/app/models/blog_comment.rb index 2b31af604..af21b4f69 100644 --- a/app/models/blog_comment.rb +++ b/app/models/blog_comment.rb @@ -1,5 +1,8 @@ +#encoding: utf-8 class BlogComment < ActiveRecord::Base # attr_accessible :title, :body + require 'net/http' + require 'json' include Redmine::SafeAttributes belongs_to :blog belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' @@ -18,7 +21,7 @@ class BlogComment < ActiveRecord::Base after_save :add_user_activity after_update :update_activity - after_create :update_parent_time + after_create :update_parent_time, :blog_wechat_message before_destroy :destroy_user_activity scope :like, lambda {|arg| @@ -72,4 +75,18 @@ class BlogComment < ActiveRecord::Base end def project end + + #鍗氬鍥炲寰俊妯℃澘娑堟伅 + def blog_wechat_message + ws = WechatService.new + if self.parent_id.nil? + self.author.watcher_users.each do |watcher| + content = strip_html self.author.try(:realname) + " 鍙戣〃浜嗗崥瀹細" + self.title.html_safe, 200 + ws.message_update_template watcher.id, "blog_comment", self.id, "#{l(:label_new_blog_template)}", content, format_time(self.created_at) + end + else + content = strip_html self.content.html_safe, 200 + ws.comment_template self.parent.author_id, "blog_comment", self.parent_id, "#{l(:label_blog_comment_template)}", self.author.try(:realname), format_time(self.created_at), content + end + end end diff --git a/app/models/comment.rb b/app/models/comment.rb index b87203a50..8632c243a 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -16,6 +16,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Comment < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes include ApplicationHelper has_many_kindeditor_assets :assets, :dependent => :destroy @@ -39,13 +41,21 @@ class Comment < ActiveRecord::Base after_destroy :down_course_score def act_as_system_message + ws = WechatService.new if self.commented.course if self.author_id != self.commented.author_id self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.commented.author_id} and shield_type='Course' and shield_id=#{self.commented.course.id}").count + if count == 0 + content = strip_html self.comments.html_safe, 200 + ws.comment_template self.commented.author_id, "course_notice", self.id, "#{l(:label_notice_comment_template)}", self.author.try(:realname), format_time(self.created_on), content + end end else # 椤圭洰鐩稿叧 if self.author_id != self.commented.author_id self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false) + #content = strip_html self.comments.html_safe, 200 + #ws.comment_template self.commented.author_id, "blog_comment", self.id, "#{l(:label_news_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/course_message.rb b/app/models/course_message.rb index 79d27f3c5..703da936b 100644 --- a/app/models/course_message.rb +++ b/app/models/course_message.rb @@ -1,8 +1,9 @@ class CourseMessage < ActiveRecord::Base # status璇存槑锛 status鍦ㄨ绋嬩笉鍚岀殑绫诲瀷锛屽尯鍒嗕笉鍚岀殑鍔熻兘 status = 9 浣滃搧鐨勬彁浜よ褰 # HomeworkCommon锛歴tatus锛 - # nil锛氬彂甯冧簡浣滀笟锛 1锛氫綔涓氭埅姝㈡椂闂村埌浜嗘彁閱掞紒锛2:寮鍚尶璇勶紱 3锛氬叧闂尶璇勶紱 4锛氬尶璇勫紑濮嬪け璐 - attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status + # nil锛氬彂甯冧簡浣滀笟锛 1锛氫綔涓氭埅姝㈡椂闂村埌浜嗘彁閱掞紒锛2:寮鍚尶璇勶紱 3锛氬叧闂尶璇勶紱 4锛氬尶璇勫紑濮嬪け璐ワ紱 5锛氱敵璇峰紩鐢ㄤ綔涓, 6:鐢宠缁撴灉 + # apply_user_id: 鐢宠鑰呯殑鐢ㄦ埛id + attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed, :content, :status, :apply_user_id, :apply_result # 澶氭 铏氭嫙鍏宠仈 belongs_to :course_message ,:polymorphic => true @@ -14,7 +15,7 @@ class CourseMessage < ActiveRecord::Base validates :course_id,presence: true validates :course_message_id,presence: true validates :course_message_type, presence: true - validates_length_of :content, :maximum => 100 + #validates_length_of :content, :maximum => 100 after_create :add_user_message def add_user_message diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 283fea058..998ace441 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -1,7 +1,10 @@ +#encoding: utf-8 #鑰佸笀甯冪疆鐨勪綔涓氳〃 #homework_type: 0:鏅氫綔涓;1:鍖胯瘎浣滀笟;2:缂栫▼浣滀笟 class HomeworkCommon < ActiveRecord::Base # attr_accessible :name, :user_id, :description, :publish_time, :end_time, :homework_type, :late_penalty, :course_id,:simi_time + require 'net/http' + require 'json' include Redmine::SafeAttributes include ApplicationHelper @@ -15,6 +18,7 @@ class HomeworkCommon < ActiveRecord::Base has_many :student_works, :dependent => :destroy, :conditions => "is_test=0" has_many :student_works_evaluation_distributions, :through => :student_works #涓涓綔涓氱殑鍒嗛厤鐨勫尶璇勫垪琛 has_many :journals_for_messages, :as => :jour, :dependent => :destroy + has_many :apply_homeworks, :dependent => :destroy has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #鐢ㄦ埛娲诲姩 # 璇剧▼鍔ㄦ has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy @@ -26,7 +30,7 @@ class HomeworkCommon < ActiveRecord::Base :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} after_create :act_as_activity, :send_mail, :act_as_course_message - after_update :update_activity + after_update :update_activity, :wechat_message after_save :act_as_course_activity after_destroy :delete_kindeditor_assets @@ -56,6 +60,11 @@ class HomeworkCommon < ActiveRecord::Base self.course.members.each do |m| # if m.user_id != self.user_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count + if count == 0 + ws = WechatService.new + ws.homework_template(m.user_id, "homework", self.id, "#{l(:label_new_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + end # end end end @@ -98,6 +107,17 @@ class HomeworkCommon < ActiveRecord::Base jfm end + #淇敼浣滀笟鍚庡彂閫佸井淇℃ā鏉挎秷鎭 + def wechat_message + self.course.members.each do |member| + count = ShieldWechatMessage.where("container_type='User' and container_id=#{member.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count + if count == 0 + ws = WechatService.new + ws.homework_template(member.user_id, "homework", self.id, "#{l(:label_update_homework_template)}", self.course.name, self.name.html_safe, self.end_time.to_s + " 23:59:59") + end + end + end + delegate :language_name, :language, :to => :homework_detail_programing end diff --git a/app/models/issue.rb b/app/models/issue.rb index 0d72407ba..d5d148117 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -16,6 +17,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Issue < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes include Redmine::Utils::DateCalculation include UserScoreHelper @@ -157,6 +160,14 @@ class Issue < ActiveRecord::Base unless self.author_id == self.assigned_to_id self.forge_messages << ForgeMessage.new(:user_id => self.assigned_to_id, :project_id => self.project_id, :viewed => false) end + self.project.members.each do |m| + count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project_id}").count + if m.user_id != self.author_id && count == 0 + ws = WechatService.new + content = strip_html self.project.name + " 鏈夋柊缂洪櫡浜嗭細" + self.subject.html_safe, 200 + ws.message_update_template m.user_id, "issues", self.id, "#{l(:label_new_issue_template)}", content, format_time(self.created_on) + end + end if self.tracker_id == 5 self.project.members.each do |m| if m.roles.first.to_s.include?("Manager") && m.user_id != self.author_id && m.user_id != self.assigned_to_id @@ -251,7 +262,7 @@ class Issue < ActiveRecord::Base # set default values for new records only self.status ||= IssueStatus.default self.priority ||= IssuePriority.default - self.watcher_user_ids = [] + # self.watcher_user_ids = [] end end diff --git a/app/models/journal.rb b/app/models/journal.rb index fd67e8a62..02086fa62 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -1,3 +1,4 @@ +#coding=utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -16,6 +17,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Journal < ActiveRecord::Base + require 'net/http' + require 'json' include UserScoreHelper belongs_to :journalized, :polymorphic => true,:touch => true # added as a quick fix to allow eager loading of the polymorphic association @@ -52,7 +55,7 @@ class Journal < ActiveRecord::Base # fq after_save :act_as_activity,:be_user_score, :act_as_forge_message, act_as_at_message(:notes, :user_id) - after_create :update_issue_time + after_create :issue_wechat_message # end #after_destroy :down_user_score #before_save :be_user_score @@ -233,4 +236,11 @@ class Journal < ActiveRecord::Base forge_activity.update_attribute(:created_at, self.created_on) unless forge_activity.nil? end end + + #缂洪櫡鍥炲寰俊妯℃澘娑堟伅 + def issue_wechat_message + ws = WechatService.new + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.issue.author_id, "issues", self.journalized_id, "#{l(:label_issue_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index fa5beb813..4b5ac227f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -1,7 +1,9 @@ -# fq +#coding=utf-8 # 鏁版嵁搴撳瓧娈典腑甯︽湁m鍓嶇紑鍜宨s_readed鏄簩娆″紑鍙戞坊鍔狅紝涔嬪墠鐨勫瓧娈靛熀鏈鐢 # 娉ㄦ剰reply_id 鏄彁鍒颁汉鐨刬d锛屼笉鏄暀瑷id, Base涓彨鍋 at_user class JournalsForMessage < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes include UserScoreHelper include ApplicationHelper @@ -253,17 +255,34 @@ class JournalsForMessage < ActiveRecord::Base self.course_messages << CourseMessage.new(:user_id => r, :course_id => self.jour.id, :viewed => false) end end + if self.jour_type == 'HomeworkCommon' + if self.m_parent_id.nil? + if self.user_id != self.jour.user_id + self.course_messages << CourseMessage.new(:user_id => self.jour.user_id,:course_id => self.jour.course.id, :viewed => false) + end + end + count = ShieldWechatMessage.where("container_type='User' and container_id=#{self.jour.user_id} and shield_type='Course' and shield_id=#{self.jour.course_id}").count + if count == 0 + ws = WechatService.new + #content = truncate(strip_tags(self.notes.to_s), length: 200) + content = strip_html self.notes.html_safe, 200 + ws.comment_template self.jour.user_id, "homework", self.jour_id, "#{l(:label_homework_comment_template)}", self.user.try(:realname), format_time(self.created_on), content + end + end end # 鐢ㄦ埛鐣欒█娑堟伅閫氱煡 def act_as_user_feedback_message # 涓荤暀瑷 + ws = WechatService.new if self.jour_type == 'Principal' receivers = [] if self.reply_id == 0 if self.user_id != self.jour_id # 杩囨护鑷繁缁欒嚜宸辩殑鐣欒█娑堟伅 receivers << self.jour + content = strip_html self.notes, 200 + ws.message_update_template self.jour_id, "journal_for_message", self.id, "#{l(:label_new_journals_template)}", content, format_time(self.created_on) end else # 鐣欒█鍥炲 reply_to = User.find(self.reply_id) @@ -273,11 +292,12 @@ class JournalsForMessage < ActiveRecord::Base if self.user_id != self.parent.jour_id && self.reply_id != self.parent.jour_id # 缁欎笢瀹跺彂淇℃伅锛屽鏋滃洖澶嶇殑瀵硅薄鏄笢瀹跺垯涓嶅彂 receivers << self.parent.jour end + content = strip_html self.notes, 200 + ws.comment_template self.reply_id, "journal_for_message", self.parent.id, "#{l(:label_journals_comment_template)}", self.user.try(:realname), format_time(self.created_on), content end receivers.each do |r| self.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => self.id, :journals_for_message_type => "Principal", :viewed => false) end - end end @@ -298,5 +318,4 @@ class JournalsForMessage < ActiveRecord::Base down_course_score_num(self.jour.course_id, self.user_id, "HomeworkCommon") end end - end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 05b0349ec..8d8fa7085 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -626,6 +627,7 @@ class Mailer < ActionMailer::Base # attachments_added(attachments) => Mail::Message object # Mailer.attachments_added(attachments).deliver => sends an email to the project's recipients def homework_added(homework_common) + logger.info "homework added" @homework_common = homework_common @author = homework_common.user @homework_common_url = url_for(:controller => "homework_common", :action =>"index", :homework => @homework_common.id) @@ -727,7 +729,7 @@ class Mailer < ActionMailer::Base :cc => cc, :subject => "[#{message.board.project.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", :filter => true - elsif message.course + elsif message.course redmine_headers 'Course' => message.course.id, 'Topic-Id' => (message.parent_id || message.id) @author = message.author @@ -742,7 +744,7 @@ class Mailer < ActionMailer::Base :cc => cc, :subject => "[#{message.board.course.name} - #{message.board.name} - msg#{message.root.id}] #{message.subject}", :filter => true - end + end end # Builds a Mail::Message object used to email the recipients of a project of the specified wiki content was added. @@ -1039,7 +1041,13 @@ class Mailer < ActionMailer::Base :subject => @subject end - + def apply_for_homework_request(homework, user) + @receive = User.find(homework.user_id) + @user = user + @subject = "#{@user.show_name} #{l(:label_apply_for_homework)} #{homework.name} " + mail :to => @receive.mail, + :subject => @subject + end private @@ -1096,5 +1104,4 @@ class Mailer < ActionMailer::Base 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] } return newpass end - end diff --git a/app/models/message.rb b/app/models/message.rb index bb12473be..7bfb9d80e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -16,6 +17,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class Message < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes include UserScoreHelper include ApplicationHelper @@ -80,7 +83,7 @@ class Message < ActiveRecord::Base # after_create :add_author_as_watcher, :reset_counters!, :add_boards_count after_update :update_messages_board, :update_activity after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score - after_create :act_as_course_activity, :act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count + after_create :act_as_course_activity, :act_as_forge_activity, :act_as_student_score, act_as_at_message(:content, :author_id), :add_author_as_watcher, :reset_counters!, :add_boards_count, :act_as_system_message #before_save :be_user_score scope :visible, lambda {|*args| @@ -255,17 +258,27 @@ class Message < ActiveRecord::Base # 涓昏创椤圭洰鎴愬憳閮借兘鏀跺埌 # 鍥炲笘锛氬笘瀛愮殑鍙戝竷浜烘敹鍒 def act_as_system_message + ws = WechatService.new if self.course if self.parent_id.nil? # 涓昏创 self.course.members.includes(:user).each do |m| if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 鑰佸笀 鑷繁鐨勫笘瀛愪笉缁欒嚜宸卞彂閫佹秷鎭 - self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + #self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course.id}").count + if count == 0 + content = strip_html self.subject, 200 + ws.topic_publish_template m.user_id, "course_discussion", self.id, "#{l(:label_course_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + end end end else # 鍥炲笘 - self.course.members.includes(:user).each do |m| - if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 鍙拡瀵逛富璐村洖澶嶏紝鍥炲鑷繁鐨勫笘瀛愪笉鍙戞秷鎭 - self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + parent_author_id = Message.find(self.parent_id).author_id + if parent_author_id != self.author_id # 鍙拡瀵逛富璐村洖澶嶏紝鍥炲鑷繁鐨勫笘瀛愪笉鍙戞秷鎭 + #self.course_messages << CourseMessage.new(:user_id => parent_author_id, :course_id => self.board.course_id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Course' and shield_id=#{self.board.course_id}").count + if count == 0 + content = strip_html self.content.html_safe, 200 + ws.comment_template parent_author_id, "course_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end @@ -273,13 +286,22 @@ class Message < ActiveRecord::Base if self.parent_id.nil? # 涓昏创 self.project.members.includes(:user).each do |m| if m.user_id != self.author_id - self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) + #self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Project' and shield_id=#{self.project.id}").count + if count == 0 + content = strip_html self.subject, 200 + ws.topic_publish_template m.user_id, "project_discussion", self.id, "#{l(:label_project_topic_template)}", content, self.author.try(:realname), format_time(self.created_on) + end end end else # 鍥炲笘 - self.project.members.includes(:user).each do |m| - if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 鍙拡瀵逛富璐村洖澶嶏紝鍥炲鑷繁鐨勫笘瀛愪笉鍙戞秷鎭 - self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.board.project_id, :viewed => false) + parent_author_id = Message.find(self.parent_id).author_id + if parent_author_id != self.author_id # 鍙拡瀵逛富璐村洖澶嶏紝鍥炲鑷繁鐨勫笘瀛愪笉鍙戞秷鎭 + #self.forge_messages << ForgeMessage.new(:user_id => parent_author_id, :project_id => self.board.project_id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{parent_author_id} and shield_type='Project' and shield_id=#{self.board.project_id}").count + if count == 0 + content = strip_html self.content.html_safe, 200 + ws.comment_template parent_author_id, "project_discussion", self.parent_id, "#{l(:label_topic_comment_template)}", self.author.try(:realname), format_time(self.created_on), content end end end diff --git a/app/models/news.rb b/app/models/news.rb index 6746d90cd..f0457dc81 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -1,3 +1,4 @@ +#encoding: utf-8 # Redmine - project management software # Copyright (C) 2006-2013 Jean-Philippe Lang # @@ -16,6 +17,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class News < ActiveRecord::Base + require 'net/http' + require 'json' include Redmine::SafeAttributes belongs_to :project,:touch => true include ApplicationHelper @@ -59,7 +62,7 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score + after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score after_update :update_activity after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score @@ -167,6 +170,12 @@ class News < ActiveRecord::Base self.course.members.each do |m| if m.user_id != self.author_id self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + count = ShieldWechatMessage.where("container_type='User' and container_id=#{m.user_id} and shield_type='Course' and shield_id=#{self.course_id}").count + if count == 0 + ws = WechatService.new + content = strip_html self.author.try(:realname) + " 鍙戝竷浜嗛氱煡锛" + self.title.html_safe, 200 + ws.message_update_template m.user_id, "course_notice", self.id, "#{l(:label_new_notice_template)}", self.author.try(:realname) + " 鍙戝竷浜嗛氱煡锛" + content, format_time(self.created_on) + end end end else diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index 8cec49686..1151426e3 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -7,6 +7,7 @@ class OrgSubfield < ActiveRecord::Base has_many :messages, :through => :org_subfield_messages has_many :boards, :dependent => :destroy has_many :news, :dependent => :destroy + has_many :sub_domains, :dependent => :destroy acts_as_attachable after_create :create_board_sync after_destroy :update_priority diff --git a/app/models/organization.rb b/app/models/organization.rb index 427cd4c10..311a37bf8 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -22,4 +22,12 @@ class Organization < ActiveRecord::Base OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default', :priority => 2) OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default', :priority => 3) end + + def switch_type + self.show_mode.to_i == 1 ? true : false + end + + def allow_set_teachers + self.allow_teacher.to_i == 1 ? true : false + end end diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb index b1b7e0908..63ba89b18 100644 --- a/app/models/praise_tread.rb +++ b/app/models/praise_tread.rb @@ -88,4 +88,11 @@ class PraiseTread < ActiveRecord::Base UserLevels.update_user_level(target_user) end end + + def self.praised(activity) + self.where(praise_tread_object_id: activity.id, + praise_tread_object_type: activity.class.to_s, + user_id: User.current.id).empty? + end + end diff --git a/app/models/school.rb b/app/models/school.rb index 6cafb0473..b9a1d88cb 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -5,4 +5,5 @@ class School < ActiveRecord::Base def to_s self.name.to_s end + end diff --git a/app/models/shield_wechat_message.rb b/app/models/shield_wechat_message.rb new file mode 100644 index 000000000..ebee3b8f1 --- /dev/null +++ b/app/models/shield_wechat_message.rb @@ -0,0 +1,3 @@ +class ShieldWechatMessage < ActiveRecord::Base + attr_accessible :container_id, :container_type, :shield_id, :shield_type +end diff --git a/app/models/sso.rb b/app/models/sso.rb new file mode 100644 index 000000000..c6b57cd2d --- /dev/null +++ b/app/models/sso.rb @@ -0,0 +1,56 @@ +class Sso < ActiveRecord::Base + belongs_to :user + attr_accessible :email, :name, :openid, :password, :school, :sex, :user, :user_id + + validates :user_id, :user, :email, :openid, :presence => true + + def self.sync_user(opt) + sso = Sso.where(openid: opt["openid"]).first + return sso if sso + + sso = Sso.new + sso.name = opt["name"] + sso.openid = opt["openid"] + sso.email = opt["email"] + sso.password = opt["password"] + sso.school = opt["school"] + sso.sex = opt["sex"] + + + # 鏌ラ偖绠 + user = User.where(mail: opt["email"]).first + + unless user + # 鏌ョ敤鎴峰悕 + + user = User.where(login: opt["name"]).first + if user + # 璺冲埌淇敼鐢ㄦ埛鍚 + raise "exist user" + end + + password = opt["password"] + if password.size < 8 + password = random_pwd + end + us = UsersService.new + user = us.register(login: opt["name"], mail: opt["email"], + password: password, + :should_confirmation_password => false) + if user.new_record? + raise user.errors.full_messages.first + end + end + + sso.user = user + sso.save! + return sso + end + + + private + def self.random_pwd + ('a'..'z').to_a.shuffle[0..7].join + end + +end diff --git a/app/models/student_work.rb b/app/models/student_work.rb index 3abd4276a..ddd91df38 100644 --- a/app/models/student_work.rb +++ b/app/models/student_work.rb @@ -63,11 +63,17 @@ class StudentWork < ActiveRecord::Base final_score = final_ta_score + final_s_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end else #涓嶈冭檻鏁欏笀璇勫垎 - if student_work.teaching_asistant_score.nil? + if student_work.student_score.nil? && student_work.teaching_asistant_score.nil? + student_work.final_score = student_work.teacher_score + elsif student_work.teaching_asistant_score.nil? student_work.final_score = student_work.student_score elsif student_work.student_score.nil? student_work.final_score = student_work.teaching_asistant_score @@ -78,8 +84,12 @@ class StudentWork < ActiveRecord::Base final_score = final_ta_score + final_s_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end elsif homework.homework_type == 2 && homework.homework_detail_programing #缂栫▼浣滀笟-----璁惧畾锛氱郴缁熻瘎鍒嗗繀瀹氫笉涓虹┖ if homework.teacher_priority == 1 #鏁欏笀浼樺厛 @@ -114,9 +124,13 @@ class StudentWork < ActiveRecord::Base final_score = final_sy_score + final_ts_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score - end + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end + end else #涓嶈冭檻鏁欏笀璇勫垎 if student_work.teaching_asistant_score.nil? #鏁欒緟鏈瘎鍒 if student_work.student_score.nil? @@ -145,8 +159,12 @@ class StudentWork < ActiveRecord::Base final_score = final_sy_score + final_ts_score + final_st_score student_work.final_score = format("%.2f",final_score.to_f) end - score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty if student_work.final_score - student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + if student_work.final_score + score = student_work.final_score - student_work.absence_penalty - student_work.late_penalty + student_work.work_score = format("%.2f",(score < 0 ? 0 : score).to_f) if score + else + student_work.work_score = nil + end end end end diff --git a/app/models/student_works_score.rb b/app/models/student_works_score.rb index aa38c5dcd..b2fc4fdcd 100644 --- a/app/models/student_works_score.rb +++ b/app/models/student_works_score.rb @@ -18,17 +18,29 @@ class StudentWorksScore < ActiveRecord::Base receiver = self.student_work.user # 鍒ゆ柇鏄涓娆¤瘎闃呰繕鏄洿鏂 status:0 鏂板缓锛1 鏇存柊 if self.created_at == self.updated_at - if self.comment.nil? + if self.comment.nil? && self.score self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false, :content => "浣滀笟璇勫垎锛#{self.score}", :status=> false) + elsif self.score.nil? && self.comment + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, + :viewed => false, :content => "璇勮锛#{self.comment}", :status=> false) + elsif self.comment.nil? && self.score.nil? + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, + :viewed => false, :content => "涓婁紶浜嗘壒闃呴檮浠", :status=> false) else self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false, :content => "浣滀笟璇勫垎锛#{self.score}    璇勮锛#{self.comment}", :status=> false) end else # 鏇存柊 - if self.comment.nil? + if self.comment.nil? && self.score self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false, :content => "浣滀笟璇勫垎锛#{self.score}", :status=> true) + elsif self.score.nil? && self.comment + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, + :viewed => false, :content => "璇勮锛#{self.comment}", :status=> true) + elsif self.comment.nil? && self.score.nil? + self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, + :viewed => false, :content => "涓婁紶浜嗘壒闃呴檮浠", :status=> true) else self.course_messages << CourseMessage.new(:user_id => receiver.id, :course_id => self.student_work.homework_common.course.id, :viewed => false, :content => "浣滀笟璇勫垎锛#{self.score}    璇勮锛#{self.comment}", :status=> true) diff --git a/app/models/sub_document_comment.rb b/app/models/sub_document_comment.rb new file mode 100644 index 000000000..799fed7ce --- /dev/null +++ b/app/models/sub_document_comment.rb @@ -0,0 +1,33 @@ +class SubDocumentComment < ActiveRecord::Base + attr_accessible :content, :creator_id, :locked, :org_subfield_id, :parent_id, :reply_id, :sticky, :sub_domain_id, :title + + include Redmine::SafeAttributes + include ApplicationHelper + belongs_to :sub_domain + belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id' + acts_as_tree :order => "#{SubDocumentComment.table_name}.sticky asc, #{SubDocumentComment.table_name}.created_at desc" + acts_as_attachable + has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy + after_create :document_save_as_sub_activity + after_update :update_activity + validates_presence_of :content + + #鍔ㄦ佺殑鏇存柊 + private + def update_activity + org_activity = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", id).first + if org_activity + org_activity.updated_at = Time.now + org_activity.save + end + end + + def document_save_as_sub_activity + if(self.parent().nil?) + self.org_acts << OrgActivity.new(:user_id => User.current.id, :container_id => self.sub_domain.id, :container_type => 'SubDomain') + else + act = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", self.root.id).first + act.update_attributes(:updated_at => self.updated_at) + end + end +end diff --git a/app/models/sub_domain.rb b/app/models/sub_domain.rb new file mode 100644 index 000000000..0ae325e1a --- /dev/null +++ b/app/models/sub_domain.rb @@ -0,0 +1,5 @@ +class SubDomain < ActiveRecord::Base + attr_accessible :field_type, :hide, :name, :org_subfield_id, :priority, :status + belongs_to :org_subfield, :foreign_key => :org_subfield_id + has_many :sub_document_comments, :dependent => :destroy +end diff --git a/app/models/user.rb b/app/models/user.rb index 2a9a13c73..035aff625 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -108,6 +108,7 @@ class User < Principal has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy has_many :student_work_projects, :dependent => :destroy + has_many :apply_homeworks, :dependent => :destroy #end has_and_belongs_to_many :groups, :after_add => Proc.new {|user, group| group.user_added(user)}, @@ -179,6 +180,9 @@ class User < Principal ##### has_many :shares ,:dependent => :destroy + has_one :user_wechat + + has_one :sso # add by zjc has_one :level, :class_name => 'UserLevels', :dependent => :destroy @@ -305,6 +309,20 @@ class User < Principal end # ====================================================================== + def my_workplace + self.user_extensions.try(:occupation).to_s + end + + def my_blogs_count + self.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count + end + + def my_students + my_students=StudentsForCourse.find_by_sql("SELECT SUM(student_count) as students_count, c.tea_id FROM courses c, (SELECT course_id , COUNT(id) AS student_count FROM students_for_courses GROUP BY course_id) AS ct + WHERE c.id= ct.course_id and c.tea_id = #{self.id} GROUP BY c.tea_id").first + results = my_students.blank? ? 0 : my_students.students_count + results + end # 鏌ヨ鐢ㄦ埛鏈杩囩殑璁板綍 # 鐢ㄦ埛鐣欒█璁板綍 @@ -1069,16 +1087,25 @@ class User < Principal anonymous_user end + def self.is_id?(id) + Fixnum===id || id.to_i.to_s == id + end + # refactor User model find function, # return anonymous user when can not find user id = user_id def self.find (*args, &block) begin + return find_by_login(args.first) if args.size==1 && !is_id?(args.first) super rescue self.anonymous end # super end + + def to_param + login + end # Salts all existing unsalted passwords # It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password)) # This method is used in the SaltPasswords migration and is to be kept as is @@ -1181,17 +1208,17 @@ class User < Principal def create_user_ealasticsearch_index if self.id != 2 && self.id != 4 - self.__elasticsearch__.index_document + self.__elasticsearch__.index_document if Rails.env.production? end end def update_user_ealasticsearch_index if self.id != 2 && self.id != 4 - self.__elasticsearch__.update_document + self.__elasticsearch__.update_document if Rails.env.production? end end def delete_user_ealasticsearch_index if self.id != 2 && self.id != 4 - self.__elasticsearch__.delete_document + self.__elasticsearch__.delete_document if Rails.env.production? end end diff --git a/app/models/user_wechat.rb b/app/models/user_wechat.rb new file mode 100644 index 000000000..49053dbf0 --- /dev/null +++ b/app/models/user_wechat.rb @@ -0,0 +1,6 @@ +class UserWechat < ActiveRecord::Base + attr_accessible :subscribe, :openid, :nickname, :sex, :language, :city, :province, :country, + :headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user, :user_id + + belongs_to :user +end diff --git a/app/services/wechat_service.rb b/app/services/wechat_service.rb new file mode 100644 index 000000000..1dcd147d4 --- /dev/null +++ b/app/services/wechat_service.rb @@ -0,0 +1,117 @@ +#encoding: utf-8 +class WechatService + + def template_data(openid, template_id, type, id, first, key1, key2, key3, remark="") + data = { + touser:openid, + template_id:template_id, + url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect", + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#707070" + }, + keyword1:{ + value:key1, + color:"#707070" + }, + keyword2:{ + value:key2, + color:"#707070" + }, + keyword3:{ + value:key3, + color:"#707070" + }, + remark:{ + value:remark, + color:"#707070" + } + } + } + data + end + + def homework_template(user_id, type, id, first, key1, key2, key3, remark="") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = template_data uw.openid,"3e5Dj2GIx8MOcMyRKpTUEQnM7Tg0ASSCNc01NS9HCGI", 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 "[homework] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" + end + + def topic_publish_template(user_id, type, id, first, key1, key2, key3, remark="") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = template_data uw.openid,"oKzFCdk7bsIHnGbscA__N8LPQrBkUShvpjV3-kuwWDQ", type, id,first, key1, key2, key3, remark + Rails.logger.info "start send template message: #{data}" + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[topic_publish] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" + end + + def comment_template(user_id,type, id, first, key1, key2, key3, remark="") + uw = UserWechat.where(user_id: user_id).first + unless uw.nil? + data = template_data uw.openid,"A_3f5v90-zK73V9Kijm-paDkl9S-NuM8Cf-1UJi92_c",type, id,first, key1, key2, key3, remark + Rails.logger.info "start send template message: #{data}" + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[comment] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" + end + + def message_update_template(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:"YTyNPZnQD8uZFBFq-Q6cCOWaq5LA9vL6RFlF2JuD5Cg", + url:"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect", + topcolor:"#FF0000", + data:{ + first: { + value:first, + color:"#707070" + }, + keyword1:{ + value:key1, + color:"#707070" + }, + keyword2:{ + value:key2, + color:"#707070" + }, + remark:{ + value:remark, + color:"#707070" + } + } + } + Rails.logger.info "start send template message: #{data}" + begin + req = Wechat.api.template_message_send Wechat::Message.to(uw.openid).template(data) + rescue Exception => e + Rails.logger.error "[message_update] ===> #{e}" + end + Rails.logger.info "send over. #{req}" + end + Rails.logger.info "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=https://www.trustie.net/assets/wechat/app.html#/#{type}/#{id}?response_type=code&scope=snsapi_base&state=123#wechat_redirect" + end +end \ No newline at end of file diff --git a/app/views/admin/apply_for_homework.html.erb b/app/views/admin/apply_for_homework.html.erb new file mode 100644 index 000000000..25d15f707 --- /dev/null +++ b/app/views/admin/apply_for_homework.html.erb @@ -0,0 +1,89 @@ +

+ <%=l(:label_apply_homework)%> +

+ +
+ + + + + + + + + + + + + + <%@count=@page*30 %> + <% for homework in @homework do %> + <% unless homework.nil? %> + <% @count+=1 %> + + + <% c_h = HomeworkCommon.find homework.homework_common_id %> + <% if c_h %> + + <% if c_h.course %> + + <% end %> + + <% end %> + + + + + <% end %> + <% end %> + +
+ 搴忓彿 + + 浣滀笟鍚嶇О + + 璇剧▼鍚嶇О + + 浣滆 + + 鐢宠鑰 + + 鐢宠鐘舵 + + 鐢宠鏃ユ湡 +
+ <%=@count %> + + <%=link_to(c_h.try(:name), student_work_index_path(:homework => c_h.id))%> + + <%= link_to(c_h.course.name, course_path(c_h.course.id)) %> + <%= c_h.try(:user)%><% else %><%=c_h.try(:user).try(:realname) %><% end %>'> + <% if c_h.try(:user).try(:realname) == ' '%> + <%= link_to(c_h.try(:user), user_path(c_h.user_id)) %> + <% else %> + <%= link_to(c_h.try(:user).try(:realname), user_path(c_h.user_id)) %> + <% end %> + <%= homework.try(:user)%><% else %><%=homework.try(:user).try(:realname) %><% end %>'> + <% if homework.try(:user).try(:realname) == ' '%> + <%= link_to(homework.try(:user), user_path(homework.user_id)) %> + <% else %> + <%= link_to(homework.try(:user).try(:realname), user_path(homework.user_id)) %> + <% end %> + + <% if homework.status == 1 %> + 绛夊緟鍥炲 + <% elsif homework.status == 2 %> + 宸查氳繃 + <% else %> + 宸叉嫆缁 + <% end %> + + <%=format_date( homework.created_at ) %> +
+
+ + + +<% html_title(l(:label_apply_homework)) -%> diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index 550b1e4ef..dd818fe72 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -17,51 +17,51 @@
<% if topics.any? %> - <% topics.each do |activity| %> -
    -
  • - <% if activity.parent_id.nil? %> - <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl" %> - <% else %> - <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%> - <% end %> - <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> - [宸茶涓洪椤礭 - <% end %> - <% if activity.sticky == 1 %> - - <% end%> - <% if activity.locked %> - - <% end %> -
    -
  • - <% count=0 %> - <% if activity.parent %> - <% count=activity.parent.children.count%> - <% else %> - <% count=activity.children.count%> - <% end %> -
  • + <% topics.each do |activity| %> +
      +
    • + <% if activity.parent_id.nil? %> + <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl" %> + <% else %> + <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "list-title fl"%> + <% end %> + <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %> + [宸茶涓洪椤礭 + <% end %> + <% if activity.sticky == 1 %> + + <% end%> + <% if activity.locked %> + + <% end %> +
      +
    • + <% count=0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
    • 鍙戝竷锛<%= format_time(activity.created_on) %> 鏇存柊锛<%= format_time(activity.updated_on) %> -

      - <%= count>0 ? "#{count}" :"0" %> - 鍥炲 - | - <%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" :"0" %> - -

      -
    • -
      -
    - <% end %> -
    -
      - <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %> -
    +

    + <%= count>0 ? "#{count}" :"0" %> + 鍥炲 + | + <%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" :"0" %> + +

    +
  • -
+ + <% end %> +
+
    + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %> +
+
+
<% else %>

<%= l(:label_no_data) %>

<% end %> diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 3deb04f6c..df61d2b9c 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -2,6 +2,7 @@ <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> <% end %> \ No newline at end of file diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb index a24835fc1..875b9ec4c 100644 --- a/app/views/exercise/_new_MCQ.html.erb +++ b/app/views/exercise/_new_MCQ.html.erb @@ -54,9 +54,16 @@
-<% end %> \ No newline at end of file +<% end %> + \ No newline at end of file diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb index 6180dac8e..24a0ad047 100644 --- a/app/views/exercise/_new_single.html.erb +++ b/app/views/exercise/_new_single.html.erb @@ -42,9 +42,16 @@
-<% end %> \ No newline at end of file +<% end %> + \ No newline at end of file diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb index eef7546e5..99c48a3ab 100644 --- a/app/views/exercise/_show_MC.html.erb +++ b/app/views/exercise/_show_MC.html.erb @@ -90,7 +90,7 @@ ''+ ''+ ''+ ''+ '
    + <% if User.current.logged? %>
  • - <% if User.current.logged? %> <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == org_subfield.id && file.container_type == "OrgSubfield" %>
    • <%= link_to("鍙       閫".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    • @@ -66,8 +66,8 @@
    • <%= link_to("鍙  閫".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
    <% end %> - <% end %>
  • + <% end %>
diff --git a/app/views/files/_org_upload_attachment_list_banner.html.erb b/app/views/files/_org_upload_attachment_list_banner.html.erb index 5388afb5b..1ffb68d74 100644 --- a/app/views/files/_org_upload_attachment_list_banner.html.erb +++ b/app/views/files/_org_upload_attachment_list_banner.html.erb @@ -23,7 +23,7 @@ - 寤鸿涓婁紶 闀垮害涓1452px/楂樺害涓304px 鐨勫浘鐗 + 寤鸿涓婁紶 闀垮害:1920px 楂樺害:313px 鐨勫浘鐗
diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 2b3772734..61ffb8b10 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -109,11 +109,13 @@ <% end %> }); + var first_click = true; function check_and_submit(){ if(!check_memo_name()){ return; } - if($("textarea[name='memo[subject]']").val().trim() != "" && !memo_content.isEmpty() ){ + if($("textarea[name='memo[subject]']").val().trim() != "" && !memo_content.isEmpty() && first_click){ + first_click = false; memo_content.sync(); $.ajax({ url:'/forums/'+'<%= @forum.id.to_s%>'+'/memos', diff --git a/app/views/homework_common/index.html.erb b/app/views/homework_common/index.html.erb index e4b63a536..e34cf0736 100644 --- a/app/views/homework_common/index.html.erb +++ b/app/views/homework_common/index.html.erb @@ -47,7 +47,7 @@
    <% @homework_commons.each_with_index do |homework_common,index |%>
  • - <%= link_to "浣滀笟#{@homework_commons.count - index}锛#{homework_common.name}",student_work_index_path(:homework => homework_common.id)%> + <%= link_to "浣滀笟#{@homework_commons.count - index}锛#{homework_common.name}",student_work_index_path(:homework => homework_common.id),:target=>"_blank"%>
  • <% end%>
diff --git a/app/views/layouts/_user_courses.html.erb b/app/views/layouts/_user_courses.html.erb index 07eb70f0f..ff18e68bd 100644 --- a/app/views/layouts/_user_courses.html.erb +++ b/app/views/layouts/_user_courses.html.erb @@ -3,8 +3,10 @@ <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", :id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "鍏紑璇剧▼锛":"绉佹湁璇剧▼锛")+course.name+"锛"+current_time_and_term(course)+"锛"%> - <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> -
    + <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> + <% wechat_count = ShieldWechatMessage.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> + +
<%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %> +
璁块棶璁℃暟 <%= @organization.visits.to_i %>
diff --git a/app/views/layouts/base_org2.html.erb b/app/views/layouts/base_org2.html.erb index fc550c90f..9b481fac5 100644 --- a/app/views/layouts/base_org2.html.erb +++ b/app/views/layouts/base_org2.html.erb @@ -1,192 +1,236 @@ - - - - - <%= h html_title %> - - - <%= csrf_meta_tag %> - <%= favicon %> - <%= javascript_heads %> - <%= heads_for_theme %> - <%= stylesheet_link_tag 'org2','jquery/jquery-ui-1.9.2' %> - <%= javascript_include_tag 'cookie','project', 'organization','header','prettify','select_list_move','org'%> - <%= javascript_include_tag 'attachments' %> - <%#= call_hook :view_layouts_base_html_head %> - - <%#= yield :header_tags -%> - - - - - - - - - - - - - - - - -
-
- <%= render :partial => 'organizations/org_logined_header' %> -
- -
- -
-
    - <% @subfield_content.each do |field| %> - <% if is_default_field?(field) %> - <% case field.name %> - <% when 'activity' %> - - <% when 'course' %> - - <% when 'project' %> - - <% end %> - <% else %> - <% if field.field_type == "Post" && field.hide == 0 %> - - <% elsif field.field_type == "Resource" && field.hide == 0 %> - - <% end %> - <% end %> - <% end %> - <% if User.current.admin_of_org?(@organization) %> - - <% end %> -
-
-
-
-<%# 鏇存柊璁块棶鏁,鍒锋柊鐨勬椂鍊欐洿鏂拌闂鏁 %> -<% update_visiti_count @organization %> -<%# over %> - -
-
- <% @subfield_content.each do |field| %> - <% if field.status.to_i == 1 %> - <%= render :partial => 'organizations/org_subfield_leftT', :locals => {:field => field} %> - <% elsif field.status.to_i == 2 %> - <%#= render :partial => 'organizations/org_subfield_leftM', :locals => {:field => field} %> -
- <%= render :partial => 'organizations/org_subfield_leftM1', :locals => {:field => field} %> - <% elsif field.status.to_i == 3 %> - <%= render :partial => 'organizations/org_subfield_leftM2', :locals => {:field => field} %> -
-
- <% elsif field.status.to_i == 4 %> - <%= render :partial => 'organizations/org_subfield_leftMD', :locals => {:field => field} %> - <% elsif field.status.to_i == 5 %> - <%= render :partial => 'organizations/org_subfield_leftD', :locals => {:field => field} %> - <% end %> - <% end %> -
- -
- <% @subfield_content.each do |field| %> - <% if field.status.to_i == 6 %> - <%= render :partial => 'organizations/org_subfield_rightT', :locals => {:field => field} %> - <% elsif field.status.to_i == 7 %> - <%= render :partial => 'organizations/org_subfield_rightM', :locals => {:field => field} %> - <% elsif field.status.to_i == 8 %> - <%= render :partial => 'organizations/org_subfield_rightD', :locals => {:field => field} %> - <% end %> - <% end %> -
-
-
- -
- -
- -
-
- - -<%#= call_hook :view_layouts_base_body_bottom %> - - - + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= stylesheet_link_tag 'org2','jquery/jquery-ui-1.9.2' %> + <%= javascript_include_tag 'cookie','project', 'organization','header','prettify','select_list_move','org'%> + <%= javascript_include_tag 'attachments' %> + <%#= call_hook :view_layouts_base_html_head %> + + <%#= yield :header_tags -%> + + + + + + + + + + + + + + + +
+
+ <%= render :partial => 'organizations/org_logined_header' %> +
+ +
+ +
+
    + <% @subfield_content.each do |field| %> + <% if is_default_field?(field) %> + <% case field.name %> + <% when 'activity' %> + + <% when 'course' %> + + <% when 'project' %> + + <% end %> + <% else %> + <% if field.field_type == "Post" && field.hide == 0 %> + + + + <% elsif field.field_type == "Resource" && field.hide == 0 %> + + <% end %> + <% end %> + <% end %> + <% if User.current.admin_of_org?(@organization) %> + + <% end %> +
+
+
+
+<%# 鏇存柊璁块棶鏁,鍒锋柊鐨勬椂鍊欐洿鏂拌闂鏁 %> +<% update_visiti_count @organization %> +<%# over %> + +
+
+ <% @subfield_content.each do |field| %> + <% if field.status.to_i == 1 %> + <%= render :partial => 'organizations/org_subfield_leftT', :locals => {:field => field} %> + <% elsif field.status.to_i == 3 %> + <%#= render :partial => 'organizations/org_subfield_leftM', :locals => {:field => field} %> +
+ <%= render :partial => 'organizations/org_subfield_leftM1', :locals => {:field => field} %> + <%= render :partial => 'organizations/org_subfield_leftM2', :locals => {:field => field} %> +
+
+ <% elsif field.status.to_i == 4 %> + <%= render :partial => 'organizations/org_subfield_leftMD', :locals => {:field => field} %> + <% elsif field.status.to_i == 5 %> + <%= render :partial => 'organizations/org_subfield_leftD', :locals => {:field => field} %> + <% end %> + <% end %> +
+ +
+ <% @subfield_content.each do |field| %> + <% if field.status.to_i == 6 %> + <%= render :partial => 'organizations/org_subfield_rightT', :locals => {:field => field} %> + <% elsif field.status.to_i == 7 %> + <%= render :partial => 'organizations/org_subfield_rightM', :locals => {:field => field} %> + <% elsif field.status.to_i == 8 %> + <%= render :partial => 'organizations/org_subfield_rightD', :locals => {:field => field} %> + <% elsif field.status.to_i == 23 %> + <%= render :partial => 'organizations/org_subfield_rightM2', :locals => {:field => field} %> + <% end %> + <% end %> +
+
+
+ +
+ +
+ +
+
+ + +
+ + + +<%#= call_hook :view_layouts_base_body_bottom %> + + + + + + + + diff --git a/app/views/layouts/base_sub_domain.html.erb b/app/views/layouts/base_sub_domain.html.erb new file mode 100644 index 000000000..871e2cdea --- /dev/null +++ b/app/views/layouts/base_sub_domain.html.erb @@ -0,0 +1,191 @@ + + + + + <%= h html_title %> + + + <%= csrf_meta_tag %> + <%= favicon %> + <%= javascript_heads %> + <%= heads_for_theme %> + <%= stylesheet_link_tag 'org_new_style','jquery/jquery-ui-1.9.2', 'org2' %> + <%= javascript_include_tag 'cookie','project', 'organization','header','prettify','select_list_move','org'%> + <%= javascript_include_tag 'attachments' %> + <%#= call_hook :view_layouts_base_html_head %> + + <%#= yield :header_tags -%> + + + + + + + + + + + + + + + +
+
+
+ <%= render :partial => 'organizations/org_logined_header' %> +
+ +
+ +
+
    + <% @subfield_content.each do |field| %> + <% if is_default_field?(field) %> + <% case field.name %> + <% when 'activity' %> + + <% when 'course' %> + + <% when 'project' %> + + <% end %> + <% else %> + <% if field.field_type == "Post" && field.hide == 0 %> + + + + <% elsif field.field_type == "Resource" && field.hide == 0 %> + + <% end %> + <% end %> + <% end %> + <% if User.current.admin_of_org?(@organization) %> + + <% end %> +
+
+
+
+ banner image + +
+
+
+
+<%# 鏇存柊璁块棶鏁,鍒锋柊鐨勬椂鍊欐洿鏂拌闂鏁 %> + <% update_visiti_count @organization %> +<%# over %> + + + + <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
+ +
+ +
+ +
+
+
+ + +
+ + + + + + + + diff --git a/app/views/layouts/base_wechat.html.erb b/app/views/layouts/base_wechat.html.erb new file mode 100644 index 000000000..729f762ac --- /dev/null +++ b/app/views/layouts/base_wechat.html.erb @@ -0,0 +1,44 @@ + + + + + <%= csrf_meta_tag %> + + 缁戝畾鐢ㄦ埛 + + + + + +<%= yield %> + + + + + + + + + + + + \ No newline at end of file diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index f36f8a63c..33c9d7f8d 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -91,16 +91,19 @@
- <% unless @replies.empty? %>
-
鍥炲锛<%=@reply_count %>锛
-
- +
鍥炲 + <%= @reply_count>0 ? "锛#{@reply_count}锛" : "" %> + + <% if @topic.author == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>@topic, :user_activity_id=>@topic.id,:type=>"activity"}%> + <% end %> + +
+ <% unless @replies.empty? %>
<% @replies.each_with_index do |reply,i| %> - <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first, :flag => 0} %> - <% end %> +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> +<% end %> + +<%= render :partial => 'new' %> +<% unless @documents.nil? %> + <% @documents.each do |document| %> + + <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first, :flag => 0} %> + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb index 3e08d9f9e..5cc6d5c91 100644 --- a/app/views/org_subfields/create.js.erb +++ b/app/views/org_subfields/create.js.erb @@ -4,6 +4,7 @@ :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); $("#sub_field_left_lists").html(""); $("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); + $("#org_excellent_teachers").html("<%= escape_javascript(render :partial => 'organizations/setting_excellent_teachers') %>"); <% end %> $("#subfield_name").val(""); $("#sub_dir").val(""); \ No newline at end of file diff --git a/app/views/org_subfields/destroy.js.erb b/app/views/org_subfields/destroy.js.erb index d069b1cd8..c14eeae8f 100644 --- a/app/views/org_subfields/destroy.js.erb +++ b/app/views/org_subfields/destroy.js.erb @@ -2,4 +2,5 @@ $("#org_subfield_list").html(""); $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); $("#sub_field_left_lists").html(""); -$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); +$("#org_excellent_teachers").html("<%= escape_javascript(render :partial => 'organizations/setting_excellent_teachers') %>"); \ No newline at end of file diff --git a/app/views/organizations/_join_course_menu.html.erb b/app/views/organizations/_join_course_menu.html.erb index b21e52d2f..b15dce2c6 100644 --- a/app/views/organizations/_join_course_menu.html.erb +++ b/app/views/organizations/_join_course_menu.html.erb @@ -24,7 +24,8 @@
-
璇烽夋嫨鍏宠仈鍒扮粍缁囩殑璇剧▼
+
璇烽夋嫨鍏宠仈鍒扮粍缁囩殑璇剧▼
+
鎮ㄧ殑绉佹湁璇剧▼涓嶈兘琚叧鑱斿埌缁勭粐
<%=form_tag url_for(:controller => 'organizations', :action => 'join_courses', :organization_id => organization_id),:method => 'post', :id => 'join_courses_form', :remote => true,:class=>"resourcesSearchBox" do %> diff --git a/app/views/organizations/_join_project_menu.html.erb b/app/views/organizations/_join_project_menu.html.erb index c9bd48610..809fb046f 100644 --- a/app/views/organizations/_join_project_menu.html.erb +++ b/app/views/organizations/_join_project_menu.html.erb @@ -24,7 +24,8 @@
-
璇烽夋嫨鍏宠仈鍒扮粍缁囩殑椤圭洰
+
璇烽夋嫨鍏宠仈鍒扮粍缁囩殑椤圭洰
+
鎮ㄧ殑绉佹湁椤圭洰涓嶈兘琚叧鑱斿埌缁勭粐
<%=form_tag url_for(:controller => 'organizations', :action => 'join_projects', :organization_id => organization_id),:method => 'post', :id => 'join_projects_form', :remote => true,:class=>"resourcesSearchBox" do %> diff --git a/app/views/organizations/_link_subfield_more.html.erb b/app/views/organizations/_link_subfield_more.html.erb new file mode 100644 index 000000000..cb4a82ed1 --- /dev/null +++ b/app/views/organizations/_link_subfield_more.html.erb @@ -0,0 +1,9 @@ +<% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "鏇村", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "more" , :target => "_blank" %> + <% else %> + <%= link_to "鏇村", show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "more" , :target => "_blank" %> + <% end %> +<% else %> + <%= link_to "鏇村", organization_path(@organization, :org_subfield_id => field.id), :class => "more" , :target => "_blank" %> +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_org_course_create.html.erb b/app/views/organizations/_org_course_create.html.erb index 875c45059..a09246dc7 100644 --- a/app/views/organizations/_org_course_create.html.erb +++ b/app/views/organizations/_org_course_create.html.erb @@ -34,4 +34,9 @@
-
\ No newline at end of file +
+ \ No newline at end of file diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 4ac2ebcbf..b4ca46959 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -140,8 +140,8 @@
<% if activity.student_works.count != 0 %> <% sw_id = "("+activity.student_works.map{|sw| sw.id}.join(",")+")" %> - <% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> - <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %> + <%# student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> + <% student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") %> <% unless student_work_scores.empty? %> <% last_score = student_work_scores.first %>
@@ -153,14 +153,24 @@
<% if activity.homework_type != 2 %> <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> - <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> + <% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %> <% else %> - <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> + <% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %> <% end %> <% student_works.each_with_index do |sw, i| %>
- <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_url_in_org(activity.id), :alt => "瀛︾敓澶村儚" %> - + + <% if User.current.member_of_course?(activity.course) || User.current.admin? || activity.is_open == 1 %> + <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_url_in_org(activity.id, '', sw.id), :alt => "瀛︾敓澶村儚" %> + + <% else %> + <%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '璇ヤ綔涓氱殑浣滃搧鏆傛湭鍏紑') %> + + <% end %> <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>

鍒嗘暟锛<%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>鍒

@@ -182,7 +192,8 @@ <% sort_projects = project_sort_update projects %>
- # <%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_url_in_org(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>鏇存柊浜嗛」鐩紝鏈杩戞洿鏂帮細 + <% first_pro = project_sort_first(projects).first %> + # <%=time_from_now first_pro.updated_at %><%= link_to User.find(first_pro.user_id).show_name, user_activities_url_in_org(first_pro.user_id), :class => "newsBlue ml5 mr5"%>鏇存柊浜嗛」鐩紝鏈杩戞洿鏂帮細
<% sort_projects.each_with_index do |pro, i| %> @@ -211,7 +222,7 @@
椤圭洰鍚嶇О锛<%=project.name %>
鍒涘缓鑰咃細<%=(User.find project.user_id).show_name %>(缁勯暱)
- 鏇存柊鏃堕棿锛<%=time_from_now time %> + 鏇存柊鏃堕棿锛<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %>
<% if i == 9 && projects.count > 10 %> @@ -275,7 +286,8 @@ <% count=activity.journals_for_messages.count %>
-
鍥炲 +
鍥炲 + <%= count>0 ? "锛#{count}锛" : "" %> <% if activity.user == User.current %> @@ -317,23 +329,60 @@ <% else %> <%= link_to comment.try(:user).try(:realname), user_url_in_org(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> - <%= format_time(comment.created_on) %> - - <% if comment.user == User.current %> - + <%= time_from_now(comment.created_on) %> +
+ <% unless comment.m_parent_id.nil? %> + <% parents_rely = [] %> + <% parents_rely = get_reply_parents parents_rely, comment %> + <% length = parents_rely.length %> +
+ <% if length <= 3 %> + <%=render :partial => 'users/comment_reply', :locals => {:comment => comment.parent} %> <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> +
+
+
+ <%=render :partial => 'users/comment_reply', :locals => {:comment => parents_rely[length - 1]} %> +
+ <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[length - 2]} %> +
+
<%= link_to '鐐瑰嚮灞曞紑闅愯棌妤煎眰', show_all_replies_users_path(:comment => comment),:remote=>true %>
+ <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[0]} %> +
<% end %> - - -
+
+ <% end %>
<%= comment.notes.html_safe %>
+
+
+ + + <% if comment.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> + + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :is_in_course => -1, :user_activity_id => user_activity_id, :course_activity=>course_activity}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + + <% if User.current.admin? ||is_teacher || comment.user == User.current%> + <%= link_to('鍒犻櫎', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => -1, :user_activity_id => user_activity_id, :course_activity=>course_activity}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> + <% end %> + +
+
+
+

@@ -372,4 +421,7 @@ $("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap'); $("#moreProject_<%=user_activity_id %>").show(); }); + $(function(){ + user_card_show_hide(); + }); \ No newline at end of file diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb index 9a9943e9b..56dafed08 100644 --- a/app/views/organizations/_org_course_message.html.erb +++ b/app/views/organizations/_org_course_message.html.erb @@ -157,3 +157,8 @@ <% end %>
+ diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb index 7f50b3725..a6183e891 100644 --- a/app/views/organizations/_org_course_news.html.erb +++ b/app/views/organizations/_org_course_news.html.erb @@ -121,3 +121,8 @@
+ diff --git a/app/views/organizations/_org_course_poll.html.erb b/app/views/organizations/_org_course_poll.html.erb index 10d1919a2..cb390f7f5 100644 --- a/app/views/organizations/_org_course_poll.html.erb +++ b/app/views/organizations/_org_course_poll.html.erb @@ -56,3 +56,8 @@ <% end %> + diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index ebab8354c..4340213a4 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -43,6 +43,13 @@ $(this).prev().css("color","#808080"); $(this).css("z-index", "1"); }) + + //浜岀骇鑿滃崟婊戝姩鏃剁澶存柟鍚戞帶鍒 + $(".homepageLeftMenuMoreIcon").toggle(function(){ + $(this).css("background","url(/images/homepage_icon.png) 100px -624px no-repeat"); + },function(){ + $(this).css("background","url(/images/homepage_icon.png) -74px -240px no-repeat"); + }); }) @@ -83,35 +90,55 @@ <% end %> <% else %> -
- <% if field.field_type == "Post" %> - <% if !field.subfield_subdomain_dir.nil? %> - <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> - <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> - <% else %> - <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> - <% end %> - <% else %> - <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> - <% end %> - <% if User.current.member_of_org?organization %> - <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "鍙戝竷甯栧瓙"%> +
+ <% if field.field_type == "Post" || field.field_type == "Complex" || field.field_type == "Compstu" || field.field_type == "Comptec" %> +
+ + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <% else %> + <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <% end %> + <% else %> + <% if field.field_type == "Comptec" %> + <%= link_to "#{field.name}", teachers_organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <% else %> + <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText homepageMenuControl hidden", :onclick => "$('#homepageLeftMenuPost').slideToggle();" %> + <% end %> + <% end %> + <% if User.current.logged? and User.current.admin_of_org?(organization) && field.field_type != "Comptec" %> + <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "鍙戝竷甯栧瓙" %> + <% end %> +
+ + + <% unless (field.sub_domains.count == 0 || !if_hidden_subdomain(field)) %> +
  • + +
  • <% end %> <% else %> - <% if !field.subfield_subdomain_dir.nil? %> - <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> - <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> +
    + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText homepageMenuControl hidden" %> + <% else %> + <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText homepageMenuControl hidden" %> + <% end %> <% else %> - <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText homepageMenuControl hidden" %> <% end %> - <% else %> - <%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %> - <% end %> - <% if User.current.member_of_org?organization %> - <%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "涓婁紶璧勬簮" %> - - <% end %> - + <% if User.current.member_of_org?organization %> + <%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "涓婁紶璧勬簮" %> + + <% end %> + +
    <% end %>
    + diff --git a/app/views/organizations/_org_subdomain.html.erb b/app/views/organizations/_org_subdomain.html.erb new file mode 100644 index 000000000..b096a14ae --- /dev/null +++ b/app/views/organizations/_org_subdomain.html.erb @@ -0,0 +1,11 @@ +<% subdomains.each do |subdomain|%> +
  • + <%= link_to subdomain.name, org_subfield_sub_domain_sub_document_comments_path(subdomain, :org_subfield_id => org_subfield_id), :class => "coursesLineGrey hidden", :title => subdomain.name %> +
  • +<% end %> +<%# if subdomains.size == 5 %> + + + + +<%# end%> \ No newline at end of file diff --git a/app/views/organizations/_org_subfield_leftD.html.erb b/app/views/organizations/_org_subfield_leftD.html.erb index 676d5d1c3..6af0e9f60 100644 --- a/app/views/organizations/_org_subfield_leftD.html.erb +++ b/app/views/organizations/_org_subfield_leftD.html.erb @@ -1,117 +1,104 @@ -
    -

    鍚堜綔浼欎即鏇村

    -
    -
      -
    • - - -
    • -
    • - - -
    • -
    -
    -
    -
    <
    -
    >
    -
    -
    -
    -
    - -<% if is_default_field?(field) %> - <% case field.name %> - <% when 'course' %> -

    鏆傛棤鍐呭锛

    - <% when 'project' %> -

    鏆傛棤鍐呭锛

    - <% end %> -<% else %> - <% if field.field_type == "Post" %> <%# 璁ㄨ绫诲瀷 %> - <% org_acts = get_subfield_acts field %> - <% unless org_acts.blank? %> - <% org_acts.each do |activity| %> -
    -

    鍚堜綔浼欎即鏇村

    -
    - <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' && activity.org_act_id != @organization.home_id %> - <% document = activity.org_act %> - <% org_subfield_id = params[:org_subfield_id] %> - <% flag = 2 %> - <% iamge_path = get_image_path_from_content(document.content) %> - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "369", :height => "169"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "369", :height => "169"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank" %> - <% end %> - <% elsif activity.container_type == 'OrgSubfield' %> - <% if activity.org_act_type == 'Message' and activity.org_act_id and Message.where("id=#{activity.org_act_id}").count > 0 %> - <% message = Message.find(activity.org_act_id) %> - <% if message.board.org_subfield_id %> - <% iamge_path = get_image_path_from_content(message.content) %> - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "369", :height => "169"), board_message_url_in_org(message.board.id,message.id), :target => "_blank" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "369", :height => "169"), board_message_url_in_org(message.board.id,message.id), :target => "_blank" %> - <% end %> - <% else %> - <% iamge_path = get_image_path_from_content(message.content) %> - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "370", :height => "220"), board_message_path(message.board,activity), :target => "_blank" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "370", :height => "220"), board_message_path(message.board,activity), :target => "_blank" %> - <% end %> - <% end %> - <% end %> - <% if activity.org_act_type == 'News' and News.where("id=?", activity.org_act_id).count > 0 %> - <% news = News.find(activity.org_act_id) %> - <% iamge_path = get_image_path_from_content(news.description) %> - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "369", :height => "169"), news_path(news), :target => "_blank" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "369", :height => "169"), news_path(news), :target => "_blank" %> - <% end %> - <% end %> - <% end %> -
    -
    - <% end %> - <% else %> -
    -

    鍚堜綔浼欎即鏇村

    -
    -
      -
    • - - -
    • -
    • - - -
    • -
    -
    -
    -
    <
    -
    >
    -
    -
    -
    -
    - <% end %> - <% elsif field.field_type == "Resource" %> - <% org_attachs = get_attach_org2(field) %> -
    - <% if !field.subfield_subdomain_dir.nil? %> - <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> - <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "369", :height => "169"), show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :target => "_blank" %> - <% else %> - <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "369", :height => "169"), show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :target => "_blank" %> - <% end %> - <% else %> - <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "369", :height => "169"), org_subfield_files_path(field), :class => "more-btn-center mt30", :target => "_blank" %> - <% end %> -
    - <% end %> -<% end %> +<% if is_default_field?(field) %> + <% case field.name %> +<% when 'course' %> +

    鏆傛棤鍐呭锛

    + <% when 'project' %> +

    鏆傛棤鍐呭锛

    + <% end %> +<% else %> + <% if field.field_type == "Post" %> <%# 璁ㄨ绫诲瀷 %> + <% org_acts = get_subfield_acts field %> + <% unless org_acts.blank? %> +
    +

    <%= field.name %> + <%= render :partial => 'organizations/link_subfield_more', :locals => {:field => field} %> +

    +
    +
      +
      +
      + <% org_acts.first(8).each do |activity| %> + <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' && activity.org_act_id != @organization.home_id %> + <% document = activity.org_act %> + <% org_subfield_id = params[:org_subfield_id] %> + <% flag = 2 %> + <% iamge_path = get_image_path_from_content(document.content) %> + <% if iamge_path.nil? %> +
    • <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "368", :height => "43"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class => "partnerimg" %>
    • + <% else %> +
    • <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "368", :height => "43"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class => "partnerimg" %>
    • + <% end %> + <% elsif activity.container_type == 'OrgSubfield' %> + <% if activity.org_act_type == 'Message' and activity.org_act_id and Message.where("id=#{activity.org_act_id}").count > 0 %> + <% message = Message.find(activity.org_act_id) %> + <% if message.board.org_subfield_id %> + <% iamge_path = get_image_path_from_content(message.content) %> + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "368", :height => "43"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class => "partnerimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "368", :height => "43"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class => "partnerimg" %> + <% end %> + <% else %> + <% iamge_path = get_image_path_from_content(message.content) %> + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "370", :height => "220"), board_message_path(message.board,activity), :target => "_blank", :class => "partnerimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "370", :height => "220"), board_message_path(message.board,activity), :target => "_blank", :class => "partnerimg" %> + <% end %> + <% end %> + <% end %> + <% if activity.org_act_type == 'News' and News.where("id=?", activity.org_act_id).count > 0 %> + <% news = News.find(activity.org_act_id) %> + <% iamge_path = get_image_path_from_content(news.description) %> + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "368", :height => "43"), news_path(news), :target => "_blank", :class => "partnerimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "368", :height => "43"), news_path(news), :target => "_blank", :class => "partnerimg" %> + <% end %> + <% end %> + <% end %> + <% end %> +
      +
      +
    +
    +
    +
    <
    +
    >
    +
    +
    +
    +
    + <% else %> + <%= render :partial => 'organizations/org_subfield_leftD_default', :locals => {:field => field} %> + <% end %> + <% elsif field.field_type == "Resource" %> + <% org_attachs = get_attach_org2(field) %> +
    + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", @organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "368", :height => "43"), show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :target => "_blank" %> + <% else %> + <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "368", :height => "43"), show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :target => "_blank" %> + <% end %> + <% else %> + <%= link_to image_tag("/images/default_blank/ad-default.jpg", :width => "368", :height => "43"), org_subfield_files_path(field), :class => "more-btn-center mt30", :target => "_blank" %> + <% end %> +
    + <% end %> +<% end %> + + diff --git a/app/views/organizations/_org_subfield_leftD_default.html.erb b/app/views/organizations/_org_subfield_leftD_default.html.erb new file mode 100644 index 000000000..257622836 --- /dev/null +++ b/app/views/organizations/_org_subfield_leftD_default.html.erb @@ -0,0 +1,19 @@ +
    +

    鏍忕洰鍚嶇О

    +
    +
      +
      +
    • +
    • +
    • +
    • +
      +
    +
    +
    +
    <
    +
    >
    +
    +
    +
    +
    diff --git a/app/views/organizations/_org_subfield_leftM1.html.erb b/app/views/organizations/_org_subfield_leftM1.html.erb index a987e23cb..e7481ce0a 100644 --- a/app/views/organizations/_org_subfield_leftM1.html.erb +++ b/app/views/organizations/_org_subfield_leftM1.html.erb @@ -1,256 +1,285 @@ -

    <%= field.name %>鏇村

    -
    -<% if is_default_field?(field) %> - <% case field.name %> - <% when 'course' %> - <% if @course_acts.blank? %> - <%= render :partial => 'organizations/org_subfield_leftM1_default', :locals => {:field => field} %> - <% else %> - <% @course_acts.first(1).each do |act| %> - <% if act.org_act_type == "HomeworkCommon" %> - <% activity = HomeworkCommon.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <%= link_to activity.name.to_s, student_work_index_url_in_org(activity.id), :target => '_blank', :class => "h3-title" %> -

    - <%= format_date activity.updated_at %> -
    -

    <%= activity.description.to_s.html_safe %>

    -
    -
    - <% elsif act.org_act_type == "Message" %> - <% activity = Message.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.content) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> - <% end %> -

    - <%= format_date activity.updated_on %> -
    -

    <%= activity.content.to_s.html_safe %>

    -
    -
    - <% elsif act.org_act_type == "News" %> - <% activity = News.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <%= link_to activity.title.to_s, news_url_in_org(activity.id), :target => '_blank', :class => "h3-title" %> -

    - <%= format_date activity.created_on %> -
    -

    <%= activity.description.to_s.html_safe %>

    -
    -
    - <% elsif act.org_act_type == "Poll" %> - <% activity = Poll.find(act.org_act_id) %> - <% has_commit = has_commit_poll?(activity.id ,User.current)%> - <% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> - <% iamge_path = get_image_path_from_content(activity.polls_description) %> - <% if ( activity.polls_status==2) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <% if has_commit %> - <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "h3-title" %> - <% else %> - <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "h3-title" %> - <% end %> -

    - <%= format_date activity.published_at %> -
    -

    <%= activity.polls_description.to_s.html_safe %>

    -
    -
    - <% end %> - <% end %> - <% end %> - <% end %> - <% when 'project' %> - <% if @project_acts.blank? %> - <%= render :partial => 'organizations/org_subfield_leftM1_default', :locals => {:field => field} %> - <% else %> - <% @project_acts.first(4).each do |act| %> - <% if act.org_act_type == "Issue" %> - <% activity = Issue.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :target => '_blank', :class => "h3-title" %> -

    - <%= format_date activity.updated_on %> -
    -

    <%= activity.description.to_s.html_safe %>

    -
    -
    - <% elsif act.org_act_type == "Message" %> - <% activity = Message.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.content) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> - <% end %> -

    - <%= format_date activity.updated_on %> -
    -

    <%= activity.content.to_s.html_safe %>

    -
    -
    - <% elsif act.org_act_type == "News" %> - <% activity = News.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <%= link_to activity.description.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "h3-title" %> -

    - 2016-04-08 -
    -

    <%= activity.description.to_s.html_safe %>

    -
    -
    - <% end %> - <% end %> - <% end %> - <% end %> -<% else %> - <% if field.field_type == "Post" %> - <% org_acts = get_subfield_acts field %> - <% if org_acts.blank? %> - <%= render :partial => 'organizations/org_subfield_leftM1_default', :locals => {:field => field} %> - <% else %> - <% org_acts.first(4).each do |activity| %> - <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' && activity.org_act_id != @organization.home_id %> - <% document = activity.org_act %> - <% org_subfield_id = params[:org_subfield_id] %> - <% flag = 2 %> - <% iamge_path = get_image_path_from_content(document.content) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => '_blank', :class => "h3-title" %> -

    - <%= format_date document.created_at %> -
    -

    <%= document.content.to_s.html_safe %>

    -
    -
    - <% else activity.container_type == 'OrgSubfield' %> - <% if activity.org_act_type == 'Message' and activity.org_act_id and Message.where("id=#{activity.org_act_id}").count > 0 %> - <% message = Message.find(activity.org_act_id) %> - <% if message.parent_id.nil? %> - <% content = message.content%> - <% else %> - <% content = message.parent.content%> - <% end %> - <% iamge_path = get_image_path_from_content(content) %> - <% if message.board.org_subfield_id %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <% if message.parent_id.nil? %> - <%= link_to message.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h3-title" %> - <% else %> - <%= link_to message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h3-title" %> - <% end %> -

    - <%= format_date message.created_on %> -
    -

    <%= content.to_s.html_safe %>

    -
    -
    - <% else %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <% if message.parent_id.nil? %> - <%= link_to message.subject.to_s.html_safe, board_message_path(message.board,message), :target => '_blank', :class => "h3-title" %> - <% else %> - <%= link_to message.parent.subject.to_s.html_safe, board_message_path(message.board,activity), :target => '_blank', :class => "h3-title" %> - <% end %> -

    - <%= format_date message.created_on %> -
    -

    <%= content.to_s.html_safe %>

    -
    -
    - <% end %> - <% end %> - <% if activity.org_act_type == 'News' and News.where("id=?", activity.org_act_id).count > 0 %> - <% news = News.find(activity.org_act_id) %> - <% iamge_path = get_image_path_from_content(news.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "380", :height => "165"), news_path(news), :target => "_blank", :class =>"sn-news-bigimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), news_path(news), :target => "_blank", :class =>"sn-news-bigimg" %> - <% end %> -

    - <%= link_to news.title.to_s, news_path(news), :target => '_blank', :class => "h3-title" %> -

    - <%= format_date news.created_on %> -
    -

    <%= news.description.to_s.html_safe %>

    -
    -
    - <% end %> - <% end %> - <% end %> - <% end %> - <% end %> -<% end %> - - + +<% if is_default_field?(field) %> + <% case field.name %> + <% when 'course' %> + <% if @course_acts.blank? %> +

    璇剧▼鍔ㄦ

    +
    + <%= render :partial => 'organizations/org_subfield_leftM1_default', :locals => {:field => field} %> + <% else %> +

    璇剧▼鍔ㄦ

    +
    + <% @course_acts.first(1).each do |act| %> + <% if act.org_act_type == "HomeworkCommon" %> + <% activity = HomeworkCommon.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to activity.name.to_s, student_work_index_url_in_org(activity.id), :target => '_blank', :class => "h3-title" %> +

    + <%= format_date activity.updated_at %> +
    +
    <%= activity.description.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", activity.name.to_s, student_work_index_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% elsif act.org_act_type == "Message" %> + <% activity = Message.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.content) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to activity.parent_id.nil? ? activity.subject.to_s.html_safe : activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> +

    + <%= format_date activity.updated_on %> +
    +
    <%= activity.content.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", activity.parent_id.nil? ? activity.subject.to_s.html_safe : activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% elsif act.org_act_type == "News" %> + <% activity = News.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to activity.title.to_s, news_url_in_org(activity.id), :target => '_blank', :class => "h3-title" %> +

    + <%= format_date activity.created_on %> +
    +
    <%= activity.description.to_s.html_safe %>
    +
    + +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", activity.title.to_s, news_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% elsif act.org_act_type == "Poll" %> + <% activity = Poll.find(act.org_act_id) %> + <% has_commit = has_commit_poll?(activity.id ,User.current)%> + <% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> + <% iamge_path = get_image_path_from_content(activity.polls_description) %> + <% if ( activity.polls_status==2) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <% if has_commit %> + <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "h3-title" %> + <% else %> + <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "h3-title" %> + <% end %> +

    + <%= format_date activity.published_at %> +
    +
    <%= activity.polls_description.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% end %> + <% end %> + <% end %> + <% end %> + <% when 'project' %> + <% if @project_acts.blank? %> +

    椤圭洰鍔ㄦ

    +
    + <%= render :partial => 'organizations/org_subfield_leftM1_default', :locals => {:field => field} %> + <% else %> +

    椤圭洰鍔ㄦ

    +
    + <% @project_acts.first(1).each do |act| %> + <% if act.org_act_type == "Issue" %> + <% activity = Issue.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :target => '_blank', :class => "h3-title" %> +

    + <%= format_date activity.updated_on %> +
    +
    <%= activity.description.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", activity.subject.to_s, issue_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% elsif act.org_act_type == "Message" %> + <% activity = Message.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.content) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to activity.parent_id.nil? ? activity.subject.to_s.html_safe : activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h3-title" %> +

    + <%= format_date activity.updated_on %> +
    +
    <%= activity.content.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", activity.parent_id.nil? ? activity.subject.to_s.html_safe : activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% elsif act.org_act_type == "News" %> + <% activity = News.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to activity.description.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "h3-title" %> +

    + 2016-04-08 +
    +
    <%= activity.description.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", news_url_in_org(activity.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% end %> + <% end %> + <% end %> + <% end %> +<% else %> + <% if field.field_type == "Post" %> + <% org_acts = get_subfield_acts field %> + <% if org_acts.blank? %> +

    <%= field.name %>

    +
    + <%= render :partial => 'organizations/org_subfield_leftM1_default', :locals => {:field => field} %> + <% else %> +

    <%= field.name %> + <%= render :partial => 'organizations/link_subfield_more', :locals => {:field => field} %> +

    +
    + <% org_acts.first(1).each do |activity| %> + <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' && activity.org_act_id != @organization.home_id %> + <% document = activity.org_act %> + <% org_subfield_id = params[:org_subfield_id] %> + <% flag = 2 %> + <% iamge_path = get_image_path_from_content(document.content) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => '_blank', :class => "h3-title" %> +

    + <%= format_date document.created_at %> +
    +
    <%= document.content.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% else activity.container_type == 'OrgSubfield' %> + <% if activity.org_act_type == 'Message' and activity.org_act_id and Message.where("id=#{activity.org_act_id}").count > 0 %> + <% message = Message.find(activity.org_act_id) %> + <% if message.parent_id.nil? %> + <% content = message.content%> + <% else %> + <% content = message.parent.content%> + <% end %> + <% iamge_path = get_image_path_from_content(content) %> + <% if message.board.org_subfield_id %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to message.parent_id.nil? ? message.subject.to_s.html_safe : message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h3-title" %> +

    + <%= format_date message.created_on %> +
    +
    <%= content.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", message.parent_id.nil? ? message.subject.to_s.html_safe : message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% else %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <% if message.parent_id.nil? %> + <%= link_to message.subject.to_s.html_safe, board_message_path(message.board,message), :target => '_blank', :class => "h3-title" %> + <% else %> + <%= link_to message.parent.subject.to_s.html_safe, board_message_path(message.board,activity), :target => '_blank', :class => "h3-title" %> + <% end %> +

    + <%= format_date message.created_on %> +
    +
    <%= content.to_s.html_safe %>
    +
    +
    + <% if message.parent_id.nil? %> + <%=link_to "鏌ョ湅鍏ㄦ枃>>", message.subject.to_s.html_safe, board_message_path(message.board,message), :target => "_blank", :class => "sn-link-grey2 sn-fr" %> + <% else %> + <%=link_to "鏌ョ湅鍏ㄦ枃>>", message.parent.subject.to_s.html_safe, board_message_path(message.board,activity), :target => "_blank", :class => "sn-link-grey2 sn-fr" %> + <% end %> +
    +
    + <% end %> + <% end %> + <% if activity.org_act_type == 'News' and News.where("id=?", activity.org_act_id).count > 0 %> + <% news = News.find(activity.org_act_id) %> + <% iamge_path = get_image_path_from_content(news.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-02.jpg", :width => "380", :height => "165"), news_path(news), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "380", :height => "165"), news_path(news), :target => "_blank", :class =>"sn-news-bigimg",:style=>"display:block;" %> + <% end %> +

    + <%= link_to news.title.to_s, news_path(news), :target => '_blank', :class => "h3-title" %> +

    + <%= format_date news.created_on %> +
    +
    <%= news.description.to_s.html_safe %>
    +
    +
    <%=link_to "鏌ョ湅鍏ㄦ枃>>", news.title.to_s, news_path(news), :target => "_blank", :class => "sn-link-grey2 sn-fr" %>
    +
    + <% end %> + <% end %> + <% end %> + <% end %> + <% end %> +<% end %> + + + + diff --git a/app/views/organizations/_org_subfield_leftM1_default.html.erb b/app/views/organizations/_org_subfield_leftM1_default.html.erb index 919d76363..d785b6225 100644 --- a/app/views/organizations/_org_subfield_leftM1_default.html.erb +++ b/app/views/organizations/_org_subfield_leftM1_default.html.erb @@ -1,8 +1,8 @@ -
    - -

    - -
    -

    -
    -
    +
    + +

    + +
    +

    +
    +
    diff --git a/app/views/organizations/_org_subfield_leftM2.html.erb b/app/views/organizations/_org_subfield_leftM2.html.erb index aec1a88fe..1beccb918 100644 --- a/app/views/organizations/_org_subfield_leftM2.html.erb +++ b/app/views/organizations/_org_subfield_leftM2.html.erb @@ -5,18 +5,19 @@ <% if @course_acts.blank? %> <%= render :partial => 'organizations/org_subfield_leftM2_default', :locals => {:field => field} %> <% else %> - <% @course_acts.first(4).each do |act| %> + <% @course_acts[1..4].each do |act| %> <% if act.org_act_type == "HomeworkCommon" %> <% activity = HomeworkCommon.find(act.org_act_id) %> <% iamge_path = get_image_path_from_content(activity.description) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/right_top.jpg", :width => "85", :height => "85"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    - <%= link_to activity.name.to_s, student_work_index_url_in_org(activity.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to activity.name.to_s, student_work_index_url_in_org(activity.id), :target => '_blank', :class => "h4-title fl mt10" %>...
    +

    <%= format_date activity.updated_at %>
    @@ -26,15 +27,15 @@ <% iamge_path = get_image_path_from_content(activity.content) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h4-title fl mt10" %>...
    <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h4-title fl mt10" %>...
    <% end %>

    <%= format_date activity.updated_on %> @@ -45,12 +46,12 @@ <% iamge_path = get_image_path_from_content(activity.description) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    - <%= link_to activity.title.to_s, news_url_in_org(activity.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to activity.title.to_s, news_url_in_org(activity.id), :target => '_blank', :class => "h4-title fl mt10" %>...

    <%= format_date activity.created_on %>
    @@ -63,15 +64,15 @@ <% if ( activity.polls_status==2) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    <% if has_commit %> - <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "h4-title fl mt10" %>...
    <% else %> - <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "h4-title fl mt10" %>...
    <% end %>

    <%= format_date activity.published_at %> @@ -85,18 +86,18 @@ <% if @project_acts.blank? %> <%= render :partial => 'organizations/org_subfield_leftM2_default', :locals => {:field => field} %> <% else %> - <% @project_acts.first(4).each do |act| %> + <% @project_acts[1..4].each do |act| %> <% if act.org_act_type == "Issue" %> <% activity = Issue.find(act.org_act_id) %> <% iamge_path = get_image_path_from_content(activity.description) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    - <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :target => '_blank', :class => "h4-title fl mt10" %>...

    <%= format_date activity.updated_on %>
    @@ -106,15 +107,15 @@ <% iamge_path = get_image_path_from_content(activity.content) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h4-title fl mt10" %>...
    <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "h4-title fl mt10" %>...
    <% end %>

    <%= format_date activity.updated_on %> @@ -125,12 +126,12 @@ <% iamge_path = get_image_path_from_content(activity.description) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    - <%= link_to activity.description.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to activity.description.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "h4-title fl mt10" %>...

    <%= format_date activity.created_on %>
    @@ -145,7 +146,7 @@ <% if org_acts.blank? %> <%= render :partial => 'organizations/org_subfield_leftM2_default', :locals => {:field => field} %> <% else %> - <% org_acts.first(4).each do |activity| %> + <% org_acts[1..4].each do |activity| %> <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' && activity.org_act_id != @organization.home_id %> <% document = activity.org_act %> <% org_subfield_id = params[:org_subfield_id] %> @@ -153,12 +154,12 @@ <% iamge_path = get_image_path_from_content(document.content) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    - <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => '_blank', :class => "h4-title fl mt10" %>...

    <%= format_date document.created_at %>
    @@ -175,15 +176,15 @@ <% if message.board.org_subfield_id %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    <% if message.parent_id.nil? %> - <%= link_to message.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to message.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h4-title fl mt10" %>...
    <% else %> - <%= link_to message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "h4-title fl mt10" %>...
    <% end %>

    <%= format_date message.created_on %> @@ -192,15 +193,15 @@ <% else %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    <% if message.parent_id.nil? %> - <%= link_to message.subject.to_s.html_safe, board_message_path(message.board,message), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to message.subject.to_s.html_safe, board_message_path(message.board,message), :target => '_blank', :class => "h4-title fl mt10" %>...
    <% else %> - <%= link_to message.parent.subject.to_s.html_safe, board_message_path(message.board,activity), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to message.parent.subject.to_s.html_safe, board_message_path(message.board,activity), :target => '_blank', :class => "h4-title fl mt10" %>...
    <% end %>

    <%= format_date message.created_on %> @@ -213,12 +214,12 @@ <% iamge_path = get_image_path_from_content(news.description) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "85", :height => "85"), news_path(news), :target => "_blank", :class =>"sn-news-smallimg fl" %> + <%= link_to image_tag("/images/default_blank/left-03.jpg", :width => "85", :height => "85"), news_path(news), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% else %> <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "85", :height => "85"), news_path(news), :target => "_blank", :class =>"sn-news-smallimg fl" %> <% end %>

    - <%= link_to news.title.to_s, news_path(news), :target => '_blank', :class => "h4-title fl mt10" %> +
    <%= link_to news.title.to_s, news_path(news), :target => '_blank', :class => "h4-title fl mt10" %>...

    <%= format_date news.created_on %>
    @@ -230,4 +231,15 @@ <% end %> <% end %>
    -
    \ No newline at end of file +
    + \ No newline at end of file diff --git a/app/views/organizations/_org_subfield_leftM2_default.html.erb b/app/views/organizations/_org_subfield_leftM2_default.html.erb index 1b47d9d5c..639b8d5be 100644 --- a/app/views/organizations/_org_subfield_leftM2_default.html.erb +++ b/app/views/organizations/_org_subfield_leftM2_default.html.erb @@ -1,26 +1,38 @@ - \ No newline at end of file +
    + +

    + 鏃堕棿 +
    +
    +
    + +

    + 鏃堕棿 +
    +
    +
    + +

    + 鏃堕棿 +
    +
    +
    + +

    + 鏃堕棿 +
    +
    + + \ No newline at end of file diff --git a/app/views/organizations/_org_subfield_leftMD.html.erb b/app/views/organizations/_org_subfield_leftMD.html.erb index 2db926776..d0439439a 100644 --- a/app/views/organizations/_org_subfield_leftMD.html.erb +++ b/app/views/organizations/_org_subfield_leftMD.html.erb @@ -1,258 +1,300 @@ -
    -

    <%= field.name %>鏇村

    -
    + <% if is_default_field?(field) %> <% case field.name %> <% when 'course' %> <% if @course_acts.blank? %> - <%= render :partial => 'organizations/org_subfield_leftMD_default', :locals => {:field => field} %> +
    +

    璇剧▼鍔ㄦ

    +
    + <%= render :partial => 'organizations/org_subfield_leftMD_default', :locals => {:field => field} %> +
    +
    +
    <% else %> - <% @course_acts.first(4).each do |act| %> - <% if act.org_act_type == "HomeworkCommon" %> - <% activity = HomeworkCommon.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <%= link_to activity.name.to_s, student_work_index_url_in_org(activity.id), :target => '_blank', :class => "resources-title" %> -

    -
    - <%= link_to activity.description.to_s.html_safe, student_work_index_url_in_org(activity.id), :target => '_blank', :class => "resources-tag" %> -
    - 鏇村 -
    - <% elsif act.org_act_type == "Message" %> - <% activity = Message.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.content) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-title" %> - <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-title" %> - <% end %> -

    -
    - <%= link_to activity.content.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-tag" %> -
    - 鏇村 -
    - <% elsif act.org_act_type == "News" %> - <% activity = News.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <%= link_to activity.title.to_s, news_url_in_org(activity.id), :target => '_blank', :class => "resources-title" %> -

    -
    - <%= link_to activity.description.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "resources-tag" %> -
    - 鏇村 -
    - <% elsif act.org_act_type == "Poll" %> - <% activity = Poll.find(act.org_act_id) %> - <% has_commit = has_commit_poll?(activity.id ,User.current)%> - <% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> - <% iamge_path = get_image_path_from_content(activity.polls_description) %> - <% if ( activity.polls_status==2) %> +
    +

    璇剧▼鍔ㄦ

    +
    + <% @course_acts.first(4).each do |act| %> + <% if act.org_act_type == "HomeworkCommon" %> + <% activity = HomeworkCommon.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), student_work_index_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% end %> +

    + <%= link_to activity.name.to_s, student_work_index_url_in_org(activity.id), :target => '_blank', :class => "resources-title sn-hidden" %> +

    +
    + <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => activity.id, :content=> activity.description, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to activity.description.to_s.html_safe, student_work_index_url_in_org(activity.id), :target => '_blank', :class => "resources-tag" %> +
    + <%#= link_to "鏇村", student_work_index_url_in_org(activity.id), :class => "more-btn", :target => "_blank" %> +
    + <% elsif act.org_act_type == "Message" %> + <% activity = Message.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.content) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-resourcesimg" %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-resourcesimg" %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> <% end %>

    - <% if has_commit %> - <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "resources-title" %> + <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-title sn-hidden" %> <% else %> - <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "resources-title" %> + <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-title sn-hidden" %> <% end %>

    - <%= link_to activity.polls_description.to_s.html_safe, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "resources-tag" %> + <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => activity.id, :content=> activity.content, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to activity.content.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-tag" %> +
    +
    + <% elsif act.org_act_type == "News" %> + <% activity = News.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), news_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% end %> +

    + <%= link_to activity.title.to_s, news_url_in_org(activity.id), :target => '_blank', :class => "resources-title sn-hidden" %> +

    +
    + <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => activity.id, :content=> activity.description, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to activity.description.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "resources-tag" %>
    - 鏇村 + <%#= link_to "鏇村", news_url_in_org(activity.id), :class => "more-btn", :target => "_blank" %>
    + <% elsif act.org_act_type == "Poll" %> + <% activity = Poll.find(act.org_act_id) %> + <% has_commit = has_commit_poll?(activity.id ,User.current)%> + <% poll_name = activity.polls_name.empty? ? l(:label_poll_new) : activity.polls_name%> + <% iamge_path = get_image_path_from_content(activity.polls_description) %> + <% if ( activity.polls_status==2) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-resourcesimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => "_blank", :class =>"sn-resourcesimg" %> + <% end %> +

    + <% if has_commit %> + <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "resources-title sn-hidden" %> + <% else %> + <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "resources-title sn-hidden" %> + <% end %> +

    +
    + <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => activity.id, :content=> activity.polls_description, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to activity.polls_description.to_s.html_safe, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :target => '_blank', :class => "resources-tag" %> +
    +
    + <% end %> <% end %> <% end %> - <% end %> +
    +
    +
    <% end %> <% when 'project' %> <% if @project_acts.blank? %> - <%= render :partial => 'organizations/org_subfield_leftMD_default', :locals => {:field => field} %> +
    +

    椤圭洰鍔ㄦ

    +
    + <%= render :partial => 'organizations/org_subfield_leftMD_default', :locals => {:field => field} %> +
    +
    +
    <% else %> - <% @project_acts.first(4).each do |act| %> - <% if act.org_act_type == "Issue" %> - <% activity = Issue.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :target => '_blank', :class => "resources-title" %> -

    -
    - <%= link_to activity.description.to_s.html_safe, issue_url_in_org(activity.id), :target => '_blank', :class => "resources-tag" %> -
    - 鏇村 -
    - <% elsif act.org_act_type == "Message" %> - <% activity = Message.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.content) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-title" %> +
    +

    椤圭洰鍔ㄦ

    +
    + <% @project_acts.first(4).each do |act| %> + <% if act.org_act_type == "Issue" %> + <% activity = Issue.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-title" %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), issue_url_in_org(activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> <% end %> -

    -
    - <%= link_to activity.content.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-tag" %> +

    + <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :target => '_blank', :class => "resources-title sn-hidden" %> +

    +
    + <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => activity.id, :content=> activity.description, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to activity.description.to_s.html_safe, issue_url_in_org(activity.id), :target => '_blank', :class => "resources-tag" %> +
    - 鏇村 -
    - <% elsif act.org_act_type == "News" %> - <% activity = News.find(act.org_act_id) %> - <% iamge_path = get_image_path_from_content(activity.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <%= link_to activity.description.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "resources-title" %> -

    -
    - <%= link_to activity.content.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "resources-tag" %> -
    - 鏇村 -
    + <% elsif act.org_act_type == "Message" %> + <% activity = Message.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.content) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% end %> +

    + <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-title sn-hidden" %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-title sn-hidden" %> + <% end %> +

    +
    + <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => activity.id, :content=> activity.content, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to activity.content.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-tag" %> +
    +
    + <% elsif act.org_act_type == "News" %> + <% activity = News.find(act.org_act_id) %> + <% iamge_path = get_image_path_from_content(activity.description) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_url_in_org(activity.board_id, activity.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% end %> +

    + <%= link_to activity.description.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "resources-title sn-hidden" %> +

    +
    + <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => activity.id, :content=> activity.description, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to activity.content.to_s.html_safe, news_url_in_org(activity.id), :target => '_blank', :class => "resources-tag" %> +
    + <%#= link_to "鏇村", news_url_in_org(activity.id), :class => "more-btn", :target => "_blank" %> +
    + <% end %> <% end %> - <% end %> +
    +
    +
    + <% end %> <% end %> <% else %> <% if field.field_type == "Post" %> <% org_acts = get_subfield_acts field %> <% if org_acts.blank? %> - <%= render :partial => 'organizations/org_subfield_leftMD_default', :locals => {:field => field} %> +
    +

    <%= field.name %>

    +
    + <%= render :partial => 'organizations/org_subfield_leftMD_default', :locals => {:field => field} %> +
    +
    +
    <% else %> - <% org_acts.first(4).each do |activity| %> - <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' && activity.org_act_id != @organization.home_id %> - <% document = activity.org_act %> - <% org_subfield_id = params[:org_subfield_id] %> - <% flag = 2 %> - <% iamge_path = get_image_path_from_content(document.content) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => '_blank', :class => "resources-title" %> -

    -
    - <%= link_to document.content.to_s.html_safe, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => '_blank', :class => "resources-tag" %> -
    - 鏇村 -
    - <% else activity.container_type == 'OrgSubfield' %> - <% if activity.org_act_type == 'Message' and activity.org_act_id and Message.where("id=#{activity.org_act_id}").count > 0 %> - <% message = Message.find(activity.org_act_id) %> - <% if message.parent_id.nil? %> - <% content = message.content%> - <% else %> - <% content = message.parent.content%> +
    +

    <%= field.name %> + <%= render :partial => 'organizations/link_subfield_more', :locals => {:field => field} %> +

    +
    + <% org_acts.first(4).each do |activity| %> + <% if activity.container_type == 'Organization' && activity.org_act_type == 'OrgDocumentComment' && activity.org_act_id != @organization.home_id %> + <% document = activity.org_act %> + <% org_subfield_id = params[:org_subfield_id] %> + <% flag = 2 %> + <% iamge_path = get_image_path_from_content(document.content) %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% end %> +

    + <%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => '_blank', :class => "resources-title sn-hidden" %> +

    +
    + <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => document.id, :content=> document.content, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to document.content.to_s.html_safe, org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :target => '_blank', :class => "resources-tag" %> +
    + <%#= link_to "鏇村", org_document_comment_path(:id => document.id, :organization_id => document.organization.id), :class => "more-btn", :target => "_blank" %> + +
    + <% else activity.container_type == 'OrgSubfield' %> + <% if activity.org_act_type == 'Message' and activity.org_act_id and Message.where("id=#{activity.org_act_id}").count > 0 %> + <% message = Message.find(activity.org_act_id) %> + <% if message.parent_id.nil? %> + <% content = message.content%> + <% else %> + <% content = message.parent.content%> + <% end %> + <% iamge_path = get_image_path_from_content(content) %> + <% if message.board.org_subfield_id %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <% end %> +

    + <% if message.parent_id.nil? %> + <%= link_to message.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "resources-title sn-hidden" %> + <% else %> + <%= link_to message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "resources-title sn-hidden" %> + <% end %> +

    +
    + <%= render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => message.id, :content=> content, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to content.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-tag" %> +
    + <%#= link_to "鏇村", board_message_url_in_org(message.board.id,message.id), :class => "more-btn", :target => "_blank" %> +
    + <% else %> +
    + <% if iamge_path.nil? %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-resourcesimg" %> + <% else %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-resourcesimg" %> + <% end %> +

    + <% if message.parent_id.nil? %> + <%= link_to message.subject.to_s.html_safe, board_message_path(message.board,message), :target => '_blank', :class => "resources-title sn-hidden" %> + <% else %> + <%= link_to message.parent.subject.to_s.html_safe, board_message_path(message.board,activity), :target => '_blank', :class => "resources-title sn-hidden" %> + <% end %> +

    +
    + <%= render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => message.id, :content=> content, :maxheight=>54, :maxwordsnum => 28} %> + <%#= link_to content.to_s.html_safe, board_message_path(message.board,activity), :target => '_blank', :class => "resources-tag" %> +
    + <%#= link_to "鏇村", board_message_path(message.board,activity), :class => "more-btn", :target => "_blank" %> +
    + <% end %> <% end %> - <% iamge_path = get_image_path_from_content(content) %> - <% if message.board.org_subfield_id %> + <% if activity.org_act_type == 'News' and News.where("id=?", activity.org_act_id).count > 0 %> + <% news = News.find(activity.org_act_id) %> + <% iamge_path = get_image_path_from_content(news.description) %>
    <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <%= link_to image_tag("/images/default_blank/left-04.jpg", :width => "185", :height => "125"), news_path(news), :target => "_blank", :class =>"sn-resourcesimg" %> <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_url_in_org(message.board.id,message.id), :target => "_blank", :class =>"sn-resourcesimg" %> + <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), news_path(news), :target => "_blank", :class =>"sn-resourcesimg" %> <% end %>

    - <% if message.parent_id.nil? %> - <%= link_to message.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "resources-title" %> - <% else %> - <%= link_to message.parent.subject.to_s.html_safe, board_message_url_in_org(message.board.id,message.id), :target => '_blank', :class => "resources-title" %> - <% end %> + <%= link_to news.title.to_s, news_path(news), :target => '_blank', :class => "resources-title sn-hidden" %>

    - <%= link_to content.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :target => '_blank', :class => "resources-tag" %> + <%#= link_to news.description.to_s.html_safe, news_path(news), :target => '_blank', :class => "resources-tag" %> + <%= render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id => news.id, :content=> news.description, :maxheight=>54, :maxwordsnum => 28, :maxwordsnum => 28} %>
    - 鏇村 -
    - <% else %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), board_message_path(message.board,activity), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <% if message.parent_id.nil? %> - <%= link_to message.subject.to_s.html_safe, board_message_path(message.board,message), :target => '_blank', :class => "resources-title" %> - <% else %> - <%= link_to message.parent.subject.to_s.html_safe, board_message_path(message.board,activity), :target => '_blank', :class => "resources-title" %> - <% end %> -

    -
    - <%= link_to content.to_s.html_safe, board_message_path(message.board,activity), :target => '_blank', :class => "resources-tag" %> -
    - 鏇村 + <%#= link_to "鏇村", news_path(news), :class => "more-btn", :target => "_blank" %>
    <% end %> <% end %> - <% if activity.org_act_type == 'News' and News.where("id=?", activity.org_act_id).count > 0 %> - <% news = News.find(activity.org_act_id) %> - <% iamge_path = get_image_path_from_content(news.description) %> -
    - <% if iamge_path.nil? %> - <%= link_to image_tag("/images/default_blank/files-default.jpg", :width => "185", :height => "125"), news_path(news), :target => "_blank", :class =>"sn-resourcesimg" %> - <% else %> - <%= link_to image_tag("/files/uploads/image#{iamge_path}", :width => "185", :height => "125"), news_path(news), :target => "_blank", :class =>"sn-resourcesimg" %> - <% end %> -

    - <%= link_to news.title.to_s, news_path(news), :target => '_blank', :class => "resources-title" %> -

    -
    - <%= link_to news.description.to_s.html_safe, news_path(news), :target => '_blank', :class => "resources-tag" %> -
    - 鏇村 -
    - <% end %> <% end %> - <% end %> +
    +
    +
    <% end %> <% end %> <% end %> -
    -
    -
    \ No newline at end of file diff --git a/app/views/organizations/_org_subfield_leftMD_default.html.erb b/app/views/organizations/_org_subfield_leftMD_default.html.erb index 4268c7cc8..c080d5481 100644 --- a/app/views/organizations/_org_subfield_leftMD_default.html.erb +++ b/app/views/organizations/_org_subfield_leftMD_default.html.erb @@ -1,11 +1,11 @@ \ No newline at end of file diff --git a/app/views/organizations/_org_subfield_leftT.html.erb b/app/views/organizations/_org_subfield_leftT.html.erb index e64044a6b..f683aabad 100644 --- a/app/views/organizations/_org_subfield_leftT.html.erb +++ b/app/views/organizations/_org_subfield_leftT.html.erb @@ -14,7 +14,7 @@ <% iamge_path = get_image_path_from_content(activity.description) %> -<% end%> \ No newline at end of file +<% end%> + \ No newline at end of file diff --git a/app/views/poll/_new_mulit.html.erb b/app/views/poll/_new_mulit.html.erb index 8a2205760..d25d34542 100644 --- a/app/views/poll/_new_mulit.html.erb +++ b/app/views/poll/_new_mulit.html.erb @@ -3,7 +3,7 @@
    - +
    @@ -13,7 +13,7 @@
    -<% end%> \ No newline at end of file +<% end%> + \ No newline at end of file diff --git a/app/views/poll/_new_single.html.erb b/app/views/poll/_new_single.html.erb index 7588bf3b4..fe8e7b604 100644 --- a/app/views/poll/_new_single.html.erb +++ b/app/views/poll/_new_single.html.erb @@ -3,12 +3,12 @@
    - +
    -<% end%> \ No newline at end of file +<% end%> + \ No newline at end of file diff --git a/app/views/poll/_poll_form.html.erb b/app/views/poll/_poll_form.html.erb index e08b13033..73c783794 100644 --- a/app/views/poll/_poll_form.html.erb +++ b/app/views/poll/_poll_form.html.erb @@ -51,8 +51,8 @@ function chooseQuestionType(quest_type,quest_id){ } function add_MC(){ - $("#new_poll_question").html("<%= escape_javascript(render :partial => 'new_MC') %>"); - $("#poll_questions_title").focus(); + $("#new_poll_question_new").html("<%= escape_javascript(render :partial => 'new_MC') %>"); + $("#poll_questions_title_new").focus(); } function insert_MC(quest_type,quest_num,quest_id){ @@ -94,7 +94,7 @@ function add_MC(){ ''+ '
    '+ ''+ ''+ '
    -<% @stundet_works.each do |student_work|%> +<% @stundet_works.each_with_index do |student_work, i|%> <% if @is_evaluation%> - <%= render :partial => "evaluation_work", :locals => {:student_work => student_work}%> + <%= render :partial => "evaluation_work", :locals => {:student_work => student_work, :index => i}%> <% else%> - <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work}%> + <%= render :partial => "evaluation_un_work", :locals => {:student_work => student_work, :index => i}%> <% end%>
    @@ -49,7 +49,6 @@
    <% end%> +
    + <%= form_tag org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id), :id => 'new_sub_document_form' do |f| %> +
    + +
    +
    +
    + + <% end %> +
    diff --git a/app/views/sub_document_comments/_show_newstyle.html.erb b/app/views/sub_document_comments/_show_newstyle.html.erb new file mode 100644 index 000000000..8b0f8c533 --- /dev/null +++ b/app/views/sub_document_comments/_show_newstyle.html.erb @@ -0,0 +1,111 @@ +
    +
    +
    鎮ㄧ殑浣嶇疆锛<%= link_to "棣栭〉", organization_path(@organization), :class => "sn-link-grey2" %> > + <%=link_to @org_subfield.name, organization_path(@organization, :org_subfield_id => @org_subfield.id), :class => "sn-link-grey2" %> > + <%= link_to @subdomain.name, org_subfield_sub_domain_sub_document_comments_path(:sub_domain_id => @subdomain.id, :org_subfield_id => @org_subfield.id), :class => "sn-link-grey2" %> > + <%= @document.title %>
    +
    +
    +

    <%= @document.title %>

    +
    +

    鏉ユ簮锛<%= @organization.name %> 鍙戝竷鏃堕棿锛<%= format_date(@document.created_at) %>

    +

    <%= @document.content.html_safe %>

    +
    +
    + + <% if User.current.logged? %> + <% comments_for_doc = @document.children.reorder("created_at desc") %> + <% count = @document.children.count() %> +
    +

    鐣欒█鏉<%= count %>鏉$暀瑷

    + <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc',:controller => 'sub_document_comments', :id => @document.id, :flag => true}, :html => {:multipart => true, :id => 'message_form', :class => "sn-reply-form", } do |f| %> + + <%#= f.kindeditor :sub_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor', :class => "sn-reply-text" %> +
    + 鍙戣〃 +
    + + <%#= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> + <% end %> + +
    +

    鍏ㄩ儴璇勮

    + +
    + <% comments_for_doc.each_with_index do |reply,i| %> +
    + + <%= link_to User.find(reply.creator_id).realname, user_url_in_org(reply.creator_id), :class => "sn-reply-username fl" %><%= time_from_now(reply.created_at) %> +
    + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => reply.id, :content=> reply.content} %> + <%#= reply.content.html_safe unless reply.content.nil? %> +
    + +
    +
    + <% end %> +
    + <% if count > 3 %> + + <% end %> +
    +
    + <% end %> +
    + + \ No newline at end of file diff --git a/app/views/sub_document_comments/_show_sub_document.html.erb b/app/views/sub_document_comments/_show_sub_document.html.erb new file mode 100644 index 000000000..135a48268 --- /dev/null +++ b/app/views/sub_document_comments/_show_sub_document.html.erb @@ -0,0 +1,161 @@ +
    +
    +
    + <%= link_to image_tag(url_to_avatar(User.find(document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(document.creator_id) %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => User.find(document.creator_id)} %> +
    +
    +
    + <%= link_to User.find(document.creator_id), user_url_in_org(document.creator.id), :class => "newsBlue mr15" %> + TO  <%= link_to @organization.name, organization_path(@organization), :class => "newsBlue" %> + | + <%=link_to @org_subfield.name, organization_path(@organization, :org_subfield_id => @org_subfield.id), :class => "newsBlue" %> + | + <%=link_to @subdomain.name, org_subfield_sub_domain_sub_document_comments_path(:sub_domain_id => @subdomain.id, :org_subfield_id => @org_subfield.id), :class => "newsBlue" %> + + <%# if document.organization.home_id == document.id %> + + <%# end %> +
    + +
    + 鍙戝竷鏃堕棿锛<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %> +
    +
    + 鏇存柊鏃堕棿锛<%= format_time(OrgActivity.where("org_act_type='#{document.class}' and org_act_id =#{document.id}").first.updated_at) %> +
    +
    + <% unless document.content.blank? %> + <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id => document.id, :content => document.content} %> + <% end %> +
    + + +
    +
    + <%#= render :partial=>"attachments/activity_attach", :locals=>{:activity => document} %> +
    + + <% if User.current.admin? || User.current.admin_of_org?(@organization) || User.current.id == document.creator_id %> +
    +
      +
    • +
        + + + + + +
      • + <%= link_to "缂栬緫鏂囩珷", edit_org_subfield_sub_domain_sub_document_comment_path(document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => document.sub_domain.id, :flag => flag), :class => "postOptionLink" %> +
      • +
      • + <%= link_to "鍒犻櫎鏂囩珷", org_subfield_sub_domain_sub_document_comment_path(document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => document.sub_domain.id, :flag => flag), :method => 'delete', + :data => {:confirm => l(:text_are_you_sure)}, + :remote => true, :class => 'postOptionLink' %> +
      • +
      +
    • +
    +
    +
    + <% end %> + + +
    +
    + + <% comments_for_doc = document.children.reorder("created_at desc") %> + <% count = document.children.count() %> + +
    +
    +
    鍥炲 + <%= count>0 ? "锛#{count}锛" : "" %> + + + + + + + +
    + <% if count > 3 %> + + <% end %> +
    +
    +
      + <% reply_id = 0 %> + <% comments_for_doc.each do |comment| %> + <% reply_id += 1 %> +
    • +
      <%= link_to image_tag(url_to_avatar(User.find(comment.creator_id)), :width => 33, :height => 33, :alt => "鐢ㄦ埛澶村儚"), user_url_in_org(comment.creator_id) %>
      +
      +
      + <%= link_to User.find(comment.creator_id), user_url_in_org(comment.creator_id), :class => "newsBlue mr10 f14" %> + <%= format_activity_day(comment.created_at) %> <%= format_time(comment.created_at, false) %> + + + + + + + +
      + <% unless comment.content.blank? %> +
      <%= comment.content.html_safe %>
      + <% end %> +
      +
      +
    • + <% end %> +
    +
    +
    +
    + <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "鐢ㄦ埛澶村儚"), user_url_in_org(User.current.id) %> +
    +
    +
    + <%= form_for('new_form', :url => add_reply_org_subfield_sub_domain_sub_document_comment_path(:id => document.id, :act_id => act.id, :flag => flag), :method => "post", :remote => true) do |f| %> + +
    + + + +
    +

    + <% end %> +
    +
    +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/app/views/sub_document_comments/_show_sub_document_newstyle.html.erb b/app/views/sub_document_comments/_show_sub_document_newstyle.html.erb new file mode 100644 index 000000000..a82e24ad4 --- /dev/null +++ b/app/views/sub_document_comments/_show_sub_document_newstyle.html.erb @@ -0,0 +1,32 @@ +
    +
    +
    +
    + 鎮ㄧ殑浣嶇疆锛<%= link_to "棣栭〉", organization_path(@organization), :class => "sn-link-grey2" %> > + <%=link_to @org_subfield.name, organization_path(@organization, :org_subfield_id => @org_subfield.id), :class => "sn-link-grey2" %> > + <%= link_to @subdomain.name, org_subfield_sub_domain_sub_document_comments_path(:sub_domain_id => @subdomain.id, :org_subfield_id => @org_subfield.id), :class => "sn-link-grey2" %> +
    +
    +
    +

    <%= @subdomain.name %>

    +
      + <% documents.each do |document| %> +
    • +
      <%=link_to document.title, org_subfield_sub_domain_sub_document_comment_path(document, :org_subfield_id => @org_subfield, :sub_domain_id => @subdomain), :class => "sn-newslist-titile fl", :target => "_blank" %> + <%= format_date(document.created_at) %> + 鍥炲锛<%= document.children.count %>锛 + +
      +
    • + <% end %> +
    + +
    +
      + <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => true, :remote => @is_remote, :flag => true %> +
      +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/sub_document_comments/add_reply.js.erb b/app/views/sub_document_comments/add_reply.js.erb new file mode 100644 index 000000000..06919628b --- /dev/null +++ b/app/views/sub_document_comments/add_reply.js.erb @@ -0,0 +1,2 @@ +$("#organization_document_<%= @act.id %>").replaceWith("<%= escape_javascript(render :partial => 'sub_document_comments/show_sub_document', :locals => {:document => @document,:flag => params[:flag], :act => @act, :organization => @organization}) %>"); +sd_create_editor_from_data(<%= @act.id %>,"","100%", "<%=@act.class.to_s%>"); diff --git a/app/views/sub_document_comments/destroy.js.erb b/app/views/sub_document_comments/destroy.js.erb new file mode 100644 index 000000000..4a45e48dd --- /dev/null +++ b/app/views/sub_document_comments/destroy.js.erb @@ -0,0 +1,6 @@ +//location.reload(); +<% if params[:detail_page] %> +window.location.href = '<%= org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id)%>'; +<% else %> +window.location.reload(); +<% end %> \ No newline at end of file diff --git a/app/views/sub_document_comments/edit.html.erb b/app/views/sub_document_comments/edit.html.erb new file mode 100644 index 000000000..7fe93d79b --- /dev/null +++ b/app/views/sub_document_comments/edit.html.erb @@ -0,0 +1,63 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> + <%= javascript_include_tag "des_kindEditor" %> +<% end %> + + +
    +
    缂栬緫鏂囩珷
    +
    +
    +
    +
    + <%= form_tag url_for(:controller => 'sub_document_comments',:action => 'update', :id => @sub_document.id, :flag => @flag, :org_subfield_id => params[:org_subfield_id], :sub_domain_id => params[:sub_domain_id]), :method => 'put', :id => 'new_org_document_form' do |f| %> +
    + +
    +
    +
    +
    +
    + + <%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %> +
    +
    + +

    +

    +

    +
    + + + + + + +
    +
    + 纭畾 + + 鍙栨秷 +
    +
    +
    + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/sub_document_comments/index.html.erb b/app/views/sub_document_comments/index.html.erb new file mode 100644 index 000000000..7e56b0242 --- /dev/null +++ b/app/views/sub_document_comments/index.html.erb @@ -0,0 +1,20 @@ +<% if @organization.switch_type %> + <% unless @documents.nil? %> + <%= render :partial => 'sub_document_comments/show_sub_document_newstyle', :locals => {:documents => @documents} %> + <% end %> +<% else %> + <%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> + <% end %> + <%= render :partial => 'new' %> + <% unless @documents.nil? %> + <% @documents.each do |document| %> + + <%= render :partial => 'sub_document_comments/show_sub_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='SubDocumentComment'and org_act_id=?", document.id).first, :flag => 0} %> + <% end %> + <% end %> +<% end %> diff --git a/app/views/sub_document_comments/new.html.erb b/app/views/sub_document_comments/new.html.erb new file mode 100644 index 000000000..de8436f7c --- /dev/null +++ b/app/views/sub_document_comments/new.html.erb @@ -0,0 +1,71 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> + <%= javascript_include_tag "des_kindEditor" %> +<% end %> + + +
    +
    <%= OrgSubfield.try(:find, params[:field_id]).try(:name) %>
    +
    +
    + <%= form_tag org_subfield_sub_domain_sub_document_comment_path(:org_subfield_id => @org_subfield.id, :sub_domain_id => @subdomain.id), :id => 'new_sub_document_form' do |f| %> +
    + +
    +
    +
    +
    +
    +
    + + <%#= kindeditor_tag 'org_document_comment[content]','', :editor_id => 'org_document_description_editor', :height => "150px" %> +
    +
    +

    +

    +

    +
    +
    +
    + <%#= render :partial => 'org_document_comments/attachment', :locals => {:container => nil} %> +
    +
    +
    + +
    + 纭畾 + + 鍙栨秷 +
    +
    +
    + <% end %> +
    diff --git a/app/views/sub_document_comments/show.html.erb b/app/views/sub_document_comments/show.html.erb new file mode 100644 index 000000000..3155c178b --- /dev/null +++ b/app/views/sub_document_comments/show.html.erb @@ -0,0 +1,191 @@ +<% if @organization.switch_type %> + <%= render :partial => 'sub_document_comments/show_newstyle', :locals => {:document => @document} %> +<% else %> + <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"create_kindeditor",'blog' %> + +
    +
    +
    + <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(@document.creator_id) %> +
    +
    +
    + <%= link_to User.find(@document.creator_id), user_url_in_org(@document.creator_id), :class => "newsBlue mr15" %> + TO  <%= link_to @organization.name, organization_path(@organization), :class => "newsBlue" %> + | + <%=link_to @org_subfield.name, organization_path(@organization, :org_subfield_id => @org_subfield.id), :class => "newsBlue" %> + | + <%=link_to @subdomain.name, org_subfield_sub_domain_sub_document_comments_path(:sub_domain_id => @subdomain.id, :org_subfield_id => @org_subfield.id), :class => "newsBlue" %> + <%# if @organization.home_id == @document.id %> + + <%# else %> + + <%# end %> +
    +
    <%= link_to @document.title %>
    +
    + 鍙戝竷鏃堕棿锛<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %>
    + <% unless @document.content.blank? %> +
    + <%= @document.content.html_safe %> +
    + <% end %> +
    + <%#= render :partial=>"attachments/activity_attach", :locals=>{:activity => @document} %> + <%#= link_to_attachments_course @document, :author => false %> +
    + + <% if User.current.admin? || User.current.admin_of_org?(@organization) || User.current.id == @document.creator_id %> +
    +
      +
    • +
        + + + + + +
      • + <%= link_to "缂栬緫鏂囩珷", edit_org_subfield_sub_domain_sub_document_comment_path(@document, :org_subfield_id=> params[:org_subfield_id], :sub_domain_id => @document.sub_domain.id, :flag => 1), :class => "postOptionLink" %> +
      • +
      • + <%= link_to "鍒犻櫎鏂囩珷", org_document_comment_path(:id => @document.id, :organization_id => @organization.id, :detail_page => 1), :method => 'delete', + :data => {:confirm => l(:text_are_you_sure)}, + :remote => true, :class => 'postOptionLink' %> +
      • +
      +
    • +
    +
    +
    + <% end %> +
    +
    + <% comments_for_doc = @document.children.reorder("created_at desc") %> + <% count = @document.children.count() %> + +
    + <%# if count > 0 %> +
    +
    鍥炲 + <%= count>0 ? "锛#{count}锛" : "" %> + + <%# if @document.creator_id.to_i == User.current.id.to_i %> + + <%# else %> + <%#=render :partial=> "praise_tread/praise", :locals => {:activity=>@document, :user_activity_id=>@document.id,:type=>"activity"}%> + <%# end %> + +
    + <% if count > 3 %> + + <% end %> +
    +
    + <% comments_for_doc.each_with_index do |reply,i| %> + + <% user = User.find(reply.creator_id) %> +
    +
    + <%= link_to image_tag(url_to_avatar(user), :width => 33,:height => 33), user_url_in_org(user.id) %> +
    +
    + <%= link_to User.find(reply.creator_id).realname, user_url_in_org(reply.creator_id), :class => "newsBlue mr10 f14" %> +
    + <%= reply.content.html_safe unless reply.content.nil? %> +
    +
    + <%= format_time(reply.created_at) %> + +
    +

    +
    +
    +
    + <% end %> +
    +
    + <%# end %> + <% if User.current.logged?%> +
    + +
    +
    + <%= form_for :org_comment, :url => {:action => 'add_reply_in_doc', :controller => 'sub_document_comments', :id => @document.id}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= f.kindeditor :sub_content,:width=>'99%',:height => '100px;',:editor_id=>'message_content_editor' %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'message_content_editor.html("");', :class => " grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_reply), "javascript:void(0)", :onclick => "message_content_editor.sync();$('#message_form').submit();", :class => "blue_btn fr c_white mt10 mb10", :style => "margin-right: 5px;" %> + <% end %> +
    +
    +
    + <% end %> +
    +
    + + +<% end %> diff --git a/app/views/sub_document_comments/update.js.erb b/app/views/sub_document_comments/update.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/sub_domains/_new.html.erb b/app/views/sub_domains/_new.html.erb new file mode 100644 index 000000000..25b660750 --- /dev/null +++ b/app/views/sub_domains/_new.html.erb @@ -0,0 +1,27 @@ +
    +
    娣诲姞浜岀骇鐩綍
    + <%= form_tag url_for(:controller => 'sub_domains', :action => 'create', :org_subfield_id => field.id), :id=> 'add_subfield_form_subdomain',:remote => true do %> + 浜岀骇鏍忕洰鍚嶇О + +
      +
    • 鏍忕洰绫诲瀷
    • +
    • + + +
    • + + + + +
    • +
    + + + <% end %> +
    +
    + + + \ No newline at end of file diff --git a/app/views/sub_domains/create.js.erb b/app/views/sub_domains/create.js.erb new file mode 100644 index 000000000..0990e35de --- /dev/null +++ b/app/views/sub_domains/create.js.erb @@ -0,0 +1,8 @@ +<% if @res %> +$("#org_subfield_list").html(""); +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); +<% end %> +$("#subfield_name").val(""); +$("#sub_dir").val(""); \ No newline at end of file diff --git a/app/views/sub_domains/destroy.js.erb b/app/views/sub_domains/destroy.js.erb new file mode 100644 index 000000000..913c400f7 --- /dev/null +++ b/app/views/sub_domains/destroy.js.erb @@ -0,0 +1,4 @@ +$("#org_subfield_list").html(""); +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/sub_domains/domain_update_priority.js.erb b/app/views/sub_domains/domain_update_priority.js.erb new file mode 100644 index 000000000..475649aac --- /dev/null +++ b/app/views/sub_domains/domain_update_priority.js.erb @@ -0,0 +1,2 @@ +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields.order("priority")}) %>"); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/sub_domains/hide_sub_domain.js.erb b/app/views/sub_domains/hide_sub_domain.js.erb new file mode 100644 index 000000000..eec025b97 --- /dev/null +++ b/app/views/sub_domains/hide_sub_domain.js.erb @@ -0,0 +1,3 @@ +$("#hide_<%= @subdomain.id %>").text("鍙"); +$("#sub_domain_hide_<%= @subdomain.id %>").css("display", "none"); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/sub_domains/new.html.erb b/app/views/sub_domains/new.html.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/sub_domains/new.js.erb b/app/views/sub_domains/new.js.erb new file mode 100644 index 000000000..3f7f1ad47 --- /dev/null +++ b/app/views/sub_domains/new.js.erb @@ -0,0 +1,6 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'sub_domains/new',:locals => {:field => @org_subfield}) %>'); +showModal('ajax-modal', '513px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","40%").css("left","50%").css("border","3px solid #269ac9"); +$('#ajax-modal').parent().addClass("popbox_polls"); diff --git a/app/views/sub_domains/show.html.erb b/app/views/sub_domains/show.html.erb new file mode 100644 index 000000000..522be5ab8 --- /dev/null +++ b/app/views/sub_domains/show.html.erb @@ -0,0 +1,141 @@ +
    +
    +
    +
    + 鎮ㄧ殑浣嶇疆锛<%= link_to "棣栭〉", organizations_path(@organization), :class => "sn-link-grey2" %> > 鏁版嵁璧勬簮 > 浠跨湡鏁版嵁 +
    +
    +
    +

    鏈鏂拌祫璁

    + +
    + +
    + +
    + +
    + +
    +
    +
    \ No newline at end of file diff --git a/app/views/sub_domains/show_sub_domain.js.erb b/app/views/sub_domains/show_sub_domain.js.erb new file mode 100644 index 000000000..c74413c6c --- /dev/null +++ b/app/views/sub_domains/show_sub_domain.js.erb @@ -0,0 +1,3 @@ +$("#hide_<%= @subdomain.id %>").text("闅愯棌"); +$("#sub_domain_hide_<%= @subdomain.id %>").css("display", "block"); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/sub_domains/update.js.erb b/app/views/sub_domains/update.js.erb new file mode 100644 index 000000000..02810eee7 --- /dev/null +++ b/app/views/sub_domains/update.js.erb @@ -0,0 +1,3 @@ +$("#subsubdomain_show_<%= @subdomain.id %>").html("<%= @subdomain.name %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb index c8e91c1a2..c0b4176c3 100644 --- a/app/views/tags/_tag_list.html.erb +++ b/app/views/tags/_tag_list.html.erb @@ -12,7 +12,7 @@ :taggable_id => obj.id, :taggable_type => object_flag %> <% end %> <% when '6' %> - <% if obj.author_id == User.current.id || User.current.admin?%> + <% if obj.author_id == User.current.id || User.current.admin? || (obj.container_type == 'Course' && User.current.allowed_to?(:as_teacher,obj.course)) %> <% select_tag_name ||= ""%> <%= link_to 'x', :controller => "tags", :action => "remove_tag_new", :remote => true, :tag_name => tag, :taggable_id => obj.id, :taggable_type => object_flag, :select_tag_name => select_tag_name %> diff --git a/app/views/users/_apply_for_homework.html.erb b/app/views/users/_apply_for_homework.html.erb new file mode 100644 index 000000000..250cc5810 --- /dev/null +++ b/app/views/users/_apply_for_homework.html.erb @@ -0,0 +1,16 @@ +
    +
    +

    + <% if state == 2 %> + 璇锋眰宸插彂閫佽嚦<%=homework.user.show_name %>鑰佸笀锛屽笇鏈涗粬鍚屾剰涓庝綘鍒嗕韩锛氾級 + <% elsif state == 3 %> + 鎮ㄥ凡鍙戦佽繃鍒嗕韩璇锋眰锛岃鍕块噸澶嶅彂閫併 + <% end %> +

    + +
    +
    \ No newline at end of file diff --git a/app/views/users/_apply_homework.html.erb b/app/views/users/_apply_homework.html.erb new file mode 100644 index 000000000..ddfac69cc --- /dev/null +++ b/app/views/users/_apply_homework.html.erb @@ -0,0 +1,28 @@ +
    +
    + <%= form_tag(apply_for_homework_user_path(:id=>User.current.id,:homework_id=>homework.id), :multipart => true,:remote => true,:name=>"apply_for_homework_form",:id=>'apply_for_homework_form') do %> +

    鐢宠鍒嗕韩

    +

    + 鐢宠璇存槑锛堝繀閫夛級锛 + +

    + + + <% end %> +
    +
    + \ No newline at end of file diff --git a/app/views/users/_apply_homework_course_message.html.erb b/app/views/users/_apply_homework_course_message.html.erb new file mode 100644 index 000000000..cf048bcd6 --- /dev/null +++ b/app/views/users/_apply_homework_course_message.html.erb @@ -0,0 +1,27 @@ +
  • +
  • + <%= link_to User.find(ma.apply_user_id).show_name, + user_path(User.find(ma.apply_user_id)), :class => "newsBlue homepageNewsPublisher" %> + ">鐢宠寮曠敤浣滀笟锛 +
  • +
  • + <% content = ma.content.nil? ? '' : '锛'+ ma.content.to_s %> + <%= link_to User.find(ma.apply_user_id).show_name+"鐢宠寮曠敤浣滀笟\""+"#{HomeworkCommon.find(ma.course_message_id).name}"+"\"#{content}", student_work_index_path(:homework => ma.course_message.id), :title => User.find(ma.apply_user_id).show_name+"鐢宠寮曠敤浣滀笟\""+"#{HomeworkCommon.find(ma.course_message_id).name}"+"\"#{content}",:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey "}" %> + + +
  • + +
  • + + <% if ma.apply_result == 0 || ma.apply_result.nil?%> + <%= link_to '鍚屾剰',dealwith_apply_homework_user_path(User.current,:agree=>'Y',:msg_id=>ma.id),:remote=>'true'%> + | + <%= link_to '鎷掔粷',dealwith_apply_homework_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true'%> + <% elsif ma.apply_result == 1%> + 鎮ㄥ凡缁忓悓鎰忎簡璇ョ敵璇 + <% elsif ma.apply_result == 2%> + 鎮ㄥ凡缁忔嫆缁濅簡璇ョ敵璇 + <%end %> + +
  • +
  • <%= time_tag(ma.created_at).html_safe %>
  • \ No newline at end of file diff --git a/app/views/users/_comment_reply.html.erb b/app/views/users/_comment_reply.html.erb new file mode 100644 index 000000000..ddc654463 --- /dev/null +++ b/app/views/users/_comment_reply.html.erb @@ -0,0 +1,27 @@ +
    + <% unless comment.parent.nil? %> +
    + <%=render :partial => 'users/comment_reply', :locals => {:comment => comment.parent} %> +
    + <% end %> + +
    + <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33"), user_path(comment.user_id), :alt => "鐢ㄦ埛澶村儚" %> +
    +
    + <% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "content-username" %> + <% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "content-username" %> + <% end %> + <%= time_from_now(comment.created_on) %> +
    <%= comment.notes.html_safe %>
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_comment_reply_detail.html.erb b/app/views/users/_comment_reply_detail.html.erb new file mode 100644 index 000000000..caac3ee62 --- /dev/null +++ b/app/views/users/_comment_reply_detail.html.erb @@ -0,0 +1,20 @@ + +
    +<%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33"), user_path(comment.user_id), :alt => "鐢ㄦ埛澶村儚" %> +
    +
    +<% if comment.try(:user).try(:realname) == ' ' %> + <%= link_to comment.try(:user), user_path(comment.user_id), :class => "content-username" %> +<% else %> + <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "content-username" %> +<% end %> +<%= time_from_now(comment.created_on) %> +
    <%= comment.notes.html_safe %>
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_course_attachment.html.erb b/app/views/users/_course_attachment.html.erb index 6f6cf82f3..63c57f708 100644 --- a/app/views/users/_course_attachment.html.erb +++ b/app/views/users/_course_attachment.html.erb @@ -38,4 +38,9 @@
    - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/users/_course_create.html.erb b/app/views/users/_course_create.html.erb index dc1e0ee81..6b2234337 100644 --- a/app/views/users/_course_create.html.erb +++ b/app/views/users/_course_create.html.erb @@ -34,4 +34,9 @@
    - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 743090a4d..28f0f99db 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -146,7 +146,8 @@
    <% if activity.student_works.count != 0 %> <% sw_id = "("+activity.student_works.map{|sw| sw.id}.join(",")+")" %> - <% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> + <%# student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> + <% student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") %> <% unless student_work_scores.empty? %> <% last_score = student_work_scores.first %>
    @@ -158,17 +159,17 @@
    <% if activity.homework_type != 2 %> <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> - <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> + <% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %> <% else %> - <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> + <% student_works = activity.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %> <% end %> <% student_works.includes(:user).each_with_index do |sw, i| %>
    <% if User.current.member_of_course?(activity.course) || User.current.admin? || activity.is_open == 1 %> - <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "瀛︾敓澶村儚" %> + <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id,:show_work_id => sw.id), :alt => "瀛︾敓澶村儚" %> <% else %> <%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '璇ヤ綔涓氱殑浣滃搧鏆傛湭鍏紑') %> @@ -197,7 +198,8 @@ <% sort_projects = project_sort_update projects %>
    - # <%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_path(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>鏇存柊浜嗛」鐩紝鏈杩戞洿鏂帮細 + <% first_pro = project_sort_first(projects).first %> + # <%=time_from_now first_pro.updated_at %><%= link_to User.find(first_pro.user_id).show_name, user_activities_path(first_pro.user_id), :class => "newsBlue ml5 mr5"%>鏇存柊浜嗛」鐩紝鏈杩戞洿鏂帮細
    <% sort_projects.each_with_index do |pro, i| %> @@ -226,7 +228,7 @@
    椤圭洰鍚嶇О锛<%=project.name %>
    鍒涘缓鑰咃細<%=(User.find project.user_id).show_name %>(缁勯暱)
    - 鏇存柊鏃堕棿锛<%=time_from_now time %> + 鏇存柊鏃堕棿锛<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %>
    <% if i == 9 && projects.count > 10 %> @@ -290,7 +292,8 @@ <% count=activity.journals_for_messages.count %>
    -
    鍥炲 +
    鍥炲 + <%= count>0 ? "锛#{count}锛" : "" %> <% if activity.user == User.current %> @@ -332,24 +335,60 @@ <% else %> <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> - <%= format_time(comment.created_on) %> - - <% if comment.user == User.current %> - + <%= time_from_now(comment.created_on) %> +
    + <% unless comment.m_parent_id.nil? %> + <% parents_rely = [] %> + <% parents_rely = get_reply_parents parents_rely, comment %> + <% length = parents_rely.length %> +
    + <% if length <= 3 %> + <%=render :partial => 'users/comment_reply', :locals => {:comment => comment.parent} %> <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - <% end %> - - - -
    +
    + <% end %>
    <%= comment.notes.html_safe %>
    +
    +
    + + + <% if comment.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> + + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :is_in_course => -1, :user_activity_id => user_activity_id, :course_activity=>course_activity}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + + <% if User.current.admin? ||is_teacher || comment.user == User.current%> + <%= link_to('鍒犻櫎', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => -1, :user_activity_id => user_activity_id, :course_activity=>course_activity}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> + <% end %> + +
    +
    +
    +

    @@ -388,4 +427,7 @@ $("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap'); $("#moreProject_<%=user_activity_id %>").show(); }); + $(function(){ + user_card_show_hide(); + }); diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb index f9a59f024..1d0c4cba5 100644 --- a/app/views/users/_course_journalsformessage.html.erb +++ b/app/views/users/_course_journalsformessage.html.erb @@ -107,4 +107,9 @@
    + diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb index 3f2b8b5c4..2f790b19b 100644 --- a/app/views/users/_course_message.html.erb +++ b/app/views/users/_course_message.html.erb @@ -2,7 +2,7 @@
    <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "鐢ㄦ埛澶村儚" %> - <%#= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %> + <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
    @@ -89,7 +89,7 @@
    鍥炲 - <%= count>0 ? "锛#{count}锛" : "" %>? + <%= count>0 ? "锛#{count}锛" : "" %> <% if activity.author == User.current %> @@ -174,4 +174,9 @@
    <% end %>
    -
    \ No newline at end of file +
    + \ No newline at end of file diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index efaa72beb..403a922ed 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -146,3 +146,8 @@
    + diff --git a/app/views/users/_course_poll.html.erb b/app/views/users/_course_poll.html.erb index 970fb516e..dab970cdf 100644 --- a/app/views/users/_course_poll.html.erb +++ b/app/views/users/_course_poll.html.erb @@ -55,3 +55,8 @@ <% end %> + diff --git a/app/views/users/_homework_repository.html.erb b/app/views/users/_homework_repository.html.erb index 1ed8ae688..463d250f5 100644 --- a/app/views/users/_homework_repository.html.erb +++ b/app/views/users/_homework_repository.html.erb @@ -8,7 +8,7 @@ function (data) { } ); - } + };
    @@ -19,7 +19,9 @@ <%= homework.name%> - 绉佹湁 + <% if homework.course.is_public == 0 %> + 绉佹湁 + <% end %>
  • @@ -35,7 +37,22 @@
  • <%= homework.quotes %>
  • <%=format_date homework.publish_time %>
  • -
  • 鎻愪氦鐢宠
  • + <% if homework.user != User.current && (homework.course.is_public == 0 && !User.current.allowed_to?(:as_teacher,homework.course)) %> +
  • + <% ah = ApplyHomework.where("user_id = ? and homework_common_id = ?", User.current.id, homework.id).first %> + <% if ah.nil? %> + <%= link_to("璇锋眰鍒嗕韩", apply_homework_user_path(User.current.id,:homework_id => homework.id), :class => 'green_btn_share c_white', :remote => true) %> + <% elsif ah.status == 1 %> + 绛夊緟鍥炲 + <% elsif ah.status == 2 %> + 鍙紩鐢 + <% elsif ah.status == 3 %> + 宸叉嫆缁 + <% end %> +
  • + <% else %> +
  • --
  • + <% end %> <% end %>
    \ No newline at end of file diff --git a/app/views/users/_homework_repository_detail.html.erb b/app/views/users/_homework_repository_detail.html.erb index efbf24955..cf04e16cb 100644 --- a/app/views/users/_homework_repository_detail.html.erb +++ b/app/views/users/_homework_repository_detail.html.erb @@ -1,7 +1,7 @@
    棰樼洰淇℃伅
    - <% if homework.nil? %> + <% if homework.nil? && status == 0 %> 鏈搴撻伒寰垱浣滃叡鐢ㄨ鍙瘉
    鏁欏笀缁欏鐢熷嚭棰樻湰璐ㄤ笂鏄竴绉嶅垱浣滆涓猴紝棰樼洰鐨勪綔鑰呴氬父涓烘浠樺嚭澶ч噺鏃堕棿鍜岀簿鍔涖傚ソ鐨勯鐩笉浠呰兘鍔犳繁瀛︾敓瀵圭煡璇嗙偣鐨勭悊瑙o紝杩樿兘婵鍙戝鐢熷叴瓒o紝鎻愬崌瀛︿範鏁堢巼銆備负姝わ紝鏈綉绔欑殑棰樺簱璁稿彲璇佸熀浜庡垱浣滃叡鐢ㄨ鍙瘉锛 Creative Commons License 锛夊缓绔嬶紝鍏舵牳蹇冩潯娆惧寘鎷細

    @@ -14,6 +14,14 @@ 瀵规璁稿彲璇佺殑鏀寔鎴栧弽瀵癸紝璇峰湪缃戠珯涓暀瑷锛屾垜浠笉鏂畬鍠勶紝璋㈣阿锛
    + <% elsif homework.nil? && status == 1 %> + 鎮ㄩ変腑鐨勪綔涓氱洰鍓嶄负绉佹湁浣滀笟锛屾偍鐨勫垎浜姹傚凡鍙戦佽嚦鑰佸笀锛岃鑰愬績绛夊緟鑰佸笀鐨勫悓鎰忋 + <% elsif homework.nil? && status == 2 %> + 鎮ㄩ変腑鐨勪綔涓氱洰鍓嶄负绉佹湁浣滀笟锛岃鐐瑰嚮鈥滆姹傚垎浜濇寜閽悜棰樼洰鐨勪綔鑰呭彂閫佸垎浜姹傚惂锛
    + 绁濇偍鎴愬姛锛氾級 +
    + <% elsif homework.nil? && status == 3 %> + 鎮ㄩ変腑鐨勪綔涓氱洰鍓嶄负绉佹湁浣滀笟锛屾偍鐨勫垎浜姹傚凡琚佸笀鎷掔粷锛屾殏鏃朵笉鍙煡鐪嬩綔涓氳鎯呫 <% else %>
    鏍囬锛<%=homework.name %>
    鏉ユ簮锛<%=homework.course.name %>
    diff --git a/app/views/users/_join_course_course_message.html.erb b/app/views/users/_join_course_course_message.html.erb new file mode 100644 index 000000000..28675b7eb --- /dev/null +++ b/app/views/users/_join_course_course_message.html.erb @@ -0,0 +1,37 @@ +
  • +
  • + 绯荤粺鎻愮ず + ">鎮ㄦ湁浜嗘柊鐨勮绋嬫垚鍛樼敵璇凤細 +
  • +
  • + + <%= link_to User.find(ma.course_message_id).name+"鐢宠鎴愪负璇剧▼\""+"#{Course.find(ma.course_id).name}"+"\"鐨"+"#{ma.content == '9' ? "鏁欏笀" : "鏁欒緟"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id), + :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %> + + + +
  • + +
  • + + <% if ma.status == 0 || ma.status.nil?%> + <%= link_to '鍚屾剰',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>ma.id),:remote=>'true'%> + | + <%= link_to '鎷掔粷',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true'%> + <% elsif ma.status == 1%> + 鎮ㄥ凡缁忓悓鎰忎簡璇ョ敵璇 + <% elsif ma.status == 2%> + 鎮ㄥ凡缁忔嫆缁濅簡璇ョ敵璇 + <%end %> + +
  • +
  • <%= time_tag(ma.created_at).html_safe %>
  • \ No newline at end of file diff --git a/app/views/users/_project_attachment.html.erb b/app/views/users/_project_attachment.html.erb index b3d904104..795432008 100644 --- a/app/views/users/_project_attachment.html.erb +++ b/app/views/users/_project_attachment.html.erb @@ -38,4 +38,9 @@
    -
    \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/users/_project_boardlist.html.erb b/app/views/users/_project_boardlist.html.erb index 928d682d8..25fd675fb 100644 --- a/app/views/users/_project_boardlist.html.erb +++ b/app/views/users/_project_boardlist.html.erb @@ -44,7 +44,7 @@ <% end %>

    <%=render :partial =>"users/intro_content_ex", :locals=>{:user_activity_id =>activity.id, :content=>content, :maxheight=>54, :maxwordsnum=>100} %>

    -
    +
    鍙戝笘锛<%= format_time(activity.created_on) %> 鏇存柊锛<%= format_time(ForgeActivity.where("forge_act_type='#{activity.class}' and forge_act_id =#{activity.id}").first.updated_at) %> <% count=0 %> diff --git a/app/views/users/_project_create.html.erb b/app/views/users/_project_create.html.erb index 0e35bca25..83bfe3f04 100644 --- a/app/views/users/_project_create.html.erb +++ b/app/views/users/_project_create.html.erb @@ -36,4 +36,9 @@
    - \ No newline at end of file + + \ No newline at end of file diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 008f08706..daa7c71c2 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -96,3 +96,8 @@ <%= render :partial => 'users/project_issue_reply', :locals => {:activity => activity, :user_activity_id => user_activity_id} %> + \ No newline at end of file diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb index c071f4a13..0a41dbbf5 100644 --- a/app/views/users/_project_message.html.erb +++ b/app/views/users/_project_message.html.erb @@ -167,3 +167,8 @@ <% end %> + diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb new file mode 100644 index 000000000..30f4e3542 --- /dev/null +++ b/app/views/users/_reply_to.html.erb @@ -0,0 +1,20 @@ +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "鐢ㄦ埛澶村儚" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller => 'words', :action => 'reply_to_homework', :id => reply.id},:method => "post", :remote => true) do |f| %> + > + > + > + +
    + + +
    +

    + <% end%> +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/users/_resource_share_for_project_popup.html.erb b/app/views/users/_resource_share_for_project_popup.html.erb index 2e6d0987b..c758ef492 100644 --- a/app/views/users/_resource_share_for_project_popup.html.erb +++ b/app/views/users/_resource_share_for_project_popup.html.erb @@ -24,6 +24,8 @@ <%= submit_tag '',:class=>'searchIcon2',:onfocus=>"this.blur();",:style=>'border-style:none' %> <% end %> + +
    <%= render :partial => 'users/project_file_form', :locals => {:user => user, :projects => projects, :send_id => send_id, :send_ids => send_ids, :type => type} %>
    diff --git a/app/views/users/_send_notice.html.erb b/app/views/users/_send_notice.html.erb new file mode 100644 index 000000000..aede2a33b --- /dev/null +++ b/app/views/users/_send_notice.html.erb @@ -0,0 +1,18 @@ +
    +
    +

    + <% if status == 1 %> + 鎮ㄧ殑鍒嗕韩璇锋眰鏆傛湭閫氳繃瀹℃牳锛屾殏鏃朵笉鍙彂閫佽嚦璇剧▼銆 + <% elsif status == 2 %> + 鎮ㄩ変腑鐨勪綔涓氱洰鍓嶄负绉佹湁浣滀笟锛岃鐐瑰嚮鈥滆姹傚垎浜濇寜閽悜棰樼洰鐨勪綔鑰呭彂閫佸垎浜姹傚惂锛佺鎮ㄦ垚鍔燂細锛 + <% elsif status == 3 %> + 鎮ㄧ殑鍒嗕韩璇锋眰宸茶鑰佸笀鎷掔粷锛屼笉鍙彂閫佽嚦璇剧▼銆 + <% end %> +

    + +
    +
    \ No newline at end of file diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb index 841fd9377..74f090344 100644 --- a/app/views/users/_user_blog.html.erb +++ b/app/views/users/_user_blog.html.erb @@ -144,4 +144,7 @@ $("#relatePWrap_<%=user_activity_id %>").toggleClass('relatePWrap'); $("#moreProject_<%=user_activity_id %>").show(); }); + $(function(){ + user_card_show_hide(); + }); diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 4bab8d98f..b8c5c2017 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -71,7 +71,7 @@ <%= user_for_homework_common homework_common,is_teacher %> <% work = cur_user_works_for_homework homework_common %> - <% if homework_common.end_time < Date.today && !is_teacher && !work.nil? %> + <% if !is_teacher && !work.nil? && homework_common.end_time < Date.today %>
    <%=link_to "杩藉姞闄勪欢", student_work_index_url_in_org(homework_common.id, 1), :class => 'c_blue', :title => "鍙拷鍔犱綔鍝佷慨璁㈤檮浠" %>
    @@ -149,8 +149,8 @@
    <% if homework_common.student_works.count != 0 %> <% sw_id = "("+homework_common.student_works.map{|sw| sw.id}.join(",")+")" %> - <% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> - <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %> + <%# student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %> + <% student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id} and score is not null").reorder("created_at desc") %> <% unless student_work_scores.empty? %> <% last_score = student_work_scores.first %>
    @@ -162,17 +162,17 @@
    <% if homework_common.homework_type != 2 %> <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %> - <% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %> + <% student_works = homework_common.student_works.select("student_works.*,student_works.work_score as score").where("student_works.id in #{ids}").order("score desc") %> <% else %> - <% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %> + <% student_works = homework_common.student_works.select("student_works.*,student_works.work_score as score").order("score desc") %> <% end %> <% student_works.includes(:user).each_with_index do |sw, i| %>
    <% if User.current.member_of_course?(homework_common.course) || User.current.admin? || homework_common.is_open == 1 %> - <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => homework_common.id), :alt => "瀛︾敓澶村儚" %> + <%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => homework_common.id, :show_work_id => sw.id), :alt => "瀛︾敓澶村儚" %> <% else %> <%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '璇ヤ綔涓氱殑浣滃搧鏆傛湭鍏紑') %> @@ -201,7 +201,8 @@ <% sort_projects = project_sort_update projects %>
    - # <%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_path(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>鏇存柊浜嗛」鐩紝鏈杩戞洿鏂帮細 + <% first_pro = project_sort_first(projects).first %> + # <%=time_from_now first_pro.updated_at %><%= link_to User.find(first_pro.user_id).show_name, user_activities_path(first_pro.user_id), :class => "newsBlue ml5 mr5"%>鏇存柊浜嗛」鐩紝鏈杩戞洿鏂帮細
    <% sort_projects.each_with_index do |pro, i| %> @@ -230,7 +231,7 @@
    椤圭洰鍚嶇О锛<%=project.name %>
    鍒涘缓鑰咃細<%=(User.find project.user_id).show_name %>(缁勯暱)
    - 鏇存柊鏃堕棿锛<%=time_from_now time %> + 鏇存柊鏃堕棿锛<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %>
    <% if i == 9 && projects.count > 10 %> @@ -296,7 +297,8 @@ <% count=homework_common.journals_for_messages.count %>
    -
    鍥炲 +
    鍥炲 + <%= count>0 ? "锛#{count}锛" : "" %> <% if homework_common.user == User.current %> @@ -338,22 +340,60 @@ <% else %> <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %> <% end %> - <%= format_time(comment.created_on) %> - <% if comment.user == User.current %> - - <% else %> - <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> - <% end %> - - + <% unless comment.m_parent_id.nil? %> + <% parents_rely = [] %> + <% parents_rely = get_reply_parents parents_rely, comment %> + <% length = parents_rely.length %> +
    + <% if length <= 3 %> + <%=render :partial => 'users/comment_reply', :locals => {:comment => comment.parent} %> + <% else %> +
    +
    +
    + <%=render :partial => 'users/comment_reply', :locals => {:comment => parents_rely[length - 1]} %> +
    + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[length - 2]} %> +
    +
    <%= link_to '鐐瑰嚮灞曞紑闅愯棌妤煎眰', show_all_replies_users_path(:comment => comment),:remote=>true %>
    + <%=render :partial => 'users/comment_reply_detail', :locals => {:comment => parents_rely[0]} %> +
    <% end %> +
    + <% end %> +
    + <%= comment.notes.html_safe %>
    +
    +
    + + + <% if comment.user == User.current %> + + <% else %> + <%=render :partial=> "praise_tread/praise", :locals => {:activity=>comment, :user_activity_id=>comment.id,:type=>"reply"}%> + <% end %> + + + <%= link_to( + l(:button_reply), + {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => 'HomeworkCommon', :is_in_course => is_in_course, :course_activity => -1}, + :remote => true, + :method => 'get', + :title => l(:button_reply)) %> + + + + <% if User.current.admin? ||is_teacher || comment.user == User.current%> + <%= link_to('鍒犻櫎', {:controller => 'words', :action => 'destroy', :object_id => comment, :user_id => comment.user,:is_in_course => is_in_course, :course_activity => -1}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20", :title => l(:button_delete)) %> + <% end %> + +
    -
    - <%= comment.notes.html_safe %>
    +

    @@ -392,4 +432,7 @@ $("#relatePWrap_<%=homework_common.id %>").toggleClass('relatePWrap'); $("#moreProject_<%=homework_common.id %>").show(); }); + $(function(){ + user_card_show_hide(); + }); \ No newline at end of file diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 9689ecda0..3f6836614 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -3,6 +3,7 @@ <%= javascript_include_tag 'homework','baiduTemplate' %> \ No newline at end of file diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index ccd329852..d278c7d74 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -229,7 +229,32 @@
  • <%= time_tag(ma.created_at).html_safe %>
  • <% end %> - + <% if ma.course_message_type == "HomeworkCommon" && ma.status == 5 %> +
      + <%= render :partial => 'apply_homework_course_message', :locals => {:ma => ma} %> +
    + <% end %> + <% if ma.course_message_type == "HomeworkCommon" && ma.status == 6 %> +
    + <% end %> <% if ma.course_message_type == "Poll" %> <% end %> + <% elsif ma.course_message.jour_type == 'HomeworkCommon' %> + <% else %>
    • @@ -446,6 +491,26 @@
    • <%= time_tag(ma.created_at).html_safe %>
    <% end %> + + <% if ma.course_message_type == "StudentWork" && ma.status == 2 %> + + <% end %> <% if ma.course_message_type == "Course" %>
      @@ -483,43 +548,8 @@
    <% end %> <% if ma.course_message_type == "JoinCourseRequest" %> -
      -
    • -
    • - 绯荤粺鎻愮ず - ">鎮ㄦ湁浜嗘柊鐨勮绋嬫垚鍛樼敵璇凤細 -
    • -
    • - <%= link_to User.find(ma.course_message_id).name+"鐢宠鎴愪负璇剧▼\""+"#{Course.find(ma.course_id).name}"+"\"鐨"+"#{ma.content == '9' ? "鏁欏笀" : "鏁欒緟"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id), - :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %> - - - -
    • - -
    • - - <% if ma.status == 0 || ma.status.nil?%> - <%= link_to '鍚屾剰',dealwith_apply_request_user_path(User.current,:agree=>'Y',:msg_id=>ma.id),:remote=>'true'%> - | - <%= link_to '鎷掔粷',dealwith_apply_request_user_path(User.current,:agree=>'N',:msg_id=>ma.id),:remote=>'true'%> - <% elsif ma.status == 1%> - 鎮ㄥ凡缁忓悓鎰忎簡璇ョ敵璇 - <% elsif ma.status == 2%> - 鎮ㄥ凡缁忔嫆缁濅簡璇ョ敵璇 - <%end %> - -
    • -
    • <%= time_tag(ma.created_at).html_safe %>
    • +
        + <%= render :partial => 'join_course_course_message', :locals => {:ma => ma} %>
      <% end %> <% if ma.course_message_type == "CourseRequestDealResult" %> diff --git a/app/views/users/_user_resource_info.html.erb b/app/views/users/_user_resource_info.html.erb index a3bc45481..58829386c 100644 --- a/app/views/users/_user_resource_info.html.erb +++ b/app/views/users/_user_resource_info.html.erb @@ -28,7 +28,7 @@
      -
        +
          <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
      @@ -37,7 +37,7 @@ -
        +