diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index af337a4e7..000000000
--- a/.gitignore
+++ /dev/null
@@ -1,23 +0,0 @@
-*.swp
-/.project
-/.idea
-/.bundle
-*.swp
-/config/database.yml
-/config/configuration.yml
-/files/*
-/log/*
-/public/tmp/*
-/tmp/*
-/public/cache/*
-.gitignore
-/config/newrelic.yml
-/public/images/avatars/*
-/Gemfile
-/Gemfile.lock
-/db/schema.rb
-/Gemfile.lock
-/lib/plugins/acts_as_versioned/test/debug.log
-.rbenv-gemsets
-.DS_Store
-public/api_doc/
diff --git a/Gemfile b/Gemfile
index 037c606c8..3f07ad408 100644
--- a/Gemfile
+++ b/Gemfile
@@ -21,7 +21,8 @@ gem 'acts-as-taggable-on', '2.4.1'
gem 'spreadsheet'
gem 'ruby-ole'
#gem 'email_verifier', path: 'lib/email_verifier'
-
+gem 'rufus-scheduler'
+gem 'dalli', path: 'lib/dalli-2.7.2'
group :development do
gem 'grape-swagger'
gem 'grape-swagger-ui', git: 'https://github.com/guange2015/grape-swagger-ui.git'
diff --git a/Gemfile.lock b/Gemfile.lock
deleted file mode 100644
index 355ca422d..000000000
--- a/Gemfile.lock
+++ /dev/null
@@ -1,348 +0,0 @@
-GIT
- remote: https://github.com/guange2015/grape-swagger-ui.git
- revision: 4c33439f236c174ae0e774b3435ef2547995c21d
- specs:
- grape-swagger-ui (0.0.4)
- railties (>= 3.1)
-
-PATH
- remote: lib/better_errors
- specs:
- better_errors (1.1.0)
- coderay (>= 1.0.0)
- erubis (>= 2.6.6)
-
-PATH
- remote: lib/rack-mini-profiler
- specs:
- rack-mini-profiler (0.9.1)
- rack (>= 1.1.3)
-
-PATH
- remote: lib/seems_rateable
- specs:
- seems_rateable (1.0.13)
- jquery-rails
- rails
-
-GEM
- remote: http://rubygems.org/
- remote: https://rubygems.org/
- specs:
- actionmailer (3.2.13)
- actionpack (= 3.2.13)
- mail (~> 2.5.3)
- actionpack (3.2.13)
- activemodel (= 3.2.13)
- activesupport (= 3.2.13)
- builder (~> 3.0.0)
- erubis (~> 2.7.0)
- journey (~> 1.0.4)
- rack (~> 1.4.5)
- rack-cache (~> 1.2)
- rack-test (~> 0.6.1)
- sprockets (~> 2.2.1)
- activemodel (3.2.13)
- activesupport (= 3.2.13)
- builder (~> 3.0.0)
- activerecord (3.2.13)
- activemodel (= 3.2.13)
- activesupport (= 3.2.13)
- arel (~> 3.0.2)
- tzinfo (~> 0.3.29)
- activeresource (3.2.13)
- activemodel (= 3.2.13)
- activesupport (= 3.2.13)
- activesupport (3.2.13)
- i18n (= 0.6.1)
- multi_json (~> 1.0)
- acts-as-taggable-on (2.4.1)
- rails (>= 3, < 5)
- arel (3.0.3)
- axiom-types (0.1.1)
- descendants_tracker (~> 0.0.4)
- ice_nine (~> 0.11.0)
- thread_safe (~> 0.3, >= 0.3.1)
- builder (3.0.0)
- capybara (2.4.1)
- mime-types (>= 1.16)
- nokogiri (>= 1.3.3)
- rack (>= 1.0.0)
- rack-test (>= 0.5.4)
- xpath (~> 2.0)
- celluloid (0.16.0)
- timers (~> 4.0.0)
- childprocess (0.5.3)
- ffi (~> 1.0, >= 1.0.11)
- climate_control (0.0.3)
- activesupport (>= 3.0)
- cocaine (0.5.4)
- climate_control (>= 0.0.3, < 1.0)
- coderay (1.0.9)
- coercible (1.0.0)
- descendants_tracker (~> 0.0.1)
- coffee-rails (3.2.2)
- coffee-script (>= 2.2.0)
- railties (~> 3.2.0)
- coffee-script (2.3.0)
- coffee-script-source
- execjs
- coffee-script-source (1.7.1)
- descendants_tracker (0.0.4)
- thread_safe (~> 0.3, >= 0.3.1)
- diff-lcs (1.2.5)
- equalizer (0.0.9)
- erubis (2.7.0)
- execjs (2.2.1)
- factory_girl (4.4.0)
- activesupport (>= 3.0.0)
- faker (1.4.3)
- i18n (~> 0.5)
- fastercsv (1.5.5)
- ffi (1.9.3)
- ffi (1.9.3-x86-mingw32)
- formatador (0.2.5)
- grape (0.9.0)
- activesupport
- builder
- hashie (>= 2.1.0)
- multi_json (>= 1.3.2)
- multi_xml (>= 0.5.2)
- rack (>= 1.3.0)
- rack-accept
- rack-mount
- virtus (>= 1.0.0)
- grape-entity (0.4.4)
- activesupport
- multi_json (>= 1.3.2)
- grape-swagger (0.8.0)
- grape
- grape-entity
- guard (2.11.1)
- formatador (>= 0.2.4)
- listen (~> 2.7)
- lumberjack (~> 1.0)
- nenv (~> 0.1)
- notiffany (~> 0.0)
- pry (>= 0.9.12)
- shellany (~> 0.0)
- thor (>= 0.18.1)
- guard-rspec (2.5.0)
- guard (>= 1.1)
- rspec (~> 2.11)
- hashie (3.3.1)
- hike (1.2.3)
- hitimes (1.2.2)
- hitimes (1.2.2-x86-mingw32)
- htmlentities (4.3.2)
- i18n (0.6.1)
- ice_nine (0.11.0)
- journey (1.0.4)
- jquery-rails (2.0.3)
- railties (>= 3.1.0, < 5.0)
- thor (~> 0.14)
- json (1.8.1)
- kaminari (0.16.1)
- actionpack (>= 3.0.0)
- activesupport (>= 3.0.0)
- libv8 (3.16.14.3)
- listen (2.8.5)
- celluloid (>= 0.15.2)
- rb-fsevent (>= 0.9.3)
- rb-inotify (>= 0.9)
- lumberjack (1.0.9)
- mail (2.5.4)
- mime-types (~> 1.16)
- treetop (~> 1.4.8)
- metaclass (0.0.4)
- method_source (0.8.2)
- mime-types (1.25.1)
- mini_portile (0.6.0)
- mocha (1.1.0)
- metaclass (~> 0.0.1)
- multi_json (1.10.1)
- multi_xml (0.5.5)
- mysql2 (0.3.11)
- mysql2 (0.3.11-x86-mingw32)
- nenv (0.2.0)
- net-ldap (0.3.1)
- nokogiri (1.6.3)
- mini_portile (= 0.6.0)
- nokogiri (1.6.3-x86-mingw32)
- mini_portile (= 0.6.0)
- notiffany (0.0.3)
- nenv (~> 0.1)
- shellany (~> 0.0)
- paperclip (3.5.4)
- activemodel (>= 3.0.0)
- activesupport (>= 3.0.0)
- cocaine (~> 0.5.3)
- mime-types
- polyglot (0.3.5)
- pry (0.9.12.6)
- coderay (~> 1.0)
- method_source (~> 0.8)
- slop (~> 3.4)
- pry (0.9.12.6-x86-mingw32)
- coderay (~> 1.0)
- method_source (~> 0.8)
- slop (~> 3.4)
- win32console (~> 1.3)
- rack (1.4.5)
- rack-accept (0.4.5)
- rack (>= 0.4)
- rack-cache (1.2)
- rack (>= 0.4)
- rack-mount (0.8.3)
- rack (>= 1.0.0)
- rack-openid (1.4.2)
- rack (>= 1.1.0)
- ruby-openid (>= 2.1.8)
- rack-raw-upload (1.1.1)
- multi_json
- rack-ssl (1.3.4)
- rack
- rack-test (0.6.2)
- rack (>= 1.0)
- rails (3.2.13)
- actionmailer (= 3.2.13)
- actionpack (= 3.2.13)
- activerecord (= 3.2.13)
- activeresource (= 3.2.13)
- activesupport (= 3.2.13)
- bundler (~> 1.0)
- railties (= 3.2.13)
- railties (3.2.13)
- actionpack (= 3.2.13)
- activesupport (= 3.2.13)
- rack-ssl (~> 1.3.2)
- rake (>= 0.8.7)
- rdoc (~> 3.4)
- thor (>= 0.14.6, < 2.0)
- rake (10.3.2)
- rb-fsevent (0.9.4)
- rb-inotify (0.9.5)
- ffi (>= 0.5.0)
- rdoc (3.12.2)
- json (~> 1.4)
- ref (1.0.5)
- rich (1.4.6)
- jquery-rails
- kaminari
- mime-types
- paperclip
- rack-raw-upload
- rails (>= 3.2.0)
- sass-rails
- rspec (2.13.0)
- rspec-core (~> 2.13.0)
- rspec-expectations (~> 2.13.0)
- rspec-mocks (~> 2.13.0)
- rspec-core (2.13.1)
- rspec-expectations (2.13.0)
- diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.13.1)
- rspec-rails (2.13.1)
- actionpack (>= 3.0)
- activesupport (>= 3.0)
- railties (>= 3.0)
- rspec-core (~> 2.13.0)
- rspec-expectations (~> 2.13.0)
- rspec-mocks (~> 2.13.0)
- ruby-ole (1.2.11.7)
- ruby-openid (2.1.8)
- rubyzip (1.1.6)
- sass (3.3.10)
- sass-rails (3.2.6)
- railties (~> 3.2.0)
- sass (>= 3.1.10)
- tilt (~> 1.3)
- selenium-webdriver (2.42.0)
- childprocess (>= 0.5.0)
- multi_json (~> 1.0)
- rubyzip (~> 1.0)
- websocket (~> 1.0.4)
- shellany (0.0.1)
- shoulda (3.5.0)
- shoulda-context (~> 1.0, >= 1.0.1)
- shoulda-matchers (>= 1.4.1, < 3.0)
- shoulda-context (1.2.1)
- shoulda-matchers (2.6.1)
- activesupport (>= 3.0.0)
- slop (3.6.0)
- spreadsheet (1.0.0)
- ruby-ole (>= 1.0)
- sprockets (2.2.2)
- hike (~> 1.2)
- multi_json (~> 1.0)
- rack (~> 1.0)
- tilt (~> 1.1, != 1.3.0)
- therubyracer (0.12.1)
- libv8 (~> 3.16.14.0)
- ref
- thor (0.19.1)
- thread_safe (0.3.4)
- tilt (1.4.1)
- timers (4.0.1)
- hitimes
- treetop (1.4.15)
- polyglot
- polyglot (>= 0.3.1)
- tzinfo (0.3.40)
- uglifier (2.5.1)
- execjs (>= 0.3.0)
- json (>= 1.8.0)
- virtus (1.0.3)
- axiom-types (~> 0.1)
- coercible (~> 1.0)
- descendants_tracker (~> 0.0, >= 0.0.3)
- equalizer (~> 0.0, >= 0.0.9)
- websocket (1.0.7)
- win32console (1.3.2-x86-mingw32)
- xpath (2.0.0)
- nokogiri (~> 1.3)
-
-PLATFORMS
- ruby
- x86-mingw32
-
-DEPENDENCIES
- activerecord-jdbc-adapter (= 1.2.5)
- activerecord-jdbcmysql-adapter
- acts-as-taggable-on (= 2.4.1)
- better_errors!
- builder (= 3.0.0)
- capybara (~> 2.4.1)
- coderay (~> 1.0.6)
- coffee-rails (~> 3.2.1)
- factory_girl (~> 4.4.0)
- faker
- fastercsv (~> 1.5.0)
- grape (~> 0.9.0)
- grape-entity
- grape-swagger
- grape-swagger-ui!
- guard-rspec (= 2.5.0)
- htmlentities
- i18n (~> 0.6.0)
- jquery-rails (~> 2.0.2)
- kaminari
- mocha (~> 1.1.0)
- mysql2 (= 0.3.11)
- net-ldap (~> 0.3.1)
- nokogiri (~> 1.6.3)
- paperclip (~> 3.5.4)
- rack-mini-profiler!
- rack-openid
- rails (= 3.2.13)
- rich (= 1.4.6)
- rspec-rails (= 2.13.1)
- ruby-ole
- ruby-openid (~> 2.1.4)
- sass-rails (~> 3.2.3)
- seems_rateable!
- selenium-webdriver (~> 2.42.0)
- shoulda (~> 3.5.0)
- spreadsheet
- therubyracer
- uglifier (>= 1.0.3)
diff --git a/app/api/mobile/api.rb b/app/api/mobile/api.rb
index bee78a20e..8f7f0342f 100644
--- a/app/api/mobile/api.rb
+++ b/app/api/mobile/api.rb
@@ -6,6 +6,7 @@ module Mobile
require_relative 'apis/watches'
require_relative 'apis/upgrade'
require_relative 'apis/homeworks'
+ require_relative 'apis/comments'
class API < Grape::API
version 'v1', using: :path
format :json
@@ -37,6 +38,7 @@ module Mobile
mount Apis::Watches
mount Apis::Upgrade
mount Apis::Homeworks
+ mount Apis::Comments
#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/comments.rb b/app/api/mobile/apis/comments.rb
new file mode 100644
index 000000000..7a7f17d8f
--- /dev/null
+++ b/app/api/mobile/apis/comments.rb
@@ -0,0 +1,93 @@
+#coding=utf-8
+module Mobile
+ module Apis
+ class Comments < Grape::API
+ resource :comments do
+ desc '课程通知评论'
+ params do
+ requires :token, type: String
+ requires :comments, type: String
+ end
+ post ':id' do
+ cs = CommentService.new
+ cs_params = {
+ id: params[:id],
+ comment: params.reject{|k,v| [:id].include?(k)}}
+ comments = cs.news_comments cs_params,current_user
+ raise "create comments failed #{comments.errors.full_messages}" if comments.new_record?
+ present :data, comments, with: Mobile::Entities::Comment
+ present :status, 0
+ end
+
+ desc '作业留言(教师布置的作业)'
+ params do
+ requires :token, type: String
+ requires :message,type: String, desc: '留言'
+ #optional :reference_content, type: String ,desc: '引用的内容'
+ #optional :reference_user_id, type: Integer,desc: '被引用的人'
+ end
+ post ':id/create_homework_message' do
+ cs_params = {
+ id: params[:id],
+ token: params[:token],
+ reference_content: params[:reference_content],
+ bid_message: params.reject{|k,v| [:id,:token,:reference_content].include?(k)}}
+ cs = CommentService.new
+ message = cs.homework_message cs_params,current_user
+ present :data, message, with: Mobile::Entities::Jours
+ present :status, 0
+ end
+
+ desc '课程留言'
+ params do
+ requires :token, type: String
+ requires :course_message,type: String, desc: '留言'
+ end
+ post ':id/leave_course_message' do
+ cs_params = {
+ id: params[:id],
+ token: params[:token],
+ new_form: params.reject{|k,v| [:id,:token].include?(k)}}
+ cs = CommentService.new
+ message = cs.leave_course_message cs_params,current_user
+ present :data, message, with: Mobile::Entities::Jours
+ present :status, 0
+ end
+
+ desc '回复留言'
+ params do
+ requires :token, type: String
+ requires :reference_id, type: Integer,desc: '所属留言树的根留言id(最顶层的非回复的留言,留言对象中的m_parent_id)'
+ requires :reference_user_id,type: Integer ,desc: '被回复的留言的作者id'
+ #requires :reference_message_id,type: Integer,desc: '被回复的留言的id'
+ requires :user_notes,type: String,desc: '留言的内容'
+ requires :jour_type,type: String,desc: '等于父留言的jour_type'
+ requires :jour_id,type:Integer, desc: '等于父留言的jour_id'
+ end
+ post ':reference_message_id/create_reply'do
+ cs = CommentService.new
+ message = cs.create_reply params,current_user
+ raise "create reply failed #{message.errors.full_messages}" if message.new_record?
+ present :data, message, with: Mobile::Entities::Jours
+ present :status, 0
+ end
+
+ desc ' 意见反馈'
+ params do
+ requires :token, type: String
+ requires :subject,type: String,desc: '意见'
+ end
+ post do
+ cs_params = {
+ memo: {:subject => params[:subject],:content => '该贴来自手机App意见反馈'},
+ }
+ cs = CommentService.new
+ memo = cs.create_feedback cs_params, current_user
+ raise "commit failed #{memo.errors.full_messages}" if memo.new_record?
+ present :status, 0
+ end
+
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/api/mobile/apis/courses.rb b/app/api/mobile/apis/courses.rb
index 7c1aa5e7e..6d68d549a 100644
--- a/app/api/mobile/apis/courses.rb
+++ b/app/api/mobile/apis/courses.rb
@@ -8,10 +8,11 @@ module Mobile
optional :school_id, type: Integer, desc: '传入学校id,返回该学校课程列表'
requires :per_page_count, type: Integer, desc: '每页总数'
requires :page, type: Integer, desc: '当前页码'
+ optional :token, type: String
end
get do
cs = CoursesService.new
- courses = cs.course_list(params)
+ courses = cs.course_list(params,current_user.nil? ? User.find(2):current_user)
present :data, courses, with: Mobile::Entities::Course
present :status, 0
end
@@ -130,10 +131,11 @@ module Mobile
desc "搜索课程"
params do
requires :name, type: String, desc: "课程名"
+ optional :token, type: String
end
get 'search' do
cs = CoursesService.new
- courses = cs.search_course(params)
+ courses = cs.search_course(params,current_user.nil? ? User.find(2):current_user)
present :data, courses, with: Mobile::Entities::Course
present :status, 0
end
@@ -165,13 +167,15 @@ module Mobile
desc "返回单个课程"
params do
requires :id, type: Integer
+ optional :token, type: String
end
route_param :id do
get do
cs = CoursesService.new
course = cs.show_course(params,(current_user.nil? ? User.find(2):current_user))
#course = Course.find(params[:id])
- {status: 0, data: course}
+ present :data, course, with: Mobile::Entities::Course
+ present :status, 0
end
end
@@ -188,17 +192,18 @@ module Mobile
desc "课程通知列表"
params do
+ optional :token, type: String
end
get ":course_id/news" do
cs = CoursesService.new
- news = cs.course_news_list params
+ news = cs.course_news_list params,current_user.nil? ? User.find(2):current_user
present :data, news, with: Mobile::Entities::News
present :status, 0
end
desc "显示课程通知"
params do
-
+ optional :token, type: String
end
get "news/:id" do
cs = CoursesService.new
@@ -208,6 +213,16 @@ module Mobile
present :status, 0
end
+ desc '用户课程动态'
+ params do
+ requires :token, type: String
+ end
+ get "course_dynamic/:id" do
+ cs = CoursesService.new
+ count = cs.course_dynamic(params,current_user)
+ present :data, count, with: Mobile::Entities::CourseDynamic
+ present :status, 0
+ end
end
end
diff --git a/app/api/mobile/apis/homeworks.rb b/app/api/mobile/apis/homeworks.rb
index cba295064..7a8c87987 100644
--- a/app/api/mobile/apis/homeworks.rb
+++ b/app/api/mobile/apis/homeworks.rb
@@ -70,6 +70,32 @@ module Mobile
present :status, 0
end
+ desc "作品打分"
+ params do
+ requires :token, type: String
+ requires :is_teacher, type: String,desc: '是否为教师(匿评作品详情返回的结果中可获取此参数的值)'
+ requires :is_anonymous_comments, type: String, desc: '是否为匿评(匿评作品详情返回的结果中可获取此参数的值)'
+ optional :stars_value, type: Integer,desc: '用户给出的评分'
+ optional :cur_page,type: Integer,desc: '匿评作品详情返回的结果中可获取此参数的值'
+ optional :cur_type, type: Integer,desc: '匿评作品详情返回的结果中可获取此参数的值'
+ optional :user_message, type: String, desc: '用户评论'
+ end
+
+ post ':homework_id/scoring' do
+ cs_params = {
+ new_form: params.reject{|k,v| [:token,:is_teacher,:is_anonymous_comments,:stars_value,:cur_page,:cur_type,:homework_id].include?(k)},
+ token: params[:token],
+ is_teacher: params[:is_teacher],
+ is_anonymous_comments: params[:is_anonymous_comments],
+ stars_value: params[:stars_value],
+ cur_page: params[:cur_page],
+ cur_type: params[:cur_type],
+ homework_id: params[:homework_id]
+ }
+ Homeworks.get_service.add_score_and_jour cs_params,current_user
+ present :status, 0
+ end
+
end
end
diff --git a/app/api/mobile/apis/users.rb b/app/api/mobile/apis/users.rb
index 69260716e..9a5307be6 100644
--- a/app/api/mobile/apis/users.rb
+++ b/app/api/mobile/apis/users.rb
@@ -22,13 +22,15 @@ module Mobile
desc "显示用户"
params do
-
+ requires :id, type: Integer
end
- get ':id' do
- us = UsersService.new
- ue = us.show_user params
- present :data, ue,with: Mobile::Entities::User
- present :status, 0
+ route_param :id do
+ get do
+ us = UsersService.new
+ ue = us.show_user params
+ present :data, ue,with: Mobile::Entities::User
+ present :status, 0
+ end
end
desc "修改用户"
@@ -77,11 +79,12 @@ module Mobile
present :status, 0
end
- desc "用户搜索"
+ desc "用户搜索"
params do
requires :name, type: String, desc: '用户名关键字'
+ requires :search_by, type: String,desc: '搜索依据:0 昵称,1 用户名,2 邮箱'
end
- get 'search' do
+ get 'search/search_user' do
us = UsersService.new
user = us.search_user params
present :data, user, with: Mobile::Entities::User
diff --git a/app/api/mobile/entities/anonymous_works_params.rb b/app/api/mobile/entities/anonymous_works_params.rb
index 95cf9215d..e6bc8f346 100644
--- a/app/api/mobile/entities/anonymous_works_params.rb
+++ b/app/api/mobile/entities/anonymous_works_params.rb
@@ -15,6 +15,7 @@ module Mobile
anonymous_works_params_expose :m_score
anonymous_works_params_expose :is_anonymous_comments
anonymous_works_params_expose :cur_type
+ anonymous_works_params_expose :cur_page
expose :jours ,using: Mobile::Entities::Jours do |f, opt|
if f.is_a?(Hash) && f.key?(:jours)
f[:jours]
diff --git a/app/api/mobile/entities/comment.rb b/app/api/mobile/entities/comment.rb
new file mode 100644
index 000000000..803d0c6d0
--- /dev/null
+++ b/app/api/mobile/entities/comment.rb
@@ -0,0 +1,30 @@
+module Mobile
+ module Entities
+ class Comment < Grape::Entity
+ include Redmine::I18n
+ def self.comment_expose(field)
+ expose field do |f,opt|
+ if f.is_a?(Hash) && f.key?(field)
+ f[field]
+ elsif f.is_a?(::Comment)
+ if f.respond_to?(field)
+ if field == :created_on
+ format_time(f.send(field))
+ else
+ f.send(field)
+ end
+ end
+ end
+ end
+ end
+ comment_expose :id
+ expose :author, using: Mobile::Entities::User do |c, opt|
+ if c.is_a? ::Comment
+ c.author
+ end
+ end
+ comment_expose :comments
+ comment_expose :created_on
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/api/mobile/entities/course.rb b/app/api/mobile/entities/course.rb
index ec00579ce..4c91738c1 100644
--- a/app/api/mobile/entities/course.rb
+++ b/app/api/mobile/entities/course.rb
@@ -1,6 +1,7 @@
module Mobile
module Entities
class Course < Grape::Entity
+ include Redmine::I18n
def self.course_expose(field)
expose field do |f,opt|
c = nil
@@ -9,9 +10,11 @@ module Mobile
else
c = f[:course]
end
- if field == :img_url
+ if f.is_a?(Hash) && f.key?(field)
f[field] if f.is_a?(Hash) && f.key?(field)
#f.img_url if f.respond_to?(:img_url)
+ elsif field == :created_at || field == :updated_at
+ (format_time(c[field]) if (c.is_a?(Hash) && c.key?(field))) || (format_time(c.send(field)) if c.respond_to?(field))
else
(c[field] if (c.is_a?(Hash) && c.key?(field))) || (c.send(field) if c.respond_to?(field))
end
@@ -50,9 +53,11 @@ module Mobile
c[:course].teacher
end
end
- expose :my_homework,using: Mobile::Entities::HomeworkAttach do |f, opt|
+ expose :my_homework,using: Mobile::Entities::Homework do |f, opt|
f[:my_homework] if f.is_a?(Hash) && f.key?(:my_homework)
end
+ course_expose :current_user_is_member
+ course_expose :current_user_is_teacher
end
end
end
diff --git a/app/api/mobile/entities/course_dynamic.rb b/app/api/mobile/entities/course_dynamic.rb
new file mode 100644
index 000000000..5e22e3df7
--- /dev/null
+++ b/app/api/mobile/entities/course_dynamic.rb
@@ -0,0 +1,16 @@
+module Mobile
+ module Entities
+ class CourseDynamic < Grape::Entity
+ def self.course_dynamic_expose(field)
+ expose field do |c,opt|
+ c[field] if (c.is_a?(Hash) && c.key?(field))
+ end
+ end
+ course_dynamic_expose :type
+ course_dynamic_expose :count
+ course_dynamic_expose :course_name
+ course_dynamic_expose :course_id
+ course_dynamic_expose :course_img_url
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/api/mobile/entities/homework.rb b/app/api/mobile/entities/homework.rb
index 9be9bc53e..d4c34ffec 100644
--- a/app/api/mobile/entities/homework.rb
+++ b/app/api/mobile/entities/homework.rb
@@ -1,10 +1,15 @@
module Mobile
module Entities
class Homework < Grape::Entity
+ include Redmine::I18n
def self.homework_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
- f[field]
+ if field == :created_on
+ format_time(f[field])
+ else
+ f[field]
+ end
elsif f.is_a?(::Bid)
if f.respond_to?(field)
f.send(field)
@@ -18,8 +23,16 @@ module Mobile
homework_expose :id
#课程名称
homework_expose :course_name
- #课程老师
- homework_expose :course_teacher
+
+ homework_expose :course_id
+ #作业发布者
+ expose :author,using: Mobile::Entities::User do |f, opt|
+ f[:author]
+ end
+
+ #作业发布者真名
+ homework_expose :author_real_name
+
#作业次数
homework_expose :homework_times
#作业名称
@@ -36,6 +49,13 @@ module Mobile
#只有作业启用了匿评功能且当前用户是课程老师且已提交的作品数量大于或等于2才能开启匿评
homework_expose :homework_state
+ homework_expose :created_on
+ homework_expose :deadline
+
+ expose :jours,using: Mobile::Entities::Jours do |f, opt|
+ f[:jours] if f.is_a?(Hash) && f.key?(:jours)
+ end
+
expose :homework_for_anonymous_comments,using: Mobile::Entities::HomeworkAttach do |f, opt|
f[:homework_for_anonymous_comments] if f.is_a?(Hash) && f.key?(:homework_for_anonymous_comments)
end
diff --git a/app/api/mobile/entities/homework_attach.rb b/app/api/mobile/entities/homework_attach.rb
index 256dcdf61..690ec8e94 100644
--- a/app/api/mobile/entities/homework_attach.rb
+++ b/app/api/mobile/entities/homework_attach.rb
@@ -17,6 +17,8 @@ module Mobile
case field
when :homework_times
f.bid.courses.first.homeworks.index(f.bid) + 1 unless (f.bid.nil? || f.bid.courses.nil? || f.bid.courses.first.nil?)
+ when :comment_status
+ f.bid.comment_status
end
end
end
@@ -28,6 +30,8 @@ module Mobile
homework_attach_expose :homework_times
homework_attach_expose :description
homework_attach_expose :created_at
+ #comment_status 0:所属作业尚未开启匿评,1:匿评中 2:匿评结束
+ homework_attach_expose :comment_status
expose :attachments,using: Mobile::Entities::Attachment do |f, opt|
if f.respond_to?(:attachments)
f.send(:attachments)
diff --git a/app/api/mobile/entities/homework_jours.rb b/app/api/mobile/entities/homework_jours.rb
index 63c6997fd..0b9defe67 100644
--- a/app/api/mobile/entities/homework_jours.rb
+++ b/app/api/mobile/entities/homework_jours.rb
@@ -6,7 +6,11 @@ module Mobile
def self.homework_jours_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
- f[field]
+ if field == :created_at
+ format_time(f[field])
+ else
+ f[field]
+ end
elsif f.is_a?(::SeemsRateableRates)
end
diff --git a/app/api/mobile/entities/jours.rb b/app/api/mobile/entities/jours.rb
index 5a9f48cbc..10fd0f893 100644
--- a/app/api/mobile/entities/jours.rb
+++ b/app/api/mobile/entities/jours.rb
@@ -18,12 +18,15 @@ module Mobile
end
end
jours_expose :id
+ jours_expose :jour_type
+ jours_expose :jour_id
expose :user,using: Mobile::Entities::User do |f, opt|
f.user
end
jours_expose :created_on
jours_expose :notes
jours_expose :m_reply_id
+ jours_expose :m_parent_id
expose :reply_user,using: Mobile::Entities::User do |f, opt|
f.at_user
end
diff --git a/app/api/mobile/entities/news.rb b/app/api/mobile/entities/news.rb
index 7c77f8c82..f189771e3 100644
--- a/app/api/mobile/entities/news.rb
+++ b/app/api/mobile/entities/news.rb
@@ -1,6 +1,7 @@
module Mobile
module Entities
class News < Grape::Entity
+ include Redmine::I18n
def self.news_expose(field)
expose field do |f,opt|
if f.is_a?(Hash) && f.key?(field)
@@ -9,13 +10,18 @@ module Mobile
n = f[:news]
comments = f[:comments]
if n.is_a?(::News)
- n.send(field) if n.respond_to?(field)
+ if field == :created_on
+ format_time(n.send(field)) if n.respond_to?(field)
+ else
+ n.send(field) if n.respond_to?(field)
+ end
+
end
end
end
end
-
+ news_expose :id
#新闻标题
news_expose :title
@@ -34,7 +40,11 @@ module Mobile
#评论数量
news_expose :comments_count
#评论
- news_expose :comments
+ expose :comments, using: Mobile::Entities::Comment do |f, opt|
+ if f.is_a?(Hash) && f.key?(:comments)
+ f[:comments]
+ end
+ end
end
diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index ff66b8d46..87c028354 100644
--- a/app/controllers/account_controller.rb
+++ b/app/controllers/account_controller.rb
@@ -315,7 +315,7 @@ class AccountController < ApplicationController
code = /\d*/
#根据home_url生产正则表达式
eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/")
- if code=~params[:back_url] && last_login_on != ''
+ if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && last_login_on != ''
redirect_to user_activities_path(user)
else
if last_login_on == ''
diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 7e5894b83..a22012390 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -9,7 +9,7 @@ class BidsController < ApplicationController
menu_item :homework_statistics, :only => :homework_statistics
menu_item :edit, :only => :edit
-
+ before_filter :auth_login1, :only => [:show_courseEx]
before_filter :can_show_course,only: []
before_filter :can_show_contest,only: []
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 7653be94d..8fae547c4 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -5,6 +5,7 @@ class CoursesController < ApplicationController
helper :members
helper :words
+ before_filter :auth_login1, :only => [:show, :feedback]
menu_item :overview
menu_item :feedback, :only => :feedback
menu_item :homework, :only => :homework
@@ -98,7 +99,8 @@ class CoursesController < ApplicationController
#更新课程信息
def update
cs = CoursesService.new
- @course = cs.edit_course params,@course,User.current
+ c = cs.edit_course params,@course,User.current
+ @course = c[:course]
if @course.errors.full_messages.count <= 0
respond_to do |format|
format.html {
@@ -254,8 +256,8 @@ class CoursesController < ApplicationController
end
@is_remote = true
@result_count = @results.count
- @results = paginateHelper @results
-
+ @results = paginateHelper @results, 10
+ @search_name = q
end
def addgroups
@@ -428,17 +430,34 @@ class CoursesController < ApplicationController
# @results = paginateHelper @results@score_sort_by = "desc"
@is_remote = true
@score_sort_by = params[:sort_by] if params[:sort_by]
+ @search_name = params[:search_name] if params[:search_name]
group_id = params[:group_id]
- if group_id == '0'
- page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
- @results = student_homework_score(0,page, 10,@score_sort_by)
+ if !@search_name.nil?
+ if group_id == '0'
+ page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
- @results = paginateHelper_for_members @results, 10
+ @results = searchmember_by_name(student_homework_score(0,0,0,@score_sort_by), @search_name)
+ @result_count = @results.count
+ @results = paginateHelper @results, 10
+ else
+ @group = CourseGroup.find(group_id)
+ @results = searchmember_by_name(student_homework_score(group_id, 0, 0,@score_sort_by),@search_name)
+ @result_count = @results.count
+ @results = paginateHelper @results, 10
+ end
else
- @group = CourseGroup.find(group_id)
- @results = student_homework_score(group_id, 0, 0,@score_sort_by)
- @results = paginateHelper @results, 10
+ if group_id == '0'
+ page = params[:page].nil? ? 0 : (params['page'].to_i - 1)
+ @results = student_homework_score(0,page, 10,@score_sort_by)
+
+ @results = paginateHelper_for_members @results, 10
+ else
+ @group = CourseGroup.find(group_id)
+ @results = student_homework_score(group_id, 0, 0,@score_sort_by)
+ @results = paginateHelper @results, 10
+ end
end
+
end
# 显示每个学生的作业评分详情
def show_member_score
@@ -481,7 +500,7 @@ class CoursesController < ApplicationController
def create
cs = CoursesService.new
- @course = cs.create_course params,User.current
+ @course = cs.create_course(params,User.current)[:course]
if @course.new_record?
respond_to do |format|
format.html { render :action => 'new', :layout => 'base' } #Added by young
@@ -938,10 +957,34 @@ class CoursesController < ApplicationController
else
render_403
end
-
end
-
+ #根据已有课程复制课程
+ #param id:已有课程ID
+ def copy_course
+ if @course
+ @new_course = Course.new @course.attributes
+ @new_course.tea_id = User.current.id
+ @new_course.created_at = DateTime.now
+ @new_course.updated_at = DateTime.now
+ @new_course.endup_time = nil
+ if @new_course.save
+ r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
+ m = Member.new(:user => User.current, :roles => [r])
+ m.project_id = -1
+ course = CourseInfos.new(:user_id => User.current.id, :course_id => @new_course.id)
+ #user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
+ if @new_course.is_public == 1
+ course_status = CourseStatus.create(:course_id => @new_course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => 1)
+ end
+ @new_course.members << m
+ @new_course.course_infos << course
+ redirect_to settings_course_url @new_course
+ end
+ else
+ render_404
+ end
+ end
private
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 56f760e13..5336ab54d 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -20,7 +20,7 @@ class FilesController < ApplicationController
layout 'base_projects' #by young
menu_item :files
-
+ before_filter :auth_login1, :only => [:index]
before_filter :find_project_by_project_id#, :except => [:getattachtype]
before_filter :authorize, :except => [:getattachtype,:quote_resource_show,:search]
diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb
index 54b8c6305..2f7092d9a 100644
--- a/app/controllers/forums_controller.rb
+++ b/app/controllers/forums_controller.rb
@@ -15,12 +15,14 @@ class ForumsController < ApplicationController
PageLimit = 20
def create_feedback
if User.current.logged?
- @memo = Memo.new(params[:memo])
- @memo.forum_id = "1"
- @memo.author_id = User.current.id
+ #@memo = Memo.new(params[:memo])
+ #@memo.forum_id = "1"
+ #@memo.author_id = User.current.id
#@forum = @memo.forum
+ cs = CommentService.new
+ @memo = cs.create_feedback params,User.current
respond_to do |format|
- if @memo.save
+ if !@memo.new_record?
format.html { redirect_to forum_path(@memo.forum) }
else
sort_init 'updated_at', 'desc'
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 8d6943f02..d2a253c2a 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -17,6 +17,7 @@
class MessagesController < ApplicationController
include ApplicationHelper
+ before_filter :authorize1, :only => [:show]
menu_item :boards
default_search_scope :messages
before_filter :find_board, :only => [:new, :preview,:edit]
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 2df17d73f..b44e8a348 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -17,6 +17,7 @@
class NewsController < ApplicationController
layout 'base_projects'# by young
+ before_filter :authorize1, :only => [:show]
default_search_scope :news
model_object News
before_filter :find_model_object, :except => [:new, :create, :index]
diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb
index 1b2794034..b897d039a 100644
--- a/app/controllers/poll_controller.rb
+++ b/app/controllers/poll_controller.rb
@@ -23,6 +23,10 @@ class PollController < ApplicationController
def show
@poll = Poll.find params[:id]
+ if @poll.polls_status != 2 && !User.current.allowed_to?(:as_teacher,@course)
+ render_403
+ return
+ end
#已提交问卷的用户不能再访问该界面
if has_commit_poll?(@poll.id,User.current.id) && (!User.current.admin?)
render_403
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 9a9537e6d..dfdcf6576 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -19,12 +19,13 @@
# Description 封装代码,简化代码,格式化代码,
class ProjectsController < ApplicationController
layout :select_project_layout
-
- menu_item :overview
+ before_filter :authorize1, :only => [:show]
+ menu_item :overview, :only => :show
menu_item :roadmap, :only => :roadmap
menu_item :settings, :only => :settings
menu_item :homework, :only => [:homework, :new_homework]
menu_item :feedback, :only => :feedback
+ menu_item :share, :only => :share
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join,
:course, :enterprise_course, :course_enterprise,:view_homework_attaches]
@@ -249,6 +250,17 @@ class ProjectsController < ApplicationController
def show
=begin
# 试图跳转到请求的按钮
+ if params[:login]
+ login = params[:login]
+ login = login.sub(/%40/,'@')
+ mail = params[:login]
+ password = params[:password]
+ us = UsersService.new
+ user = us.register_auto(login,mail, password)
+ Member.create(:role_ids => [4], :user_id => user.id,:project_id => @project.id)
+ UserGrade.create(:user_id => user.id, :project_id => @project.id)
+ User.current = user unless User.current.nil?
+ end
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 526ae227d..b3e808b19 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -18,7 +18,7 @@ class UsersController < ApplicationController
layout :setting_layout
#Added by young
- before_filter :auth_login1, :only => [:show, :user_activities]
+ before_filter :auth_login1, :only => [:show, :user_activities, :user_newfeedback]
menu_item :activity
menu_item :user_information, :only => :info
menu_item :user_course, :only => :user_courses
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index 144199b86..db2f287eb 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -25,22 +25,30 @@ class WelcomeController < ApplicationController
before_filter :entry_select, :only => [:index]
def index
- unless params[:project].nil?
- @cur_projects = Project.find(params[:project])
- @organization = @cur_projects.enterprise_name
- @organization_projects = Project.find_by_sql(["select * from projects where enterprise_name =? ", @organization])
+ # 企业版定制: params[:project]为传过来的参数
+ unless params[:organization].nil?
+ @cur_projects = Project.find(params[:organization])
+ @organization = @cur_projects.enterprise_name
+ @organization_projects = (current_user.admin? || User.current.member_of?(@cur_projects)) ? Project.where("enterprise_name =? ", @organization) : Project.all_public.where("enterprise_name =? ", @organization)
@e_count = @organization_projects.count
+ @part_projects = []
+ # 取十个
+ @organization_projects.each do |obj|
+ break if(@organization_projects[10] == obj)
+ @part_projects << Project.visible.find_by_id("#{obj.id}") unless obj.id.nil?
+ end
+ # 不够十个的用最火项目替代
+ @e_count < 9 ? @part_projects = find_miracle_project( 9 - @e_count, 3,"score desc") : @part_projects
+ # 配置文件首页定制
@enterprise_page = FirstPage.find_by_page_type('enterprise')
if @enterprise_page.nil?
@enterprise_page = FirstPage.new
@enterprise_page.page_type = 'enterprise'
end
- if @e_count < 9
- part_count = 9 - @e_count
- # @part_projects = find_all_hot_project part_count, order
- @part_projects = find_miracle_project(part_count, 3,"score desc")
- end
+ # 主页配置部分结束
+
end
+ # end 企业版定制结束
if @first_page.nil? || @first_page.sort_type.nil?
@projects = find_miracle_project(10, 3,"score desc")
else
@@ -76,7 +84,7 @@ class WelcomeController < ApplicationController
def course
@course_page = FirstPage.find_by_page_type('course')
- @school_id = params[:school_id] || User.current.user_extensions.school.try(:id)
+ @school_id = params[:school_id] || User.current.user_extensions.school.try(:id) || 117
@logoLink ||= logolink()
##3-8月份为查找春季课程,9-2月份为查找秋季课程
diff --git a/app/helpers/api_helper.rb b/app/helpers/api_helper.rb
index 8ff6f725c..c865a500b 100644
--- a/app/helpers/api_helper.rb
+++ b/app/helpers/api_helper.rb
@@ -37,4 +37,27 @@ module ApiHelper
end
result
end
+
+ #########################################################
+ #sw
+ #获取课程未匿评数量
+ #param: user => "用户", course_id => "查询的课程ID"
+ #return: 作业的数量
+ #########################################################
+ def get_course_anonymous_evaluation user,course
+ count = 0
+ if course
+ is_teacher = is_course_teacher user,course
+ if is_teacher #如果是老师,显示学生提交的作业数
+ course.homeworks.each do |bid|
+ count += bid.homeworks.count
+ end
+ else #如果是学生,显示未匿评的数量
+ course.homeworks.each do |bid|
+ count += get_student_not_batch_homework_list bid,user
+ end
+ end
+ end
+ [count,is_teacher]
+ end
end
\ No newline at end of file
diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb
index c41ba54ee..72d381b28 100644
--- a/app/helpers/homework_attach_helper.rb
+++ b/app/helpers/homework_attach_helper.rb
@@ -130,4 +130,20 @@ module HomeworkAttachHelper
WHERE homework_attaches.bid_id = #{bid.id} AND homework_evaluations.user_id = #{user.id} ORDER BY m_score DESC")
student_batch_homework_list
end
+
+ #########################################################
+ #sw
+ #获取学生未进行匿评的数量
+ #param: bid => 作业 user => 用户
+ #return 指定用户未进行匿评的作业的数量
+ #user必须是学生用户
+ #######################################################
+ def get_student_not_batch_homework_list bid,user
+ HomeworkAttach.find_by_sql("SELECT * FROM(SELECT homework_attaches.*,
+ (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{user.id} AND is_teacher_score = 0) AS m_score
+ FROM homework_attaches
+ INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
+ WHERE homework_attaches.bid_id = #{bid.id} AND homework_evaluations.user_id = #{user.id}) AS table1
+ WHERE table1.m_score IS NULL").count
+ end
end
\ No newline at end of file
diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb
index d101fd36c..eba3c0b3c 100644
--- a/app/helpers/welcome_helper.rb
+++ b/app/helpers/welcome_helper.rb
@@ -314,28 +314,28 @@ module WelcomeHelper
str = ' '.html_safe
case event.event_type
when 'news'
- str << content_tag("span", l(:field_user_active_published)) <<
+ str << content_tag("span", l('user.active.published')) <<
content_tag("span", find_all_event_type(event)) <<
': '.html_safe <<
link_to(strip_tags(event.event_description).gsub(/ /,''), event.event_url, {:title => event.event_description})
when 'issue', 'message' , 'bid' , 'wiki-page' , 'document'
- str << content_tag("span", l(:field_user_active_published)) <<
+ str << content_tag("span", l('user.active.published')) <<
content_tag("span", find_all_event_type(event)) <<
': '.html_safe <<
link_to(event.event_title, event.event_url, {:title => event.event_title})
when 'reply' ,'Reply', 'Memo'
- str << content_tag("span", l(:field_user_active_published)) <<
+ str << content_tag("span", l('user.active.published')) <<
content_tag("span", find_all_event_type(event)) <<
': '.html_safe <<
link_to(strip_tags(event.event_description).gsub(/ /,''), event.event_url, {:title => event.event_description})
when 'attachment'
- str << content_tag('span', l(:field_user_active_uploaded)) <<
+ str << content_tag('span', l('user.active.uploaded')) <<
content_tag('span', find_all_event_type(event)) <<
': '.html_safe <<
link_to(event.event_title, event.event_url, {:title => event.event_title}) <<
link_to((' ['.html_safe+l(:label_downloads_list).to_s << ']'), project_files_path(event.container.project), :class => "attachments_list_color")
else
- str << content_tag("span", l(:field_user_active_updated)) <<
+ str << content_tag("span", l('user.active.updated')) <<
content_tag("span", find_all_event_type(event)) <<
': '.html_safe << link_to(event.event_title, event.event_url, {:title => event.event_title})
end
diff --git a/app/models/bid.rb b/app/models/bid.rb
index 0fc46d24d..e5de47b24 100644
--- a/app/models/bid.rb
+++ b/app/models/bid.rb
@@ -86,7 +86,9 @@ class Bid < ActiveRecord::Base
# 'deadline'
def add_jour(user, notes, reference_user_id = 0, options = {})
if options.count == 0
- self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
+ jfm = JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
+ self.journals_for_messages << jfm
+ jfm
else
jfm = self.journals_for_messages.build(options)
jfm.save
diff --git a/app/models/forum.rb b/app/models/forum.rb
index 6f834702b..878937ea7 100644
--- a/app/models/forum.rb
+++ b/app/models/forum.rb
@@ -18,7 +18,7 @@ class Forum < ActiveRecord::Base
acts_as_taggable
scope :by_join_date, order("created_at DESC")
- after_create :send_email
+ #after_create :send_email
def reset_counters!
self.class.reset_counters!(id)
end
diff --git a/app/models/forum_observer.rb b/app/models/forum_observer.rb
index 1c514d6ab..6afcac824 100644
--- a/app/models/forum_observer.rb
+++ b/app/models/forum_observer.rb
@@ -1,8 +1,8 @@
class ForumObserver < ActiveRecord::Observer
- def after_create(forum)
- Thread.start do
- Mailer.forum_add(forum).deliver if Setting.notified_events.include?('forum_add')
- end
-
- end
+ # def after_create(forum)
+ # Thread.start do
+ # Mailer.forum_add(forum).deliver if Setting.notified_events.include?('forum_add')
+ # end
+ #
+ # end
end
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index 4af9ec2f7..23d9c7753 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -21,8 +21,8 @@ class JournalsForMessage < ActiveRecord::Base
:foreign_key => 'jour_id',
:conditions => "#{self.table_name}.jour_type = 'Project' "
belongs_to :course,
- :foreign_key => 'jour_id',
- :conditions => "#{self.table_name}.jour_type = 'Course' "
+ :foreign_key => 'jour_id'
+
belongs_to :jour, :polymorphic => true
belongs_to :user
diff --git a/app/models/mailer.rb b/app/models/mailer.rb
index f42c20acc..14c01b93d 100644
--- a/app/models/mailer.rb
+++ b/app/models/mailer.rb
@@ -27,21 +27,104 @@ class Mailer < ActionMailer::Base
{ :host => Setting.host_name, :protocol => Setting.protocol }
end
- # 贴吧新建贴吧发送邮件
- # example Mailer.forum(forum).deliver
- def forum_add(forum)
+ # author: alan
+ # 发送邀请未注册用户加入项目邮件
+ # 功能: 在加入项目的同时自动注册用户
+ def send_invite_in_project(email, project, invitor)
+ @subject = "#{invitor.name} #{l(:label_invite_project)} #{project.name} "
+ password = newpass(6)
+ @project_url = url_for(:controller => 'projects', :action => 'show', :id => project.id,
+ :password => password, :login => email)
+ mail :to => email, :subject => @subject
+ end
- redmine_headers 'Forum' => forum.id
- @forum = forum
- @author = forum.creator
- recipients = forum.creator.mail
- # cc = wiki_content.page.wiki.watcher_recipients - recipients
- @issue_author_url = url_for(user_activities_url(@author))
- @forum_url = url_for(:controller => 'forums', :action => 'show', :id => forum.id)
- mail :to => recipients,:subject => "[ #{l(:label_forum)} : #{forum.name} #{l(:notice_successful_create)}]"
+ # author: alan
+ # 根据用户选择发送个人日报或周报
+ # 发送内容: 项目【缺陷,讨论区,新闻】,课程【通知,留言,新闻】, 贴吧, 个人留言
+ def send_for_user_activities(user, date_to, days)
+ date_from = date_to - days.days
+
+ # 生成token用于直接点击登录
+ @user = user
+ token = Token.new(:user =>user , :action => 'autologin')
+ token.save
+ @token = token
+
+ @user_url = url_for(my_account_url(user,:token => @token.value))
+ # 查询user参加的项目及课程
+ projects = user.projects
+ courses = user.courses
+ project_ids = projects.map{|project| project.id}.join(",")
+ course_ids = courses.map {|course| course.id}.join(",")
+
+ # 查询user的缺陷,包括发布的,跟踪的以及被指派的缺陷
+ @issues = Issue.find_by_sql("select DISTINCT i.* from issues i, watchers w
+ where (i.assigned_to_id = #{user.id} or i.author_id = #{user.id}
+ or (w.watchable_type = 'Issue' and w.watchable_id = i.id and w.user_id = #{user.id}))
+ and (i.created_on between '#{date_from}' and '#{date_to}') order by i.created_on desc")
+
+ # @bids 查询课程作业,包括老师发布的作业,以及user提交作业
+ # @attachments查询课程课件更新
+ @attachments ||= []
+
+ @bids ||= [] # 老师发布的作业
+
+ unless courses.first.nil?
+ count = courses.count
+ count = count - 1
+ for i in 0..count do
+ bids = courses[i].homeworks.where("bids.created_on between '#{date_from}' and '#{date_to}'").order("bids.created_on desc")
+ attachments = courses[i].attachments.where("attachments.created_on between '#{date_from}' and '#{date_to}'").order('attachments.created_on DESC')
+ @bids += bids if bids.count > 0
+ @attachments += attachments if attachments.count > 0
+ end
+ end
+ # user 提交的作业
+ @homeworks = HomeworkAttach.where("user_id=#{user.id} and (created_at between '#{date_from}' and '#{date_to}')").order("created_at desc")
+
+ # 查询user在课程。项目中发布的讨论帖子
+ messages = Message.find_by_sql("select DISTINCT * from messages where author_id = #{user.id} and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
+ @course_messages ||= []
+ @project_messages ||= []
+ unless messages.first.nil?
+ messages.each do |msg|
+ if msg.project
+ @project_messages << msg
+ elsif msg.course
+ @course_messages << msg
+ end
+ end
+ end
+ # 查询user在课程中发布的通知,项目中发的新闻
+ @course_news = News.find_by_sql("select DISTINCT n.* from news n
+ where n.course_id in (#{course_ids})
+ and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
+ @project_news = News.find_by_sql("select DISTINCT n.* from news n where n.project_id in (#{project_ids})
+ and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
+
+ # 查询user在课程及个人中留言
+ @course_journal_messages = JournalsForMessage.find_by_sql("select DISTINCT * from journals_for_messages where
+ jour_type='Course' and user_id = #{user.id}
+ and (created_on between '#{date_from}' and '#{date_to}') order by created_on desc")
+ @user_journal_messages = user.journals_for_messages.where("m_parent_id IS NULL and (created_on between '#{date_from}' and '#{date_to}')").order('created_on DESC')
+
+
+ # 查询user新建贴吧或发布帖子
+ @forums = Forum.find_by_sql("select DISTINCT * from forums where creator_id = #{user.id} and (created_at between '#{date_from}' and '#{date_to}') order by created_at desc")
+ @memos = Memo.find_by_sql("select DISTINCT m.* from memos m, forums f where (m.author_id = #{user.id} or (m.forum_id = f.id and f.creator_id = #{user.id}))
+ and (m.created_at between '#{date_from}' and '#{date_to}') order by m.created_at desc")
+ if days == 1
+ subject = "[ #{user.show_name} : #{l(:label_day_mail)}]"
+ @subject = " #{user.show_name} : #{date_to - 1.days} #{l(:label_day_mail)}"
+ else
+ subject = "[ #{user.show_name} : #{l(:label_week_mail)}]"
+ @subject = "#{user.show_name} : #{l(:label_week_mail)}"
+ end
+ mail :to => user.mail,:subject => subject
end
+
def forum_message_added(memo)
@memo = memo
redmine_headers 'Memo' => memo.id
@@ -50,9 +133,11 @@ class Mailer < ActionMailer::Base
@forum_url = url_for(:controller => 'forums', :action => 'show', :id => @forum.id)
@issue_author_url = url_for(user_activities_url(@author))
recipients ||= []
- mems = memo.self_and_siblings
- mems.each do |mem|
- recipients << mem.author.mail unless recipients.include? mem.author.mail
+ if @forum.author.mail_notification != 'day' && @forum.author.mail_notification != 'week'
+ recipients << @forum.creator.mail
+ end
+ if @author.mail_notification != 'day' && @author.mail_notification != 'week'
+ recipients << @author.mail
end
# cc = wiki_content.page.wiki.watcher_recipients - recipients
@@ -88,6 +173,17 @@ class Mailer < ActionMailer::Base
Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
return -1
end
+
+ # 验证用户的收取邮件的方式
+ recipients ||= []
+ recipients1 ||= []
+ if @mail.mail_notification != 'week' && @mail.mail_notification != 'day'
+ recipients1 = @mail.mail
+ end
+ if journals_for_message.jour.author.mail_notification != 'week' && journals_for_message.jour.author.mail_notification != 'day'
+ recipients = journals_for_message.jour.author.mail
+ end
+
# modify by nwb
#如果是直接留言并且留言对象是课程
if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Course
@@ -98,10 +194,9 @@ class Mailer < ActionMailer::Base
#收件人邮箱
@recipients ||= []
@members.each do |teacher|
-
+ if teacher.user.mail_notification != 'week' && teacher.user.mail_notification != 'day'
@recipients << teacher.user.mail
-
-
+ end
end
mail :to => @recipients,
:subject => "#{l(:label_your_course)}#{journals_for_message.jour.name}#{l(:label_have_message)} "
@@ -109,14 +204,15 @@ class Mailer < ActionMailer::Base
if !journals_for_message.jour.author.notify_about? journals_for_message
return -1
end
- mail :to => journals_for_message.jour.author.mail, :subject => @title
+
+ mail :to => recipients, :subject => @title
elsif journals_for_message.jour.class.to_s.to_sym == :Contest
if !journals_for_message.jour.author.notify_about? journals_for_message
return -1
end
- mail :to => journals_for_message.jour.author.mail, :subject => @title
+ mail :to => recipients, :subject => @title
else
- mail :to => @mail.mail, :subject => @title
+ mail :to => recipients1, :subject => @title
end
@@ -138,7 +234,6 @@ class Mailer < ActionMailer::Base
@author = issue.author
@issue = issue
user = User.find_by_mail(recipients)
-
token = Token.new(:user =>user , :action => 'autologin')
token.save
@token = token
@@ -194,12 +289,6 @@ class Mailer < ActionMailer::Base
@user_url = url_for(my_account_url(user,:token => @token.value))
@issue_url = url_for(:controller => 'issues', :action => 'show', :id => issue.id, :anchor => "change-#{journal.id}", :token => @token.value)
-
-
-
-
-
-
s = "[#{issue.project.name} - #{issue.tracker.name} ##{issue_id}] "
s << "(#{issue.status.name}) " if journal.new_value_for('status_id')
s << issue.subject
@@ -750,4 +839,13 @@ class Mailer < ActionMailer::Base
end
end
end
+
+ # author: alan
+ # 功能: 生成len位随机字符串
+ def newpass(len)
+ chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
+ newpass = ""
+ 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }
+ return newpass
+ end
end
diff --git a/app/models/memo.rb b/app/models/memo.rb
index 4899a655a..052ca03db 100644
--- a/app/models/memo.rb
+++ b/app/models/memo.rb
@@ -42,7 +42,7 @@ class Memo < ActiveRecord::Base
"parent_id",
"replies_count"
- after_create :add_author_as_watcher, :reset_counters!, :sendmail#,:be_user_score -- 公共区发帖暂不计入得分
+ after_create :add_author_as_watcher, :reset_counters! #, :sendmail#,:be_user_score -- 公共区发帖暂不计入得分
# after_update :update_memos_forum
after_destroy :reset_counters!#,:down_user_score -- 公共区发帖暂不计入得分
# after_create :send_notification
diff --git a/app/models/user.rb b/app/models/user.rb
index 06f59c764..83e08254c 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -24,7 +24,7 @@ class User < Principal
DEVELOPER = 3
include Redmine::SafeAttributes
-
+ seems_rateable_rater
# Different ways of displaying/sorting users
USER_FORMATS = {
:firstname_lastname => {
@@ -66,10 +66,8 @@ class User < Principal
MAIL_NOTIFICATION_OPTIONS = [
['all', :label_user_mail_option_all],
- ['selected', :label_user_mail_option_selected],
- ['only_my_events', :label_user_mail_option_only_my_events],
- ['only_assigned', :label_user_mail_option_only_assigned],
- ['only_owner', :label_user_mail_option_only_owner],
+ ['week', :label_user_mail_option_week],
+ ['day', :label_user_mail_option_day],
['none', :label_user_mail_option_none]
]
@@ -149,7 +147,7 @@ class User < Principal
scope :by_join_date, order("created_on DESC")
############################# added by liuping 关注
acts_as_watchable
- seems_rateable_rater
+
has_one :user_extensions,:dependent => :destroy
## end
@@ -188,7 +186,7 @@ class User < Principal
validates_confirmation_of :password, :allow_nil => true
validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
validate :validate_password_length
- #validates_email_realness_of :mail
+ # validates_email_realness_of :mail
before_create :set_mail_notification
before_save :update_hashed_password
before_destroy :remove_references_before_destroy
diff --git a/app/services/comment_service.rb b/app/services/comment_service.rb
new file mode 100644
index 000000000..876caaaf3
--- /dev/null
+++ b/app/services/comment_service.rb
@@ -0,0 +1,90 @@
+class CommentService
+ #评论
+ def news_comments params,current_user
+ @news = News.find(params[:id])
+ @course = @news.course
+ if @course.nil?
+ raise 'news in unknown course'
+ end
+ raise Unauthorized unless @news.commentable?(current_user)
+ if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
+ raise '403'
+ end
+ @comment = Comment.new
+ @comment.send(:safe_attributes=,params[:comment],current_user)
+ @comment.author = current_user
+ @news.comments << @comment
+ @comment
+ end
+
+ #作业留言
+ def homework_message params,current_user
+ @bid = Bid.find(params[:id], :include => [{:homeworks => :user}])
+ if params[:bid_message][:message].size>0
+ if params[:reference_content]
+ message = params[:bid_message][:message] + "\n" + params[:reference_content]
+ else
+ message = params[:bid_message][:message]
+ @m = message
+ end
+ refer_user_id = params[:bid_message][:reference_user_id].to_i
+ jfm = @bid.add_jour(current_user, message, refer_user_id)
+ end
+ #@user = @bid.author
+ #@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
+ #@jour = paginateHelper @jours,10
+ @bid.set_commit(@feedback_count)
+ jfm
+ end
+ #课程留言接口
+ def leave_course_message params,current_user
+ message = params[:new_form][:course_message]
+ feedback = Course.add_new_jour(current_user, message, params[:id])
+ feedback
+ end
+
+ #回复留言接口
+ def create_reply params,current_user
+ # 这里是创建回复所使用的方法,此方法只针对回复,每一个新的留言并不在此方法管理范围内。
+ # 由于多个地方用到了留言,而之前的表设计也有jour_type/jour_id这类信息
+ # 所以在方法 add_reply_adapter 中判断所有调用此方法的来源页面,
+ # 为了保证兼容以往所有的代码,保证以往的方法可以调用,在返回页面中都做了各式各样的判断。
+ # 页面保证 render new_respond/journal_reply
+ # 修改 add_reply_adapter 中可以确保留言创建成功
+ # 删除留言功能要调用destroy,也记得在destroy.js中修改
+
+ # deny api. api useless
+ parent_id = params[:reference_id]
+ author_id = current_user.id
+ reply_user_id = params[:reference_user_id]
+ reply_id = params[:reference_message_id] # 暂时不实现
+ content = params[:user_notes]
+ jour_type = params[:jour_type]
+ jour_id = params[:jour_id]
+ @show_name = params[:show_name] == "true"
+ options = {
+ :jour_id => jour_id,
+ :jour_type => jour_type,
+ :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 = ::JournalsForMessage.new(options)
+ #@save_succ = true if @jfm.errors.empty?
+ @jfm.save
+ @jfm
+ end
+
+ #发贴,用于意见反馈
+ def create_feedback params,current_user
+ @memo = Memo.new(params[:memo])
+ @memo.forum_id = "1"
+ @memo.author_id = current_user.id
+ @memo.save
+ @memo
+ end
+
+end
\ No newline at end of file
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index 41b6f2c68..22b7f8cd3 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -2,11 +2,12 @@ class CoursesService
include ApplicationHelper
include CoursesHelper
include HomeworkAttachHelper
- #TODO:尚未整合权限系统
+ include ApiHelper
+
#参数school_id为0或不传时返回所有课程,否则返回对应学校的课程
#参数per_page_count分页功能,每页显示的课程数
#参数page分页功能,当前页码
- def course_list params
+ def course_list params,current_user
@school_id = params[:school_id]
per_page_option = params[:per_page_count] || 10
page_no = params[:page] || 1
@@ -24,13 +25,13 @@ class CoursesService
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
course_list = []
@courses.each do |course|
- course_list << {:course => course,:img_url => url_to_avatar(course)}
+ course_list << {:course => course,:img_url => url_to_avatar(course),:current_user_is_member => current_user.member_of_course?(course),:current_user_is_teacher => is_course_teacher(current_user,course)}
end
course_list
end
#搜索课程
- def search_course params
+ def search_course params,current_user
courses_all = Course.all_course
name = params[:name]
if name.blank?
@@ -43,6 +44,11 @@ class CoursesService
@courses_all = @courses;
end
@courses_all
+ course_list = []
+ @courses_all.each do |course|
+ course_list << {:course => course,:img_url => url_to_avatar(course),:current_user_is_member => current_user.member_of_course?(course),:current_user_is_teacher => is_course_teacher(current_user,course)}
+ end
+ course_list
end
#获取头像
@@ -106,14 +112,17 @@ class CoursesService
end
#课程通知列表
- def course_news_list params
+ def course_news_list params,current_user
if params[:course_id] && @course==nil
@course = Course.find(params[:course_id])
end
- scope = @course ? @course.news.course_visible : News.course_visible
+ if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
+ raise '403'
+ end
+ scope = @course ? @course.news.course_visible(current_user) : News.course_visible(current_user)
news = []
scope.each do |n|
- news << {:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
+ news << {:id => n.id,:title => n.title,:author_name => n.author.name,:author_id => n.author.id, :description => n.description,:created_on => format_time(n.created_on),:comments_count => n.comments_count}
end
news
end
@@ -128,9 +137,16 @@ class CoursesService
#显示课程通知(包括评论) 需验证权限
def show_course_news params,current_user
@news = News.find(params[:id])
+ @course = @news.course
+ if @course
+ if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
+ raise '403'
+ end
+ end
@comments = @news.comments
@comments.reverse! if current_user.wants_comments_in_reverse_order?
{:news => @news,:comments => @comments}
+
#comments = []
#@comments.each do |comment|
# comments << {:author_id => comment.author_id,:author_name => comment.author.name,:commont_content => comment.comments,:time => format_time(comment.created_on)}
@@ -147,7 +163,7 @@ class CoursesService
unless (course.is_public == 1 || currnet_user.member_of_course?(@course)|| currnet_user.admin?)
raise '403'
end
- course
+ {:course => course,:img_url => url_to_avatar(course),:current_user_is_member => current_user.member_of_course?(course),:current_user_is_teacher => is_course_teacher(current_user,course)}
end
#创建课程
@@ -195,7 +211,7 @@ class CoursesService
@course.members << m
@course.course_infos << course
end
- @course
+ {:course => @course,:img_url => url_to_avatar(@course),:current_user_is_member => current_user.member_of_course?(@course),:current_user_is_teacher => is_course_teacher(current_user,@course)}
end
#验证编辑课程的权限
@@ -232,7 +248,7 @@ class CoursesService
course_status = CourseStatus.create(:course_id => course.id, :grade => 0)
end
end
- course
+ {:course => course,:img_url => url_to_avatar(course),:current_user_is_member => current_user.member_of_course?(course),:current_user_is_teacher => is_course_teacher(current_user,course)}
end
#退出课程
@@ -316,9 +332,45 @@ class CoursesService
end
end
+ def course_dynamic(params,current_user)
+
+ @user = User.find(params[:id])
+ if !current_user.admin? && !@user.active?
+ raise '404'
+ return
+ end
+ if current_user == @user || current_user.admin?
+ membership = @user.coursememberships.all
+ else
+ membership = @user.coursememberships.all(:conditions => Course.visible_condition(current_user))
+ end
+ membership.sort! {|older, newer| newer.created_on <=> older.created_on }
+ result = []
+ membership.each do |mp|
+ course = mp.course
+ unless current_user.nil? || !(current_user.admin? || course.is_public == 1 || (course.is_public == 0 && current_user.member_of_course?(course)))
+ count,is_teacher = get_course_anonymous_evaluation current_user,course
+ if is_teacher
+ student_commit_number = count
+ else
+ need_anonymous_comments_count = count
+ end
+ news_count = course.news.count
+ message_count = course.journals_for_messages.count
+
+ result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 1,:count => message_count}
+ result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 2,:count => need_anonymous_comments_count}
+ result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 3,:count => student_commit_number}
+ result << {:course_name => course.name,:course_id => course.id,:course_img_url => url_to_avatar(course),:type => 4,:count => news_count}
+ #{:course_name => course.name,:need_anonymous_comments_count=>need_anonymous_comments_count,:student_commit_number=>student_commit_number,:news_count=> news_count,:message_count=>message_count}
+ end
+ end
+ result
+ end
+
private
def show_homework_info course,bid,current_user,is_course_teacher
- author = bid.author.lastname + bid.author.firstname
+ author_real_name = bid.author.lastname + bid.author.firstname
many_times = course.homeworks.index(bid) + 1
name = bid.name
homework_count = bid.homeworks.count #已提交的作业数量
@@ -331,8 +383,9 @@ class CoursesService
end
#end
open_anonymous_evaluation = bid.open_anonymous_evaluation
- {:course_name => course.name,:id => bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
- :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments}
+ {:course_name => course.name,:course_id => course.id,:id => bid.id, :author => bid.author,:author_real_name => author_real_name, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
+ :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:homework_for_anonymous_comments => homework_for_anonymous_comments,:created_on => bid.created_on,:deadline => bid.deadline}
+
end
#显示作业列表的同时显示分配给当前学生匿评的作业
@@ -351,4 +404,6 @@ class CoursesService
:description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation}
end
+
+
end
\ No newline at end of file
diff --git a/app/services/homework_service.rb b/app/services/homework_service.rb
index a2c063e15..f9be6f79d 100644
--- a/app/services/homework_service.rb
+++ b/app/services/homework_service.rb
@@ -6,6 +6,7 @@ class HomeworkService
include WordsHelper
include ApiHelper
include HomeworkAttachHelper
+ include CoursesHelper
# 作业详情(老师才显示启动匿评,学生不显示 )
# many_times 第几次(作业)
@@ -25,8 +26,9 @@ class HomeworkService
state = @bid.comment_status
#end
open_anonymous_evaluation = @bid.open_anonymous_evaluation
- {:course_name => course.name,:id => @bid.id, :course_teacher => author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
- :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation}
+ jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
+ {:course_name => course.name,:course_id => course.id,:id => @bid.id, :author => @bid.author,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
+ :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation,:created_on => @bid.created_on,:deadline => @bid.deadline,:jours => jours}
end
# 启动作业匿评前提示信息
@@ -115,7 +117,7 @@ class HomeworkService
@is_anonymous_comments = @bid.comment_status == 1 && !@homework.users.include?(current_user) && @homework.user != current_user && !@is_teacher #判断是不是匿评(开启匿评,当前用户不是作业的创建者或者参与者,不是老师)
jours = @homework.journals_for_messages.where("is_comprehensive_evaluation = 3 or is_comprehensive_evaluation is null").order("created_on DESC")#jours留言 is null条件用以兼容历史数据
#@jour = paginateHelper jours,5 #留言
- #@cur_page = params[:cur_page] || 1
+ @cur_page = params[:cur_page] || 1
@cur_type = params[:cur_type] || 5
teacher_stars_json_like = stars_to_json_like(@teacher_stars,true,@homework,true)
student_stars_json_like = stars_to_json_like(@student_stars,false,@homework,(false || @is_teacher))
@@ -124,7 +126,7 @@ class HomeworkService
end
[@homework,{:is_teacher => @is_teacher,:m_score => @m_score,:jours => jours,:teacher_stars => teacher_stars_json_like,
- :student_stars => student_stars_json_like,:is_anonymous_comments => @is_anonymous_comments,:cur_type => @cur_type}]
+ :student_stars => student_stars_json_like,:is_anonymous_comments => @is_anonymous_comments,:cur_type => @cur_type,:cur_page => @cur_page}]
#name = @homework.name
#desc = @homework.description
#datetime = @homework.created_at
@@ -141,16 +143,51 @@ class HomeworkService
end
#作品打分/留言
- def add_score_and_jour params
+ def add_score_and_jour params,current_user
@is_teacher,@is_anonymous_comments,@m_score = params[:is_teacher]=="true",params[:is_anonymous_comments]=="true",params[:stars_value]
@cur_page,@cur_type = params[:cur_page] || 1,params[:cur_type] || 5
@homework = HomeworkAttach.find(params[:homework_id])
+ comment_status = @homework.bid.comment_status
+ if @is_anonymous_comments && comment_status == 0
+ raise '尚未开启匿评!'
+ end
+ if @is_anonymous_comments && ((@m_score.nil? || @m_score.blank?) || !(params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != ""))
+ raise '您尚未打分或评论!'
+ end
#保存评分
- @homework.rate(@m_score.to_i,User.current.id,:quality) if @m_score
+ homework = @homework
+ is_teacher = @is_teacher ? 1 : 0
+ #保存评分@homework.rate(@m_score.to_i,User.current.id,:quality, (@is_teacher ? 1 : 0))
+ if @m_score
+ rate = @homework.rates(:quality).where(:rater_id => current_user.id, :is_teacher_score => is_teacher).first
+ if rate
+ rate.stars = @m_score
+ rate.save!
+ else
+ @homework.rates(:quality).new(:stars => @m_score, :rater_id => current_user.id, :is_teacher_score => is_teacher).save!
+ end
+
+ if homework.is_teacher_score == 0
+ if is_teacher == 1
+ homework.score = @m_score
+ homework.is_teacher_score = 1
+ else
+ sql = "SELECT AVG(stars) as stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = #{homework.id}"
+ score= HomeworkAttach.find_by_sql(sql).first.stars
+ homework.score = score
+ end
+ else
+ if is_teacher == 1
+ homework.score = @m_score
+ homework.is_teacher_score = 1
+ end
+ end
+ homework.save!
+ end
#保存评论
@is_comprehensive_evaluation = @is_teacher ? 1 : (@is_anonymous_comments ? 2 : 3) #判断当前评论是老师评论?匿评?留言
if params[:new_form] && params[:new_form][:user_message] && params[:new_form][:user_message] != "" #有没有留言
- @homework.addjours User.current.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation
+ @homework.addjours current_user.id, params[:new_form][:user_message],0,@is_comprehensive_evaluation
end
end
@@ -238,10 +275,26 @@ class HomeworkService
membership.each do |mp|
my_homeworks = []
mp.course.homeworks.each do |bid|
- hw = bid.homeworks.where("user_id = #{current_user.id}")
- my_homeworks << hw[0] unless (hw.nil? || hw[0].nil?)
+ #hw = bid.homeworks.where("user_id = #{current_user.id}")
+ @bid = bid
+ course = @bid.courses.first
+ author = @bid.author.lastname + @bid.author.firstname
+ many_times = course.homeworks.index(@bid) + 1
+ name = @bid.name
+ homework_count = @bid.homeworks.count #已提交的作业数量
+ student_questions_count = @bid.commit.nil? ? 0 : @bid.commit
+ description = @bid.description
+ #if is_course_teacher(User.current, course) && @bid.open_anonymous_evaluation == 1 && @bid.homeworks.count >= 2
+ state = @bid.comment_status
+ #end
+ open_anonymous_evaluation = @bid.open_anonymous_evaluation
+
+ my_homeworks << {:course_name => course.name,:id => @bid.id, :author => @bid.author,:author_real_name =>author, :homework_times => many_times, :homework_name => name, :homework_count => homework_count,:student_questions_count => student_questions_count,
+ :description => description, :homework_state => state,:open_anonymous_evaluation => open_anonymous_evaluation}
+ end
+ if mp.course.homeworks.count != 0
+ course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course),:my_homework => my_homeworks,:current_user_is_member => current_user.member_of_course?(mp.course),:current_user_is_teacher => is_course_teacher(current_user,mp.course)}
end
- course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course),:my_homework => my_homeworks}
end
course_list
end
diff --git a/app/services/users_service.rb b/app/services/users_service.rb
index 897171b55..8cadf031c 100644
--- a/app/services/users_service.rb
+++ b/app/services/users_service.rb
@@ -44,7 +44,31 @@ class UsersService
#location = get_user_location @user
#{:id => @user.id, :img_url => img_url, :nickname => @user.login, :gender => gender, :work_unit => work_unit, :mail => @user.mail, :location => location, :brief_introduction => @user.user_extensions.brief_introduction}
end
+ def register_auto(login,mail,password)
+ @user = User.new
+ @user.admin = false
+ @user.register
+ @user.login = login
+ @user.mail =mail
+ password_confirmation = password
+ should_confirmation_password = true
+ if !password.blank? && !password_confirmation.blank? && should_confirmation_password
+ @user.password, @user.password_confirmation = password, password_confirmation
+ elsif !password.blank? && !should_confirmation_password
+ @user.password = password
+ else
+ @user.password = ""
+ end
+ @user = automatically_register(@user)
+
+ if @user.id != nil
+ ue = @user.user_extensions ||= UserExtensions.new
+ ue.user_id = @user.id
+ ue.save
+ end
+ @user
+ end
#显示用户
#id用户id
def show_user(params)
@@ -134,7 +158,7 @@ class UsersService
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
course_list = []
membership.each do |mp|
- course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course)}
+ course_list << {:course => mp.course,:img_url => url_to_avatar(mp.course),:current_user_is_member => current_user.member_of_course?(mp.course),:current_user_is_teacher => is_course_teacher(current_user,mp.course)}
end
course_list
end
diff --git a/app/services/watches_service.rb b/app/services/watches_service.rb
index 2b9bed3cd..2aab7de81 100644
--- a/app/services/watches_service.rb
+++ b/app/services/watches_service.rb
@@ -1,7 +1,12 @@
+#coding=utf-8
class WatchesService
def watch params
@current_user = User.find(params[:current_user_id])
+ if params[:object_type] == 'user' && params[:current_user_id] == params[:object_id]
+ raise '不能关注自己!'
+ end
@watchables = find_watchables params
+
if @watchables.nil?
raise '404'
end
diff --git a/app/views/attachments/_links.html.erb b/app/views/attachments/_links.html.erb
index 2954adbcb..989ed776d 100644
--- a/app/views/attachments/_links.html.erb
+++ b/app/views/attachments/_links.html.erb
@@ -1,14 +1,21 @@
+<% is_float ||= false %>
<% for attachment in attachments %>
-
- <% if options[:length] %>
- <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%>
- <% else %>
- <%= link_to_short_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
- <% end %>
+ <%if is_float%>
+
+ <% end%>
+
+ <% if options[:length] %>
+ <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true,:length => options[:length] -%>
+ <% else %>
+ <%= link_to_attachment attachment, :class => 'icon icon-attachment', :download => true -%>
+ <% end %>
+
+ <%if is_float%>
+
+ <% end%>
-
<% if attachment.is_text? %>
<%= link_to image_tag('magnifier.png'),
:controller => 'attachments',
@@ -19,8 +26,9 @@
<%= h(truncate(" - #{attachment.description}", length: options[:length] ? options[:length]:15, omission: '...')) unless attachment.description.blank? %>
- (<%= number_to_human_size attachment.filesize %>)
-
+ (
+ <%= number_to_human_size attachment.filesize %>)
+
<% if options[:deletable] %>
<% if attachment.container_type == 'HomeworkAttach' %>
<%= link_to image_tag('delete.png'), {:controller => 'attachments', :action => 'delete_homework', :id => attachment.id},
@@ -39,8 +47,8 @@
<% end %>
<% end %>
<% if options[:wrap] %>
-
-
+
+
<% end %>
<% if options[:author] %>
diff --git a/app/views/courses/_member_list.html.erb b/app/views/courses/_member_list.html.erb
index dd543ec2c..11bfd9f81 100644
--- a/app/views/courses/_member_list.html.erb
+++ b/app/views/courses/_member_list.html.erb
@@ -25,7 +25,7 @@
<% if @subPage_title == l(:label_student_list) %>
- - <%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0)) ,:result => members,method: 'get', remote: true%>
+
- <%= link_to '作业积分', member_score_sort_course_path(:sort_by => (@score_sort_by == "desc" ? "asc" : "desc"), :group_id => (@group ? @group.id : 0),:search_name => (@search_name ? @search_name : nil)) ,:result => members,method: 'get', remote: true%>
<% if @score_sort_by == 'desc' %>
<% else %>
diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb
index b8cc2ddc9..9007e4c3c 100644
--- a/app/views/layouts/base_projects.html.erb
+++ b/app/views/layouts/base_projects.html.erb
@@ -96,21 +96,20 @@
<%= image_tag(url_to_avatar(@project), :class => 'avatar2') %>
-
- <%= link_to @project.name, project_path(@project)%>
-
-
-
- <% if @project.project_type == 0 %>
- <%= l(:label_project_grade)%> :
- <%= link_to(format("%.2f" ,project_scores(@project) ).to_i, {:controller => 'projects',
- :action => 'show_projects_score',
- :remote => true,
- :id => @project.id
- }, :style => "color: #EC6300;")%>
- <% end %>
-
-
+ <% project_score = format("%.2f" ,project_scores(@project)).to_i%>
+
+ <%= link_to @project.name, project_path(@project)%>
+
+
+ <% if @project.project_type == 0 && project_score != 0 %>
+ <%= l(:label_project_grade)%> :
+ <%= link_to(project_score, {:controller => 'projects',
+ :action => 'show_projects_score',
+ :remote => true,
+ :id => @project.id}, :style => "color: #EC6300;")%>
+ <% end %>
+
+
<%= render 'layouts/join_exit_project' %>
@@ -134,7 +133,7 @@
|
- <%=link_to "#{@project.issues.where('status_id in (1,2,4,6)').count}", project_issues_path(@project) %>
+ <%=link_to "#{@project.issues.where('status_id in (1,2,4,6)').count}/#{@project.issues.count}", project_issues_path(@project) %>
|
diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb
index 3b2bd8dfe..a7ed0aa25 100644
--- a/app/views/layouts/base_users.html.erb
+++ b/app/views/layouts/base_users.html.erb
@@ -68,7 +68,7 @@
- <%=link_to "主页", home_path %> >
+ <%=link_to l(:field_homepage), home_path %> >
<%=link_to @user.name, user_path %>
@@ -343,7 +343,7 @@
<% if @user.user_extensions.identity == 2 %>
<%= render_menu :user_enterprise_menu %>
<% else %>
- <%= render_menu :user_menu,@user %>
+ <%= render_menu :user_menu, @user %>
<% end %>
diff --git a/app/views/mailer/send_for_user_activities.html.erb b/app/views/mailer/send_for_user_activities.html.erb
new file mode 100644
index 000000000..1735bd899
--- /dev/null
+++ b/app/views/mailer/send_for_user_activities.html.erb
@@ -0,0 +1,373 @@
+
+
+
+
+
+
+
+<%= @subject %>
+
+<% if @attachments.first || @course_news.first || @bids.first ||
+ @homeworks.first || @course_journal_messages.first|| @course_messages.first %>
+
+ <%= l(:label_course_overview)%>
+ <% unless @course_news.first.nil? %>
+
+
+
+ <%= l(:label_course_news) %>
+ (<%= @course_news.count %>)
+
+
+ <% @course_news.each do |course_new|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(course_new.course.name,length: 30,omission: '...'), course_url(course_new.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to course_new.author, user_activities_url(course_new.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_project_notice) %>
+
+ <%= link_to truncate(course_new.title,length: 30,omission: '...'), news_url(course_new,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(course_new.created_on) %>
+
+ <% end %>
+
+
+
+ <% end %>
+ <% if !@bids.first.nil? || !@homeworks.first.nil? %>
+
+
+ <%= l(:label_homework_overview) %>(<%= @bids.count %>)
+ <% unless @bids.first.nil?%>
+ <% @bids.each do |bid| %>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(bid.courses.first.name,length: 30,omission: '...'), course_url(bid.courses.first, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to bid.author, user_activities_url(bid.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_course_homework) %>
+
+ <%= link_to truncate(bid.name,length: 30,omission: '...'), course_for_bid_url(:id => bid.id,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(bid.created_on) %>
+
+ <% end %>
+ <% end %>
+ <% unless @homeworks.first.nil? %>
+ <% @homeworks.each do |homework| %>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to homework.user, user_activities_url(homework.user,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_course_submit_homework) %>
+
+ <%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(:id => homework.bid.id,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(homework.created_on) %>
+
+ <% end %>
+ <% end %>
+
+
+
+ <% end %>
+
+ <% unless @course_journal_messages.first.nil? %>
+
+
+
+ <%= l(:view_course_journals_for_messages) %>
+ (<%= @course_journal_messages.count %>)
+
+
+ <% @course_journal_messages.each do |course_journal_message|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(course_journal_message.course.name,length: 30,omission: '...'), course_url(course_journal_message.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to course_journal_message.user, user_activities_url(course_journal_message.user,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_send_course_journals_for_messages) %>
+
+ <%= link_to truncate(course_journal_message.notes,length: 30,omission: '...'), course_feedback_url(course_journal_message.course,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(course_journal_message.created_on) %>
+
+ <% end %>
+
+
+
+ <% end %>
+
+ <% unless @course_messages.first.nil? %>
+
+
+
+ <%= l(:view_borad_course) %>
+ (<%= @course_journal_messages.count %>)
+
+
+ <% @course_messages.each do |course_message|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(course_message.course.name,length: 30,omission: '...'), course_url(course_message.course.id, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to course_message.author, user_activities_url(course_message.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_send_course_messages) %>
+
+ <%= link_to truncate(course_message.subject,length: 30,omission: '...'),board_message_url(course_message, :board_id => course_message.board_id,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(course_message.created_on) %>
+
+ <% end %>
+
+
+
+ <% end %>
+
+ <% unless @attachments.first.nil? %>
+
+
+ <%= l(:label_course_attendingcontestwork_download) %>
+ (<%= @attachments.count %>)
+
+
+ <% @attachments.each do |attachment|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(attachment.course.name,length: 30,omission: '...'), course_url(attachment.course, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to attachment.author, user_activities_url(attachment.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_course_file_upload) %>
+
+ <%= link_to truncate(attachment.filename,length: 30,omission: '...'),course_files_url(attachment.course,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(attachment.created_on) %>
+
+ <% end %>
+
+
+ <% end %>
+
+ <% end %>
+ <% if @issues.first || @project_messages.first %>
+
+ <%= l(:label_project_overview_new)%>
+ <% unless @issues.first.nil? %>
+
+
+ <%= l(:label_issue_tracking) %>
+ (<%= @issues.count %>)
+
+
+ <% @issues.each do |issue|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(issue.project.name,length: 30,omission: '...'), project_url(issue.project, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to issue.author, user_activities_url(issue.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_project_issue) %>
+
+ <%= link_to truncate(issue.subject,length: 30,omission: '...'),issue_url(issue, :token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(issue.created_on) %>
+
+ <% end %>
+
+
+
+ <% end %>
+
+ <% unless @project_messages.first.nil? %>
+
+
+ <%= l(:project_moule_boards_show) %>
+ (<%= @project_messages.count %>)
+
+
+ <% @project_messages.each do |project_message|%>
+ -
+ ▪
+ [
+
+ <%= link_to truncate(project_message.project.name,length: 30,omission: '...'), project_url(project_message.project, :token => @token.value),
+ :class=> "wmail_column",
+ :style=> " font-weight: bold; display:block; float:left; color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ ]
+
+ <%= link_to project_message.author, user_activities_url(project_message.author,:token => @token.value), :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"%>
+ <%= l(:label_send_course_messages) %>
+
+ <%= link_to truncate(project_message.subject,length: 30,omission: '...'),board_message_url(project_message, :board_id => project_message.board_id,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(project_message.created_on) %>
+
+ <% end %>
+
+
+
+ <% end %>
+
+
+
+
+ <% end %>
+ <% unless @user_journal_messages.first.nil? %>
+
+ <%= l(:label_activities) %>
+
+
+
+ <%= l(:label_user_message) %>
+ (<%= @user_journal_messages.count %>)
+
+
+ <% @user_journal_messages.each do |user_journal_message|%>
+ -
+ ▪
+
+ <%= link_to user_journal_message.user, user_activities_url(user_journal_message.user,:token => @token.value),
+ :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ <%= l(:label_show_your_message) %>
+
+ <%= link_to truncate(user_journal_message.notes,length: 30,omission: '...'),feedback_url(@user,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(user_journal_message.created_on) %>
+
+ <% end %>
+
+
+
+
+
+ <% end %>
+ <% if @forums.first || @memos.first %>
+
+ <%= l(:lable_bar_active) %>
+ <% unless @forums.first.nil? %>
+
+
+ <%= l(:label_user_forum) %>
+ (<%= @forums.count %>)
+
+
+ <% @forums.each do |forum|%>
+ -
+ ▪
+
+ <%= link_to forum.creator, user_activities_url(forum.creator,:token => @token.value),
+ :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ <%= l(:label_forum_new) %>
+
+ <%= link_to truncate(forum.name,length: 30,omission: '...'),forum_url(forum,:token => @token.value),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(forum.created_at) %>
+
+ <% end %>
+
+
+
+ <% end %>
+ <% unless @memos.first.nil? %>
+
+
+ <%= l(:label_user_message_forum) %>
+ (<%= @memos.count %>)
+
+
+ <% @memos.each do |memo|%>
+ -
+ ▪
+
+ <%= link_to memo.author, user_activities_url(memo.author,:token => @token.value),
+ :class => "wmail_name",
+ :style => "color:#fe5722; float:left;display:block; margin-right:5px; margin-left:5px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;" %>
+ <%= memo.parent_id.nil? ? l(:label_memo_new_from_forum) : l(:label_reply) %>
+
+ <%= link_to truncate(memo.subject,length: 30,omission: '...'),forum_memo_url(memo.forum, (memo.parent_id.nil? ? memo : memo.parent_id)),
+ :class => 'wmail_info',
+ :style => "color:#5a5a5a; float:left; margin-right:5px; display:block;color:#1b55a7;overflow:hidden; white-space: nowrap; text-overflow:ellipsis;"
+ %>
+ <%= format_time(memo.created_at) %>
+
+ <% end %>
+
+
+
+ <% end %>
+
+<% end %>
+
+
+
+
+
diff --git a/app/views/mailer/send_for_user_activities.text.erb b/app/views/mailer/send_for_user_activities.text.erb
new file mode 100644
index 000000000..4de42b8aa
--- /dev/null
+++ b/app/views/mailer/send_for_user_activities.text.erb
@@ -0,0 +1,296 @@
+<%= @subject %>
+<% if @attachments.first || @course_news.first || @bids.first ||
+ @homeworks.first || @course_journal_messages.first|| @course_messages.first %>
+<%= l(:label_course_overview)%>
+ <% unless @course_news.first.nil? %>
+ <%= l(:label_course_news) %>
+ (<%= @course_news.count %>)
+
+
+ <% @course_news.each do |course_new|%>
+
+ ▪
+ [
+
+ <%= link_to truncate(course_new.course.name,length: 30,omission: '...'), course_url(course_new.course, :token => @token.value)%>
+ ]
+
+ <%= link_to course_new.author, user_activities_url(course_new.author,:token => @token.value)
+ %>
+ <%= l(:label_project_notice) %>
+
+ <%= link_to truncate(course_new.title,length: 30,omission: '...'), news_url(course_new,:token => @token.value)
+
+
+ %> <%= format_time(course_new.created_on) %>
+
+ <% end %>
+
+ <% end %>
+ <% if !@bids.first.nil? || !@homeworks.first.nil? %>
+ <%= l(:label_homework_overview) %><%= @bids.count %>
+ <% unless @bids.first.nil?%>
+ <% @bids.each do |bid| %>
+ ▪
+ [
+
+ <%= link_to truncate(bid.courses.first.name,length: 30,omission: '...'),course_url(bid.courses.first, :token => @token.value)
+
+ %>
+ ]
+
+ <%= link_to bid.author, user_activities_url(bid.author,:token => @token.value)
+ %>
+ <%= l(:label_course_homework) %>
+
+ <%= link_to truncate(bid.name,length: 30,omission: '...'), course_for_bid_url(bid,:token => @token.value)
+
+
+ %>
+ <%= format_time(bid.created_on) %>
+
+ <% end %>
+ <% end %>
+ <% unless @homeworks.first.nil? %>
+ <% @homeworks.each do |homework| %>
+ ▪[
+
+ <%= link_to truncate(homework.bid.courses.first.name,length: 30,omission: '...'), course_url(homework.bid.courses.first, :token => @token.value)
+
+ %>
+ ]
+
+ <%= link_to homework.user, user_activities_url(homework.user,:token => @token.value)
+ %>
+ <%= l(:label_course_submit_homework) %>
+
+ <%= link_to truncate(homework.name,length: 30,omission: '...'), course_for_bid_url(homework.bid,:token => @token.value)
+
+
+ %>
+ <%= format_time(homework.created_at) %>
+ <% end %>
+ <% end %>
+
+
+
+ <% end %>
+
+ <% unless @course_journal_messages.first.nil? %>
+
+ <%= l(:view_course_journals_for_messages) %> (<%= @course_journal_messages.count %>)
+
+
+ <% @course_journal_messages.each do |course_journal_message|%>
+
+ [
+
+ <%= link_to truncate(course_journal_message.course.name,length: 30,omission: '...'), course_url(course_journal_message.course, :token => @token.value)
+
+ %>
+ ]
+
+ <%= link_to course_journal_message.user, user_activities_url(course_journal_message.user,:token => @token.value)
+ %>
+ <%= l(:label_send_course_journals_for_messages) %>
+
+ <%= link_to truncate(course_journal_message.notes,length: 30,omission: '...'), course_feedback_url(course_journal_message.course,:token => @token.value)
+
+
+ %>
+ <%= format_time(course_journal_message.created_on) %>
+
+ <% end %>
+
+
+ <% end %>
+
+ <% unless @course_messages.first.nil? %>
+
+ <%= l(:view_borad_course) %>
+ (<%= @course_journal_messages.count %>)
+
+
+ <% @course_messages.each do |course_message|%>
+
+ ▪
+ [
+
+ <%= link_to truncate(course_message.course.name,length: 30,omission: '...'), course_url(course_message.course, :token => @token.value)
+
+ %>
+ ]
+
+ <%= link_to course_message.author, user_activities_url(course_message.author,:token => @token.value)
+ %>
+ <%= l(:label_send_course_messages) %>
+
+ <%= link_to truncate(course_message.subject,length: 30,omission: '...'),board_message_url(course_message, :board_id => course_message.board_id,:token => @token.value)
+
+
+ %>
+ <%= format_time(course_message.created_on) %>
+
+ <% end %>
+
+
+ <% end %>
+
+ <% unless @attachments.first.nil? %>
+
+ <%= l(:label_course_attendingcontestwork_download) %>
+ (<%= @attachments.count %>)
+
+
+ <% @attachments.each do |attachment|%>
+ ▪[
+
+ <%= link_to truncate(attachment.course.name,length: 30,omission: '...'), course_url(attachment.course, :token => @token.value)
+
+ %>
+ ]
+
+ <%= link_to attachment.author, user_activities_url(attachment.author,:token => @token.value)
+ %>
+ <%= l(:label_course_file_upload) %>
+
+ <%= link_to truncate(attachment.filename,length: 30,omission: '...'),course_files_url(attachment.course,:token => @token.value)
+
+
+ %>
+ <%= format_time(attachment.created_on) %>
+
+ <% end %>
+
+
+ <% end %>
+<% end %>
+
+<% @issues.first || @project_messages.first %>
+<%= l(:label_project_overview_new)%>
+ <% unless @issues.first.nil? %>
+
+ <%= l(:label_issue_tracking) %>
+ (<%= @issues.count %>)
+
+ <% @issues.each do |issue|%>
+ ▪
+ [
+
+ <%= link_to truncate(issue.project.name,length: 30,omission: '...'), project_url(issue.project, :token => @token.value)
+
+ %>
+ ]
+
+ <%= link_to issue.author, user_activities_url(issue.author,:token => @token.value)
+ %>
+ <%= l(:label_project_issue) %>
+
+ <%= link_to truncate(issue. subject,length: 30,omission: '...'),issue_url(issue, :token => @token.value)
+
+
+ %>
+ <%= format_time(issue.created_on) %>
+ <% end %>
+
+
+ <% end %>
+
+ <% unless @project_messages.first.nil? %>
+
+ <%= l(:project_moule_boards_show) %>
+ (<%= @project_messages.count %>)
+
+ <% @project_messages.each do |project_message|%>
+ ▪[
+
+ <%= link_to truncate(project_message.project.name,length: 30,omission: '...'), project_url(project_message.project, :token => @token.value)
+
+ %>
+ ]
+
+ <%= link_to project_message.author, board_message_url(project_message, :board_id => project_message.board_id,:token => @token.value)
+ %>
+ <%= l(:label_send_course_messages) %>
+
+ <%= link_to truncate(project_message. subject,length: 30,omission: '...'),board_message_url(project_message, :board_id => project_message.board_id,:token => @token.value)
+
+
+ %>
+ <%= format_time(project_message.created_on) %>
+ <% end %>
+
+
+ <% end %>
+
+
+<% unless @user_journal_messages.first.nil? %>
+<%= l(:label_activities) %>
+
+
+ <%= l(:label_user_message) %>
+ (<%= @user_journal_messages.count %>)
+
+ <% @user_journal_messages.each do |user_journal_message|%>
+ ▪
+
+ <%= link_to user_journal_message.user, user_activities_url(user_journal_message.user,:token => @token.value)
+
+ %>
+ <%= l(:label_show_your_message) %>
+
+ <%= link_to truncate(user_journal_message.notes,length: 30,omission: '...'), feedback_url(@user,:token => @token.value)
+
+
+ %>
+ <%= format_time(user_journal_message.created_on) %>
+
+ <% end %>
+
+
+<% end %>
+<% if @forums.first || @memos.first %>
+ <%= l(:lable_bar_active) %>
+ <% unless @forums.first.nil? %>
+
+ <%= l(:label_user_forum) %>
+ (<%= @forums.count %>)
+
+ <% @forums.each do |forum|%>
+ ▪
+
+ <%= link_to forum.creator, user_activities_url(forum.creator,:token => @token.value) %>
+ <%= l(:label_forum_new) %>
+
+ <%= link_to truncate(forum.name,length: 30,omission: '...'),forum_url(forum,:token => @token.value)
+ %>
+ <%= format_time(forum.created_at) %>
+
+ <% end %>
+
+
+ <% end %>
+ <% unless @memos.first.nil? %>
+
+ <%= l(:label_user_message_forum) %>
+ (<%= @memos.count %>)
+
+ <% @memos.each do |memo|%>
+ ▪
+
+ <%= link_to memo.author, user_activities_url(memo.author,:token => @token.value)%>
+ <%= memo.parent_id.nil? ? l(:label_memo_new_from_forum) : l(:label_reply) %>
+
+ <%= link_to truncate(memo.subject,length: 30,omission: '...'),forum_memo_url(memo.forum, (memo.parent_id.nil? ? memo : memo.parent_id))
+ %>
+ <%= format_time(memo.created_at) %>
+
+ <% end %>
+
+
+
+ <% end %>
+
+<% end %>
+
+ <%= link_to l(:mail_footer), @user_url, :style => "margin-top:20px;color:#2775d2; margin-left:10px;" %>
diff --git a/app/views/mailer/send_invite_in_project.html.erb b/app/views/mailer/send_invite_in_project.html.erb
new file mode 100644
index 000000000..980adc12d
--- /dev/null
+++ b/app/views/mailer/send_invite_in_project.html.erb
@@ -0,0 +1,17 @@
+
+
+
+
+ - <%= l(:mail_issue_content)%>
+
+
<%= @subject %>
+ <%= link_to @project_url, @project_url%>
+
+
+
+
+
+
+
+
+
diff --git a/app/views/mailer/send_invite_in_project.text.erb b/app/views/mailer/send_invite_in_project.text.erb
new file mode 100644
index 000000000..6ee038055
--- /dev/null
+++ b/app/views/mailer/send_invite_in_project.text.erb
@@ -0,0 +1,2 @@
+<%= @subject %>
+<%= link_to @project_url, @project_url%>
\ No newline at end of file
diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb
index 0330b65e4..995529fe9 100644
--- a/app/views/memos/show.html.erb
+++ b/app/views/memos/show.html.erb
@@ -67,7 +67,7 @@
<% if @memo.attachments.any?%>
<% options = {:author => true, :deletable => @memo.deleted_attach_able_by?(User.current) } %>
- <%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options} %>
+ <%= render :partial => 'attachments/links', :locals => {:attachments => @memo.attachments, :options => options, :is_float => true} %>
<% end %>
@@ -136,7 +136,7 @@
<% if reply.attachments.any?%>
<% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %>
- <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options} %>
+ <%= render :partial => 'attachments/links', :locals => {:attachments => reply.attachments, :options => options, :is_float => true} %>
<% end %>
|
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 47cfb4221..554f50633 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -151,9 +151,9 @@
<% if !User.current.user_extensions.nil? && !User.current.user_extensions.student_id.nil? %>
- <%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => "请输入学号" %>
+ <%= text_field_tag :no, User.current.user_extensions.student_id, :placeholder => l(:label_account_identity_studentID) %>
<% else %>
- <%= text_field_tag :no, nil, :placeholder => "请输入学号" %>
+ <%= text_field_tag :no, nil, :placeholder => l(:label_account_identity_studentID) %>
<% end %>
@@ -217,18 +217,18 @@
<% if User.current.user_extensions.nil? %>
-
+ readonly>
<% else %>
<% if User.current.user_extensions.identity == 3 || User.current.user_extensions.identity == 2 %>
-
+ readonly>
<% elsif User.current.user_extensions.school.nil? %>
-
+ readonly>
<% else %>
diff --git a/app/views/organizations/index.html.erb b/app/views/organizations/index.html.erb
index 3e0e507c5..45813ced5 100644
--- a/app/views/organizations/index.html.erb
+++ b/app/views/organizations/index.html.erb
@@ -5,11 +5,11 @@
<% if @projects.count == 0 %>
<%= l(:label_enterprise_nil) %>
<% else %>
- <% @projects.each do |project| %>
- <% unless project.enterprise_name.blank? %>
+ <% @projects.each do |organization| %>
+ <% unless organization.enterprise_name.blank? %>
-
- <%= link_to project.enterprise_name, home_path(:project => project) %>
+ <%= link_to organization.enterprise_name, home_path(:organization => organization) %>
<% end %>
<% end %>
diff --git a/app/views/poll/_alert.html.erb b/app/views/poll/_alert.html.erb
new file mode 100644
index 000000000..b3de53d1f
--- /dev/null
+++ b/app/views/poll/_alert.html.erb
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb
index 644b678b8..33bff6258 100644
--- a/app/views/poll/_poll.html.erb
+++ b/app/views/poll/_poll.html.erb
@@ -46,7 +46,7 @@
<% else%>
- -
+
-
发布问卷
<% end%>
diff --git a/app/views/poll/publish_poll.js.erb b/app/views/poll/publish_poll.js.erb
index ad052f8f2..6074df6c6 100644
--- a/app/views/poll/publish_poll.js.erb
+++ b/app/views/poll/publish_poll.js.erb
@@ -1,2 +1,10 @@
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
-alert("发布成功");
\ No newline at end of file
+$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_memo_create_succ)}) %>");
+showModal('ajax-modal', '180px');
+$('#ajax-modal').css('height','111px');
+$('#ajax-modal').siblings().remove();
+$('#ajax-modal').before("" +
+ "");
+$('#ajax-modal').parent().removeClass("alert_praise");
+$('#ajax-modal').parent().css("top","").css("left","");
+$('#ajax-modal').parent().addClass("poll_alert_form");
\ No newline at end of file
diff --git a/app/views/poll/republish_poll.js.erb b/app/views/poll/republish_poll.js.erb
index a2d8e28fa..94369678d 100644
--- a/app/views/poll/republish_poll.js.erb
+++ b/app/views/poll/republish_poll.js.erb
@@ -1,2 +1,10 @@
$("#polls_<%= @poll.id %>").html("<%= escape_javascript(render :partial => 'poll',:locals => {:poll => @poll}) %>");
-alert("取消成功");
\ No newline at end of file
+$('#ajax-modal').html("<%= escape_javascript(render :partial => 'alert', locals: { :message => l(:label_poll_republish_success)}) %>");
+showModal('ajax-modal', '180px');
+$('#ajax-modal').css('height','80px');
+$('#ajax-modal').siblings().remove();
+$('#ajax-modal').before("" +
+ "");
+$('#ajax-modal').parent().removeClass("alert_praise");
+$('#ajax-modal').parent().css("top","").css("left","");
+$('#ajax-modal').parent().addClass("poll_alert_form");
\ No newline at end of file
diff --git a/app/views/projects/_join_project.html.erb b/app/views/projects/_join_project.html.erb
index fdc60904d..98ab5dcd2 100644
--- a/app/views/projects/_join_project.html.erb
+++ b/app/views/projects/_join_project.html.erb
@@ -1,7 +1,7 @@
- 快速进入项目通道
+ <%= l('project.join.title')%>