| @@ -17,10 +17,6 @@ | |||||
| /public/cache/* | /public/cache/* | ||||
| /config/newrelic.yml | /config/newrelic.yml | ||||
| /public/images/avatars/* | /public/images/avatars/* | ||||
| /Gemfile | |||||
| /Gemfile.lock | |||||
| /db/schema.rb | |||||
| /Gemfile.lock | |||||
| /lib/plugins/acts_as_versioned/test/debug.log | /lib/plugins/acts_as_versioned/test/debug.log | ||||
| .rbenv-gemsets | .rbenv-gemsets | ||||
| .DS_Store | .DS_Store | ||||
| @@ -40,6 +40,8 @@ gem 'ruby-ole' | |||||
| gem 'rails_kindeditor',path:'lib/rails_kindeditor' | gem 'rails_kindeditor',path:'lib/rails_kindeditor' | ||||
| gem 'binding_of_caller' | gem 'binding_of_caller' | ||||
| gem 'chinese_pinyin' | gem 'chinese_pinyin' | ||||
| gem 'jbuilder' | |||||
| gem 'test-unit', '~> 3.0' | |||||
| # gem 'sunspot_rails', '~> 1.3.3' | # gem 'sunspot_rails', '~> 1.3.3' | ||||
| # gem 'sunspot_solr' | # gem 'sunspot_solr' | ||||
| # gem 'sunspot' | # gem 'sunspot' | ||||
| @@ -50,6 +52,10 @@ gem 'kaminari' | |||||
| gem 'elasticsearch-model' | gem 'elasticsearch-model' | ||||
| gem 'elasticsearch-rails' | gem 'elasticsearch-rails' | ||||
| gem 'ancestry' | |||||
| gem 'ransack' | |||||
| gem 'whenever', '~> 1.0' | |||||
| #rails 3.2.22.2 bug | #rails 3.2.22.2 bug | ||||
| # gem "test-unit", "~>3.0" | # gem "test-unit", "~>3.0" | ||||
| @@ -59,6 +65,7 @@ gem 'elasticsearch-rails' | |||||
| group :development do | group :development do | ||||
| gem 'grape-swagger' | gem 'grape-swagger' | ||||
| gem 'sextant' | |||||
| gem 'better_errors', '~> 1.1.0' | gem 'better_errors', '~> 1.1.0' | ||||
| # gem "query_reviewer" | # gem "query_reviewer" | ||||
| gem 'rack-mini-profiler', '~> 0.9.3' | gem 'rack-mini-profiler', '~> 0.9.3' | ||||
| @@ -0,0 +1,410 @@ | |||||
| PATH | |||||
| remote: lib/gitlab-cli | |||||
| specs: | |||||
| gitlab (3.2.0) | |||||
| httparty | |||||
| terminal-table | |||||
| PATH | |||||
| remote: lib/grack | |||||
| specs: | |||||
| grack (2.0.2) | |||||
| rack (~> 1.4.5) | |||||
| PATH | |||||
| remote: lib/rails_kindeditor | |||||
| specs: | |||||
| rails_kindeditor (0.4.5) | |||||
| carrierwave | |||||
| mini_magick | |||||
| PATH | |||||
| remote: lib/wechat | |||||
| specs: | |||||
| wechat (0.7.1) | |||||
| activerecord (>= 3.2, < 5.1.x) | |||||
| http (~> 1.0, >= 1.0.1) | |||||
| nokogiri (>= 1.6.0) | |||||
| thor | |||||
| GEM | |||||
| remote: https://gems.ruby-china.com/ | |||||
| specs: | |||||
| actionmailer (3.2.22.5) | |||||
| actionpack (= 3.2.22.5) | |||||
| mail (~> 2.5.4) | |||||
| actionpack (3.2.22.5) | |||||
| activemodel (= 3.2.22.5) | |||||
| activesupport (= 3.2.22.5) | |||||
| 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.22.5) | |||||
| activesupport (= 3.2.22.5) | |||||
| builder (~> 3.0.0) | |||||
| activerecord (3.2.22.5) | |||||
| activemodel (= 3.2.22.5) | |||||
| activesupport (= 3.2.22.5) | |||||
| arel (~> 3.0.2) | |||||
| tzinfo (~> 0.3.29) | |||||
| activeresource (3.2.22.5) | |||||
| activemodel (= 3.2.22.5) | |||||
| activesupport (= 3.2.22.5) | |||||
| activesupport (3.2.22.5) | |||||
| i18n (~> 0.6, >= 0.6.4) | |||||
| multi_json (~> 1.0) | |||||
| acts-as-taggable-on (2.4.1) | |||||
| rails (>= 3, < 5) | |||||
| addressable (2.6.0) | |||||
| public_suffix (>= 2.0.2, < 4.0) | |||||
| ancestry (3.0.7) | |||||
| activerecord (>= 3.2.0) | |||||
| ansi (1.5.0) | |||||
| arel (3.0.3) | |||||
| awesome_print (1.8.0) | |||||
| axiom-types (0.1.1) | |||||
| descendants_tracker (~> 0.0.4) | |||||
| ice_nine (~> 0.11.0) | |||||
| thread_safe (~> 0.3, >= 0.3.1) | |||||
| better_errors (1.1.0) | |||||
| coderay (>= 1.0.0) | |||||
| erubis (>= 2.6.6) | |||||
| binding_of_caller (0.8.0) | |||||
| debug_inspector (>= 0.0.1) | |||||
| builder (3.0.0) | |||||
| byebug (11.0.1) | |||||
| carrierwave (0.11.2) | |||||
| activemodel (>= 3.2.0) | |||||
| activesupport (>= 3.2.0) | |||||
| json (>= 1.7) | |||||
| mime-types (>= 1.16) | |||||
| mimemagic (>= 0.3.0) | |||||
| certified (1.0.0) | |||||
| chinese_pinyin (1.0.1) | |||||
| chronic (0.10.2) | |||||
| climate_control (0.2.0) | |||||
| cocaine (0.5.8) | |||||
| climate_control (>= 0.0.3, < 1.0) | |||||
| coderay (1.1.2) | |||||
| 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.4.1) | |||||
| coffee-script-source | |||||
| execjs | |||||
| coffee-script-source (1.12.2) | |||||
| daemons (1.3.1) | |||||
| debug_inspector (0.0.3) | |||||
| delayed_job (4.1.7) | |||||
| activesupport (>= 3.0, < 5.3) | |||||
| delayed_job_active_record (4.1.3) | |||||
| activerecord (>= 3.0, < 5.3) | |||||
| delayed_job (>= 3.0, < 5) | |||||
| descendants_tracker (0.0.4) | |||||
| thread_safe (~> 0.3, >= 0.3.1) | |||||
| domain_name (0.5.20190701) | |||||
| unf (>= 0.0.5, < 1.0.0) | |||||
| elasticsearch (7.2.0) | |||||
| elasticsearch-api (= 7.2.0) | |||||
| elasticsearch-transport (= 7.2.0) | |||||
| elasticsearch-api (7.2.0) | |||||
| multi_json | |||||
| elasticsearch-model (6.0.0) | |||||
| activesupport (> 3) | |||||
| elasticsearch (> 1) | |||||
| hashie | |||||
| elasticsearch-rails (6.0.0) | |||||
| elasticsearch-transport (7.2.0) | |||||
| faraday | |||||
| multi_json | |||||
| equalizer (0.0.11) | |||||
| erubis (2.7.0) | |||||
| execjs (2.7.0) | |||||
| factory_girl (4.9.0) | |||||
| activesupport (>= 3.0.0) | |||||
| factory_girl_rails (4.9.0) | |||||
| factory_girl (~> 4.9.0) | |||||
| railties (>= 3.0.0) | |||||
| faraday (0.15.4) | |||||
| multipart-post (>= 1.2, < 3) | |||||
| fastercsv (1.5.5) | |||||
| ffi (1.11.1) | |||||
| 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.5) | |||||
| activesupport | |||||
| multi_json (>= 1.3.2) | |||||
| grape-swagger (0.20.0) | |||||
| awesome_print | |||||
| grape | |||||
| grape-entity | |||||
| hashie (3.6.0) | |||||
| hike (1.2.3) | |||||
| htmlentities (4.3.4) | |||||
| http (1.0.4) | |||||
| addressable (~> 2.3) | |||||
| http-cookie (~> 1.0) | |||||
| http-form_data (~> 1.0.1) | |||||
| http_parser.rb (~> 0.6.0) | |||||
| http-cookie (1.0.3) | |||||
| domain_name (~> 0.5) | |||||
| http-form_data (1.0.3) | |||||
| http_parser.rb (0.6.0) | |||||
| httparty (0.16.2) | |||||
| multi_xml (>= 0.5.2) | |||||
| i18n (0.6.11) | |||||
| ice_nine (0.11.2) | |||||
| iconv (1.0.8) | |||||
| jbuilder (2.6.4) | |||||
| activesupport (>= 3.0.0) | |||||
| multi_json (>= 1.2) | |||||
| jenkins_api_client (1.5.3) | |||||
| json (>= 1.0) | |||||
| mixlib-shellout (>= 1.1.0) | |||||
| nokogiri (~> 1.6) | |||||
| socksify (>= 1.7.0) | |||||
| terminal-table (>= 1.4.0) | |||||
| thor (>= 0.16.0) | |||||
| journey (1.0.4) | |||||
| jquery-rails (2.0.3) | |||||
| railties (>= 3.1.0, < 5.0) | |||||
| thor (~> 0.14) | |||||
| json (1.8.6) | |||||
| kaminari (0.17.0) | |||||
| actionpack (>= 3.0.0) | |||||
| activesupport (>= 3.0.0) | |||||
| mail (2.5.5) | |||||
| mime-types (~> 1.16) | |||||
| treetop (~> 1.4.8) | |||||
| method_source (0.9.2) | |||||
| mime-types (1.25.1) | |||||
| mimemagic (0.3.3) | |||||
| mini_magick (4.9.3) | |||||
| mini_portile2 (2.4.0) | |||||
| mixlib-shellout (3.0.4) | |||||
| multi_json (1.13.1) | |||||
| multi_xml (0.6.0) | |||||
| multipart-post (2.1.1) | |||||
| mysql2 (0.3.18) | |||||
| net-ldap (0.3.1) | |||||
| net-ssh (2.9.1) | |||||
| netrc (0.11.0) | |||||
| nio4r (2.4.0) | |||||
| nokogiri (1.10.3) | |||||
| mini_portile2 (~> 2.4.0) | |||||
| paperclip (3.5.4) | |||||
| activemodel (>= 3.0.0) | |||||
| activesupport (>= 3.0.0) | |||||
| cocaine (~> 0.5.3) | |||||
| mime-types | |||||
| polyglot (0.3.5) | |||||
| power_assert (1.1.4) | |||||
| pry (0.12.2) | |||||
| coderay (~> 1.1.0) | |||||
| method_source (~> 0.9.0) | |||||
| pry-byebug (3.7.0) | |||||
| byebug (~> 11.0) | |||||
| pry (~> 0.10) | |||||
| public_suffix (3.1.1) | |||||
| puma (4.0.0) | |||||
| nio4r (~> 2.0) | |||||
| rack (1.4.7) | |||||
| rack-accept (0.4.5) | |||||
| rack (>= 0.4) | |||||
| rack-cache (1.9.0) | |||||
| rack (>= 0.4) | |||||
| rack-cors (1.0.3) | |||||
| rack-mini-profiler (0.9.9.2) | |||||
| rack (>= 1.2.0) | |||||
| 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.3) | |||||
| rack (>= 1.0) | |||||
| rails (3.2.22.5) | |||||
| actionmailer (= 3.2.22.5) | |||||
| actionpack (= 3.2.22.5) | |||||
| activerecord (= 3.2.22.5) | |||||
| activeresource (= 3.2.22.5) | |||||
| activesupport (= 3.2.22.5) | |||||
| bundler (~> 1.0) | |||||
| railties (= 3.2.22.5) | |||||
| railties (3.2.22.5) | |||||
| actionpack (= 3.2.22.5) | |||||
| activesupport (= 3.2.22.5) | |||||
| rack-ssl (~> 1.3.2) | |||||
| rake (>= 0.8.7) | |||||
| rdoc (~> 3.4) | |||||
| thor (>= 0.14.6, < 2.0) | |||||
| rake (12.3.2) | |||||
| ransack (1.8.10) | |||||
| actionpack (>= 3.0, < 5.2) | |||||
| activerecord (>= 3.0, < 5.2) | |||||
| activesupport (>= 3.0, < 5.2) | |||||
| i18n | |||||
| rb-fsevent (0.10.3) | |||||
| rb-inotify (0.10.0) | |||||
| ffi (~> 1.0) | |||||
| rdoc (3.12.2) | |||||
| json (~> 1.4) | |||||
| redis (4.1.2) | |||||
| redis-actionpack (3.2.4) | |||||
| actionpack (~> 3.2.0) | |||||
| redis-rack (~> 1.4.4) | |||||
| redis-store (~> 1.1.4) | |||||
| redis-activesupport (3.2.5) | |||||
| activesupport (~> 3.2.0) | |||||
| redis-store (~> 1.1.0) | |||||
| redis-rack (1.4.4) | |||||
| rack (~> 1.4.0) | |||||
| redis-store (~> 1.1.4) | |||||
| redis-rails (3.2.4) | |||||
| redis-actionpack (~> 3.2.4) | |||||
| redis-activesupport (~> 3.2.4) | |||||
| redis-store (~> 1.1.4) | |||||
| redis-store (1.1.7) | |||||
| redis (>= 2.2) | |||||
| rest-client (2.0.2) | |||||
| http-cookie (>= 1.0.2, < 2.0) | |||||
| mime-types (>= 1.16, < 4.0) | |||||
| netrc (~> 0.8) | |||||
| rich (1.4.6) | |||||
| jquery-rails | |||||
| kaminari | |||||
| mime-types | |||||
| paperclip | |||||
| rack-raw-upload | |||||
| rails (>= 3.2.0) | |||||
| sass-rails | |||||
| ruby-ole (1.2.12.2) | |||||
| ruby-openid (2.1.8) | |||||
| rubyzip (1.2.2) | |||||
| sass (3.7.4) | |||||
| sass-listen (~> 4.0.0) | |||||
| sass-listen (4.0.0) | |||||
| rb-fsevent (~> 0.9, >= 0.9.4) | |||||
| rb-inotify (~> 0.9, >= 0.9.7) | |||||
| sass-rails (3.2.6) | |||||
| railties (~> 3.2.0) | |||||
| sass (>= 3.1.10) | |||||
| tilt (~> 1.3) | |||||
| seems_rateable (1.0.13) | |||||
| jquery-rails | |||||
| rails | |||||
| sextant (0.2.4) | |||||
| rails (>= 3.2) | |||||
| socksify (1.7.1) | |||||
| spreadsheet (1.2.3) | |||||
| ruby-ole (>= 1.0) | |||||
| sprockets (2.2.3) | |||||
| hike (~> 1.2) | |||||
| multi_json (~> 1.0) | |||||
| rack (~> 1.0) | |||||
| tilt (~> 1.1, != 1.3.0) | |||||
| terminal-table (1.8.0) | |||||
| unicode-display_width (~> 1.1, >= 1.1.1) | |||||
| test-unit (3.3.2) | |||||
| power_assert | |||||
| thor (0.20.3) | |||||
| thread_safe (0.3.6) | |||||
| tilt (1.4.1) | |||||
| treetop (1.4.15) | |||||
| polyglot | |||||
| polyglot (>= 0.3.1) | |||||
| tzinfo (0.3.55) | |||||
| uglifier (4.1.20) | |||||
| execjs (>= 0.3.0, < 3) | |||||
| unf (0.1.4) | |||||
| unf_ext | |||||
| unf_ext (0.0.7.6) | |||||
| unicode-display_width (1.6.0) | |||||
| virtus (1.0.5) | |||||
| axiom-types (~> 0.1) | |||||
| coercible (~> 1.0) | |||||
| descendants_tracker (~> 0.0, >= 0.0.3) | |||||
| equalizer (~> 0.0, >= 0.0.9) | |||||
| whenever (1.0.0) | |||||
| chronic (>= 0.6.3) | |||||
| PLATFORMS | |||||
| ruby | |||||
| DEPENDENCIES | |||||
| acts-as-taggable-on (= 2.4.1) | |||||
| ancestry | |||||
| ansi | |||||
| better_errors (~> 1.1.0) | |||||
| binding_of_caller | |||||
| builder (= 3.0.0) | |||||
| certified | |||||
| chinese_pinyin | |||||
| coderay (~> 1.1.0) | |||||
| coffee-rails (~> 3.2.1) | |||||
| daemons | |||||
| delayed_job_active_record | |||||
| elasticsearch-model | |||||
| elasticsearch-rails | |||||
| factory_girl_rails | |||||
| fastercsv (~> 1.5.0) | |||||
| gitlab! | |||||
| grack! | |||||
| grape (~> 0.9.0) | |||||
| grape-entity (= 0.4.5) | |||||
| grape-swagger | |||||
| htmlentities | |||||
| i18n (~> 0.6.0) | |||||
| iconv | |||||
| jbuilder | |||||
| jenkins_api_client | |||||
| jquery-rails (~> 2.0.2) | |||||
| kaminari | |||||
| mysql2 (= 0.3.18) | |||||
| net-ldap (~> 0.3.1) | |||||
| net-ssh (= 2.9.1) | |||||
| nokogiri | |||||
| paperclip (~> 3.5.4) | |||||
| pry-byebug | |||||
| puma | |||||
| rack-cors | |||||
| rack-mini-profiler (~> 0.9.3) | |||||
| rack-openid | |||||
| rails (~> 3.2) | |||||
| rails_kindeditor! | |||||
| ransack | |||||
| redis-rails | |||||
| rest-client | |||||
| rich (= 1.4.6) | |||||
| ruby-ole | |||||
| ruby-openid (~> 2.1.4) | |||||
| rubyzip | |||||
| sass-rails (~> 3.2.3) | |||||
| seems_rateable (~> 1.0.13) | |||||
| sextant | |||||
| spreadsheet | |||||
| test-unit (~> 3.0) | |||||
| uglifier (>= 1.0.3) | |||||
| wechat! | |||||
| whenever (~> 1.0) | |||||
| BUNDLED WITH | |||||
| 1.17.3 | |||||
| @@ -0,0 +1,74 @@ | |||||
| # API文档 | |||||
| --- | |||||
| ## 基本介绍 | |||||
| trustie平台同步其他平台数据的相关接口,如Educode、Openl,在获得许可权限后,如下接口可在其他任何平台调用。 | |||||
| #### token认证 | |||||
| token在trustie控制台下通过Setting.api_token获取,获取后可放环境变量中或者某个配置文件中 | |||||
| #### 同步用户数量、开源项目数量、实训项目数量 | |||||
| ``` | |||||
| PUT homes/sync_count | |||||
| ``` | |||||
| *示例* | |||||
| ``` | |||||
| curl -X PUT http://localhost:3001/api/v1/homes/sync_count \ | |||||
| -d "token=34c82f51e0b699d9d16d70fd6497c9b1e4821d6ea3e872558a6537a091076b8e" \ | |||||
| -d "type=project" | jq | |||||
| ``` | |||||
| 请求参数说明: | |||||
| token(requires): String,权限验证 | |||||
| type(requires): String;同步的类型,取值范围: {user(用户) | project(开源项目) | practical_training_project(实训项目) | school(应用高校)} | |||||
| number(optional): Integer;同步数量, 该参数可选,不传时,后台默认值为1 | |||||
| 返回值 | |||||
| ``` | |||||
| { | |||||
| "status": 1, | |||||
| "message": "token is invalid!" | |||||
| } | |||||
| ``` | |||||
| --- | |||||
| #### 同步动态新闻 | |||||
| ``` | |||||
| PUT homes/sync_news | |||||
| ``` | |||||
| *示例* | |||||
| ``` | |||||
| curl -X PUT http://localhost:3001/api/v1/homes/sync_news \ | |||||
| -d "token=34c82f51e0b699d9d16d70fd6497c9b1e4821d6ea3e872558a6537a091076b8e" \ | |||||
| -d "title=“基于OpenI海参的视频编码大赛”海口启动" \ | |||||
| -d "simple_intruduce=2019年8月31日下午,“AVS工作组第70次会议暨AI标准工作组第8次会议”闭幕式在海口召开,会上启动了“基于OpenI海参的视频编码大赛”,哈尔滨工业大学范晓鹏教授介绍了大赛背景、选题及参赛流程等信息,正式开启大赛参赛团队招募。" \ | |||||
| -d "remote_url=https://www.openi.org.cn/html/2019/dongtai_0903/255.html" | jq | |||||
| ``` | |||||
| 请求参数说明: | |||||
| cover_remote_url(optional): String, 封面访问地址 | |||||
| category_id(optional): Integer, 分类ID | |||||
| content(optional): String, 新闻内容 | |||||
| title(requires): String, 新闻标题 | |||||
| simple_intruduce(requires): String, 新闻简介 | |||||
| remote_url(requires): String, 新闻访问地址 | |||||
| platform(requires): String, 该条数据的来源{educoder | trusite | ihub | gcc | openi |toschina | military | jiaotong_university}; 如educoder说明是来源educoder平台 | |||||
| 返回值 | |||||
| ``` | |||||
| { | |||||
| "status": 1, | |||||
| "message": "token is invalid!" | |||||
| } | |||||
| ``` | |||||
| --- | |||||
| @@ -1,5 +0,0 @@ | |||||
| = Redmine | |||||
| Redmine is a flexible project management web application written using Ruby on Rails framework. | |||||
| More details can be found in the doc directory or on the official website http://www.redmine.org | |||||
| @@ -1,7 +1,7 @@ | |||||
| ===================================[2014-04-09]================================= | ===================================[2014-04-09]================================= | ||||
| kw: 域名, 二级域名, subdomain, forge, course, contest | |||||
| 域名跳转(forge/course/contest)这几个设置在settings.yml中 | |||||
| 但是跳转在development模式下会导致无法开发 | |||||
| kw: 锟斤拷锟斤拷, 锟斤拷锟斤拷锟斤拷锟斤拷, subdomain, forge, course, contest | |||||
| 锟斤拷锟斤拷锟斤拷转锟斤拷forge/course/contest锟斤拷锟解几锟斤拷锟斤拷锟斤拷锟斤拷settings.yml锟斤拷 | |||||
| 锟斤拷锟斤拷锟斤拷转锟斤拷development模式锟铰会导锟斤拷锟睫凤拷锟斤拷锟斤拷 | |||||
| app/models/setting.rb :165 | app/models/setting.rb :165 | ||||
| # fixed domain url in development. tantantan's bug | # fixed domain url in development. tantantan's bug | ||||
| @@ -10,90 +10,95 @@ app/models/setting.rb :165 | |||||
| define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/ | define_singleton_method m do; nil; end if m.to_s =~ /([a-zA-Z]+_domain)$/ | ||||
| end | end | ||||
| end | end | ||||
| 程序部分链接中制定了subdomain参数,使链接在二级域名中来回跳转。 | |||||
| 为了开发方便,使之功能在development模式下失效。 | |||||
| 锟斤拷锟津部凤拷锟斤拷锟斤拷锟斤拷锟狡讹拷锟斤拷subdomain锟斤拷锟斤拷锟斤拷使锟斤拷锟斤拷锟节讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷转锟斤拷 | |||||
| 为锟剿匡拷锟斤拷锟斤拷锟姐,使之锟斤拷锟斤拷锟斤拷development模式锟斤拷失效锟斤拷 | |||||
| ===================================[2014-04-09]================================= | ===================================[2014-04-09]================================= | ||||
| kw: 菜单, 导航栏, layout | |||||
| 网页上方的导航条没有用Redmine::MenuManager | |||||
| MenuManager的样式无法定制,菜单显示条件if中的proc执行行为没有了解 | |||||
| kw: 锟剿碉拷, 锟斤拷锟斤拷锟斤拷, layout | |||||
| 锟斤拷页锟较凤拷锟侥碉拷锟斤拷锟斤拷没锟斤拷锟斤拷Redmine::MenuManager | |||||
| MenuManager锟斤拷锟斤拷式锟睫凤拷锟斤拷锟狡o拷锟剿碉拷锟斤拷示锟斤拷锟斤拷if锟叫碉拷proc执锟斤拷锟斤拷为没锟斤拷锟剿斤拷 | |||||
| #导航栏匹配域名显示和改变 | |||||
| #锟斤拷锟斤拷锟斤拷匹锟斤拷锟斤拷锟斤拷锟斤拷示锟酵改憋拷 | |||||
| app\helper\application_helper.rb | app\helper\application_helper.rb | ||||
| render_dynamic_nav 方法中,利用变量,可以设置在layout中具体显示哪些条目 | |||||
| render_dynamic_nav 锟斤拷锟斤拷锟叫o拷锟斤拷锟矫憋拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷layout锟叫撅拷锟斤拷锟斤拷示锟斤拷些锟斤拷目 | |||||
| app\views\layouts\_base_header.html.erb | app\views\layouts\_base_header.html.erb | ||||
| 需要显示的条目,由具体的实例变量设置(在各个layout中) | |||||
| 锟斤拷要锟斤拷示锟斤拷锟斤拷目锟斤拷锟缴撅拷锟斤拷锟斤拷实锟斤拷锟斤拷锟斤拷锟斤拷锟矫o拷锟节革拷锟斤拷layout锟叫o拷 | |||||
| ===================================[2014-04-09]================================= | ===================================[2014-04-09]================================= | ||||
| kw: home_path, 首页, 跳转, 二级域名, welcome | |||||
| #首页根据域名匹配进入不同的页面 | |||||
| kw: home_path, 锟斤拷页, 锟斤拷转, 锟斤拷锟斤拷锟斤拷锟斤拷, welcome | |||||
| #锟斤拷页锟斤拷锟斤拷锟斤拷锟斤拷匹锟斤拷锟斤拷锟诫不同锟斤拷页锟斤拷 | |||||
| app\controller\welcome_controller.rb | app\controller\welcome_controller.rb | ||||
| #entry_select 放射设置二级域名所显示的首页 | |||||
| #entry_select 锟斤拷锟斤拷锟斤拷锟矫讹拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷示锟斤拷锟斤拷页 | |||||
| ===================================[2014-06-06]================================= | ===================================[2014-06-06]================================= | ||||
| kw: user_scores | kw: user_scores | ||||
| user_scores表结构有问题,需要运行 | |||||
| user_scores锟斤拷锟结构锟斤拷锟斤拷锟解,锟斤拷要锟斤拷锟斤拷 | |||||
| bundle exec rake db:migrate:down VERSION=20140410021724 | bundle exec rake db:migrate:down VERSION=20140410021724 | ||||
| bundle exec rake db:migrate:up VERSION=20140410021724 | bundle exec rake db:migrate:up VERSION=20140410021724 | ||||
| ===================================[2014-07-08]================================= | ===================================[2014-07-08]================================= | ||||
| kw: CKEditor, 富文本, 编辑器 | |||||
| CKEditor插件加载方法 | |||||
| 1.把插件文件夹拷入plugins文件夹,确保文件夹名为redmine_ckeditor | |||||
| 2.运行 bundle install --without development test | |||||
| 3.运行 rake redmine:plugins:migrate RAILS_ENV=production | |||||
| 4.启动服务器 | |||||
| 5.配置CKEditor插件(Administration > Plugins > Configure) | |||||
| 6.把文本格式 (Administration > Settings > General > Text formatting)改为CKEditor | |||||
| 注意:一定要先配置CKEditor插件再见文本格式更改,不然,数据库不会生成对应记录,会报错。。 | |||||
| kw: CKEditor, 锟斤拷锟侥憋拷, 锟洁辑锟斤拷 | |||||
| CKEditor锟斤拷锟斤拷锟斤拷锟截凤拷锟斤拷 | |||||
| 1.锟窖诧拷锟斤拷锟侥硷拷锟叫匡拷锟斤拷plugins锟侥硷拷锟叫o拷确锟斤拷锟侥硷拷锟斤拷锟斤拷为redmine_ckeditor | |||||
| 2.锟斤拷锟斤拷 bundle install --without development test | |||||
| 3.锟斤拷锟斤拷 rake redmine:plugins:migrate RAILS_ENV=production | |||||
| 4.锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 | |||||
| 5.锟斤拷锟斤拷CKEditor锟斤拷锟斤拷(Administration > Plugins > Configure) | |||||
| 6.锟斤拷锟侥憋拷锟斤拷式 (Administration > Settings > General > Text formatting)锟斤拷为CKEditor | |||||
| 注锟解:一锟斤拷要锟斤拷锟斤拷锟斤拷CKEditor锟斤拷锟斤拷锟劫硷拷锟侥憋拷锟斤拷式锟斤拷锟侥o拷锟斤拷然锟斤拷锟斤拷锟捷库不锟斤拷锟斤拷锟缴讹拷应锟斤拷录锟斤拷锟结报锟斤拷锟斤拷锟斤拷 | |||||
| ===================================[2014-07-19]================================= | ===================================[2014-07-19]================================= | ||||
| kw: 首页, 定制, forge, course, contest, 排序 | |||||
| 若遇到首页定制报错问题请尝试如下操作 | |||||
| 如果运行迁移文件有报错与‘sort_type’相关 | |||||
| 先运行 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202 | |||||
| 在按如下步骤执行,未报与之相关的则直接按如下步骤执行 | |||||
| 1.运行 bundle exec rake db:migrate:down version=20140719080032 | |||||
| 2.运行 bundle exec rake db:migrate:up version=20140719080032 | |||||
| kw: 锟斤拷页, 锟斤拷锟斤拷, forge, course, contest, 锟斤拷锟斤拷 | |||||
| 锟斤拷锟斤拷锟斤拷锟斤拷页锟斤拷锟狡憋拷锟斤拷锟斤拷锟斤拷锟诫尝锟斤拷锟斤拷锟铰诧拷锟斤拷 | |||||
| 锟斤拷锟斤拷锟斤拷锟斤拷迁锟斤拷锟侥硷拷锟叫憋拷锟斤拷锟诫‘sort_type锟斤拷锟斤拷锟斤拷 | |||||
| 锟斤拷锟斤拷锟斤拷 bundle exec rake db:migrate:down version=20140716021202 bundle exec rake db:migrate:up version=20140716021202 | |||||
| 锟节帮拷锟斤拷锟铰诧拷锟斤拷执锟叫o拷未锟斤拷锟斤拷之锟斤拷锟截碉拷锟斤拷直锟接帮拷锟斤拷锟铰诧拷锟斤拷执锟斤拷 | |||||
| 1.锟斤拷锟斤拷 bundle exec rake db:migrate:down version=20140719080032 | |||||
| 2.锟斤拷锟斤拷 bundle exec rake db:migrate:up version=20140719080032 | |||||
| ===================================[2014-07-30]================================= | ===================================[2014-07-30]================================= | ||||
| kw: 首页, 定制, forge, course, contest, 排序,image_width | |||||
| kw: 锟斤拷页, 锟斤拷锟斤拷, forge, course, contest, 锟斤拷锟斤拷锟斤拷image_width | |||||
| undefined image_width 问题 | |||||
| undefined image_width 锟斤拷锟斤拷 | |||||
| bundle exec rake db:migrate:down version=20140725062302 | bundle exec rake db:migrate:down version=20140725062302 | ||||
| bundle exec rake db:migrate:up version=20140725062302 | bundle exec rake db:migrate:up version=20140725062302 | ||||
| =================================[2014-07-19]===================================== | =================================[2014-07-19]===================================== | ||||
| kw: Mysql2::Error,存储过程,CALL sp_project_status_cursor(); | |||||
| kw: Mysql2::Error,锟芥储锟斤拷锟斤拷,CALL sp_project_status_cursor(); | |||||
| bundle exec rake db:migrate:down version=20130828004955 | bundle exec rake db:migrate:down version=20130828004955 | ||||
| bundle exec rake db:migrate:up version=20130828004955 | bundle exec rake db:migrate:up version=20130828004955 | ||||
| =================================[2014-08-13]==================================== | =================================[2014-08-13]==================================== | ||||
| kw:配置支持的图片格式 | |||||
| 默认支持如下格式:"bmp,jpeg,jpg,png,gif" | |||||
| 可在configuration.yml中修改,格式:pic_types: "bmp,jpeg,jpg,png,gif"(注意:pic_types若前面有#号需去掉) | |||||
| 配置完成后重启服务 | |||||
| kw:锟斤拷锟斤拷支锟街碉拷图片锟斤拷式 | |||||
| 默锟斤拷支锟斤拷锟斤拷锟铰革拷式锟斤拷"bmp,jpeg,jpg,png,gif" | |||||
| 锟斤拷锟斤拷configuration.yml锟斤拷锟睫改o拷锟斤拷式锟斤拷pic_types: "bmp,jpeg,jpg,png,gif"(注锟解:pic_types锟斤拷前锟斤拷锟斤拷#锟斤拷锟斤拷去锟斤拷) | |||||
| 锟斤拷锟斤拷锟斤拷锟缴猴拷锟斤拷锟斤拷锟斤拷锟斤拷 | |||||
| =================================[2014-08-16]==================================== | =================================[2014-08-16]==================================== | ||||
| kw:数据迁移,project_scores表已存在 | |||||
| kw:锟斤拷锟斤拷迁锟狡o拷project_scores锟斤拷锟窖达拷锟斤拷 | |||||
| bundle exec rake db:migrate:down VERSION=20140811022947 | bundle exec rake db:migrate:down VERSION=20140811022947 | ||||
| bundle exec rake db:migrate:up VERSION=20140811022947 | bundle exec rake db:migrate:up VERSION=20140811022947 | ||||
| bundle exec rake db:migrate | bundle exec rake db:migrate | ||||
| bundle exec rake project_score:calculate | bundle exec rake project_score:calculate | ||||
| =================================[2014-10-17]==================================== | =================================[2014-10-17]==================================== | ||||
| kw:数据迁移,web_footer_oranizers表已存在 | |||||
| kw:锟斤拷锟斤拷迁锟狡o拷web_footer_oranizers锟斤拷锟窖达拷锟斤拷 | |||||
| bundle exec rake db:migrate:down VERSION=20141013014908 | bundle exec rake db:migrate:down VERSION=20141013014908 | ||||
| bundle exec rake db:migrate:up VERSION=20141013014908 | bundle exec rake db:migrate:up VERSION=20141013014908 | ||||
| bundle exec rake db:migrate | bundle exec rake db:migrate | ||||
| kw:数据迁移,web_footer_companies表已存在 | |||||
| kw:锟斤拷锟斤拷迁锟狡o拷web_footer_companies锟斤拷锟窖达拷锟斤拷 | |||||
| bundle exec rake db:migrate:down VERSION=20141013023400 | bundle exec rake db:migrate:down VERSION=20141013023400 | ||||
| bundle exec rake db:migrate:up VERSION=20141013023400 | bundle exec rake db:migrate:up VERSION=20141013023400 | ||||
| bundle exec rake db:migrate | bundle exec rake db:migrate | ||||
| =================================[2019-11-12]==================================== | |||||
| 鍒濆�鍖栧紑婧愰」鐩�浉鍏崇殑licenses鍜宨gnores | |||||
| bundle exec rake licenses:init | |||||
| bundle exec rake ignores:init | |||||
| @@ -21,6 +21,7 @@ module Mobile | |||||
| require_relative 'apis/resources' | require_relative 'apis/resources' | ||||
| require_relative 'apis/syllabuses' | require_relative 'apis/syllabuses' | ||||
| require_relative 'apis/projects' | require_relative 'apis/projects' | ||||
| require_relative 'apis/homes' | |||||
| class API < Grape::API | class API < Grape::API | ||||
| version 'v1', using: :path | version 'v1', using: :path | ||||
| @@ -56,6 +57,11 @@ module Mobile | |||||
| nil | nil | ||||
| end | end | ||||
| # 使用固定token来简单验证用户是否有调用某个api权限 | |||||
| def authenticate_token! | |||||
| raise 'token is invalid!' unless params[:token].strip == Setting.api_token | |||||
| end | |||||
| end | end | ||||
| mount Apis::Auth | mount Apis::Auth | ||||
| @@ -77,10 +83,9 @@ module Mobile | |||||
| mount Apis::Resources | mount Apis::Resources | ||||
| mount Apis::Syllabuses | mount Apis::Syllabuses | ||||
| mount Apis::Projects | mount Apis::Projects | ||||
| mount Apis::Homes | |||||
| add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? | add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development? | ||||
| end | end | ||||
| end | end | ||||
| @@ -0,0 +1,71 @@ | |||||
| #coding=utf-8 | |||||
| module Mobile | |||||
| module Apis | |||||
| class Homes< Grape::API | |||||
| resources :homes do | |||||
| desc "Current user's information in access token's scope<span class='accstr'>*</span>", { | |||||
| headers: { | |||||
| "Authorization" => { | |||||
| description: "Valdates your identity", | |||||
| required: true | |||||
| } | |||||
| } | |||||
| } | |||||
| desc "同步用户数量、开源项目数量、实训项目数量" | |||||
| params do | |||||
| optional :number, type: Integer, default: 1, desc: "同步的数量" | |||||
| requires :token, type: String, desc: "token is validate user identity" | |||||
| requires :type, type: String, values: ['user', 'project', 'practical_training_project', 'school'], desc: "type requires." | |||||
| end | |||||
| put 'sync_count' do | |||||
| authenticate_token! | |||||
| begin | |||||
| HomesService.new.sync_count(params[:type].strip, params[:number].to_i) | |||||
| present :status, 0 | |||||
| present :message, "sync success." | |||||
| rescue Exception=>e | |||||
| present :status, -1 | |||||
| present :message, e.message | |||||
| end | |||||
| end | |||||
| desc "同步社区动态新闻" | |||||
| params do | |||||
| optional :cover_remote_url, type: String, regexp: Home::REG_URL_FORMAT | |||||
| optional :category_id, type: Integer | |||||
| optional :content, type: String | |||||
| requires :title, type: String | |||||
| requires :simple_intruduce, type: String | |||||
| requires :remote_url, type: String, regexp: Home::REG_URL_FORMAT | |||||
| requires :platform, type: String, desc: "platform requires." , values: DynamicNew::PLATFORMS | |||||
| end | |||||
| put 'sync_news' do | |||||
| authenticate_token! | |||||
| news_params = { | |||||
| title: params[:title], | |||||
| simple_intruduce: params[:simple_intruduce], | |||||
| remote_url: params[:remote_url], | |||||
| category_id: params[:category_id], | |||||
| content: params[:content], | |||||
| cover_remote_url: params[:cover_remote_url], | |||||
| platform: params[:platform] | |||||
| } | |||||
| begin | |||||
| DynamicNewsService.new.sync(news_params) | |||||
| present :status, 0 | |||||
| present :message, 'sync success' | |||||
| rescue => e | |||||
| logger.info e | |||||
| present :status, -1 | |||||
| present :message, e.message | |||||
| end | |||||
| end | |||||
| end | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| # Place all the behaviors and hooks related to the matching controller here. | |||||
| # All this logic will automatically be available in application.js. | |||||
| # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| // Place all the styles related to the private_messages controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| @@ -0,0 +1,3 @@ | |||||
| // Place all the styles related to the statistic_works controller here. | |||||
| // They will automatically be included in application.css. | |||||
| // You can use Sass (SCSS) here: http://sass-lang.com/ | |||||
| @@ -45,6 +45,7 @@ class AccountController < ApplicationController | |||||
| else | else | ||||
| redirect_to user_path(User.current) | redirect_to user_path(User.current) | ||||
| end | end | ||||
| else | else | ||||
| render :layout => 'login' | render :layout => 'login' | ||||
| end | end | ||||
| @@ -134,7 +135,7 @@ class AccountController < ApplicationController | |||||
| Mailer.run.lost_password(token) | Mailer.run.lost_password(token) | ||||
| flash[:notice] = l(:notice_account_lost_email_sent) | flash[:notice] = l(:notice_account_lost_email_sent) | ||||
| redirect_to lost_password_path | redirect_to lost_password_path | ||||
| return | |||||
| return | |||||
| end | end | ||||
| end | end | ||||
| render :layout => 'static_base' | render :layout => 'static_base' | ||||
| @@ -186,6 +187,15 @@ class AccountController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||
| sync_params = { | |||||
| username: params[:user][:login], | |||||
| password: params[:user][:password], | |||||
| email: params[:user][:mail], | |||||
| platform: "trustie" | |||||
| } | |||||
| # Delayed::Job.enqueue(SyncUserLoginJob.new.perform("remote_register",sync_params)) #同步注册 | |||||
| SyncUserLoginJob.new.perform("remote_register",sync_params) | |||||
| end | end | ||||
| end | end | ||||
| @@ -379,7 +389,7 @@ class AccountController < ApplicationController | |||||
| def password_authentication | def password_authentication | ||||
| user, last_login_on = User.try_to_login(params[:username], params[:password]) | user, last_login_on = User.try_to_login(params[:username], params[:password]) | ||||
| if user.nil? | if user.nil? | ||||
| invalid_credentials | invalid_credentials | ||||
| elsif user.status == 2 | elsif user.status == 2 | ||||
| @@ -390,6 +400,8 @@ class AccountController < ApplicationController | |||||
| else | else | ||||
| # Valid user | # Valid user | ||||
| successful_authentication(user, last_login_on) | successful_authentication(user, last_login_on) | ||||
| # sync password to forge | |||||
| # SyncUserPwdToForge.new(user.login, params[:password]).call unless user.is_sync_pwd? | |||||
| end | end | ||||
| end | end | ||||
| @@ -447,8 +459,8 @@ class AccountController < ApplicationController | |||||
| call_hook(:controller_account_success_authentication_after, {:user => user }) | call_hook(:controller_account_success_authentication_after, {:user => user }) | ||||
| code = /\d*/ | code = /\d*/ | ||||
| #根据home_url生产正则表达式 | |||||
| eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") | |||||
| #根据homes_url生产正则表达式 | |||||
| eval("code = " + "/^" + homes_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") | |||||
| if (code=~params[:back_url] || params[:back_url].to_s.include?('lost_password')) && 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,host: Setting.host_user) | redirect_to user_activities_path(user,host: Setting.host_user) | ||||
| elsif params[:back_url64] | elsif params[:back_url64] | ||||
| @@ -476,6 +488,8 @@ class AccountController < ApplicationController | |||||
| def set_autologin_cookie(user) | def set_autologin_cookie(user) | ||||
| token = Token.get_or_create_permanent_login_token(user) | token = Token.get_or_create_permanent_login_token(user) | ||||
| SendUserTokenToForge.new(user.login, token.value).call # 将用户的token值同步到forge平台 | |||||
| cookie_options = { | cookie_options = { | ||||
| :value => token.value, | :value => token.value, | ||||
| :expires => 1.month.from_now, | :expires => 1.month.from_now, | ||||
| @@ -487,6 +501,7 @@ class AccountController < ApplicationController | |||||
| cookie_options = cookie_options.merge(domain: Redmine::Configuration['cookie_domain']) | cookie_options = cookie_options.merge(domain: Redmine::Configuration['cookie_domain']) | ||||
| end | end | ||||
| cookies[autologin_cookie_name] = cookie_options | cookies[autologin_cookie_name] = cookie_options | ||||
| logger.info("cookies is #{cookies} -------=====> cookies[autologin_cookie_name]: #{cookies[autologin_cookie_name]}") | |||||
| end | end | ||||
| # Onthefly creation failed, display the registration form to fill/fix attributes | # Onthefly creation failed, display the registration form to fill/fix attributes | ||||
| @@ -502,7 +517,7 @@ class AccountController < ApplicationController | |||||
| # render :layout => 'login' | # render :layout => 'login' | ||||
| redirect_to signin_path(:login=>true) | redirect_to signin_path(:login=>true) | ||||
| end | end | ||||
| def invalid_credentials_new | def invalid_credentials_new | ||||
| logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" | logger.warn "Failed login for '#{params[:username]}' from #{request.remote_ip} at #{Time.now.utc}" | ||||
| # flash[:error] = l(:notice_account_invalid_creditentials_new) | # flash[:error] = l(:notice_account_invalid_creditentials_new) | ||||
| @@ -527,6 +527,27 @@ class AdminController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| def home | |||||
| if request.get? | |||||
| @home = Home.first | |||||
| elsif request.post? | |||||
| @home = Home.first || Home.new | |||||
| @home.name = params[:home][:name] | |||||
| @home.content = params[:home][:content] | |||||
| if @home.save | |||||
| respond_to do |format| | |||||
| flash[:notice] = l(:notice_successful_update) | |||||
| format.html { redirect_to admin_home_path } | |||||
| end | |||||
| else | |||||
| respond_to do |format| | |||||
| flash.now[:error] = "#{l :label_first_page_create_fail}: #{@home.errors.full_messages[0]}" | |||||
| format.html { render :action => 'home' } | |||||
| end | |||||
| end | |||||
| end | |||||
| end | |||||
| def course_page_made | def course_page_made | ||||
| if request.get? | if request.get? | ||||
| @course_page = FirstPage.find_by_page_type('course') | @course_page = FirstPage.find_by_page_type('course') | ||||
| @@ -712,6 +733,21 @@ class AdminController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| # 动态消息列表 | |||||
| def dynamic_news | |||||
| @category_id = params[:category_id] || 0 | |||||
| scope = DynamicNew.desc.like(params[:title]) | |||||
| scope = scope.by_category(@category_id.to_i) unless @category_id.to_i == 0 | |||||
| @dynamic_news_count = scope.count | |||||
| @dynamic_news = paginateHelper scope, 15 | |||||
| @page = (params['page'] || 1).to_i - 1 | |||||
| respond_to do |format| | |||||
| format.js | |||||
| format.html | |||||
| end | |||||
| end | |||||
| # 单位审核 | # 单位审核 | ||||
| # 未审批tab页 | # 未审批tab页 | ||||
| # status: 0 未审批; 1 已批阅; 2已更改; 3拒绝; | # status: 0 未审批; 1 已批阅; 2已更改; 3拒绝; | ||||
| @@ -26,7 +26,7 @@ class ApplicationController < ActionController::Base | |||||
| include Redmine::Pagination | include Redmine::Pagination | ||||
| include RoutesHelper | include RoutesHelper | ||||
| helper :routes | helper :routes | ||||
| #added by william | #added by william | ||||
| helper :watchers | helper :watchers | ||||
| @@ -57,7 +57,7 @@ class ApplicationController < ActionController::Base | |||||
| helper Redmine::MenuManager::MenuHelper | helper Redmine::MenuManager::MenuHelper | ||||
| def user_agent | def user_agent | ||||
| logger.info "HTTP_USER_AGENT #{request.env["HTTP_USER_AGENT"]}" | |||||
| logger.info "HTTP_USER_AGENT #{request.env["HTTP_USER_AGENT"]}" | |||||
| end | end | ||||
| def session_expiration | def session_expiration | ||||
| @@ -72,7 +72,7 @@ class ApplicationController < ActionController::Base | |||||
| end | end | ||||
| end | end | ||||
| def session_expired? | def session_expired? | ||||
| if Setting.session_lifetime? | if Setting.session_lifetime? | ||||
| unless session[:ctime] && (Time.now.utc.to_i - session[:ctime].to_i <= Setting.session_lifetime.to_i * 60) | unless session[:ctime] && (Time.now.utc.to_i - session[:ctime].to_i <= Setting.session_lifetime.to_i * 60) | ||||
| @@ -474,7 +474,7 @@ class ApplicationController < ActionController::Base | |||||
| rescue ActiveRecord::RecordNotFound | rescue ActiveRecord::RecordNotFound | ||||
| render_404 | render_404 | ||||
| end | end | ||||
| # Finds and sets @project based on @object.project | # Finds and sets @project based on @object.project | ||||
| def find_project_from_association | def find_project_from_association | ||||
| render_404 unless @object.present? | render_404 unless @object.present? | ||||
| @@ -488,7 +488,7 @@ class ApplicationController < ActionController::Base | |||||
| end | end | ||||
| end | end | ||||
| def find_contest_from_association | def find_contest_from_association | ||||
| render_404 unless @object.present? | render_404 unless @object.present? | ||||
| @@ -810,10 +810,10 @@ class ApplicationController < ActionController::Base | |||||
| end | end | ||||
| if offset.nil? && options[:page].present? | if offset.nil? && options[:page].present? | ||||
| offset = (options[:page].to_i - 1) * limit | offset = (options[:page].to_i - 1) * limit | ||||
| offset = 0 if offset < 0 | |||||
| offset = 0 if offset < 0 | |||||
| offset ||= 0 | offset ||= 0 | ||||
| end | end | ||||
| [offset, limit] | [offset, limit] | ||||
| end | end | ||||
| @@ -876,7 +876,7 @@ class ApplicationController < ActionController::Base | |||||
| if unsaved_issue_ids.empty? | if unsaved_issue_ids.empty? | ||||
| flash[:notice] = l(:notice_successful_update) unless issues.empty? | flash[:notice] = l(:notice_successful_update) unless issues.empty? | ||||
| else | else | ||||
| flash[:error] = l(:notice_failed_to_save_issues, | |||||
| flash[:error] = l(:notice_failed_to_save_issues, | |||||
| :count => unsaved_issue_ids.size, | :count => unsaved_issue_ids.size, | ||||
| :total => issues.size, | :total => issues.size, | ||||
| :ids => '#' + unsaved_issue_ids.join(', #')) | :ids => '#' + unsaved_issue_ids.join(', #')) | ||||
| @@ -961,7 +961,7 @@ class ApplicationController < ActionController::Base | |||||
| def find_web_footer | def find_web_footer | ||||
| @organizer = WebFooterOranizer.first | @organizer = WebFooterOranizer.first | ||||
| @companies = WebFooterCompany.all | |||||
| @companies = WebFooterCompany.partners | |||||
| end | end | ||||
| @@ -994,4 +994,8 @@ class ApplicationController < ActionController::Base | |||||
| end | end | ||||
| true | true | ||||
| end | end | ||||
| def set_nav_status(active) | |||||
| @active = active | |||||
| end | |||||
| end | end | ||||
| @@ -21,7 +21,7 @@ class BoardsController < ApplicationController | |||||
| before_filter :find_project_by_project_id, :find_board_if_available, :except => [:join_to_org_subfields] | before_filter :find_project_by_project_id, :find_board_if_available, :except => [:join_to_org_subfields] | ||||
| before_filter :authorize, :except => [:new, :show, :create, :index, :join_to_org_subfields, :update_position, :update_name] | before_filter :authorize, :except => [:new, :show, :create, :index, :join_to_org_subfields, :update_position, :update_name] | ||||
| accept_rss_auth :index, :show | accept_rss_auth :index, :show | ||||
| helper :sort | helper :sort | ||||
| include SortHelper | include SortHelper | ||||
| @@ -33,6 +33,7 @@ class BoardsController < ApplicationController | |||||
| #modify by nwb | #modify by nwb | ||||
| @flag = params[:flag] || false | @flag = params[:flag] || false | ||||
| if @project | if @project | ||||
| set_nav_status(NavStatues::PROJECT) | |||||
| if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin? && !User.current.allowed_to?(:view_messages, @project) | if !@project.is_public? && !User.current.member_of?(@project) && !User.current.admin? && !User.current.allowed_to?(:view_messages, @project) | ||||
| render_403 | render_403 | ||||
| else | else | ||||
| @@ -45,6 +46,7 @@ class BoardsController < ApplicationController | |||||
| render :layout => false if request.xhr? | render :layout => false if request.xhr? | ||||
| end | end | ||||
| elsif @course | elsif @course | ||||
| set_nav_status(NavStatues::COURSE) | |||||
| if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) | if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) | ||||
| @boards = @course.boards.includes(:last_message => :author).all | @boards = @course.boards.includes(:last_message => :author).all | ||||
| if @course.boards.empty? | if @course.boards.empty? | ||||
| @@ -68,6 +70,7 @@ class BoardsController < ApplicationController | |||||
| render_403 | render_403 | ||||
| end | end | ||||
| elsif @contest | elsif @contest | ||||
| set_nav_status(NavStatues::COMPETION) | |||||
| if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest))) | if (User.current.admin? || @contest.is_public || (!@contest.is_public && User.current.member_of_contest?(@contest))) | ||||
| @boards = @contest.boards.includes(:last_message => :author).all | @boards = @contest.boards.includes(:last_message => :author).all | ||||
| if @contest.boards.empty? | if @contest.boards.empty? | ||||
| @@ -32,6 +32,7 @@ class CalendarsController < ApplicationController | |||||
| def show | def show | ||||
| # 控制顶部导航样式 | # 控制顶部导航样式 | ||||
| @project_menu_type = 8 | @project_menu_type = 8 | ||||
| set_nav_status(NavStatues::PROJECT) | |||||
| if params[:year] and params[:year].to_i > 1900 | if params[:year] and params[:year].to_i > 1900 | ||||
| @year = params[:year].to_i | @year = params[:year].to_i | ||||
| @@ -88,6 +88,14 @@ class ContestantWorksController < ApplicationController | |||||
| end | end | ||||
| @student_work_count = @contestwork.contestant_works.has_committed.select("contestant_works.*,contestant_works.work_score as score").order("#{@order} #{@b_sort}").count | @student_work_count = @contestwork.contestant_works.has_committed.select("contestant_works.*,contestant_works.work_score as score").order("#{@order} #{@b_sort}").count | ||||
| @is_group_project_homework = @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project | |||||
| @all_group_projects = [] | |||||
| if @is_group_project_homework | |||||
| project_ids = @contestwork.contestant_works.has_committed.joins(:contestant_work_projects).where("contestant_works.id = contestant_work_projects.contestant_work_id").pluck("contestant_work_projects.project_id").uniq | |||||
| @all_group_projects = GetForgeProjectService.new.call(project_ids) | |||||
| end | |||||
| @score = @b_sort == "desc" ? "asc" : "desc" | @score = @b_sort == "desc" ? "asc" : "desc" | ||||
| @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0 | @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0 | ||||
| # 消息传过来的ID | # 消息传过来的ID | ||||
| @@ -8,13 +8,17 @@ class ContestsController < ApplicationController | |||||
| helper :files | helper :files | ||||
| include AvatarHelper | include AvatarHelper | ||||
| include ApplicationHelper | include ApplicationHelper | ||||
| before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :private_or_public, :switch_role, :set_invite_code_halt, :renew, | before_filter :find_contest, :only => [:show, :settings, :update, :destroy, :contest_activities, :private_or_public, :switch_role, :set_invite_code_halt, :renew, | ||||
| :member, :export_all_members, :feedback] | :member, :export_all_members, :feedback] | ||||
| before_filter :is_logged, :only => [:index, :new, :create] | before_filter :is_logged, :only => [:index, :new, :create] | ||||
| before_filter :is_admin?, :only => [:settings, :set_invite_code_halt, :destroy] | before_filter :is_admin?, :only => [:settings, :set_invite_code_halt, :destroy] | ||||
| before_filter :is_member?, :only => [:show, :contest_activities] | before_filter :is_member?, :only => [:show, :contest_activities] | ||||
| before_filter :only => [:show, :feedback, :member, :new] do | |||||
| set_nav_status(NavStatues::COMPETION) | |||||
| end | |||||
| layout "base_contests" | layout "base_contests" | ||||
| def show | def show | ||||
| @@ -29,6 +29,9 @@ class CoursesController < ApplicationController | |||||
| before_filter :authorize_course_global, :only => [:new,:create] | before_filter :authorize_course_global, :only => [:new,:create] | ||||
| before_filter :toggleCourse, :only => [:finishcourse, :restartcourse] | before_filter :toggleCourse, :only => [:finishcourse, :restartcourse] | ||||
| before_filter :is_deleted, :only => [:show, :settings] | before_filter :is_deleted, :only => [:show, :settings] | ||||
| before_filter :only => [:show, :course_statistics, :feedback, :member] do |controller| | |||||
| set_nav_status(NavStatues::COURSE) | |||||
| end | |||||
| before_filter :require_login, :only => [:join, :unjoin] | before_filter :require_login, :only => [:join, :unjoin] | ||||
| #before_filter :allow_join, :only => [:join] | #before_filter :allow_join, :only => [:join] | ||||
| @@ -0,0 +1,61 @@ | |||||
| class DynamicNewsController < ApplicationController | |||||
| layout 'admin', only: [:new, :destroy, :edit] | |||||
| before_filter :require_admin, :except => [:index, :show] | |||||
| before_filter :find_dynamic_new, :only => [:destroy, :edit, :update] | |||||
| def index | |||||
| end | |||||
| def new | |||||
| @category_id = params[:category_id] || 0 | |||||
| @dynamic_new = DynamicNew.new | |||||
| end | |||||
| def create | |||||
| tmp_file = params[:cover] | |||||
| @dynamic_new = DynamicNew.new(params[:dynamic_new]) | |||||
| begin | |||||
| identity = SecureRandom.uuid | |||||
| unless tmp_file.nil? | |||||
| File.open(Rails.root.join('public', 'images', 'dynamic_new', identity.to_s+'.png'), 'wb') do |file| | |||||
| file.write(tmp_file.read) | |||||
| end | |||||
| @dynamic_new.cover_remote_url = "/images/dynamic_new/#{identity}.png" | |||||
| end | |||||
| # TODO: 如下警告信息导致值写不进库 | |||||
| # WARNING: Can't mass-assign protected attributes: simple_intruduce, | |||||
| @dynamic_new.simple_intruduce = params[:dynamic_new][:simple_intruduce] | |||||
| if @dynamic_new.save! | |||||
| redirect_to admin_dynamic_news_path | |||||
| else | |||||
| render :action => 'new' | |||||
| end | |||||
| rescue => e | |||||
| logger.info e | |||||
| render 'new' | |||||
| end | |||||
| end | |||||
| def destroy | |||||
| @dynamic_new.destroy | |||||
| redirect_to admin_dynamic_news_path | |||||
| end | |||||
| def edit | |||||
| end | |||||
| def update | |||||
| @dynamic_new.update_attributes!(params[:dynamic_new]) | |||||
| redirect_to admin_dynamic_news_path | |||||
| end | |||||
| def show | |||||
| end | |||||
| private | |||||
| def find_dynamic_new | |||||
| @dynamic_new = DynamicNew.find params[:id] | |||||
| end | |||||
| end | |||||
| @@ -1,4 +1,5 @@ | |||||
| class ExerciseController < ApplicationController | class ExerciseController < ApplicationController | ||||
| include ExerciseHelper | |||||
| layout "base_courses" | layout "base_courses" | ||||
| before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, | before_filter :find_exercise_and_course, :only => [:create_exercise_question, :edit, :update, :show, :destroy, | ||||
| @@ -6,7 +7,10 @@ class ExerciseController < ApplicationController | |||||
| :show_student_result,:student_exercise_list, :update_question_num, | :show_student_result,:student_exercise_list, :update_question_num, | ||||
| :send_to_course, :get_student_uncomplete_question, :edit_question_score] | :send_to_course, :get_student_uncomplete_question, :edit_question_score] | ||||
| before_filter :find_course, :only => [:index,:new,:create] | before_filter :find_course, :only => [:index,:new,:create] | ||||
| include ExerciseHelper | |||||
| before_filter :only => [:index] do |controller| | |||||
| set_nav_status(NavStatues::COURSE) | |||||
| end | |||||
| def index | def index | ||||
| =begin | =begin | ||||
| @@ -1020,4 +1024,4 @@ class ExerciseController < ApplicationController | |||||
| rescue Exception => e | rescue Exception => e | ||||
| render_404 | render_404 | ||||
| end | end | ||||
| end | |||||
| end | |||||
| @@ -280,6 +280,7 @@ class FilesController < ApplicationController | |||||
| @is_remote = false | @is_remote = false | ||||
| @curr_page = params[:page] ? params[:page].to_i : 1 | @curr_page = params[:page] ? params[:page].to_i : 1 | ||||
| if params[:project_id] | if params[:project_id] | ||||
| set_nav_status(NavStatues::PROJECT) | |||||
| # 更新资源申请消息为已读 | # 更新资源申请消息为已读 | ||||
| # ar_ids = ApplyResource.where("user_id =? and container_id =? and container_type =?", User.current.id, params[:project_id].to_i, "Project").map{|ar| ar.id} | # ar_ids = ApplyResource.where("user_id =? and container_id =? and container_type =?", User.current.id, params[:project_id].to_i, "Project").map{|ar| ar.id} | ||||
| # cms = CourseMessage.where("course_message_type =? and user_id =? and course_message_id in (#{ar_ids.empty? ? '0': ar_ids.join(',')})", "ApplyResource", User.current.id) | # cms = CourseMessage.where("course_message_type =? and user_id =? and course_message_id in (#{ar_ids.empty? ? '0': ar_ids.join(',')})", "ApplyResource", User.current.id) | ||||
| @@ -341,6 +342,7 @@ class FilesController < ApplicationController | |||||
| render :layout => 'base_projects' | render :layout => 'base_projects' | ||||
| elsif params[:course_id] | elsif params[:course_id] | ||||
| set_nav_status(NavStatues::COURSE) | |||||
| @container_type = 1 | @container_type = 1 | ||||
| @page = params[:page] ? params[:page].to_i + 1 : 2 | @page = params[:page] ? params[:page].to_i + 1 : 2 | ||||
| if params[:sort] | if params[:sort] | ||||
| @@ -8,6 +8,14 @@ class ForumsController < ApplicationController | |||||
| before_filter :authenticate_user_edit, :only => [:edit, :update] | before_filter :authenticate_user_edit, :only => [:edit, :update] | ||||
| before_filter :authenticate_user_destroy, :only => [:destroy] | before_filter :authenticate_user_destroy, :only => [:destroy] | ||||
| before_filter :require_login, :only => [:new, :create,:destroy,:update,:edit] | before_filter :require_login, :only => [:new, :create,:destroy,:update,:edit] | ||||
| before_filter do | |||||
| set_nav_status(NavStatues::FORNUM) | |||||
| end | |||||
| before_filter :only => :show do |controller| | |||||
| controller.instance_eval do | |||||
| end | |||||
| end | |||||
| helper :sort | helper :sort | ||||
| include SortHelper | include SortHelper | ||||
| @@ -413,4 +421,4 @@ class ForumsController < ApplicationController | |||||
| find_forum_if_available | find_forum_if_available | ||||
| render_403 unless @forum.destroyable_by? User.current | render_403 unless @forum.destroyable_by? User.current | ||||
| end | end | ||||
| end | |||||
| end | |||||
| @@ -34,6 +34,7 @@ class GanttsController < ApplicationController | |||||
| def show | def show | ||||
| # 控制顶部导航样式 | # 控制顶部导航样式 | ||||
| @project_menu_type = 9 | @project_menu_type = 9 | ||||
| set_nav_status(NavStatues::PROJECT) | |||||
| @gantt = Redmine::Helpers::Gantt.new(params) | @gantt = Redmine::Helpers::Gantt.new(params) | ||||
| @gantt.project = @project | @gantt.project = @project | ||||
| @@ -0,0 +1,108 @@ | |||||
| class HomesController < ApplicationController | |||||
| layout 'base_introduce' | |||||
| before_filter :find_home, :except => [:index, :new, :create, :partners, :news] | |||||
| def index | |||||
| @home = Home.includes(:banners, :cover => [:file]).first | |||||
| @dynamic_news = DynamicNew.desc.limit(4) | |||||
| @companies = WebFooterCompany.dedicators | |||||
| @partners = WebFooterCompany.opensources | |||||
| @first_companies_group = Array(@companies.slice(0, 5)) | |||||
| @second_companies_group = Array(@companies.slice(5, 8)) | |||||
| @third_companies_group = Array(@companies.slice(13, 5)) | |||||
| fresh_when :last_modified => @home.updated_at.utc, :etag => [@home, @companies, @partners, @slide_wall, @first_companies_group, @second_companies_group, @third_companies_group] | |||||
| end | |||||
| def partners | |||||
| @companies = WebFooterCompany.where(key: ['opensource', 'dedicator']).group_by(&:key).sort { |a, b| b[0]<=>a[0] } | |||||
| end | |||||
| def news | |||||
| scope = DynamicNew.desc | |||||
| @dynamic_news_count = scope.count | |||||
| @dynamic_news = paginateHelper scope, 15 | |||||
| @page = (params['page'] || 1).to_i - 1 | |||||
| respond_to do |format| | |||||
| format.js | |||||
| format.html | |||||
| end | |||||
| end | |||||
| # GET /homes/1 | |||||
| # GET /homes/1.json | |||||
| def show | |||||
| respond_to do |format| | |||||
| format.html # show.html.erb | |||||
| format.json { render json: @home } | |||||
| end | |||||
| end | |||||
| # GET /homes/new | |||||
| # GET /homes/new.json | |||||
| def new | |||||
| @home = Home.new | |||||
| respond_to do |format| | |||||
| format.html # new.html.erb | |||||
| format.json { render json: @home } | |||||
| end | |||||
| end | |||||
| # GET /homes/1/edit | |||||
| def edit | |||||
| end | |||||
| # POST /homes | |||||
| # POST /homes.json | |||||
| def create | |||||
| @home = Home.new(params[:home]) | |||||
| respond_to do |format| | |||||
| if @home.save | |||||
| format.html { redirect_to @home, notice: 'Home was successfully created.' } | |||||
| format.json { render json: @home, status: :created, location: @home } | |||||
| else | |||||
| format.html { render action: "new" } | |||||
| format.json { render json: @home.errors, status: :unprocessable_entity } | |||||
| end | |||||
| end | |||||
| end | |||||
| # PUT /homes/1 | |||||
| # PUT /homes/1.json | |||||
| def update | |||||
| respond_to do |format| | |||||
| if @home.update_attributes(params[:home]) | |||||
| format.html { redirect_to @home, notice: 'Home was successfully updated.' } | |||||
| format.json { head :no_content } | |||||
| else | |||||
| format.html { render action: "edit" } | |||||
| format.json { render json: @home.errors, status: :unprocessable_entity } | |||||
| end | |||||
| end | |||||
| end | |||||
| # DELETE /homes/1 | |||||
| # DELETE /homes/1.json | |||||
| def destroy | |||||
| @home.destroy | |||||
| respond_to do |format| | |||||
| format.html { redirect_to homes_url } | |||||
| format.json { head :no_content } | |||||
| end | |||||
| end | |||||
| private | |||||
| def find_home | |||||
| @home = Home.find_by_frendly_id! params[:id] | |||||
| end | |||||
| end | |||||
| @@ -13,6 +13,9 @@ class HomeworkCommonController < ApplicationController | |||||
| :start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works, | :start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works, | ||||
| :open_student_works,:add_to_homework_bank,:publish_homework] | :open_student_works,:add_to_homework_bank,:publish_homework] | ||||
| before_filter :member_of_course, :only => [:index] | before_filter :member_of_course, :only => [:index] | ||||
| before_filter :only => [:index] do |controller| | |||||
| set_nav_status(NavStatues::COURSE) | |||||
| end | |||||
| def index | def index | ||||
| #unless params[:page] | #unless params[:page] | ||||
| @@ -32,6 +32,9 @@ class IssuesController < ApplicationController | |||||
| before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form] | before_filter :build_new_issue_from_params, :only => [:new, :create, :update_form] | ||||
| accept_rss_auth :index, :show | accept_rss_auth :index, :show | ||||
| accept_api_auth :index, :show, :create, :update, :destroy | accept_api_auth :index, :show, :create, :update, :destroy | ||||
| before_filter :only => [:index, :show, :new, :edit] do |controller| | |||||
| set_nav_status(NavStatues::PROJECT) | |||||
| end | |||||
| rescue_from Query::StatementInvalid, :with => :query_statement_invalid | rescue_from Query::StatementInvalid, :with => :query_statement_invalid | ||||
| @@ -6,7 +6,10 @@ class MemosController < ApplicationController | |||||
| before_filter :authenticate_user_edit, :only => [:edit, :update] | before_filter :authenticate_user_edit, :only => [:edit, :update] | ||||
| before_filter :authenticate_user_destroy, :only => [:destroy] | before_filter :authenticate_user_destroy, :only => [:destroy] | ||||
| before_filter :require_login, :only => [:new, :create] | before_filter :require_login, :only => [:new, :create] | ||||
| before_filter :only => [:new, :show, :edit] do | |||||
| set_nav_status(NavStatues::FORNUM) | |||||
| end | |||||
| helper :attachments | helper :attachments | ||||
| include AttachmentsHelper | include AttachmentsHelper | ||||
| include ApplicationHelper | include ApplicationHelper | ||||
| @@ -39,7 +42,7 @@ class MemosController < ApplicationController | |||||
| format.json { render json: @memo } | format.json { render json: @memo } | ||||
| end | end | ||||
| end | end | ||||
| def create | def create | ||||
| if params[:quote].nil? | if params[:quote].nil? | ||||
| @quote = "" | @quote = "" | ||||
| @@ -85,7 +88,7 @@ class MemosController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||
| REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE) | REPLIES_PER_PAGE = 20 unless const_defined?(:REPLIES_PER_PAGE) | ||||
| def show | def show | ||||
| # 更新贴吧帖子留言对应的memo_messages的viewed字段 | # 更新贴吧帖子留言对应的memo_messages的viewed字段 | ||||
| @@ -137,7 +140,7 @@ class MemosController < ApplicationController | |||||
| @my_topic_count = 0 | @my_topic_count = 0 | ||||
| @my_replies_count = Memo.where(:parent_id => @memo.id).count | @my_replies_count = Memo.where(:parent_id => @memo.id).count | ||||
| respond_to do |format| | respond_to do |format| | ||||
| format.js | format.js | ||||
| format.html {render :layout => 'base_new_forum'} | format.html {render :layout => 'base_new_forum'} | ||||
| @@ -140,6 +140,7 @@ class MyController < ApplicationController | |||||
| # Edit user's account | # Edit user's account | ||||
| def account | def account | ||||
| # 更新消息状态 | # 更新消息状态 | ||||
| if params[:flag] | if params[:flag] | ||||
| applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first | applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first | ||||
| @@ -153,7 +154,7 @@ class MyController < ApplicationController | |||||
| end | end | ||||
| @user = User.current | @user = User.current | ||||
| old_user_login = @user.login | |||||
| #是否是Oschina过来的 | #是否是Oschina过来的 | ||||
| @is_oauth = !!Oschina.find_by_user_id(@user.id) | @is_oauth = !!Oschina.find_by_user_id(@user.id) | ||||
| @@ -234,6 +235,28 @@ class MyController < ApplicationController | |||||
| set_language_if_valid @user.language | set_language_if_valid @user.language | ||||
| flash[:notice] = l(:notice_account_updated) | flash[:notice] = l(:notice_account_updated) | ||||
| redirect_to user_url(@user) | redirect_to user_url(@user) | ||||
| user_params = { | |||||
| mail: params[:user][:mail], | |||||
| login: params[:login], | |||||
| lastname: params[:lastname] | |||||
| } | |||||
| user_extension_params = { | |||||
| school_id: params[:occupation], | |||||
| gender: params[:sex], | |||||
| location: params[:province], | |||||
| location_city: params[:city], | |||||
| identity: params[:identity].to_i, | |||||
| technical_title: params[:technical_title], | |||||
| student_id: params[:no], | |||||
| description: params[:description] | |||||
| } | |||||
| sync_params = { | |||||
| old_user_login: old_user_login, | |||||
| user_params: user_params.reject { |k,v| v.blank? }, | |||||
| user_extension_params: user_extension_params.reject { |k,v| v.blank? } | |||||
| } | |||||
| # Delayed::Job.enqueue(SyncUserLoginJob.new.perform("remote_update",sync_params)) #同步更新 | |||||
| SyncUserLoginJob.new.perform("remote_update",sync_params) | |||||
| return | return | ||||
| else | else | ||||
| @user.login = lg | @user.login = lg | ||||
| @@ -282,8 +305,16 @@ class MyController < ApplicationController | |||||
| flash.now[:notice] = l(:notice_account_password_updated) | flash.now[:notice] = l(:notice_account_password_updated) | ||||
| # 修改完密码,让其重新登录,并更新Token | # 修改完密码,让其重新登录,并更新Token | ||||
| Token.delete_user_all_tokens(@user) | Token.delete_user_all_tokens(@user) | ||||
| sync_params = { | |||||
| login: @user.login, | |||||
| password: params[:new_password] | |||||
| } | |||||
| SyncUserLoginJob.new.perform("remote_password",sync_params) | |||||
| logout_user | logout_user | ||||
| redirect_to signin_url(back_url: my_account_path) | redirect_to signin_url(back_url: my_account_path) | ||||
| # Delayed::Job.enqueue(SyncUserLoginJob.new.perform("remote_password",sync_params)) #同步更新 | |||||
| return | return | ||||
| else | else | ||||
| #flash.now[:error] = l(:notice_account_wrong_password) | #flash.now[:error] = l(:notice_account_wrong_password) | ||||
| @@ -29,6 +29,9 @@ class NewsController < ApplicationController | |||||
| before_filter :find_optional_project, :only => :index | before_filter :find_optional_project, :only => :index | ||||
| accept_rss_auth :index | accept_rss_auth :index | ||||
| accept_api_auth :index | accept_api_auth :index | ||||
| before_filter :only => [:index] do |controller| | |||||
| set_nav_status(NavStatues::COURSE) | |||||
| end | |||||
| helper :watchers | helper :watchers | ||||
| helper :attachments | helper :attachments | ||||
| @@ -8,6 +8,7 @@ class PollController < ApplicationController | |||||
| include PollHelper | include PollHelper | ||||
| def index | def index | ||||
| if @course | if @course | ||||
| set_nav_status(NavStatues::COURSE) | |||||
| @is_teacher = User.current.allowed_to?(:as_teacher,@course) | @is_teacher = User.current.allowed_to?(:as_teacher,@course) | ||||
| if @is_teacher | if @is_teacher | ||||
| remove_invalid_poll(@course) | remove_invalid_poll(@course) | ||||
| @@ -113,18 +114,18 @@ class PollController < ApplicationController | |||||
| def statistics_result | def statistics_result | ||||
| @poll = Poll.find(params[:id]) | @poll = Poll.find(params[:id]) | ||||
| poll_questions = @poll.poll_questions | |||||
| poll_questions = @poll.poll_questions | |||||
| @poll_questions = paginateHelper poll_questions, 5 | @poll_questions = paginateHelper poll_questions, 5 | ||||
| @left_nav_type = 7 | @left_nav_type = 7 | ||||
| respond_to do |format| | respond_to do |format| | ||||
| format.html{render :layout => 'base_courses'} | format.html{render :layout => 'base_courses'} | ||||
| end | end | ||||
| end | end | ||||
| def get_poll_totalcount poll_question | def get_poll_totalcount poll_question | ||||
| @total_questions_count = poll_question.poll_votes.count | @total_questions_count = poll_question.poll_votes.count | ||||
| end | end | ||||
| def get_poll_everycount poll_answer | def get_poll_everycount poll_answer | ||||
| @every_answer_count = poll_answer.poll_votes.count | @every_answer_count = poll_answer.poll_votes.count | ||||
| end | end | ||||
| @@ -818,4 +819,4 @@ class PollController < ApplicationController | |||||
| book.write xls_report | book.write xls_report | ||||
| xls_report.string | xls_report.string | ||||
| end | end | ||||
| end | |||||
| end | |||||
| @@ -0,0 +1,141 @@ | |||||
| class PrivateMessagesController < ApplicationController | |||||
| before_filter :require_login | |||||
| before_filter :set_user | |||||
| before_filter :set_message, except: [:index] | |||||
| before_filter :set_type_and_count | |||||
| def index | |||||
| #用户更新私信为全部已读 | |||||
| if User.current == @user || User.current.admin? | |||||
| @onclick_time = User.current.onclick_time.onclick_time | |||||
| User.current.onclick_time.update_attribute(:onclick_time, Time.now) | |||||
| jours = PrivateMessage.find_by_sql("SELECT ui.* FROM (SELECT * FROM private_messages WHERE STATUS != 2 AND user_id = #{@user.id} ORDER BY id DESC) ui GROUP BY ui.target_id ORDER BY ui.send_time DESC") | |||||
| # jours = PrivateMessage.without_deleted.where("user_id = ?", @user.id).order("created_at desc") | |||||
| @limit = 20 | |||||
| @jours_count = jours.size | |||||
| @jours_all_pages = Paginator.new @jours_count, @limit, params['page'] || 1 | |||||
| @offset ||= @jours_all_pages.offset | |||||
| @jours_alls = paginateHelper jours, @limit | |||||
| @unred_all_messages = @user.count_new_message("all") | |||||
| @unred_private_messages = @user.unread_private_messages | |||||
| render :layout=>'base_user_message' | |||||
| else | |||||
| render_403 | |||||
| end | |||||
| end | |||||
| def new | |||||
| receiver_id = params[:receiver_id] | |||||
| if receiver_id.present? | |||||
| @receiver_user = User.find_by_login(receiver_id) | |||||
| end | |||||
| end | |||||
| def create | |||||
| ActiveRecord::Base.transaction do | |||||
| begin | |||||
| user_id = params[:private_message][:receiver_id] | |||||
| receiver_user = User.find_by_id(user_id) | |||||
| if receiver_user.present? | |||||
| content = params[:private_message][:content].strip.truncate(200) | |||||
| sender_params = { | |||||
| user_id: current_user.id, | |||||
| target_id: user_id, | |||||
| sender_id: current_user.id, | |||||
| receiver_id: user_id, | |||||
| content: content, | |||||
| status: 0, | |||||
| send_time: Time.now | |||||
| } | |||||
| receiver_params = { | |||||
| user_id: user_id, | |||||
| target_id: current_user.id, | |||||
| sender_id: current_user.id, | |||||
| receiver_id: user_id, | |||||
| content: content, | |||||
| status: 0, | |||||
| send_time: Time.now | |||||
| } | |||||
| @sender_message = PrivateMessage.new(sender_params) | |||||
| @receiver_message = PrivateMessage.new(receiver_params) | |||||
| @sender_message.save! | |||||
| @receiver_message.save! | |||||
| respond_to do |format| | |||||
| format.js | |||||
| format.html{ | |||||
| redirect_to private_messages_detail_user_private_messages_path(@user, target_ids: user_id) | |||||
| } | |||||
| end | |||||
| else | |||||
| redirect_to user_private_messages_path(current_user), notice: "用户不存在" | |||||
| end | |||||
| rescue Exception => e | |||||
| Rails.logger.info("#######___________####{e}") | |||||
| raise ActiveRecord::Rollback | |||||
| end | |||||
| end | |||||
| end | |||||
| def private_messages_detail | |||||
| if User.current == @user || User.current.admin? | |||||
| @unred_private_messages = @user.unread_private_messages | |||||
| @unred_all_messages = 0 | |||||
| @target_user = User.where(:id => params[:target_ids]).includes(:user_extensions).first | |||||
| if @target_user.present? | |||||
| target_user_messages = @user.private_messages.where(:target_id => params[:target_ids], :status => [0, 1]) | |||||
| @message_list = target_user_messages.order("send_time asc") | |||||
| target_user_messages.where(status: 0).update_all(status: 1) | |||||
| @onclick_time = User.current.onclick_time.onclick_time | |||||
| User.current.onclick_time.update_attribute(:onclick_time, Time.now) | |||||
| @all_users = params[:all_user] || "0" | |||||
| user_message_details = PrivateMessage.find_by_sql("SELECT ui.* FROM (SELECT * FROM private_messages WHERE STATUS != 2 AND user_id = #{@user.id} ORDER BY id DESC) ui GROUP BY ui.target_id ORDER BY ui.send_time DESC") | |||||
| user_message_details_count = user_message_details.size | |||||
| if user_message_details_count > 10 && @all_users == "0" | |||||
| user_message_details = user_message_details.first(10) | |||||
| end | |||||
| @user_message_details = user_message_details | |||||
| render :layout=>'base_user_message' | |||||
| else | |||||
| render_404 | |||||
| end | |||||
| else | |||||
| render_403 | |||||
| end | |||||
| end | |||||
| def destroy | |||||
| @message.update_attribute(:status, 2) | |||||
| end | |||||
| def get_recent_users | |||||
| @recent_users = User.where(:id => @user.private_messages.without_deleted.order("created_at desc").map(&:target_id)).includes(:user_extensions).limit(10) | |||||
| render "get_recent_users", layout: false | |||||
| end | |||||
| def message_search_users | |||||
| @search_users = User.where("id != #{@user.id} and LOWER(concat(lastname, firstname)) LIKE '%#{params[:receiver_name].strip.to_s.downcase}%'").includes(:user_extensions) | |||||
| # @search_users = User.where("LOWER(concat(lastname, ifnull(firstname, ''), login)) LIKE ?", "#{params[:receiver_name].strip.to_s.downcase}") | |||||
| render "message_search_users", layout: false | |||||
| end | |||||
| private | |||||
| def set_user | |||||
| @user = User.find_by_login(params[:user_id]) | |||||
| end | |||||
| def set_message | |||||
| @message = PrivateMessage.find_by_id(params[:id]) | |||||
| end | |||||
| def set_type_and_count | |||||
| @unred_all_messages = 0 | |||||
| @user_message_type = "2" | |||||
| end | |||||
| end | |||||
| @@ -36,6 +36,9 @@ class ProjectsController < ApplicationController | |||||
| before_filter :require_admin, :only => [ :copy, :unarchive, :calendar] | before_filter :require_admin, :only => [ :copy, :unarchive, :calendar] | ||||
| before_filter :require_admin_or_manager, :only => [ :destroy] | before_filter :require_admin_or_manager, :only => [ :destroy] | ||||
| before_filter :file | before_filter :file | ||||
| before_filter :only => [:new, :show, :settings] do |controller| | |||||
| set_nav_status(NavStatues::PROJECT) | |||||
| end | |||||
| # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 | # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 | ||||
| @@ -217,8 +220,7 @@ class ProjectsController < ApplicationController | |||||
| elsif params[:contest_id] | elsif params[:contest_id] | ||||
| @contest = Contest.find params[:contest_id] | @contest = Contest.find params[:contest_id] | ||||
| end | end | ||||
| render :layout => 'new_base' | |||||
| render :layout => 'base_projects_new' | |||||
| else | else | ||||
| redirect_to signin_url | redirect_to signin_url | ||||
| end | end | ||||
| @@ -22,6 +22,7 @@ class PullRequestsController < ApplicationController | |||||
| def index | def index | ||||
| # project_menu_type 为了控制base顶部导航 | # project_menu_type 为了控制base顶部导航 | ||||
| @project_menu_type = 6 | @project_menu_type = 6 | ||||
| set_nav_status(NavStatues::PROJECT) | |||||
| # 不符合pullrequest条件的给出提示 | # 不符合pullrequest条件的给出提示 | ||||
| @allow_to_pull_request = allow_pull_request(@project) > 0 | @allow_to_pull_request = allow_pull_request(@project) > 0 | ||||
| @@ -118,6 +119,9 @@ class PullRequestsController < ApplicationController | |||||
| if !params[:target_project_id].blank? && params[:target_project_id].to_i != @project.id | if !params[:target_project_id].blank? && params[:target_project_id].to_i != @project.id | ||||
| target_project_id = params[:forked_project_id].to_i | target_project_id = params[:forked_project_id].to_i | ||||
| request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id) | request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id) | ||||
| unless request&.id | |||||
| @message = "#{target_branch} 和 #{source_branch}分支的pull request已存在且未处理,等待处理后再创建!" and return | |||||
| end | |||||
| @fork_project_name = Project.find(params[:target_project_id]).try(:name) | @fork_project_name = Project.find(params[:target_project_id]).try(:name) | ||||
| @fork_pr_message = true if @fork_project_name | @fork_pr_message = true if @fork_project_name | ||||
| # 向管理员发送消息 | # 向管理员发送消息 | ||||
| @@ -291,7 +295,7 @@ class PullRequestsController < ApplicationController | |||||
| rescue Gitlab::Error::NotFound => e | rescue Gitlab::Error::NotFound => e | ||||
| @message = l(:label_pull_request_notfound) | @message = l(:label_pull_request_notfound) | ||||
| rescue Exception => e | rescue Exception => e | ||||
| puts e | |||||
| logger.info e | |||||
| end | end | ||||
| end | end | ||||
| @@ -400,6 +400,8 @@ update | |||||
| s = Trustie::Gitlab::Sync.new | s = Trustie::Gitlab::Sync.new | ||||
| s.create_project(@project, @repository) | s.create_project(@project, @repository) | ||||
| raise "sync failed" if @project.gpid.blank? | raise "sync failed" if @project.gpid.blank? | ||||
| @project.sync_gitignore_file | |||||
| @project.sync_license_file | |||||
| redirect_to(:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)) | redirect_to(:controller => 'repositories', :action => 'show', :id => @project, :repository_id => gitlab_repository(@project).try(:identifier)) | ||||
| else | else | ||||
| redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) | redirect_to settings_project_url(@project, :tab => 'repositories',:repository_error_message=>@repository.errors.full_messages) | ||||
| @@ -526,6 +528,7 @@ update | |||||
| def show | def show | ||||
| # 顶部导航 | # 顶部导航 | ||||
| @project_menu_type = 5 | @project_menu_type = 5 | ||||
| set_nav_status(NavStatues::PROJECT) | |||||
| # TODO: the below will move to filter, done. | # TODO: the below will move to filter, done. | ||||
| # 获取版本库目录结构 | # 获取版本库目录结构 | ||||
| @@ -0,0 +1,117 @@ | |||||
| class StatisticWorksController < ApplicationController | |||||
| # before_filter :is_logged | |||||
| # before_filter :teacher_of_course | |||||
| before_filter :find_course | |||||
| before_filter :find_homework, only: :student_work_details | |||||
| def index | |||||
| page = params[:page] || 1 | |||||
| limit = params[:limit] || 30 | |||||
| homework_ids = @course.homework_commons.select(:id).pluck(:id) | |||||
| student_works = StudentWork.joins(:homework_common).where(homework_common_id: homework_ids,work_status: [1,2], is_delete: 0).page(page).per(limit) | |||||
| works_and_commited_users = student_works.group(:homework_common_id, :anonymous_comment,"homework_commons.name").reorder("student_works.id desc").size | |||||
| work_and_commited = [] | |||||
| if works_and_commited_users.present? | |||||
| works_and_commited_users.each do |k,v| | |||||
| work_and_commited.push( | |||||
| { | |||||
| homework_id: k[0], | |||||
| homework_name: k[2], | |||||
| anonymous_comment: k[1], #是否开启匿评分,0表示关闭,1表示开启 | |||||
| commited_students_count: v | |||||
| } | |||||
| ) | |||||
| end | |||||
| end | |||||
| course_infos = { | |||||
| status: 1, | |||||
| main_tearcher: @course&.teacher&.show_name, | |||||
| syllabus_name: @course&.syllabus&.title, | |||||
| course_name: @course.try(:name), | |||||
| teachers_count: teachers_number, | |||||
| students_count: student_number, | |||||
| homeworks_count: homework_ids.size, #作业数 | |||||
| work_and_commited: work_and_commited | |||||
| } | |||||
| respond_to do |formart| | |||||
| formart.json {render json: course_infos} | |||||
| end | |||||
| end | |||||
| def student_work_details | |||||
| page = params[:page] || 1 | |||||
| limit = params[:limit] || 30 | |||||
| student_works = @homework.student_works.includes(user: :user_extensions).page(page).per(limit) | |||||
| student_works_json = [] | |||||
| if student_works.present? | |||||
| student_works.each do |work| | |||||
| user = work.user | |||||
| work_json = { | |||||
| name: user.try(:show_name), | |||||
| student_id: user&.user_extensions.try(:student_id), | |||||
| description: work.description, | |||||
| work_status: work.work_status, | |||||
| final_score: work.final_score, | |||||
| teacher_score: work.teacher_score, | |||||
| student_score: work.student_score, | |||||
| teaching_asistant_score: work.teaching_asistant_score, | |||||
| system_score: work.system_score, #学生评分 | |||||
| commit_time: work&.commit_time&.strftime("%Y-%m-%d %H:%M:%S"), #提交时间 | |||||
| } | |||||
| student_works_json.push(work_json) | |||||
| end | |||||
| end | |||||
| respond_to do |formart| | |||||
| formart.json {render json: student_works_json} | |||||
| end | |||||
| end | |||||
| private | |||||
| def find_course | |||||
| @course = Course.find params[:course_id] | |||||
| unless @course.present? | |||||
| respond_to do |formart| | |||||
| formart.json {render json: {status: -1, message: "课程不存在"}} | |||||
| end | |||||
| end | |||||
| end | |||||
| def find_homework | |||||
| @homework = HomeworkCommon.find params[:id] | |||||
| unless @homework.present? | |||||
| respond_to do |formart| | |||||
| formart.json {render json: {status: -1, message: "作业不存在"}} | |||||
| end | |||||
| end | |||||
| end | |||||
| # def teacher_of_course | |||||
| # unless User.current.allowed_to?(:as_teacher,@course) || User.current.admin? | |||||
| # respond_to do |formart| | |||||
| # formart.json {render json: {status: -1, message: "没有权限"} } | |||||
| # end | |||||
| # end | |||||
| # end | |||||
| def teachers_number | |||||
| Member.joins(:member_roles).where("members.course_id = ? && member_roles.role_id in ('3','7','9')", @course.id)&.size | |||||
| end | |||||
| def student_number | |||||
| @course&.student&.size | |||||
| end | |||||
| # def is_logged | |||||
| # unless User.current.logged? | |||||
| # respond_to do |formart| | |||||
| # formart.json {render json: {status: -1, message: "请先登录"} } | |||||
| # end | |||||
| # end | |||||
| # end | |||||
| end | |||||
| @@ -10,6 +10,10 @@ class StatisticsController < ApplicationController | |||||
| before_filter :require_login | before_filter :require_login | ||||
| before_filter :find_statistic, :only => [:show, :edit, :update, :destroy] | before_filter :find_statistic, :only => [:show, :edit, :update, :destroy] | ||||
| before_filter :require_manager, :only =>[:edit, :update, :destroy] | before_filter :require_manager, :only =>[:edit, :update, :destroy] | ||||
| before_filter :only => [:index, :new, :show, :edit] do | |||||
| set_nav_status(NavStatues::STATISTIC) | |||||
| end | |||||
| if RUBY_PLATFORM =~ /linux/ | if RUBY_PLATFORM =~ /linux/ | ||||
| require 'simple_xlsx_reader' | require 'simple_xlsx_reader' | ||||
| end | end | ||||
| @@ -181,7 +185,7 @@ class StatisticsController < ApplicationController | |||||
| if @statistic.file_size.nil? && @statistic.attachments.count > 0 | if @statistic.file_size.nil? && @statistic.attachments.count > 0 | ||||
| @statistic.update_attribute('file_size', format("%0.3f", @statistic.attachments.map{|c| c.filesize}.sum.to_f/(1024*1024))) | @statistic.update_attribute('file_size', format("%0.3f", @statistic.attachments.map{|c| c.filesize}.sum.to_f/(1024*1024))) | ||||
| end | end | ||||
| format.html { redirect_to @statistic, notice: '更新成功' } | format.html { redirect_to @statistic, notice: '更新成功' } | ||||
| format.json { head :no_content } | format.json { head :no_content } | ||||
| else | else | ||||
| @@ -53,7 +53,6 @@ class StudentWorkController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| end | end | ||||
| render :json => resultObj | render :json => resultObj | ||||
| end | end | ||||
| @@ -542,6 +541,15 @@ class StudentWorkController < ApplicationController | |||||
| @student_work_count = (search_homework_member @homework.student_works.has_committed.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name).count | @student_work_count = (search_homework_member @homework.student_works.has_committed.select("student_works.*,student_works.work_score as score").order("#{@order} #{@b_sort}"),@name).count | ||||
| end | end | ||||
| @is_group_project_homework = @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 | |||||
| @all_group_projects = [] | |||||
| if @is_group_project_homework | |||||
| project_ids = @homework.student_works.has_committed.joins(:student_work_projects).where("student_works.id = student_work_projects.student_work_id").pluck("student_work_projects.project_id").uniq | |||||
| @all_group_projects = GetForgeProjectService.new.call(project_ids) | |||||
| end | |||||
| @score = @b_sort == "desc" ? "asc" : "desc" | @score = @b_sort == "desc" ? "asc" : "desc" | ||||
| @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0 | @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0 | ||||
| # 消息传过来的ID | # 消息传过来的ID | ||||
| @@ -1426,15 +1434,40 @@ class StudentWorkController < ApplicationController | |||||
| #查找学生创建的项目列表 | #查找学生创建的项目列表 | ||||
| def search_user_projects | def search_user_projects | ||||
| condition = '%%' | |||||
| if !params[:name].nil? | |||||
| condition = "%#{params[:name].strip}%".gsub(" ","") | |||||
| end | |||||
| @project_ids = Project.visible.where("user_id = #{User.current.id} and name like '#{condition}'") | |||||
| Rails.logger.info("=============#######{request.subdomain}") | |||||
| project_url = "#{Redmine::Configuration['sync_forge_url']}" | |||||
| if request.subdomain.blank? || request.subdomain === '127.0.0.1' | |||||
| project_url = "http://127.0.0.1:3002" | |||||
| elsif request.subdomain == "ucloudtest" | |||||
| project_url = "https://testforgeplus.trustie.net" | |||||
| end | |||||
| url = "#{project_url}/api/users/trustie_projects.json" #trustie上的相关路由 | |||||
| sync_params = { | |||||
| login: current_user.try(:login), | |||||
| search: params[:name] || "" | |||||
| } | |||||
| uri = URI.parse(url) | |||||
| http = Net::HTTP.new(uri.hostname, uri.port) | |||||
| http.use_ssl = project_url.include?("forgeplus.trustie.net") | |||||
| response = http.send_request('GET', uri.path, sync_params.to_json, {'Content-Type' => 'application/json'}) | |||||
| @project_ids = [] | |||||
| if response.code == "200" | |||||
| @project_ids = eval(response.body)[:projects] | |||||
| end | |||||
| # condition = '%%' | |||||
| # if !params[:name].nil? | |||||
| # condition = "%#{params[:name].strip}%".gsub(" ","") | |||||
| # end | |||||
| # @project_ids = Project.visible.where("user_id = #{User.current.id} and name like '#{condition}'") | |||||
| @first = params[:first].to_i | @first = params[:first].to_i | ||||
| respond_to do |format| | respond_to do |format| | ||||
| format.js | format.js | ||||
| end | end | ||||
| end | end | ||||
| # 作品更换关联项目 | # 作品更换关联项目 | ||||
| @@ -0,0 +1,184 @@ | |||||
| class SyncForgesController < ApplicationController | |||||
| # before_filter :check_token | |||||
| # before_filter :check_ids | |||||
| def index | |||||
| Rails.logger.info("###############____begin__#{params[:type]}_____########{params[:parent_id].present? ? params[:parent_id] : params[:new_project_id]}") | |||||
| model_name = params[:type].to_s.constantize | |||||
| targets = model_name.where(id: params[:ids]) | |||||
| targets_params = [] | |||||
| case params[:type].to_s | |||||
| when "Project" | |||||
| targets = targets.includes(:versions,:repository,:project_score, :owner, issues: [journals: :details], members: [:user, :member_roles]) | |||||
| targets_params = get_projects(targets, params) if targets.present? | |||||
| when "Issue" | |||||
| targets = targets.includes(:author, journals: :details) | |||||
| targets_params = get_issue_issues(targets, params[:parent_id]) if targets.present? | |||||
| when "Journal" | |||||
| targets = targets.includes(:user, :details) | |||||
| targets_params = get_journal_issues(targets) if targets.present? | |||||
| when "Member" | |||||
| targets = targets.includes(:member_roles) | |||||
| targets_params = get_member_targets(targets, params[:parent_id]) if targets.present? | |||||
| else | |||||
| targets = targets.includes(:user) | |||||
| targets_params = get_common_targets(targets, params[:parent_id],params[:type].to_s) if targets.present? | |||||
| end | |||||
| Rails.logger.info("###############___completed___#{params[:type]}####{params[:parent_id].present? ? params[:parent_id] : params[:new_project_id]}") | |||||
| respond_to do | format| | |||||
| format.json { | |||||
| render json: { targets_params: targets_params } | |||||
| } | |||||
| end | |||||
| end | |||||
| private | |||||
| # def check_token | |||||
| # unless params[:token] && params[:token] == "#{Redmine::Configuration['sync_token']}" | |||||
| # respond_to do |format| | |||||
| # format.json { | |||||
| # render json: { message: "token错误" } | |||||
| # } | |||||
| # end | |||||
| # end | |||||
| # end | |||||
| def get_projects(targets, params) | |||||
| new_project_id = params[:new_project_id] | |||||
| target_params = [] | |||||
| project = targets.first | |||||
| project_json = project.as_json(:except=>[:user_id, :id, :created_on, :updated_on, :name, :is_public, :identifier]).values[0].delete_if {|k,v| v.blank?} | |||||
| issues = project.issues | |||||
| members = project.members.where("user_id != ?", project.user_id) | |||||
| versions = project.versions | |||||
| watchers = project.watchers | |||||
| praises = project.praise_tread | |||||
| user_login = project.owner.try(:login) | |||||
| issues_params = get_issue_issues(issues, new_project_id) if issues.present? | |||||
| member_params = get_member_targets(members, new_project_id) if members.present? | |||||
| versions_params = get_common_targets(versions, new_project_id, "Version") if versions.present? | |||||
| watcher_params = get_common_targets(watchers, new_project_id, "Watcher") if watchers.present? | |||||
| praise_treads = get_common_targets(praises, new_project_id, "PraiseTread") if praises.present? | |||||
| target_params.push({ | |||||
| target_params: project_json, | |||||
| issues_params: issues_params || nil, | |||||
| member_params: member_params || nil, | |||||
| versions_params: versions_params || nil, | |||||
| watcher_params: watcher_params || nil, | |||||
| praise_treads: praise_treads || nil, | |||||
| user_login: user_login | |||||
| }.delete_if {|k,v| v.blank?}) | |||||
| return target_params | |||||
| end | |||||
| def get_issue_issues(targets, new_project_id) | |||||
| target_params = [] | |||||
| targets.find_each do |re| | |||||
| user_logins = User.select([:id, :login]).where(id: [re.author_id, re.assigned_to_id]).pluck(:login) | |||||
| author_login = user_logins[0] | |||||
| assign_login = user_logins[1] | |||||
| re_json = re.as_json(:except=>[:author_id, :id, :assigned_to_id, :lock_version]).values[0].delete_if {|k,v| v.blank?} | |||||
| re_version = re.fixed_version.present? ? re.fixed_version&.name : nil | |||||
| re_json.merge!({ | |||||
| issue_type: "Issue", | |||||
| }) | |||||
| if new_project_id.present? | |||||
| re_json.merge!(project_id: new_project_id) | |||||
| end | |||||
| # if re_version.present? | |||||
| # re_json.merge!(re_version: re_version) | |||||
| # end | |||||
| journal_details = re.journals | |||||
| journal_details_params = get_journal_issues(journal_details) if journal_details.present? | |||||
| target_params.push({ | |||||
| target_params: re_json, | |||||
| journals: journal_details_params || nil, | |||||
| user_login: author_login, | |||||
| assign_login: assign_login, | |||||
| re_version: re_version | |||||
| }.delete_if {|k,v| v.blank?}) | |||||
| end | |||||
| return target_params | |||||
| end | |||||
| def get_journal_issues(targets) | |||||
| target_params = [] | |||||
| targets.find_each do |re| | |||||
| re_json = re.as_json(:except=>[:user_id, :id]).values[0].delete_if {|k,v| v.blank?} | |||||
| re_detail_json = re.details.as_json(:except => [:id, :journal_id]).map{|k| k["journal_detail"].delete_if {|k,v| v.blank?}} if re.details.present? | |||||
| user_login = re.user.try(:login) | |||||
| new_re_json = { | |||||
| target_params: re_json, | |||||
| journal_details: re_detail_json || nil, | |||||
| user_login: user_login | |||||
| } | |||||
| target_params.push(new_re_json.delete_if {|k,v| v.blank?}) | |||||
| end | |||||
| return target_params | |||||
| end | |||||
| def get_member_targets(targets,new_project_id) | |||||
| target_params = [] | |||||
| targets.find_each do |re| | |||||
| re_json = re.as_json(:except=>[:user_id, :id]).values[0].delete_if {|k,v| v.blank?} | |||||
| if new_project_id.present? | |||||
| re_json.merge!(project_id: new_project_id) | |||||
| end | |||||
| user_login = re.user.try(:login) | |||||
| member_roles_json = re.member_roles.as_json(:except => [:id, :member_id]).map{|k| k["member_role"].delete_if {|k,v| v.blank?}} if re.member_roles.present? | |||||
| new_re_json = { | |||||
| target_params: re_json, | |||||
| member_roles: member_roles_json || nil, | |||||
| user_login: user_login | |||||
| } | |||||
| target_params.push(new_re_json.delete_if {|k,v| v.blank?}) | |||||
| end | |||||
| return target_params | |||||
| end | |||||
| def get_common_targets(targets, new_project_id, type) | |||||
| target_params = [] | |||||
| targets.find_each do |re| | |||||
| re_json = re.as_json(:except=>[:user_id]).values[0].delete_if {|k,v| v.blank?} | |||||
| if new_project_id.present? | |||||
| case type | |||||
| when "Watcher" | |||||
| re_json.merge!(watchable_id: new_project_id) | |||||
| when "PraiseTread" | |||||
| re_json.merge!(praise_tread_object_id: new_project_id) | |||||
| else | |||||
| re_json.merge!(project_id: new_project_id) | |||||
| end | |||||
| end | |||||
| user_login = re.user.try(:login) | |||||
| new_re_json = { | |||||
| target_params: re_json, | |||||
| user_login: user_login | |||||
| } | |||||
| target_params.push(new_re_json.delete_if {|k,v| v.blank?}) | |||||
| end | |||||
| return target_params | |||||
| end | |||||
| # def check_ids | |||||
| # unless params[:ids].present? | |||||
| # respond_to do |format| | |||||
| # format.json { | |||||
| # render json: { message: "缺少ID参数" } | |||||
| # } | |||||
| # end | |||||
| # end | |||||
| # end | |||||
| end | |||||
| @@ -17,7 +17,6 @@ | |||||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| class UsersController < ApplicationController | class UsersController < ApplicationController | ||||
| layout :setting_layout | layout :setting_layout | ||||
| #Added by young | #Added by young | ||||
| before_filter :auth_login1, :only => [:show, :user_activities, :user_newfeedback] | before_filter :auth_login1, :only => [:show, :user_activities, :user_newfeedback] | ||||
| @@ -41,8 +40,8 @@ class UsersController < ApplicationController | |||||
| :unapproval_applied_list, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, | :unapproval_applied_list, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, | ||||
| :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist, :user_manage_issues, :user_receive_issues, | :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,:user_contestlist, :user_manage_issues, :user_receive_issues, | ||||
| :user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, | :user_courses4show,:user_projects4show,:user_contests4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction, | ||||
| :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list, | |||||
| :sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :project_community, :contest_community] | |||||
| :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list, :project_community, | |||||
| :sort_project_list,:my_homeworks,:manage_or_receive_homeworks,:search_m_r_homeworks, :cancel_or_collect,:expand_courses,:homepage, :user_issues, :course_community, :projects_list, :contest_community, :undo_items] | |||||
| before_filter :auth_user_extension, only: :show | before_filter :auth_user_extension, only: :show | ||||
| before_filter :show_system_message, :only => [:show] | before_filter :show_system_message, :only => [:show] | ||||
| #before_filter :rest_user_score, only: :show | #before_filter :rest_user_score, only: :show | ||||
| @@ -57,6 +56,18 @@ class UsersController < ApplicationController | |||||
| #visitor | #visitor | ||||
| before_filter :recorded_visitor, :only => [:show,:user_fanslist,:user_watchlist,:user_visitorlist] | before_filter :recorded_visitor, :only => [:show,:user_fanslist,:user_watchlist,:user_visitorlist] | ||||
| before_filter :only => [:user_contestlist, :contest_community] do | |||||
| set_nav_status(NavStatues::COMPETION) | |||||
| end | |||||
| before_filter :only => [:projects_list, :new, :user_receive_issues, :user_manage_issues] do | |||||
| set_nav_status(NavStatues::PROJECT) | |||||
| end | |||||
| before_filter :only => [:course_community] do | |||||
| set_nav_status(NavStatues::COURSE) | |||||
| end | |||||
| helper :sort | helper :sort | ||||
| helper :attachments | helper :attachments | ||||
| include SortHelper | include SortHelper | ||||
| @@ -477,19 +488,28 @@ class UsersController < ApplicationController | |||||
| messages.each do |message_all| | messages.each do |message_all| | ||||
| # 未读的消息存放在数组 | # 未读的消息存放在数组 | ||||
| mess = message_all.message | mess = message_all.message | ||||
| if (message_all.message_type != "SystemMessage" && !mess.nil? && (mess.viewed == 0 || !mess.viewed)) || (message_all.message_type == "SystemMessage"&& !mess.nil? && mess.created_at > onclick_time) | |||||
| unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) | |||||
| if (message_all.message_type != "SystemMessage" && !mess.nil? && (mess.viewed == 0 || !mess.viewed) && mess.created_at > onclick_time) || (message_all.message_type == "SystemMessage"&& !mess.nil? && mess.created_at > onclick_time) | |||||
| unless (message_all.message_type == 'CourseMessage') && mess && mess.course && (mess.course.is_delete == 1) | |||||
| @message_alls << mess | @message_alls << mess | ||||
| end | end | ||||
| break if @message_alls.length == 10 | break if @message_alls.length == 10 | ||||
| end | end | ||||
| end | end | ||||
| #未读私信 | |||||
| unred_private_messages = User.current.private_messages.where(status: 0) | |||||
| unred_private_messages.each do |message| | |||||
| @message_alls << message | |||||
| break if @message_alls.length == 10 | |||||
| end | |||||
| end | end | ||||
| # 用户消息 | # 用户消息 | ||||
| # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复,exercise:课程测验 | # 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复,exercise:课程测验 | ||||
| # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) | # issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment) | ||||
| def user_messages | def user_messages | ||||
| @user_message_type = "1" | |||||
| @msg_type = params[:type] || "all" | |||||
| if !User.current.logged? | if !User.current.logged? | ||||
| redirect_to signin_url | redirect_to signin_url | ||||
| return | return | ||||
| @@ -497,71 +517,40 @@ class UsersController < ApplicationController | |||||
| return render_403 | return render_403 | ||||
| end | end | ||||
| # 初始化/更新 点击按钮时间, 24小时内显示系统消息 | # 初始化/更新 点击按钮时间, 24小时内显示系统消息 | ||||
| update_onclick_time | |||||
| user_all_messages = @user.get_user_messages | |||||
| # 全部设为已读 | # 全部设为已读 | ||||
| # if params[:viewed] == "all" | |||||
| # update_message_viewed(@user) | |||||
| # end | |||||
| # @new_message_count = forge_querys.count + forum_querys.count + course_querys.count + user_querys.count | |||||
| courses = @user.courses.where("is_delete = 1") | |||||
| course_ids = courses.empty? ? "(-1)" : "(" + courses.map{|course| course.id}.join(",") + ")" | |||||
| case params[:type] | |||||
| when nil | |||||
| # 系统消息为管理员发送,我的消息中包含有系统消息 | |||||
| @message_alls = [] | |||||
| messages = MessageAll.where(:user_id => @user.id).includes(:message).order("created_at desc") | |||||
| messages.each do |message_all| | |||||
| mess = message_all.message | |||||
| unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) | |||||
| @message_alls << mess | |||||
| end | |||||
| end | |||||
| when 'unviewed' | |||||
| @message_alls = [] | |||||
| messages = MessageAll.where("message_alls.user_id =?", @user.id).includes(:message).order("created_at desc") | |||||
| messages.each do |message_all| | |||||
| # 在点击或者刷新消息列表后未读的消息存放在数组 | |||||
| mess = message_all.message | |||||
| if message_all.message_type != "SystemMessage"&& !mess.nil? && (mess.viewed == 0 || !mess.viewed) | |||||
| unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1) | |||||
| @message_alls << mess | |||||
| end | |||||
| end | |||||
| end | |||||
| #课程相关消息 | |||||
| when 'homework' | |||||
| @message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage','StudentWork','Exercise') and user_id =? and course_id NOT IN #{course_ids}", @user.id).order("created_at desc") | |||||
| when 'course_message' | |||||
| @message_alls = CourseMessage.where("course_message_type =? and user_id =? and course_id NOT IN #{course_ids}", "Message", @user.id).order("created_at desc") | |||||
| when 'course_news' | |||||
| # 课程通知包含发布的通知和回复的通知 | |||||
| @message_alls = CourseMessage.where("course_message_type in ('News', 'Comment') and user_id =? and course_id NOT IN #{course_ids}", @user.id).order("created_at desc") | |||||
| when 'poll' | |||||
| @message_alls = CourseMessage.where("course_message_type =? and user_id =? and course_id NOT IN #{course_ids}", "Poll", @user.id).order("created_at desc") | |||||
| #项目相关消息 | |||||
| when 'issue' | |||||
| @message_alls = ForgeMessage.where("forge_message_type in ('Issue', 'Journal') and user_id =?" , @user.id).order("created_at desc") | |||||
| when 'forge_message' | |||||
| @message_alls = ForgeMessage.where("forge_message_type =? and user_id =?", "Message", @user.id).order("created_at desc") | |||||
| when 'forge_news' | |||||
| @message_alls = ForgeMessage.where("forge_message_type in (?,?) and user_id =?", "News", "Comment", @user.id).order("created_at desc") | |||||
| when 'apply' | |||||
| @message_alls = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'AppliedProject', 'JoinProject', 'RemoveFromProject') and user_id =?", @user.id).order("created_at desc") | |||||
| #贴吧消息 | |||||
| when 'forum' | |||||
| @message_alls = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user.id).order("created_at desc") | |||||
| #用户留言 | |||||
| when 'user_feedback' | |||||
| @message_alls = UserFeedbackMessage.where("journals_for_message_type =? and user_id =?", "JournalsForMessage", @user.id).order("created_at desc") | |||||
| case @msg_type | |||||
| when "all" | |||||
| @message_alls = user_all_messages | |||||
| when "course" | |||||
| @message_alls = user_all_messages.where(message_type: "CourseMessage").order("created_at desc") | |||||
| when "project" | |||||
| @message_alls = user_all_messages.where(message_type: "ForgeMessage").order("created_at desc") | |||||
| when "at" | |||||
| @message_alls = user_all_messages.where(message_type: %w(UserFeedbackMessage MemoMessage AtMessage BlogMessage)).order("created_at desc") | |||||
| when "apply" | |||||
| @message_alls = user_all_messages.where(message_type: "AppliedMessage").order("created_at desc") | |||||
| else | else | ||||
| render_404 | |||||
| return | |||||
| @message_alls = user_all_messages.where(message_type: %w(SystemMessage ContestMessage OrgMessage)).order("created_at desc") | |||||
| end | end | ||||
| # @unred_all_messages = 0 | |||||
| #点击进入tab后,全部更新为已读,全部页面除外 | |||||
| # @message_alls = message_alls | |||||
| @message_alls = paginateHelper @message_alls, 25 | |||||
| @limit = 20 | |||||
| @message_count = @message_alls.size | |||||
| @message_all_pages = Paginator.new @message_count, @limit, params['page'] || 1 | |||||
| @offset ||= @message_all_pages.offset | |||||
| @message_alls = paginateHelper @message_alls, @limit | |||||
| # @message_alls = message_alls.order("created_at desc") | |||||
| @unred_all_messages = @user.count_new_message(@msg_type) | |||||
| # @unred_private_messages = 0 | |||||
| @unred_private_messages = @user.unread_private_messages | |||||
| respond_to do |format| | respond_to do |format| | ||||
| format.js | format.js | ||||
| format.html{render :layout=>'new_base_user'} | |||||
| format.html{render layout: "base_user_message"} | |||||
| end | end | ||||
| end | end | ||||
| @@ -1671,41 +1660,6 @@ class UsersController < ApplicationController | |||||
| render :layout=>'base_users_new' | render :layout=>'base_users_new' | ||||
| end | end | ||||
| # modified by fq | |||||
| def user_newfeedback | |||||
| unless User.current.logged? | |||||
| redirect_to signin_url | |||||
| return | |||||
| end | |||||
| # 自己访问自己的页面才更新消息状态 | |||||
| UserFeedbackMessage.where("user_id =? and viewed =? and journals_for_message_type =? ", User.current.id, 0, "JournalsForMessage").update_all(:viewed => true) | |||||
| # end | |||||
| @page = params[:page] ? params[:page].to_i + 1 : 0 | |||||
| if params[:type].present? | |||||
| case params[:type] | |||||
| when "public" | |||||
| jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 0').order('updated_on DESC') | |||||
| when "private" | |||||
| jours = @user.journals_for_messages.where('m_parent_id IS NULL and private = 1').order('updated_on DESC') | |||||
| else | |||||
| jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('updated_on DESC') | |||||
| end | |||||
| else | |||||
| jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('updated_on DESC') | |||||
| end | |||||
| @jour_count = jours.count | |||||
| @jour = jours.limit(10).offset(@page * 10) | |||||
| @type = params[:type] | |||||
| # if User.current == @user | |||||
| # @jour.update_all(:is_readed => true, :status => false) | |||||
| # @jour.each do |journal| | |||||
| # # fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) | |||||
| # journal.delay.set_children_readed_delay | |||||
| # end | |||||
| # end | |||||
| @state = false | |||||
| render :layout=>'new_base_user' | |||||
| end | |||||
| #给某人留言 | #给某人留言 | ||||
| def feedBackTo | def feedBackTo | ||||
| @@ -2092,143 +2046,29 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| def show | def show | ||||
| if User.current == @user | |||||
| # 点击小铃铛,更新点击时间 | |||||
| update_onclick_time if params[:click_user_message] == 'true' | |||||
| # 全部设为已读 | |||||
| # 自己的主页显示消息 | |||||
| messages_all = MessageAll.where(:user_id => @user.id) | |||||
| set_nav_status(NavStatues::HOME) | |||||
| # @user_projects = @user.projects.order("updated_on desc") | |||||
| @limit = 20 | |||||
| if is_current_user | |||||
| messages_all = @user.project_relate_messages | |||||
| @message_count = messages_all.count | @message_count = messages_all.count | ||||
| # REDO:已删除的内容应该在页面中显示不点击 | # REDO:已删除的内容应该在页面中显示不点击 | ||||
| @message_all_pages = Paginator.new @message_count, per_page_option, params['page'] | |||||
| @message_alls = messages_all.includes(:message). | |||||
| limit(@message_all_pages.per_page). | |||||
| offset(@message_all_pages.offset). | |||||
| reorder("#{MessageAll.table_name}.created_at desc") | |||||
| @unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).count | |||||
| my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course). | |||||
| where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" | |||||
| # 用户待完成的作业 | |||||
| homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}'") | |||||
| homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" | |||||
| student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0") | |||||
| @unfinished_homework_count = homeworks.count - student_works.count | |||||
| # 用户待完成的测验 | |||||
| exercises = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2") | |||||
| exercise_users = ExerciseUser.where(:user_id => @user.id, :exercise_id => exercises.map{|ex| ex.id}) | |||||
| @unfinished_test_count = exercises.count - exercise_users.count | |||||
| # 用户待完成的问卷 | |||||
| polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2") | |||||
| poll_users = PollUser.where(:user_id => @user.id, :poll_id => polls.map{|poll| poll.id}) | |||||
| @unfinished_poll_count = polls.count - poll_users.count | |||||
| # 用户待匿评的作品 | |||||
| homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status = 2") | |||||
| student_work_scores = @user.student_works_scores.where("reviewer_role = 3") | |||||
| anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")" | |||||
| unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}") | |||||
| @anonymous_evaluation_count = StudentWork.where(:id => unfinished_evaluations.map{|ev| ev.student_work_id}, :homework_common_id => homeworks.map{|hw| hw.id}).count | |||||
| # 待评阅的作业 暂不做 | |||||
| # @unreview_homework = 1 | |||||
| # 待审批的申请 | |||||
| #applied_message_count = AppliedMessage.where(:applied_type => ["Organization", "AppliedContest", "StudentWorksScoresAppeal", "AppliedProject", "ApplyAddSchools"], :user_id => User.current.id, :status => 0).count | |||||
| #applied_course_message_count = CourseMessage.where(:user_id => User.current.id, :course_message_type => "JoinCourseRequest", :status => 0).count | |||||
| # applied_pull_request_message_count = ForgeMessage.where(:user_id => User.current.id, :forge_message_type => "PullRequest", :status => [1,3]).count | |||||
| # @applied_message_alls_count = applied_message_count + applied_course_message_count + applied_pull_request_message_count | |||||
| user_id = User.current.id | |||||
| sql = "SELECT * FROM `message_alls` ma left join `forge_messages` fm on ma.message_id=fm.id | |||||
| left join `course_messages` cm on ma.message_id=cm.id left join `applied_messages` apm on ma.message_id=apm.id | |||||
| where (ma.user_id =#{user_id} and ma.message_type = 'ForgeMessage' and fm.forge_message_type='PullRequest' and fm.status=0 and fm.user_id=#{user_id} ) or | |||||
| (ma.user_id=#{user_id} and ma.message_type='AppliedMessage' and apm.applied_type in ('Organization', 'AppliedContest', 'StudentWorksScoresAppeal', 'AppliedProject', 'ApplyAddSchools') and apm.user_id =#{user_id} and apm.status =0 ) or | |||||
| (ma.user_id=#{user_id} and ma.message_type='CourseMessage' and cm.course_message_type='JoinCourseRequest' and cm.status=0 and cm.user_id=#{user_id} );" | |||||
| message_alls = MessageAll.find_by_sql(sql) | |||||
| @applied_message_alls_count = message_alls.count | |||||
| @message_all_pages = Paginator.new @message_count, @limit, params['page'] || 1 | |||||
| @offset ||= @message_all_pages.offset | |||||
| @message_alls = messages_all | |||||
| @message_alls = paginateHelper @message_alls, @limit | |||||
| else | else | ||||
| # 看别人的主页显示动态 | |||||
| #更新用户申请成为课程老师或教辅消息的状态 | |||||
| if params[:course_id] != nil | |||||
| join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", | |||||
| params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) | |||||
| join_course_messages.update_all(:viewed => true) | |||||
| end | |||||
| shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id) | |||||
| shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id) | |||||
| @page = params[:page] ? params[:page].to_i + 1 : 0 | |||||
| user_project_ids = (@user.favorite_projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.favorite_projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" | |||||
| user_course_ids = (@user.favorite_courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.favorite_courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")" | |||||
| course_types = "('Message','News','HomeworkCommon','Poll','Course','JournalsForMessage')" | |||||
| project_types = "('Message','Issue','Project')" | |||||
| principal_types = "JournalsForMessage" | |||||
| container_type = '' | |||||
| act_type = '' | |||||
| # 他的动态 | |||||
| sql = "user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))" | |||||
| if params[:type].present? | |||||
| case params[:type] | |||||
| when "course_homework" | |||||
| container_type = 'Course' | |||||
| act_type = 'HomeworkCommon' | |||||
| when "course_news" | |||||
| container_type = 'Course' | |||||
| act_type = 'News' | |||||
| when "course_message" | |||||
| container_type = 'Course' | |||||
| act_type = 'Message' | |||||
| when "course_poll" | |||||
| container_type = 'Course' | |||||
| act_type = 'Poll' | |||||
| when "course_journals" | |||||
| container_type = 'Course' | |||||
| act_type = 'JournalsForMessage' | |||||
| when "project_issue" | |||||
| container_type = 'Project' | |||||
| act_type = 'Issue' | |||||
| when "project_message" | |||||
| container_type = 'Project' | |||||
| act_type = 'Message' | |||||
| when "user_journals" | |||||
| container_type = 'Principal' | |||||
| act_type = 'JournalsForMessage' | |||||
| when "current_user" | |||||
| container_type = 'Principal' | |||||
| act_type = 'Principal' | |||||
| when "all" | |||||
| container_type = 'all' | |||||
| act_type = 'all' | |||||
| end | |||||
| end | |||||
| if container_type != '' && container_type != 'all' | |||||
| if container_type == 'Course' | |||||
| sql = "container_type = '#{container_type}' and container_id in #{user_course_ids} and act_type = '#{act_type}'" | |||||
| elsif container_type == 'Project' | |||||
| sql = "container_type = '#{container_type}' and container_id in #{user_project_ids} and act_type = '#{act_type}'" | |||||
| elsif container_type == 'Principal' && act_type == 'JournalsForMessage' | |||||
| sql = "container_type = '#{container_type}' and act_type= '#{act_type}' and container_id = #{@user.id}" | |||||
| elsif container_type == 'Principal' && act_type == 'Principal' | |||||
| sql = "user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))" | |||||
| end | |||||
| if User.current != @user | |||||
| sql += " and user_id = #{@user.id}" | |||||
| end | |||||
| else | |||||
| if User.current != @user | |||||
| blog_ids = "("+@user.blog.id.to_s+")" | |||||
| else | |||||
| blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" | |||||
| end | |||||
| sql = "(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + | |||||
| "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ | |||||
| "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + | |||||
| "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})" | |||||
| if container_type != 'all' && User.current != @user | |||||
| sql = "user_id = #{@user.id} and(" + sql + ")" | |||||
| end | |||||
| end | |||||
| @user_activities_count = UserActivity.where("#{sql}").order('updated_at desc').count | |||||
| @user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(10).offset(@page * 10) | |||||
| @type = params[:type] | |||||
| shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").pluck(:shield_id) | |||||
| user_project_ids = (@user.favorite_projects.visible.pluck(:id)-shield_project_ids).empty? ? "(-1)" : "(" + (@user.favorite_projects.visible.pluck(:id)-shield_project_ids).join(",") + ")" | |||||
| messages_all = @user.other_project_relate_messages(user_project_ids) | |||||
| @message_count = messages_all.count | |||||
| # REDO:已删除的内容应该在页面中显示不点击 | |||||
| @message_all_pages = Paginator.new @message_count, @limit, params['page'] || 1 | |||||
| @offset ||= @message_all_pages.offset | |||||
| @message_alls = messages_all | |||||
| @message_alls = paginateHelper @message_alls, @limit | |||||
| end | end | ||||
| respond_to do |format| | respond_to do |format| | ||||
| format.js | format.js | ||||
| @@ -2236,10 +2076,164 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| # #以前的用户show页面,暂时不删除 | |||||
| # def show | |||||
| # @user_projects = @user.projects.order("updated_on desc") | |||||
| # if User.current == @user | |||||
| # # 点击小铃铛,更新点击时间 | |||||
| # update_onclick_time if params[:click_user_message] == 'true' | |||||
| # # 全部设为已读 | |||||
| # # 自己的主页显示消息 | |||||
| # messages_all = MessageAll.where(:user_id => @user.id) | |||||
| # @limit = 20 | |||||
| # | |||||
| # @message_count = messages_all.count | |||||
| # # REDO:已删除的内容应该在页面中显示不点击 | |||||
| # @message_all_pages = Paginator.new @message_count, @limit, params['page'] || 1 | |||||
| # @offset ||= @message_all_pages.offset | |||||
| # @message_alls = messages_all.includes(:message).reorder("#{MessageAll.table_name}.created_at desc") | |||||
| # @message_alls = paginateHelper @message_alls, @limit | |||||
| # | |||||
| # @unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).count | |||||
| # | |||||
| # my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course). | |||||
| # where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" | |||||
| # # 用户待完成的作业 | |||||
| # homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}'") | |||||
| # homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" | |||||
| # student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0") | |||||
| # @unfinished_homework_count = homeworks.count - student_works.count | |||||
| # # 用户待完成的测验 | |||||
| # exercises = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2") | |||||
| # exercise_users = ExerciseUser.where(:user_id => @user.id, :exercise_id => exercises.map{|ex| ex.id}) | |||||
| # @unfinished_test_count = exercises.count - exercise_users.count | |||||
| # # 用户待完成的问卷 | |||||
| # polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2") | |||||
| # poll_users = PollUser.where(:user_id => @user.id, :poll_id => polls.map{|poll| poll.id}) | |||||
| # @unfinished_poll_count = polls.count - poll_users.count | |||||
| # # 用户待匿评的作品 | |||||
| # homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status = 2") | |||||
| # student_work_scores = @user.student_works_scores.where("reviewer_role = 3") | |||||
| # anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")" | |||||
| # unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}") | |||||
| # @anonymous_evaluation_count = StudentWork.where(:id => unfinished_evaluations.map{|ev| ev.student_work_id}, :homework_common_id => homeworks.map{|hw| hw.id}).count | |||||
| # # 待评阅的作业 暂不做 | |||||
| # # @unreview_homework = 1 | |||||
| # | |||||
| # # 待审批的申请 | |||||
| # #applied_message_count = AppliedMessage.where(:applied_type => ["Organization", "AppliedContest", "StudentWorksScoresAppeal", "AppliedProject", "ApplyAddSchools"], :user_id => User.current.id, :status => 0).count | |||||
| # #applied_course_message_count = CourseMessage.where(:user_id => User.current.id, :course_message_type => "JoinCourseRequest", :status => 0).count | |||||
| # # applied_pull_request_message_count = ForgeMessage.where(:user_id => User.current.id, :forge_message_type => "PullRequest", :status => [1,3]).count | |||||
| # # @applied_message_alls_count = applied_message_count + applied_course_message_count + applied_pull_request_message_count | |||||
| # user_id = User.current.id | |||||
| # sql = "SELECT * FROM `message_alls` ma left join `forge_messages` fm on ma.message_id=fm.id | |||||
| # left join `course_messages` cm on ma.message_id=cm.id left join `applied_messages` apm on ma.message_id=apm.id | |||||
| # where (ma.user_id =#{user_id} and ma.message_type = 'ForgeMessage' and fm.forge_message_type='PullRequest' and fm.status=0 and fm.user_id=#{user_id} ) or | |||||
| # (ma.user_id=#{user_id} and ma.message_type='AppliedMessage' and apm.applied_type in ('Organization', 'AppliedContest', 'StudentWorksScoresAppeal', 'AppliedProject', 'ApplyAddSchools') and apm.user_id =#{user_id} and apm.status =0 ) or | |||||
| # (ma.user_id=#{user_id} and ma.message_type='CourseMessage' and cm.course_message_type='JoinCourseRequest' and cm.status=0 and cm.user_id=#{user_id} );" | |||||
| # message_alls = MessageAll.find_by_sql(sql) | |||||
| # @applied_message_alls_count = message_alls.count | |||||
| # else | |||||
| # # 看别人的主页显示动态 | |||||
| # #更新用户申请成为课程老师或教辅消息的状态 | |||||
| # if params[:course_id] != nil | |||||
| # join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?", | |||||
| # params[:course_id], 'JoinCourseRequest', User.current.id, @user.id, false) | |||||
| # join_course_messages.update_all(:viewed => true) | |||||
| # end | |||||
| # shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id) | |||||
| # shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id) | |||||
| # @page = params[:page] ? params[:page].to_i + 1 : 0 | |||||
| # user_project_ids = (@user.favorite_projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.favorite_projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" | |||||
| # user_course_ids = (@user.favorite_courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.favorite_courses.visible.where("is_delete = 0").map{|course| course.id}-shield_course_ids).join(",") + ")" | |||||
| # course_types = "('Message','News','HomeworkCommon','Poll','Course','JournalsForMessage')" | |||||
| # project_types = "('Message','Issue','Project')" | |||||
| # principal_types = "JournalsForMessage" | |||||
| # container_type = '' | |||||
| # act_type = '' | |||||
| # # 他的动态 | |||||
| # sql = "user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))" | |||||
| # if params[:type].present? | |||||
| # case params[:type] | |||||
| # when "course_homework" | |||||
| # container_type = 'Course' | |||||
| # act_type = 'HomeworkCommon' | |||||
| # when "course_news" | |||||
| # container_type = 'Course' | |||||
| # act_type = 'News' | |||||
| # when "course_message" | |||||
| # container_type = 'Course' | |||||
| # act_type = 'Message' | |||||
| # when "course_poll" | |||||
| # container_type = 'Course' | |||||
| # act_type = 'Poll' | |||||
| # when "course_journals" | |||||
| # container_type = 'Course' | |||||
| # act_type = 'JournalsForMessage' | |||||
| # when "project_issue" | |||||
| # container_type = 'Project' | |||||
| # act_type = 'Issue' | |||||
| # when "project_message" | |||||
| # container_type = 'Project' | |||||
| # act_type = 'Message' | |||||
| # when "user_journals" | |||||
| # container_type = 'Principal' | |||||
| # act_type = 'JournalsForMessage' | |||||
| # when "current_user" | |||||
| # container_type = 'Principal' | |||||
| # act_type = 'Principal' | |||||
| # when "all" | |||||
| # container_type = 'all' | |||||
| # act_type = 'all' | |||||
| # end | |||||
| # end | |||||
| # if container_type != '' && container_type != 'all' | |||||
| # if container_type == 'Course' | |||||
| # sql = "container_type = '#{container_type}' and container_id in #{user_course_ids} and act_type = '#{act_type}'" | |||||
| # elsif container_type == 'Project' | |||||
| # sql = "container_type = '#{container_type}' and container_id in #{user_project_ids} and act_type = '#{act_type}'" | |||||
| # elsif container_type == 'Principal' && act_type == 'JournalsForMessage' | |||||
| # sql = "container_type = '#{container_type}' and act_type= '#{act_type}' and container_id = #{@user.id}" | |||||
| # elsif container_type == 'Principal' && act_type == 'Principal' | |||||
| # sql = "user_id = #{@user.id} and ((container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}))" | |||||
| # end | |||||
| # if User.current != @user | |||||
| # sql += " and user_id = #{@user.id}" | |||||
| # end | |||||
| # else | |||||
| # if User.current != @user | |||||
| # blog_ids = "("+@user.blog.id.to_s+")" | |||||
| # else | |||||
| # blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")" | |||||
| # end | |||||
| # sql = "(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + | |||||
| # "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ | |||||
| # "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " + | |||||
| # "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})" | |||||
| # if container_type != 'all' && User.current != @user | |||||
| # sql = "user_id = #{@user.id} and(" + sql + ")" | |||||
| # end | |||||
| # end | |||||
| # @user_activities_count = UserActivity.where("#{sql}").order('updated_at desc').count | |||||
| # @user_activities = UserActivity.where("#{sql}").order('updated_at desc').limit(10).offset(@page * 10) | |||||
| # @type = params[:type] | |||||
| # end | |||||
| # respond_to do |format| | |||||
| # format.js | |||||
| # format.html {render :layout => 'new_base_user'} | |||||
| # # format.html {render :layout => 'base'} | |||||
| # | |||||
| # end | |||||
| # end | |||||
| # 待解决的Issue | # 待解决的Issue | ||||
| def unsolved_issues_list | def unsolved_issues_list | ||||
| @unsolved_issues = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).order("updated_on desc") | |||||
| @undo_show_type = 1 | |||||
| @unsolved_issues = @user.user_unsolve_issues | |||||
| @unsolved_issues_count = @unsolved_issues.count | @unsolved_issues_count = @unsolved_issues.count | ||||
| @message_count = @user.user_unsolve_messages.count | |||||
| @limit = 20 | @limit = 20 | ||||
| @is_remote = true | @is_remote = true | ||||
| @unsolved_issues_pages = Paginator.new @unsolved_issues_count, @limit, params['page'] || 1 | @unsolved_issues_pages = Paginator.new @unsolved_issues_count, @limit, params['page'] || 1 | ||||
| @@ -2250,20 +2244,28 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| # 待审批的申请 | |||||
| # 待审批的消息一般不多,可以特殊处理 | |||||
| def unapproval_applied_list | |||||
| @undo_show_type = 6 | |||||
| @message_alls = @user.user_unsolve_messages | |||||
| @message_count = @message_alls.count | |||||
| @unsolved_issues_count = @user.user_unsolve_issues.count | |||||
| @message_alls = paginateHelper @message_alls, 20 | |||||
| respond_to do |format| | |||||
| format.js | |||||
| end | |||||
| end | |||||
| # 待完成的作业 | # 待完成的作业 | ||||
| def unfinished_homework_list | def unfinished_homework_list | ||||
| my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" | |||||
| homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}'") | |||||
| homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" | |||||
| student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0") | |||||
| finished_works_id = student_works.blank? ? "(-1)" : "(" + student_works.map{ |sw| sw.homework_common_id.to_i }.join(",") + ")" | |||||
| @unfinished_homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Time.now}' and id not in #{finished_works_id}").order("updated_at desc") | |||||
| @unfinished_homeworks_count = @unfinished_homeworks.count | |||||
| @undo_show_type = 2 | |||||
| @unfinished_homeworks = @user.user_undo_homeworks | |||||
| @unfinished_homeworks_count = @unfinished_homeworks.size | |||||
| @limit = 20 | @limit = 20 | ||||
| @unfinished_homework_pages = Paginator.new @unfinished_homeworks_count, @limit, params['page'] || 1 | @unfinished_homework_pages = Paginator.new @unfinished_homeworks_count, @limit, params['page'] || 1 | ||||
| @offset ||= @unfinished_homework_pages.offset | @offset ||= @unfinished_homework_pages.offset | ||||
| @unfinished_homeworks = paginateHelper @unfinished_homeworks, @limit | @unfinished_homeworks = paginateHelper @unfinished_homeworks, @limit | ||||
| respond_to do |format| | respond_to do |format| | ||||
| format.js | format.js | ||||
| end | end | ||||
| @@ -2271,12 +2273,8 @@ class UsersController < ApplicationController | |||||
| # 待完成的测验 | # 待完成的测验 | ||||
| def unfinished_test_list | def unfinished_test_list | ||||
| my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" | |||||
| exercises = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2") | |||||
| exercise_ids = exercises.blank? ? "(-1)" : "(" + exercises.map{|ex| ex.id}.join(",") + ")" | |||||
| exercise_users = ExerciseUser.where("user_id = #{@user.id} and exercise_id in #{exercise_ids}") | |||||
| finished_test_ids = exercise_users.blank? ? "(-1)" : "(" + exercise_users.map{|eu| eu.exercise_id }.join(",") + ")" | |||||
| @unfinished_test = Exercise.where("course_id in #{my_course_ids} and exercise_status = 2 and id not in #{finished_test_ids}") | |||||
| @undo_show_type = 3 | |||||
| @unfinished_test = @user.user_undo_tests | |||||
| @unfinished_test_count = @unfinished_test.count | @unfinished_test_count = @unfinished_test.count | ||||
| @limit = 20 | @limit = 20 | ||||
| @unfinished_test_pages = Paginator.new @unfinished_test_count, @limit, params['page'] || 1 | @unfinished_test_pages = Paginator.new @unfinished_test_count, @limit, params['page'] || 1 | ||||
| @@ -2289,12 +2287,14 @@ class UsersController < ApplicationController | |||||
| # 待完成的问卷 | # 待完成的问卷 | ||||
| def unfinished_poll_list | def unfinished_poll_list | ||||
| my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" | |||||
| polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2") | |||||
| poll_ids = polls.blank? ? "(-1)" : "(" + polls.map{|poll| poll.id}.join(",") + ")" | |||||
| poll_users = PollUser.where("user_id = #{@user.id} and poll_id in #{poll_ids}") | |||||
| finished_poll_ids = poll_users.blank? ? "(-1)" : "(" + poll_users.map{|pu| pu.poll_id }.join(",") + ")" | |||||
| @unfinished_poll = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2 and id not in #{finished_poll_ids}").order("updated_at desc") | |||||
| @undo_show_type = 4 | |||||
| # my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" | |||||
| # polls = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2") | |||||
| # poll_ids = polls.blank? ? "(-1)" : "(" + polls.map{|poll| poll.id}.join(",") + ")" | |||||
| # poll_users = PollUser.where("user_id = #{@user.id} and poll_id in #{poll_ids}") | |||||
| # finished_poll_ids = poll_users.blank? ? "(-1)" : "(" + poll_users.map{|pu| pu.poll_id }.join(",") + ")" | |||||
| # @unfinished_poll = Poll.where("polls_type = 'Course' and polls_group_id in #{my_course_ids} and polls_status = 2 and id not in #{finished_poll_ids}").order("updated_at desc") | |||||
| @unfinished_poll = @user.user_undo_polls | |||||
| @unfinished_poll_count = @unfinished_poll.count | @unfinished_poll_count = @unfinished_poll.count | ||||
| @limit = 20 | @limit = 20 | ||||
| @unfinished_poll_pages = Paginator.new @unfinished_poll_count, @limit, params['page'] || 1 | @unfinished_poll_pages = Paginator.new @unfinished_poll_count, @limit, params['page'] || 1 | ||||
| @@ -2307,16 +2307,20 @@ class UsersController < ApplicationController | |||||
| # 待匿评的作业 | # 待匿评的作业 | ||||
| def anonymous_evaluation_list | def anonymous_evaluation_list | ||||
| my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" | |||||
| homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status in (1,2)") | |||||
| homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" | |||||
| student_work_scores = @user.student_works_scores.where("reviewer_role = 3") | |||||
| anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")" | |||||
| unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}") | |||||
| unfinished_evaluations_work_ids = unfinished_evaluations.blank? ? "(-1)" : "(" + unfinished_evaluations.map{|st| st.student_work_id}.join(",") + ")" | |||||
| @anonymous_evaluation_count = StudentWork.where("student_works.id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").count | |||||
| homework_ids = StudentWork.where("id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").blank? ? "(-1)" : "(" + StudentWork.where("id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").map{|st| st.homework_common_id}.join(",") + ")" | |||||
| @anonymous_evaluation = HomeworkCommon.where("homework_commons.id in #{homework_ids}") | |||||
| @undo_show_type = 5 | |||||
| # my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")" | |||||
| # homeworks = HomeworkCommon.includes(:homework_detail_manual).where("homework_commons.course_id in #{my_course_ids} and homework_detail_manuals.comment_status in (1,2)") | |||||
| # homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")" | |||||
| # student_work_scores = @user.student_works_scores.where("reviewer_role = 3") | |||||
| # anonymous_evaluation_ids = student_work_scores.blank? ? "(-1)" : "(" + student_work_scores.map{|st| st.student_work_id}.join(",") + ")" | |||||
| # unfinished_evaluations = @user.student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}") | |||||
| # unfinished_evaluations_work_ids = unfinished_evaluations.blank? ? "(-1)" : "(" + unfinished_evaluations.map{|st| st.student_work_id}.join(",") + ")" | |||||
| # @anonymous_evaluation_count = StudentWork.where("student_works.id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").count | |||||
| # homework_ids = StudentWork.where("id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").blank? ? "(-1)" : "(" + StudentWork.where("id in #{unfinished_evaluations_work_ids} and homework_common_id in #{homework_ids}").map{|st| st.homework_common_id}.join(",") + ")" | |||||
| # | |||||
| # @anonymous_evaluation = HomeworkCommon.where("homework_commons.id in #{homework_ids}") | |||||
| @anonymous_evaluation = @user.user_undo_anonymous | |||||
| @anonymous_evaluation_count = @anonymous_evaluation.size | |||||
| @limit = 20 | @limit = 20 | ||||
| @anonymous_evaluation_pages = Paginator.new @anonymous_evaluation.count, @limit, params['page'] || 1 | @anonymous_evaluation_pages = Paginator.new @anonymous_evaluation.count, @limit, params['page'] || 1 | ||||
| @offset ||= @anonymous_evaluation_pages.offset | @offset ||= @anonymous_evaluation_pages.offset | ||||
| @@ -2326,22 +2330,7 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| # 待审批的申请 | |||||
| # 待审批的消息一般不多,可以特殊处理 | |||||
| def unapproval_applied_list | |||||
| user_id = User.current.id | |||||
| sql = "SELECT * FROM `message_alls` ma left join `forge_messages` fm on ma.message_id=fm.id | |||||
| left join `course_messages` cm on ma.message_id=cm.id left join `applied_messages` apm on ma.message_id=apm.id | |||||
| where (ma.user_id =#{user_id} and ma.message_type = 'ForgeMessage' and fm.forge_message_type='PullRequest' and fm.status=0 and fm.user_id=#{user_id} ) or | |||||
| (ma.user_id=#{user_id} and ma.message_type='AppliedMessage' and apm.applied_type in ('Organization', 'AppliedContest', 'StudentWorksScoresAppeal', 'AppliedProject', 'ApplyAddSchools') and apm.user_id =#{user_id} and apm.status =0 ) or | |||||
| (ma.user_id=#{user_id} and ma.message_type='CourseMessage' and cm.course_message_type='JoinCourseRequest' and cm.status=0 and cm.user_id=#{user_id}) order by ma.created_at desc;" | |||||
| @message_alls = MessageAll.find_by_sql(sql) | |||||
| @message_count = @message_alls.count | |||||
| @message_alls = paginateHelper @message_alls, 20 | |||||
| respond_to do |format| | |||||
| format.js | |||||
| end | |||||
| end | |||||
| # 课程社区 | # 课程社区 | ||||
| def course_community | def course_community | ||||
| @@ -2413,7 +2402,7 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| # 项目社区 | |||||
| # TODO: 项目社区, 已废弃 | |||||
| def project_community | def project_community | ||||
| # 看别人的主页显示动态 | # 看别人的主页显示动态 | ||||
| #更新用户申请成为课程老师或教辅消息的状态 | #更新用户申请成为课程老师或教辅消息的状态 | ||||
| @@ -2469,6 +2458,39 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| # 项目社区 | |||||
| def projects_list | |||||
| @project_community = "项目" | |||||
| @search = params[:name] | |||||
| @language = params[:language] | |||||
| @order = params[:order] || 'created_on' | |||||
| @project_status = params[:project_status] || 'all' | |||||
| scope = @user.favorite_projects.visible | |||||
| scope = @user == current_user ? scope : scope.visible | |||||
| @all_count = scope.size | |||||
| @public_count = scope.all_public.size | |||||
| @private_count = @all_count - @public_count | |||||
| scope = scope.like(@search).by_language_id(@language) | |||||
| .includes(:project_language, :members, owner: :user_extensions) | |||||
| .select("id, name, user_id, description, created_on, visits, project_language_id") | |||||
| scope = scope.visible if @user != current_user | |||||
| scope = filter_with_status(@project_status, scope) | |||||
| scope = order_by_hot_or_time(@order, scope) | |||||
| @languages = @user.projects.visible.joins(:project_language).group(:project_language_id) | |||||
| .select("project_language_id, count(*) AS ralation_projects_count, project_languages.name") | |||||
| @projects = paginateHelper scope, 10 | |||||
| respond_to do |format| | |||||
| format.js | |||||
| format.html {render :layout => 'base_user_projects'} | |||||
| end | |||||
| end | |||||
| # 竞赛社区 | # 竞赛社区 | ||||
| def contest_community | def contest_community | ||||
| @contest_community = "竞赛" | @contest_community = "竞赛" | ||||
| @@ -2674,7 +2696,7 @@ class UsersController < ApplicationController | |||||
| #Modified by nie | #Modified by nie | ||||
| unless User.current.admin? | unless User.current.admin? | ||||
| if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) | if !@user.active? #|| (@user != User.current && @memberships.empty? && events.empty?) | ||||
| # redirect_to home_path | |||||
| # redirect_to homes_path | |||||
| render_404 | render_404 | ||||
| return | return | ||||
| end | end | ||||
| @@ -4528,6 +4550,28 @@ class UsersController < ApplicationController | |||||
| end | end | ||||
| end | end | ||||
| def filter_with_status(status, scope) | |||||
| scope = | |||||
| case status | |||||
| when 'all' | |||||
| scope | |||||
| when 'public' | |||||
| scope.all_public | |||||
| when 'private' | |||||
| scope.without_public | |||||
| end | |||||
| scope | |||||
| end | |||||
| def order_by_hot_or_time(order_type, scope) | |||||
| scope = | |||||
| case order_type | |||||
| when 'created_on' | |||||
| scope.order('created_on DESC') | |||||
| when 'member_count' | |||||
| scope.sort {|a,b| b.members.size <=> a.members.size} | |||||
| end | |||||
| scope | |||||
| end | |||||
| end | end | ||||
| @@ -34,6 +34,7 @@ class VersionsController < ApplicationController | |||||
| def index | def index | ||||
| # 顶部导航 | # 顶部导航 | ||||
| @project_menu_type = 7 | @project_menu_type = 7 | ||||
| set_nav_status(NavStatues::PROJECT) | |||||
| type = params[:type] | type = params[:type] | ||||
| case type | case type | ||||
| when nil,"1" | when nil,"1" | ||||
| @@ -4,9 +4,27 @@ class WebFooterCompaniesController < ApplicationController | |||||
| menu_item :plugins, :only => :plugins | menu_item :plugins, :only => :plugins | ||||
| menu_item :info, :only => :info | menu_item :info, :only => :info | ||||
| before_filter :require_admin | before_filter :require_admin | ||||
| before_filter :find_company, :except => [:index, :new, :create] | |||||
| def index | def index | ||||
| @companys = WebFooterCompany.all | |||||
| @key = params[:key] || 'opensource' | |||||
| scope = | |||||
| case @key | |||||
| when 'partner' | |||||
| WebFooterCompany.partners | |||||
| when 'dedicator' | |||||
| WebFooterCompany.dedicators | |||||
| when 'opensource' | |||||
| WebFooterCompany.opensources | |||||
| end | |||||
| @companies = paginateHelper scope, 25 | |||||
| @page = (params['page'] || 1).to_i - 1 | |||||
| respond_to do |format| | |||||
| format.js | |||||
| format.html | |||||
| end | |||||
| end | end | ||||
| def new | def new | ||||
| @@ -15,38 +33,50 @@ class WebFooterCompaniesController < ApplicationController | |||||
| def create | def create | ||||
| @company = WebFooterCompany.new(params[:web_footer_company]) | @company = WebFooterCompany.new(params[:web_footer_company]) | ||||
| if @company.save | |||||
| @key = params[:web_footer_company][:key] | |||||
| if @company.save! | |||||
| flash[:notice] = l(:notice_successful_create) | flash[:notice] = l(:notice_successful_create) | ||||
| redirect_to web_footer_companies_url | |||||
| redirect_to web_footer_companies_url(key: @key) | |||||
| else | else | ||||
| flash[:error] = "#{l :web_footer_company_create_fail}: #{@company.errors.full_messages[0]}" | flash[:error] = "#{l :web_footer_company_create_fail}: #{@company.errors.full_messages[0]}" | ||||
| respond_to do |format| | respond_to do |format| | ||||
| format.html { render :action => 'new'} | |||||
| format.html { redirect_to new_web_footer_company_path(key: @key) } | |||||
| format.api { render_validation_errors(@company) } | format.api { render_validation_errors(@company) } | ||||
| end | end | ||||
| end | |||||
| end | |||||
| def move | |||||
| if request.put? and @company.update_attributes(params[:company]) | |||||
| flash[:notice] = l(:notice_successful_update) | |||||
| redirect_to web_footer_companies_url(type: @type) | |||||
| else | |||||
| render :action => 'edit' | |||||
| end | end | ||||
| end | end | ||||
| def destroy | def destroy | ||||
| @company = WebFooterCompany.find(params[:id]) | |||||
| @company.destroy | @company.destroy | ||||
| redirect_to web_footer_companies_url | |||||
| redirect_to web_footer_companies_url(type: @type) | |||||
| end | end | ||||
| def edit | def edit | ||||
| @company = WebFooterCompany.find(params[:id]) | |||||
| end | end | ||||
| def update | def update | ||||
| @company = WebFooterCompany.find(params[:id]) | |||||
| if @company.update_attributes(params[:web_footer_company]) | if @company.update_attributes(params[:web_footer_company]) | ||||
| flash[:notice] = l(:notice_successful_update) | flash[:notice] = l(:notice_successful_update) | ||||
| redirect_to web_footer_companies_url | |||||
| redirect_to web_footer_companies_url(type: @type) | |||||
| else | else | ||||
| flash[:error] = "#{l :web_footer_company_update_fail}: #{@company.errors.full_messages[0]}" | flash[:error] = "#{l :web_footer_company_update_fail}: #{@company.errors.full_messages[0]}" | ||||
| render :action => 'edit' | render :action => 'edit' | ||||
| end | end | ||||
| end | end | ||||
| private | |||||
| def find_company | |||||
| @company = WebFooterCompany.find(params[:id]) | |||||
| end | |||||
| end | end | ||||
| @@ -6,6 +6,9 @@ class WorksController < ApplicationController | |||||
| :set_score_rule] | :set_score_rule] | ||||
| before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:open_contestant_works] | before_filter :admin_of_contest, :only => [:new, :create, :edit, :update, :destroy,:score_rule_set,:open_contestant_works] | ||||
| before_filter :member_of_contest, :only => [:index] | before_filter :member_of_contest, :only => [:index] | ||||
| before_filter :only => [:index] do | |||||
| set_nav_status(NavStatues::COMPETION) | |||||
| end | |||||
| def index | def index | ||||
| search = "%#{params[:search].to_s.strip.downcase}%" | search = "%#{params[:search].to_s.strip.downcase}%" | ||||
| @@ -24,4 +24,8 @@ module AdminHelper | |||||
| [l(:project_status_closed), '5'], | [l(:project_status_closed), '5'], | ||||
| [l(:project_status_archived), '9']], selected.to_s) | [l(:project_status_archived), '9']], selected.to_s) | ||||
| end | end | ||||
| def dynamic_news_category_options_for_select(selected) | |||||
| options_for_select(Category.all.collect{|item| [item.name, item.id]}.insert(0, ['全部', 0]), selected) | |||||
| end | |||||
| end | end | ||||
| @@ -377,6 +377,14 @@ module ApplicationHelper | |||||
| score = obj.issue_num * 4 + obj.issue_journal_num + (obj.changeset_num||0) * 4 + obj.board_num * 2 + obj.board_message_num + obj.attach_num * 5 | score = obj.issue_num * 4 + obj.issue_journal_num + (obj.changeset_num||0) * 4 + obj.board_num * 2 + obj.board_message_num + obj.attach_num * 5 | ||||
| end | end | ||||
| def forge_static_project_score(project_socre) | |||||
| project_socre[:issue_num].to_i * 4 + project_socre[:issue_journal_num].to_i + (project_socre[:changeset_num].to_i||0) * 4 + project_socre[:board_num].to_i * 2 + project_socre[:board_message_num].to_i + project_socre[:attach_num].to_i * 5 | |||||
| end | |||||
| def encoding_utf_name(name) | |||||
| name.to_s.force_encoding("UTF-8") | |||||
| end | |||||
| # 获取组织成员中文名字 | # 获取组织成员中文名字 | ||||
| def get_org_member_role_name member | def get_org_member_role_name member | ||||
| unless member.roles[0].nil? | unless member.roles[0].nil? | ||||
| @@ -0,0 +1,2 @@ | |||||
| module DynamicNewHelper | |||||
| end | |||||
| @@ -0,0 +1,36 @@ | |||||
| module HomesHelper | |||||
| def home_cover_tag(home) | |||||
| file_path = | |||||
| if File.exists?(Rails.root.join('/public/images', url_to_avatar(home))) | |||||
| url_to_avatar(home) | |||||
| else | |||||
| "/images/introduce/activeBanner.jpg" | |||||
| end | |||||
| image_tag(file_path, class: 'mb30', width: '592px') | |||||
| end | |||||
| def home_banner_tag(banner) | |||||
| image_tag local_path(banner.file) | |||||
| end | |||||
| def default_banner_tag(home) | |||||
| return unless home.banners.size == 0 | |||||
| content_tag :a do | |||||
| image_tag "/images/introduce/trustie.jpg" | |||||
| end | |||||
| end | |||||
| def local_path(file) | |||||
| File.join("/files/uploads/image", file.disk_directory, file.disk_filename) | |||||
| end | |||||
| def render_pool_name poll | |||||
| case poll | |||||
| when 'opensource' then '合作共建开源' | |||||
| when 'partner' then '合作机构' | |||||
| when 'dedicator' then '技术合作单位' | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,2 @@ | |||||
| module PrivateMessagesHelper | |||||
| end | |||||
| @@ -110,7 +110,7 @@ module ProjectsHelper | |||||
| ] | ] | ||||
| tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} | tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} | ||||
| end | end | ||||
| def sort_project(state, project_type) | def sort_project(state, project_type) | ||||
| content = ''.html_safe | content = ''.html_safe | ||||
| case state | case state | ||||
| @@ -129,8 +129,8 @@ module ProjectsHelper | |||||
| content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") | content << content_tag('li', link_to(l(:label_sort_by_influence), projects_path(:project_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected") | ||||
| content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type))) | content << content_tag('li', link_to(l(:label_sort_by_time), projects_path(:project_sort_type => '0', :project_type => project_type))) | ||||
| end | end | ||||
| content = content_tag('ul', content) | |||||
| content_tag('div', content, :class => "tabs") | |||||
| content = content_tag('ul', content) | |||||
| content_tag('div', content, :class => "tabs") | |||||
| end | end | ||||
| # 判断我的项目中是否有重名项目 | # 判断我的项目中是否有重名项目 | ||||
| @@ -352,12 +352,12 @@ module ProjectsHelper | |||||
| when "attachment" | when "attachment" | ||||
| l :label_attachment | l :label_attachment | ||||
| when "news" | when "news" | ||||
| l :label_news | |||||
| l :label_news | |||||
| else | else | ||||
| "" | |||||
| "" | |||||
| end | end | ||||
| end | end | ||||
| def eventToLanguageCourse event_type, project | def eventToLanguageCourse event_type, project | ||||
| case event_type | case event_type | ||||
| when "issue-note" | when "issue-note" | ||||
| @@ -369,7 +369,7 @@ module ProjectsHelper | |||||
| when "news" | when "news" | ||||
| project.project_type == 1 ? (l :label_notification) : (l :label_news) | project.project_type == 1 ? (l :label_notification) : (l :label_news) | ||||
| else | else | ||||
| "" | |||||
| "" | |||||
| end | end | ||||
| end | end | ||||
| @@ -394,7 +394,7 @@ module ProjectsHelper | |||||
| @projects_status = ProjectStatus.visible.where("project_statuses.project_type <> ? or project_statuses.project_type is null", 1) | @projects_status = ProjectStatus.visible.where("project_statuses.project_type <> ? or project_statuses.project_type is null", 1) | ||||
| @projects_status = @projects_status.reorder('grade').all.reverse | @projects_status = @projects_status.reorder('grade').all.reverse | ||||
| @projects = [] | @projects = [] | ||||
| @projects_status.each do |obj| | |||||
| @projects_status.each do |obj| | |||||
| break if(@projects_status[10] == obj) | break if(@projects_status[10] == obj) | ||||
| @projects << Project.visible.find_by_id("#{obj.project_id}")#where('id=:id', id: obj.project_id) | @projects << Project.visible.find_by_id("#{obj.project_id}")#where('id=:id', id: obj.project_id) | ||||
| end | end | ||||
| @@ -411,12 +411,12 @@ module ProjectsHelper | |||||
| limit = 10 | limit = 10 | ||||
| #Project.find_by_sql("SELECT * FROM projects RIGHT OUTER JOIN (SELECT * FROM project_statuses ORDER BY grade DESC LIMIT #{limit} ) AS t ON projects.id = t.project_id ") | #Project.find_by_sql("SELECT * FROM projects RIGHT OUTER JOIN (SELECT * FROM project_statuses ORDER BY grade DESC LIMIT #{limit} ) AS t ON projects.id = t.project_id ") | ||||
| Project.find_by_sql(" | Project.find_by_sql(" | ||||
| SELECT p.id, p.name, p.description, p.identifier, t.project_id | |||||
| SELECT p.id, p.name, p.description, p.identifier, t.project_id | |||||
| FROM projects AS p RIGHT OUTER JOIN ( | FROM projects AS p RIGHT OUTER JOIN ( | ||||
| SELECT project_id,grade FROM project_statuses | |||||
| SELECT project_id,grade FROM project_statuses | |||||
| WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ") | WHERE project_type = 0 ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ") | ||||
| end | end | ||||
| # 判断课程是否结束,快别用,这个定日子的方法有问题 | # 判断课程是否结束,快别用,这个定日子的方法有问题 | ||||
| def course_timeout? project | def course_timeout? project | ||||
| @@ -674,4 +674,20 @@ module ProjectsHelper | |||||
| return nil | return nil | ||||
| end | end | ||||
| end | end | ||||
| def select_project_categories | |||||
| ProjectCategory.desc_with_position.collect { |c| [c.name, c.id]} | |||||
| end | |||||
| def select_project_languages | |||||
| ProjectLanguage.desc_with_position.collect { |pl| [pl.name, pl.id] } | |||||
| end | |||||
| def select_project_licenses | |||||
| License.all.collect { |c| [c.name, c.id]} | |||||
| end | |||||
| def select_project_ignores | |||||
| Ignore.all.collect { |c| [c.name, c.id]} | |||||
| end | |||||
| end | end | ||||
| @@ -0,0 +1,2 @@ | |||||
| module StatisticWorksHelper | |||||
| end | |||||
| @@ -30,7 +30,7 @@ module UsersHelper | |||||
| end | end | ||||
| def task_count(unsolved_issues_count, unfinished_homework_count, unfinished_test_count, unfinished_poll_count, anonymous_evaluation_count, unapproval_homework) | def task_count(unsolved_issues_count, unfinished_homework_count, unfinished_test_count, unfinished_poll_count, anonymous_evaluation_count, unapproval_homework) | ||||
| result = unsolved_issues_count + unfinished_homework_count + unfinished_test_count + unfinished_poll_count + anonymous_evaluation_count + unapproval_homework | |||||
| result = unsolved_issues_count.to_i + unfinished_homework_count.to_i + unfinished_test_count.to_i + unfinished_poll_count.to_i + anonymous_evaluation_count.to_i + unapproval_homework.to_i | |||||
| end | end | ||||
| # 判断某个时间再多少天前 | # 判断某个时间再多少天前 | ||||
| @@ -132,13 +132,13 @@ module UsersHelper | |||||
| def pull_request_message_status ma | def pull_request_message_status ma | ||||
| case ma.status | case ma.status | ||||
| when 1 | when 1 | ||||
| "创建了PullRequest:" | |||||
| "创建了PullRequest" | |||||
| when 2 | when 2 | ||||
| "接受了PullRequest:" | |||||
| "接受了PullRequest" | |||||
| when 3 | when 3 | ||||
| "重新打开了PullRequest:" | |||||
| "重新打开了PullRequest" | |||||
| when 4 | when 4 | ||||
| "关闭了PullRequest:" | |||||
| "关闭了PullRequest" | |||||
| end | end | ||||
| end | end | ||||
| @@ -169,11 +169,11 @@ module UsersHelper | |||||
| def applied_project_tip applied_message | def applied_project_tip applied_message | ||||
| case applied_message.status | case applied_message.status | ||||
| when 4 | when 4 | ||||
| "拒绝申请加入:" | |||||
| "拒绝申请加入" | |||||
| when 5,3,2,1,7 | when 5,3,2,1,7 | ||||
| "申请加入:" | |||||
| "申请加入" | |||||
| when 6 | when 6 | ||||
| "同意申请加入:" | |||||
| "同意申请加入" | |||||
| end | end | ||||
| end | end | ||||
| @@ -187,9 +187,9 @@ module UsersHelper | |||||
| def applied_school_tip applied_message | def applied_school_tip applied_message | ||||
| case applied_message.status | case applied_message.status | ||||
| when 1,2,3 | when 1,2,3 | ||||
| "您添加新的单位:" | |||||
| "您添加新的单位" | |||||
| when 0 | when 0 | ||||
| "申请了单位:" | |||||
| "申请了单位" | |||||
| end | end | ||||
| end | end | ||||
| @@ -202,7 +202,7 @@ module UsersHelper | |||||
| when 4 | when 4 | ||||
| "婉拒您" | "婉拒您" | ||||
| when 5,3,2,1,7 | when 5,3,2,1,7 | ||||
| "申请:" | |||||
| "申请" | |||||
| when 6 | when 6 | ||||
| "同意您" | "同意您" | ||||
| end | end | ||||
| @@ -0,0 +1,21 @@ | |||||
| module WebFooterCompaniesHelper | |||||
| def label_new_button_name type | |||||
| (@type == WebFooterCompany::RELATION_TYPE[1]) ? l(:label_new_open_source_company) : l(:label_new_company) | |||||
| end | |||||
| def label_title_name type | |||||
| (@type == WebFooterCompany::RELATION_TYPE[1]) ? l(:label_web_footer_open_source_compnay) : l(:label_web_footer_cooperation_compnay) | |||||
| end | |||||
| def label_root_name type | |||||
| (@type == WebFooterCompany::RELATION_TYPE[1]) ? l(:label_open_source_compnay) : l(:label_cooperation_compnay) | |||||
| end | |||||
| def label_edit_button_name type | |||||
| (@type == WebFooterCompany::RELATION_TYPE[1]) ? l(:label_new_open_source_company) : l(:label_edit_company) | |||||
| end | |||||
| def hash_company_types | |||||
| { "首页合作共建开源" => "opensource", "首页技术合作单位" => "dedicator", "网站页脚合作单位" => "partner" } | |||||
| end | |||||
| end | |||||
| @@ -17,7 +17,6 @@ | |||||
| require "digest/md5" | require "digest/md5" | ||||
| require "fileutils" | require "fileutils" | ||||
| require 'elasticsearch/model' | |||||
| class Attachment < ActiveRecord::Base | class Attachment < ActiveRecord::Base | ||||
| belongs_to :container, :polymorphic => true | belongs_to :container, :polymorphic => true | ||||
| belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" | belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'" | ||||
| @@ -45,12 +44,10 @@ class Attachment < ActiveRecord::Base | |||||
| # validates :description, length: {maximum: 254} | # validates :description, length: {maximum: 254} | ||||
| validate :validate_max_file_size | validate :validate_max_file_size | ||||
| #elasticsearch | |||||
| include Elasticsearch::Model | |||||
| include ApplicationHelper | include ApplicationHelper | ||||
| #elasticsearch kaminari init | |||||
| Kaminari::Hooks.init | |||||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||||
| #elasticsearch | |||||
| include EsSearchable | |||||
| settings index: { number_of_shards: 5 } do | settings index: { number_of_shards: 5 } do | ||||
| mappings dynamic: 'false' do | mappings dynamic: 'false' do | ||||
| indexes :filename, analyzer: 'smartcn',index_options: 'offsets' | indexes :filename, analyzer: 'smartcn',index_options: 'offsets' | ||||
| @@ -145,7 +142,7 @@ class Attachment < ActiveRecord::Base | |||||
| def get_apply_resource_status attachment_id, author_id | def get_apply_resource_status attachment_id, author_id | ||||
| status = ApplyResource.where("attachment_id =? and user_id =?", attachment_id, author_id).first.try(:status) | status = ApplyResource.where("attachment_id =? and user_id =?", attachment_id, author_id).first.try(:status) | ||||
| status == 2 | |||||
| status == 2 | |||||
| end | end | ||||
| # add by nwb | # add by nwb | ||||
| @@ -0,0 +1,3 @@ | |||||
| class Banner < ActiveRecord::Base | |||||
| has_one :file, :as => :container, :class_name => 'Attachment', dependent: :destroy | |||||
| end | |||||
| @@ -0,0 +1,3 @@ | |||||
| class Category < ActiveRecord::Base | |||||
| has_many :dynamic_news | |||||
| end | |||||
| @@ -0,0 +1,15 @@ | |||||
| require 'elasticsearch/model' | |||||
| module EsSearchable | |||||
| extend ActiveSupport::Concern | |||||
| included do | |||||
| include Elasticsearch::Model | |||||
| document_type 'doc' if Rails.env.production? # 解决因Elasticsearch版本导致es语法错误的问题 | |||||
| #elasticsearch kaminari init | |||||
| Kaminari::Hooks.init | |||||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||||
| end | |||||
| end | |||||
| @@ -1,6 +1,4 @@ | |||||
| #coding=utf-8 | #coding=utf-8 | ||||
| require 'elasticsearch/model' | |||||
| class Course < ActiveRecord::Base | class Course < ActiveRecord::Base | ||||
| include Redmine::SafeAttributes | include Redmine::SafeAttributes | ||||
| @@ -11,11 +9,7 @@ class Course < ActiveRecord::Base | |||||
| STATUS_ARCHIVED = 9 | STATUS_ARCHIVED = 9 | ||||
| #elasticsearch | #elasticsearch | ||||
| include Elasticsearch::Model | |||||
| #elasticsearch kaminari init | |||||
| Kaminari::Hooks.init | |||||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||||
| include EsSearchable | |||||
| settings index: { number_of_shards: 5 } do | settings index: { number_of_shards: 5 } do | ||||
| mappings dynamic: 'false' do | mappings dynamic: 'false' do | ||||
| indexes :name, analyzer: 'smartcn',index_options: 'offsets' | indexes :name, analyzer: 'smartcn',index_options: 'offsets' | ||||
| @@ -23,7 +17,7 @@ class Course < ActiveRecord::Base | |||||
| indexes :updated_at, index:"not_analyzed",type:"date" | indexes :updated_at, index:"not_analyzed",type:"date" | ||||
| end | end | ||||
| end | end | ||||
| attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, | attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period, | ||||
| :open_student, :enterprise_name, :is_delete, :syllabus_id, :end_time, :end_term, :publish_resource, :is_copy, :endup_time, | :open_student, :enterprise_name, :is_delete, :syllabus_id, :end_time, :end_term, :publish_resource, :is_copy, :endup_time, | ||||
| :setup_time, :school_id | :setup_time, :school_id | ||||
| @@ -72,7 +66,7 @@ class Course < ActiveRecord::Base | |||||
| acts_as_nested_set :order => 'name', :dependent => :destroy | acts_as_nested_set :order => 'name', :dependent => :destroy | ||||
| acts_as_attachable :view_permission => :view_course_files, | acts_as_attachable :view_permission => :view_course_files, | ||||
| :delete_permission => :manage_files | :delete_permission => :manage_files | ||||
| validates_presence_of :term,:name | validates_presence_of :term,:name | ||||
| validates_format_of :class_period, :with =>/^[1-9]\d*$/ | validates_format_of :class_period, :with =>/^[1-9]\d*$/ | ||||
| validates_format_of :time, :with => /^\d{4}$/ | validates_format_of :time, :with => /^\d{4}$/ | ||||
| @@ -309,7 +303,7 @@ class Course < ActiveRecord::Base | |||||
| def self_validate | def self_validate | ||||
| end | end | ||||
| def update_files_public | def update_files_public | ||||
| unless self.is_public? | unless self.is_public? | ||||
| self.attachments.each do |a| | self.attachments.each do |a| | ||||
| @@ -367,7 +361,7 @@ class Course < ActiveRecord::Base | |||||
| rescue Exception => e | rescue Exception => e | ||||
| end_time = Time.parse("3000-01-01") | end_time = Time.parse("3000-01-01") | ||||
| Rails.logger.error "[Error] course endup_time error. ===> #{e}" | Rails.logger.error "[Error] course endup_time error. ===> #{e}" | ||||
| ensure | |||||
| ensure | |||||
| return end_time | return end_time | ||||
| end | end | ||||
| end | end | ||||
| @@ -537,5 +531,3 @@ end | |||||
| # Index all article records from the DB to Elasticsearch | # Index all article records from the DB to Elasticsearch | ||||
| #Course.where('is_public = 1').import :force=>true | #Course.where('is_public = 1').import :force=>true | ||||
| @@ -0,0 +1,5 @@ | |||||
| class Cover < ActiveRecord::Base | |||||
| belongs_to :coverable, polymorphic: true | |||||
| has_one :file, :as => :container, :class_name => 'Attachment', dependent: :destroy | |||||
| end | |||||
| @@ -0,0 +1,14 @@ | |||||
| class DynamicNew < ActiveRecord::Base | |||||
| PLATFORMS = %w(educoder trusite ihub gcc openi toschina military jiaotong_university) | |||||
| belongs_to :category | |||||
| validates_presence_of :title, :simple_intruduce, :category_id | |||||
| scope :desc, -> { order('id desc') } | |||||
| scope :like, ->(q) { where("title LIKE ?", "#{q.to_s.strip.downcase}") unless q.blank? } | |||||
| scope :by_category, ->(category_id) { where(category_id: category_id) } | |||||
| def cover_url | |||||
| cover_remote_url || "/images/dynamic_new/default.png" | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,26 @@ | |||||
| class Home < ActiveRecord::Base | |||||
| SHOW_CONTENT_LENGTH = 400 | |||||
| REG_URL_FORMAT = /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/ | |||||
| has_one :cover, as: :coverable, dependent: :destroy | |||||
| has_many :banners, dependent: :destroy | |||||
| # validates_presence_of :name, :content, :frendly_id | |||||
| # validates_format_of :friendly_id, :with => /\A[a-z0-9\-]+\z/ | |||||
| # before_validation :generate_friendly_id, :on => :create | |||||
| validates_presence_of :name, :content | |||||
| def more_content? | |||||
| content.html_safe.length > Home::SHOW_CONTENT_LENGTH | |||||
| end | |||||
| def to_param | |||||
| self.frendly_id | |||||
| end | |||||
| private | |||||
| def generate_friendly_id | |||||
| self.frendly_id ||= SecureRandom.uuid | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,3 @@ | |||||
| class Ignore < ActiveRecord::Base | |||||
| attr_accessible :content, :name | |||||
| end | |||||
| @@ -0,0 +1,3 @@ | |||||
| class License < ActiveRecord::Base | |||||
| attr_accessible :key, :name | |||||
| end | |||||
| @@ -1,9 +1,7 @@ | |||||
| require 'elasticsearch/model' | |||||
| class Memo < ActiveRecord::Base | class Memo < ActiveRecord::Base | ||||
| include Redmine::SafeAttributes | include Redmine::SafeAttributes | ||||
| include UserScoreHelper | include UserScoreHelper | ||||
| include ApplicationHelper | include ApplicationHelper | ||||
| include Elasticsearch::Model | |||||
| belongs_to :forum | belongs_to :forum | ||||
| has_many_kindeditor_assets :assets, :dependent => :destroy | has_many_kindeditor_assets :assets, :dependent => :destroy | ||||
| belongs_to :author, :class_name => "User", :foreign_key => 'author_id' | belongs_to :author, :class_name => "User", :foreign_key => 'author_id' | ||||
| @@ -15,9 +13,8 @@ class Memo < ActiveRecord::Base | |||||
| validate :cannot_reply_to_locked_topic, :on => :create | validate :cannot_reply_to_locked_topic, :on => :create | ||||
| #elasticsearch kaminari init | |||||
| Kaminari::Hooks.init | |||||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||||
| #elasticsearch | |||||
| include EsSearchable | |||||
| settings index: { | settings index: { | ||||
| number_of_shards: 5 , | number_of_shards: 5 , | ||||
| analysis: { | analysis: { | ||||
| @@ -196,7 +193,7 @@ class Memo < ActiveRecord::Base | |||||
| def locked? | def locked? | ||||
| self.lock | self.lock | ||||
| end | end | ||||
| def editable_by? user | def editable_by? user | ||||
| # user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)) | # user && user.logged? || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)) | ||||
| user.admin? || self.author == user | user.admin? || self.author == user | ||||
| @@ -0,0 +1,13 @@ | |||||
| class PrivateMessage < ActiveRecord::Base | |||||
| # 私信 | |||||
| belongs_to :user | |||||
| belongs_to :target, class_name: "User" | |||||
| belongs_to :sender, class_name: "User" | |||||
| belongs_to :receiver, class_name: "User" | |||||
| #status 0表示未读,1表示已读,2表示已删除 | |||||
| scope :without_deleted, -> { where("status != 2") } | |||||
| scope :only_unread, -> { where(status: 0) } | |||||
| end | |||||
| @@ -14,7 +14,6 @@ | |||||
| # You should have received a copy of the GNU General Public License | # You should have received a copy of the GNU General Public License | ||||
| # along with this program; if not, write to the Free Software | # along with this program; if not, write to the Free Software | ||||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| require 'elasticsearch/model' | |||||
| class Project < ActiveRecord::Base | class Project < ActiveRecord::Base | ||||
| include Redmine::SafeAttributes | include Redmine::SafeAttributes | ||||
| ProjectType_project = 0 | ProjectType_project = 0 | ||||
| @@ -31,10 +30,7 @@ class Project < ActiveRecord::Base | |||||
| # Specific overidden Activities | # Specific overidden Activities | ||||
| #elasticsearch | #elasticsearch | ||||
| include Elasticsearch::Model | |||||
| #elasticsearch kaminari init | |||||
| Kaminari::Hooks.init | |||||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||||
| include EsSearchable | |||||
| settings index: { number_of_shards: 5 } do | settings index: { number_of_shards: 5 } do | ||||
| mappings dynamic: 'false' do | mappings dynamic: 'false' do | ||||
| indexes :name, analyzer: 'smartcn',index_options: 'offsets' | indexes :name, analyzer: 'smartcn',index_options: 'offsets' | ||||
| @@ -42,7 +38,15 @@ class Project < ActiveRecord::Base | |||||
| indexes :updated_on, index:"not_analyzed", type:'date' | indexes :updated_on, index:"not_analyzed", type:'date' | ||||
| end | end | ||||
| end | end | ||||
| has_many :praise_tread, as: :praise_tread_object, dependent: :destroy | |||||
| has_one :praise_tread_cache, as: :object, dependent: :destroy | |||||
| belongs_to :ignore | |||||
| belongs_to :license | |||||
| belongs_to :project_category , :counter_cache => true | |||||
| belongs_to :project_language , :counter_cache => true | |||||
| belongs_to :owner, :class_name => 'User', :foreign_key => :user_id | |||||
| has_many :student_work_projects, :dependent => :destroy | has_many :student_work_projects, :dependent => :destroy | ||||
| has_many :contestant_work_projects, :dependent => :destroy | has_many :contestant_work_projects, :dependent => :destroy | ||||
| has_many :student_works | has_many :student_works | ||||
| @@ -90,7 +94,7 @@ class Project < ActiveRecord::Base | |||||
| # end | # end | ||||
| #ADDED BY NIE | #ADDED BY NIE | ||||
| has_one :project_score, :dependent => :destroy | has_one :project_score, :dependent => :destroy | ||||
| has_many :project_infos, :dependent => :destroy | |||||
| has_many :project_infos, :dependent => :destroy | |||||
| has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy | has_one :project_status, :class_name => "ProjectStatus", :dependent => :destroy | ||||
| has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy | has_many :user_grades, :class_name => "UserGrade", :dependent => :destroy | ||||
| #end | #end | ||||
| @@ -106,7 +110,7 @@ class Project < ActiveRecord::Base | |||||
| :order => "#{CustomField.table_name}.position", | :order => "#{CustomField.table_name}.position", | ||||
| :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", | :join_table => "#{table_name_prefix}custom_fields_projects#{table_name_suffix}", | ||||
| :association_foreign_key => 'custom_field_id' | :association_foreign_key => 'custom_field_id' | ||||
| has_many :tags, :through => :project_tags, :class_name => 'Tag' | has_many :tags, :through => :project_tags, :class_name => 'Tag' | ||||
| has_many :project_tags, :class_name => 'ProjectTags' | has_many :project_tags, :class_name => 'ProjectTags' | ||||
| # 动态级联删除 | # 动态级联删除 | ||||
| @@ -131,11 +135,11 @@ class Project < ActiveRecord::Base | |||||
| :url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}}, | :url => Proc.new {|o| {:controller => 'projects', :action => 'show', :id => o}}, | ||||
| :author => nil | :author => nil | ||||
| ############################added by william | ############################added by william | ||||
| acts_as_taggable | |||||
| acts_as_taggable | |||||
| scope :by_join_date, order("created_on DESC") | scope :by_join_date, order("created_on DESC") | ||||
| ###################added by liuping 关注 | ###################added by liuping 关注 | ||||
| acts_as_watchable | |||||
| acts_as_watchable | |||||
| attr_protected :status | attr_protected :status | ||||
| validates_presence_of :name, :identifier | validates_presence_of :name, :identifier | ||||
| @@ -157,7 +161,7 @@ class Project < ActiveRecord::Base | |||||
| #ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用 | #ActiveModel::Dirty 这里有一个changed方法。对任何对象都可以用 | ||||
| after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?} | after_save :update_inherited_members, :if => Proc.new {|project| project.inherit_members_changed?} | ||||
| # 创建project之后默认创建一个board,之后的board去掉了board的概念 | # 创建project之后默认创建一个board,之后的board去掉了board的概念 | ||||
| after_create :create_board_sync,:acts_as_forge_activities, :create_project_ealasticsearch_index | |||||
| after_create :create_board_sync,:acts_as_forge_activities, :create_project_ealasticsearch_index, :sync_projects_count_to_home | |||||
| before_destroy :delete_all_members,:delete_project_ealasticsearch_index | before_destroy :delete_all_members,:delete_project_ealasticsearch_index | ||||
| after_update :update_project_ealasticsearch_index | after_update :update_project_ealasticsearch_index | ||||
| @@ -172,8 +176,10 @@ class Project < ActiveRecord::Base | |||||
| scope :active, lambda { where(:status => STATUS_ACTIVE) } | scope :active, lambda { where(:status => STATUS_ACTIVE) } | ||||
| scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) } | scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) } | ||||
| scope :all_public, lambda { where(:is_public => true) } | scope :all_public, lambda { where(:is_public => true) } | ||||
| scope :without_public, lambda { where(:is_public => false) } | |||||
| scope :by_language_id, lambda {|language_id| where(project_language_id: language_id) unless language_id.blank? } | |||||
| scope :visible, lambda {|*args| where(Project.visible_condition(args.shift || User.current, *args)) } | scope :visible, lambda {|*args| where(Project.visible_condition(args.shift || User.current, *args)) } | ||||
| scope :allowed_to, lambda {|*args| | |||||
| scope :allowed_to, lambda {|*args| | |||||
| user = User.current | user = User.current | ||||
| permission = nil | permission = nil | ||||
| if args.first.is_a?(Symbol) | if args.first.is_a?(Symbol) | ||||
| @@ -223,6 +229,10 @@ class Project < ActiveRecord::Base | |||||
| ) | ) | ||||
| end | end | ||||
| def sync_projects_count_to_home | |||||
| HomesService.new.sync_count('project', 1) if Rails.env.production? && Setting.host_name == "www.trustie.net" | |||||
| end | |||||
| # 判断项目是否为实训项目 | # 判断项目是否为实训项目 | ||||
| def is_training_project? | def is_training_project? | ||||
| (!self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 1) ? true : false | (!self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 1) ? true : false | ||||
| @@ -265,7 +275,7 @@ class Project < ActiveRecord::Base | |||||
| pjfm.save | pjfm.save | ||||
| pjfm | pjfm | ||||
| end | end | ||||
| def self.add_new_jour(user, notes, id, options={}) | def self.add_new_jour(user, notes, id, options={}) | ||||
| project = Project.find(id) | project = Project.find(id) | ||||
| if options.count == 0 | if options.count == 0 | ||||
| @@ -843,8 +853,12 @@ class Project < ActiveRecord::Base | |||||
| 'dts_test', | 'dts_test', | ||||
| 'attachmenttype', | 'attachmenttype', | ||||
| 'enterprise_name', | 'enterprise_name', | ||||
| 'gpid' | |||||
| 'gpid', | |||||
| 'project_category_id', | |||||
| 'project_language_id', | |||||
| 'license_id', | |||||
| 'ignore_id' | |||||
| safe_attributes 'enabled_module_names', | safe_attributes 'enabled_module_names', | ||||
| @@ -926,10 +940,6 @@ class Project < ActiveRecord::Base | |||||
| end | end | ||||
| end | end | ||||
| def owner | |||||
| User.find(self.user_id) | |||||
| end | |||||
| # 延迟生成邀请码 | # 延迟生成邀请码 | ||||
| def invite_code | def invite_code | ||||
| return generate_invite_code | return generate_invite_code | ||||
| @@ -961,6 +971,20 @@ class Project < ActiveRecord::Base | |||||
| ticket | ticket | ||||
| end | end | ||||
| def sync_gitignore_file | |||||
| ignore = self.ignore | |||||
| return if ignore.blank? | |||||
| Gitlab.create_file(self.gpid, :file_path => ".gitignore", :branch_name => "master", | |||||
| :content => ignore.content, :commit_message => ".gitignore") | |||||
| end | |||||
| def sync_license_file | |||||
| license = self.license | |||||
| return if license.blank? | |||||
| Gitlab.create_file(self.gpid, :file_path => "LICENSE", :branch_name => "master", | |||||
| :content => license.content, :commit_message => "LICENSE") | |||||
| end | |||||
| private | private | ||||
| def after_parent_changed(parent_was) | def after_parent_changed(parent_was) | ||||
| @@ -1225,7 +1249,7 @@ class Project < ActiveRecord::Base | |||||
| def update_position_under_parent | def update_position_under_parent | ||||
| set_or_update_position_under(parent) | set_or_update_position_under(parent) | ||||
| end | end | ||||
| def course | def course | ||||
| @course | @course | ||||
| end | end | ||||
| @@ -1258,7 +1282,7 @@ class Project < ActiveRecord::Base | |||||
| def create_board_sync | def create_board_sync | ||||
| @board = self.boards.build | @board = self.boards.build | ||||
| @board.name = " #{l(:label_borad_project) }" | @board.name = " #{l(:label_borad_project) }" | ||||
| @board.description = self.name.to_s | |||||
| @board.description = self.name.to_s | |||||
| if @board.save | if @board.save | ||||
| logger.debug "[Project Model] ===> #{@board.to_json}" | logger.debug "[Project Model] ===> #{@board.to_json}" | ||||
| else | else | ||||
| @@ -1310,4 +1334,3 @@ class Project < ActiveRecord::Base | |||||
| end | end | ||||
| #Project.where('is_public = 1').import :force=>true | #Project.where('is_public = 1').import :force=>true | ||||
| @@ -0,0 +1,9 @@ | |||||
| # 项目类别 | |||||
| class ProjectCategory < ActiveRecord::Base | |||||
| attr_accessible :name, :position, :projects_count | |||||
| # has_ancestry | |||||
| has_many :projects | |||||
| scope :desc_with_position, -> { order('position DESC') } | |||||
| end | |||||
| @@ -0,0 +1,8 @@ | |||||
| # 项目语言 | |||||
| class ProjectLanguage < ActiveRecord::Base | |||||
| attr_accessible :name, :position, :projects_count | |||||
| has_many :projects | |||||
| scope :desc_with_position, -> { order('position DESC') } | |||||
| end | |||||
| @@ -1,9 +1,15 @@ | |||||
| class School < ActiveRecord::Base | class School < ActiveRecord::Base | ||||
| attr_accessible :name, :province,:pinyin | attr_accessible :name, :province,:pinyin | ||||
| after_create :sync_schools_count_to_home | |||||
| has_many :courses | has_many :courses | ||||
| def to_s | def to_s | ||||
| self.name.to_s | self.name.to_s | ||||
| end | end | ||||
| def sync_schools_count_to_home | |||||
| HomesService.new.sync_count('school', 1) if Rails.env.production? && Setting.host_name == "www.trustie.net" | |||||
| end | |||||
| end | end | ||||
| @@ -31,6 +31,10 @@ class StudentWork < ActiveRecord::Base | |||||
| student_work_tests.order('id desc').first | student_work_tests.order('id desc').first | ||||
| end | end | ||||
| def get_project | |||||
| GetForgeProjectService.new.call(project_id).first | |||||
| end | |||||
| private | private | ||||
| def set_program_score | def set_program_score | ||||
| if self.homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分 | if self.homework_common.is_program_homework? #编程作业,学生提交作品后计算系统得分 | ||||
| @@ -3,10 +3,7 @@ class Syllabus < ActiveRecord::Base | |||||
| include Redmine::SafeAttributes | include Redmine::SafeAttributes | ||||
| include ApplicationHelper | include ApplicationHelper | ||||
| #elasticsearch | #elasticsearch | ||||
| include Elasticsearch::Model | |||||
| #elasticsearch kaminari init | |||||
| Kaminari::Hooks.init | |||||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||||
| include EsSearchable | |||||
| settings index: { number_of_shards: 5 } do | settings index: { number_of_shards: 5 } do | ||||
| mappings dynamic: 'false' do | mappings dynamic: 'false' do | ||||
| indexes :title, analyzer: 'smartcn',index_options: 'offsets' | indexes :title, analyzer: 'smartcn',index_options: 'offsets' | ||||
| @@ -16,20 +16,16 @@ | |||||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
| require "digest/sha1" | require "digest/sha1" | ||||
| require 'elasticsearch/model' | |||||
| class User < Principal | class User < Principal | ||||
| TEACHER = 0 | TEACHER = 0 | ||||
| STUDENT = 1 | STUDENT = 1 | ||||
| ENTERPRISE = 2 | ENTERPRISE = 2 | ||||
| DEVELOPER = 3 | DEVELOPER = 3 | ||||
| include Redmine::SafeAttributes | include Redmine::SafeAttributes | ||||
| seems_rateable_rater | seems_rateable_rater | ||||
| #elasticsearch | #elasticsearch | ||||
| include Elasticsearch::Model | |||||
| #elasticsearch kaminari init | |||||
| Kaminari::Hooks.init | |||||
| Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari | |||||
| include EsSearchable | |||||
| settings index: { number_of_shards: 5 } do | settings index: { number_of_shards: 5 } do | ||||
| mappings dynamic: 'false' do | mappings dynamic: 'false' do | ||||
| indexes :login, analyzer: 'smartcn',index_options: 'offsets' | indexes :login, analyzer: 'smartcn',index_options: 'offsets' | ||||
| @@ -137,12 +133,16 @@ class User < Principal | |||||
| has_many :versions, :dependent => :destroy | has_many :versions, :dependent => :destroy | ||||
| has_many :organizations, :through => :org_members | has_many :organizations, :through => :org_members | ||||
| # belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang | # belongs_to :ucourse, :class_name => 'Course', :foreign_key => :id #huang | ||||
| ## added by xianbo for delete | |||||
| ## added by xianbo for delete | |||||
| # has_many :biding_projects, :dependent => :destroy | # has_many :biding_projects, :dependent => :destroy | ||||
| belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy | belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy | ||||
| ##ended by xianbo | ##ended by xianbo | ||||
| #####fq | #####fq | ||||
| # 新版私信 | |||||
| has_many :private_messages, dependent: :destroy | |||||
| has_many :recent_contacts, through: :private_messages, source: :target | |||||
| has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy | has_many :jours, :class_name => 'JournalsForMessage', :dependent => :destroy | ||||
| has_many :journals_messages, :class_name => 'JournalsForMessage', :foreign_key => "user_id", :dependent => :destroy | has_many :journals_messages, :class_name => 'JournalsForMessage', :foreign_key => "user_id", :dependent => :destroy | ||||
| # has_many :bids, :foreign_key => 'author_id', :dependent => :destroy | # has_many :bids, :foreign_key => 'author_id', :dependent => :destroy | ||||
| @@ -174,6 +174,7 @@ class User < Principal | |||||
| has_one :onclick_time | has_one :onclick_time | ||||
| has_many :system_messages | has_many :system_messages | ||||
| has_many :at_messages | has_many :at_messages | ||||
| has_many :message_alls | |||||
| # 虚拟转换 | # 虚拟转换 | ||||
| has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" | has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" | ||||
| @@ -206,15 +207,15 @@ class User < Principal | |||||
| scope :visible, lambda {|*args| | scope :visible, lambda {|*args| | ||||
| nil | nil | ||||
| } | } | ||||
| acts_as_attachable :view_permission => :view_files, | acts_as_attachable :view_permission => :view_files, | ||||
| :delete_permission => :manage_files | :delete_permission => :manage_files | ||||
| acts_as_customizable | acts_as_customizable | ||||
| ############################added by william | ############################added by william | ||||
| acts_as_taggable | |||||
| acts_as_taggable | |||||
| scope :by_join_date, order("created_on DESC") | scope :by_join_date, order("created_on DESC") | ||||
| ############################# added by liuping 关注 | ############################# added by liuping 关注 | ||||
| acts_as_watchable | |||||
| acts_as_watchable | |||||
| has_one :user_extensions,:dependent => :destroy | has_one :user_extensions,:dependent => :destroy | ||||
| has_one :homepage, :dependent => :destroy | has_one :homepage, :dependent => :destroy | ||||
| @@ -262,7 +263,7 @@ class User < Principal | |||||
| before_save :update_hashed_password | before_save :update_hashed_password | ||||
| before_destroy :remove_references_before_destroy,:delete_user_ealasticsearch_index | before_destroy :remove_references_before_destroy,:delete_user_ealasticsearch_index | ||||
| # added by fq | # added by fq | ||||
| after_create :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index,:add_new_jour | |||||
| after_create :add_onclick_time, :act_as_principal_activity,:create_user_ealasticsearch_index,:add_new_jour, :sync_to_home | |||||
| # end | # end | ||||
| # 更新邮箱用户或用户名的同事,同步更新邀请信息 | # 更新邮箱用户或用户名的同事,同步更新邀请信息 | ||||
| after_update :update_user_ealasticsearch_index | after_update :update_user_ealasticsearch_index | ||||
| @@ -324,6 +325,11 @@ class User < Principal | |||||
| ) | ) | ||||
| end | end | ||||
| # 同步新增首页的社区用户量 | |||||
| def sync_to_home | |||||
| HomesService.new.sync_count('user', 1) if Rails.env.production? && Setting.host_name == "www.trustie.net" | |||||
| end | |||||
| # ====================================================================== | # ====================================================================== | ||||
| def my_workplace | def my_workplace | ||||
| self.user_extensions.try(:occupation).to_s | self.user_extensions.try(:occupation).to_s | ||||
| @@ -336,6 +342,24 @@ class User < Principal | |||||
| (self.login.to_i.to_s == self.login || self.login.include?(".") || self.login.include?("%") || self.login.include?("?")) ? id : login | (self.login.to_i.to_s == self.login || self.login.include?(".") || self.login.include?("%") || self.login.include?("?")) ? id : login | ||||
| end | end | ||||
| def check_user_him(user_id) | |||||
| if id == user_id | |||||
| "我" | |||||
| else | |||||
| "TA" | |||||
| end | |||||
| end | |||||
| def get_user_contact_messages(user_id) | |||||
| private_messages.where(target_id: user_id).size | |||||
| end | |||||
| #判断是否可以点击项目或issue | |||||
| def user_can_see_project(target) | |||||
| return false if target.blank? | |||||
| self.admin? || target.is_public || target.user_id == id || User.current.member_of?(target) | |||||
| end | |||||
| def my_blogs_count | def my_blogs_count | ||||
| self.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count | self.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count | ||||
| @@ -386,34 +410,153 @@ class User < Principal | |||||
| @base_homepage | @base_homepage | ||||
| end | end | ||||
| def get_user_projects | |||||
| projects.order("updated_on desc") | |||||
| end | |||||
| #未解决的issue | |||||
| def user_unsolve_issues | |||||
| Issue.where(:assigned_to_id => id, :status_id => [1, 2, 4, 6]).includes(:author, :project).order("updated_on desc") | |||||
| end | |||||
| def project_relate_messages | |||||
| sql = "SELECT * FROM `message_alls` ma left join `forge_messages` fm on ma.message_id=fm.id | |||||
| left join `applied_messages` apm on ma.message_id=apm.id | |||||
| where (ma.user_id =#{id} and ma.message_type = 'ForgeMessage' and fm.user_id=#{id} and fm.forge_message_type != 'News') or | |||||
| (ma.user_id=#{id} and ma.message_type='AppliedMessage' and apm.applied_type = 'AppliedProject' and apm.user_id =#{id}) ORDER BY ma.created_at desc;" | |||||
| MessageAll.find_by_sql(sql) | |||||
| end | |||||
| #其他用户的项目消息 | |||||
| def other_project_relate_messages(project_ids) | |||||
| sql = "SELECT * FROM `message_alls` ma left join `forge_messages` fm on fm.project_id in #{project_ids} and ma.message_id=fm.id | |||||
| left join `applied_messages` apm on apm.project_id in #{project_ids} and ma.message_id=apm.id | |||||
| where (ma.user_id =#{id} and ma.message_type = 'ForgeMessage' and fm.user_id=#{id} and fm.forge_message_type != 'News') or | |||||
| (ma.user_id=#{id} and ma.message_type='AppliedMessage' and apm.applied_type = 'AppliedProject' and apm.user_id =#{id}) ORDER BY ma.created_at desc;" | |||||
| MessageAll.find_by_sql(sql) | |||||
| end | |||||
| #未处理的消息通知 | |||||
| def user_unsolve_messages | |||||
| sql = "SELECT * FROM `message_alls` ma left join `forge_messages` fm on ma.message_id=fm.id | |||||
| left join `course_messages` cm on ma.message_id=cm.id left join `applied_messages` apm on ma.message_id=apm.id | |||||
| where (ma.user_id =#{id} and ma.message_type = 'ForgeMessage' and fm.forge_message_type='PullRequest' and fm.status=0 and fm.user_id=#{id}) or | |||||
| (ma.user_id=#{id} and ma.message_type='AppliedMessage' and apm.applied_type in ('Organization', 'AppliedContest', 'StudentWorksScoresAppeal', 'AppliedProject', 'ApplyAddSchools') and apm.user_id =#{id} and apm.status =0) or | |||||
| (ma.user_id=#{id} and ma.message_type='CourseMessage' and cm.course_message_type='JoinCourseRequest' and cm.status=0 and cm.user_id=#{id}) ORDER BY ma.created_at desc;" | |||||
| MessageAll.find_by_sql(sql) | |||||
| end | |||||
| def get_user_course_ids #获取用户的全部课堂id | |||||
| StudentsForCourse.includes(:course).where("student_id = #{id} and courses.is_delete = 0").map{|sf| sf.try(:course_id)} | |||||
| end | |||||
| def user_undo_homeworks | |||||
| user_course_ids = get_user_course_ids #学生的全部课堂 | |||||
| publish_homeworks = HomeworkCommon.where(course_id: user_course_ids)&.where("publish_time <= '#{Time.now}'") #已发布的作业 | |||||
| publish_homeworks_ids = publish_homeworks.pluck(:id) | |||||
| user_homeworks = student_works&.where(homework_common_id: publish_homeworks_ids) | |||||
| finished_user_homework_ids = user_homeworks&.where("work_status != 0").pluck(:homework_common_id) #用户已完成的作业 | |||||
| publish_homeworks.where(id: (publish_homeworks_ids - finished_user_homework_ids)).order("updated_at desc") | |||||
| end | |||||
| #待完成测验 | |||||
| def user_undo_tests | |||||
| user_course_ids = get_user_course_ids #学生的全部课堂 | |||||
| publish_exercises = Exercise.where(course_id: user_course_ids, exercise_status: 2) #已发布的作业 | |||||
| publish_exercises_ids = publish_exercises.pluck(:id).uniq | |||||
| finished_user_exercises_ids = exercise_user&.where(exercise_id: publish_exercises_ids, commit_status: 1).pluck(:exercise_id).uniq | |||||
| publish_exercises.where(id: (publish_exercises_ids - finished_user_exercises_ids)).order("updated_at desc") | |||||
| end | |||||
| #待完成的问卷 | |||||
| def user_undo_polls | |||||
| user_course_ids = get_user_course_ids #学生的全部课堂 | |||||
| publish_polls = Poll.where(polls_type: "Course",polls_group_id: user_course_ids, polls_status: 2) | |||||
| publish_polls_ids = publish_polls.pluck(:id).uniq | |||||
| finished_user_polls_ids = poll_users&.where(poll_id: publish_polls_ids).pluck(:poll_id).uniq | |||||
| publish_polls.where(id: (publish_polls_ids - finished_user_polls_ids)).order("updated_at desc") | |||||
| end | |||||
| #待完成的匿评作品 | |||||
| def user_undo_anonymous | |||||
| user_course_ids = get_user_course_ids #学生的全部课堂 | |||||
| homework_anonymous_works = HomeworkCommon.where(course_id: user_course_ids).includes(:homework_detail_manual).where("homework_detail_manuals.comment_status in (1,2)") | |||||
| homework_ids = homework_anonymous_works.map{|h| h.try(:id)} | |||||
| user_student_work_scores = student_works_scores.where(reviewer_role: 3) | |||||
| anonymous_evaluation_ids = user_student_work_scores.blank? ? "(-1)" : "(#{user_student_work_scores.pluck(:student_work_id).join(",")})" | |||||
| unfinished_evaluations_work_ids = student_works_evaluation_distributions.where("student_work_id not in #{anonymous_evaluation_ids}").pluck(:student_work_id) | |||||
| homework_ids = StudentWork.where(id: unfinished_evaluations_work_ids, homework_common_id: homework_ids ).pluck(:homework_common_id) | |||||
| homework_anonymous_works.where(id: homework_ids) | |||||
| end | |||||
| #用户的待办事项计数,包括通知和issue的数量 | |||||
| def count_undo_items | |||||
| issues_count = user_unsolve_issues.count | |||||
| apply_messages_count = user_unsolve_messages.count | |||||
| undo_homeworks_count = user_undo_homeworks.size | |||||
| undo_tests_count = user_undo_tests.size | |||||
| undo_polls_count = user_undo_polls.size | |||||
| undo_anonymous_count = user_undo_anonymous.size | |||||
| issues_count + apply_messages_count + undo_homeworks_count + undo_tests_count + undo_polls_count + undo_anonymous_count | |||||
| end | |||||
| # 查询指派给我的缺陷记录 | # 查询指派给我的缺陷记录 | ||||
| def count_new_issue_assign_to | def count_new_issue_assign_to | ||||
| self.issue_assigns | self.issue_assigns | ||||
| end | end | ||||
| # 新消息统计 | |||||
| def count_new_message | |||||
| if OnclickTime.where("user_id =?", User.current).first.nil? | |||||
| # 新消息统计, | |||||
| def count_new_message(type) | |||||
| message_new_time = OnclickTime.where(user_id: id).first | |||||
| if message_new_time.nil? | |||||
| message_new_time = OnclickTime.new | message_new_time = OnclickTime.new | ||||
| message_new_time.user_id = User.current.id | |||||
| message_new_time.user_id = id | |||||
| # 第一次初始化点击铃铛时间 | # 第一次初始化点击铃铛时间 | ||||
| message_new_time.onclick_time = User.current.last_login_on.nil? ? Time.now : User.current.last_login_on | |||||
| message_new_time.onclick_time = last_login_on.nil? ? Time.now : last_login_on | |||||
| message_new_time.save | message_new_time.save | ||||
| end | end | ||||
| user = User.current | user = User.current | ||||
| onclick_time = user.onclick_time.onclick_time | |||||
| delete_courses = Course.where(:is_delete => 1).blank? ? "(-1)" : "(" + Course.where(:is_delete => 1).map(&:id).join(",") + ")" | |||||
| course_count = CourseMessage.where("user_id =? and viewed =? and created_at >? and course_id not in #{delete_courses}", user.id, 0, onclick_time).count | |||||
| contest_count = ContestMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count | |||||
| forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count | |||||
| user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count | |||||
| user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count | |||||
| system_messages_count = SystemMessage.where("created_at >?", onclick_time).count | |||||
| at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count | |||||
| org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).count | |||||
| applied_count = AppliedMessage.where("user_id=? and viewed =? and created_at >?", user.id, 0, onclick_time).count | |||||
| blog_message_count = BlogMessage.where("user_id=? and viewed=? and created_at >?", user.id, 0, onclick_time).count | |||||
| messages_count = course_count + contest_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count + blog_message_count | |||||
| if type == "all" | |||||
| onclick_time = user.onclick_time.onclick_time | |||||
| delete_courses = Course.where(:is_delete => 1).blank? ? "(-1)" : "(" + Course.where(:is_delete => 1).map(&:id).join(",") + ")" | |||||
| course_count = CourseMessage.where("user_id =? and viewed =? and created_at >? and course_id not in #{delete_courses}", user.id, 0, onclick_time).size | |||||
| contest_count = ContestMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).size | |||||
| forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).size | |||||
| user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).size | |||||
| user_memo_count = MemoMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).size | |||||
| system_messages_count = SystemMessage.where("created_at >?", onclick_time).size | |||||
| at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).size | |||||
| org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).size | |||||
| applied_count = AppliedMessage.where("user_id=? and viewed =? and created_at >?", user.id, 0, onclick_time).size | |||||
| blog_message_count = BlogMessage.where("user_id=? and viewed=? and created_at >?", user.id, 0, onclick_time).size | |||||
| # private_messages_count = PrivateMessage.where("user_id=? and status=?",user.id, 0).size | |||||
| messages_count = course_count + contest_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count + blog_message_count | |||||
| else | |||||
| Rails.logger.info("######________type__________##########{type}") | |||||
| message_new_time.update_attribute(:onclick_time, Time.now) | |||||
| CourseMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| ForgeMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| UserFeedbackMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| MemoMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| OrgMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| AtMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| ContestMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| BlogMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| AppliedMessage.where(user_id: user.id)&.update_all(:viewed => true) | |||||
| messages_count = 0 | |||||
| end | |||||
| messages_count | |||||
| end | |||||
| def get_user_messages | |||||
| message_alls.includes(:message) | |||||
| end | |||||
| #未读私信数量 | |||||
| def unread_private_messages | |||||
| private_messages.where(status: 0).size | |||||
| end | end | ||||
| # 查询指派给我的缺陷记录 | # 查询指派给我的缺陷记录 | ||||
| @@ -447,18 +590,18 @@ class User < Principal | |||||
| end | end | ||||
| info | info | ||||
| end | end | ||||
| ###添加留言 fq | ###添加留言 fq | ||||
| def add_jour(user, notes, reference_user_id = 0, options = {}) | def add_jour(user, notes, reference_user_id = 0, options = {}) | ||||
| if options.count == 0 | if options.count == 0 | ||||
| self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true, :is_readed => false) | self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true, :is_readed => false) | ||||
| else | |||||
| else | |||||
| jfm = self.journals_for_messages.build(options) | jfm = self.journals_for_messages.build(options) | ||||
| jfm.save | jfm.save | ||||
| jfm | jfm | ||||
| end | end | ||||
| end | end | ||||
| ### fq | ### fq | ||||
| def join_in?(course) | def join_in?(course) | ||||
| joined = StudentsForCourse.where('student_id = ? and course_id = ?', self.id, course.id) | joined = StudentsForCourse.where('student_id = ? and course_id = ?', self.id, course.id) | ||||
| @@ -468,7 +611,7 @@ class User < Principal | |||||
| false | false | ||||
| end | end | ||||
| end | end | ||||
| def show_name | def show_name | ||||
| name = lastname + firstname | name = lastname + firstname | ||||
| name.empty? || name.nil? ? login : name | name.empty? || name.nil? ? login : name | ||||
| @@ -485,12 +628,12 @@ class User < Principal | |||||
| name = show_name | name = show_name | ||||
| (name != self.login) ? "#{name} #{self.login}" : name | (name != self.login) ? "#{name} #{self.login}" : name | ||||
| end | end | ||||
| #added by nie | #added by nie | ||||
| def count_new_journal_reply | def count_new_journal_reply | ||||
| count = self.journal_reply.count | count = self.journal_reply.count | ||||
| end | end | ||||
| def set_mail_notification | def set_mail_notification | ||||
| ##add byxianbo | ##add byxianbo | ||||
| thread=Thread.new do | thread=Thread.new do | ||||
| @@ -1,8 +1,19 @@ | |||||
| class WebFooterCompany < ActiveRecord::Base | class WebFooterCompany < ActiveRecord::Base | ||||
| attr_accessible :logo_size, :name, :url | |||||
| # key字段说明: | |||||
| # partner:网站页脚合作单位(管理员页面页脚), dedicator: 首页技术合作单位; opensource: 首页共建开源单位 | |||||
| RELATION_TYPE = %w(partner dedicator opensource) | |||||
| acts_as_list | |||||
| attr_accessible :logo_size, :name, :url, :position, :move_to, :key | |||||
| validates :name, presence: true, length: { maximum: 500 } | validates :name, presence: true, length: { maximum: 500 } | ||||
| validates :key, inclusion: { in: %w(partner dedicator opensource), message: "%{value} is not a valid value." } | |||||
| validates :url, length: { maximum: 500 }, | validates :url, length: { maximum: 500 }, | ||||
| format: { with: /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/, | format: { with: /(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?/, | ||||
| message: :invalid | message: :invalid | ||||
| } | } | ||||
| scope :desc, -> { order('position ASC') } | |||||
| scope :partners, -> { desc.where(:key => 'partner') } | |||||
| scope :dedicators, -> { desc.where(:key => 'dedicator') } | |||||
| scope :opensources, -> { desc.where(:key => 'opensource') } | |||||
| end | end | ||||
| @@ -0,0 +1,9 @@ | |||||
| class DynamicNewsService | |||||
| def sync(news_params) | |||||
| if news_params["category_id"].blank? | |||||
| default_category = Category.find_by_name "社区动态" | |||||
| news_params = news_params.merge({category_id: default_category&.id}) | |||||
| end | |||||
| DynamicNew.create!(news_params) | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,24 @@ | |||||
| class GetForgeProjectService | |||||
| require 'uri' | |||||
| require 'net/http' | |||||
| def call(project_ids) | |||||
| all_group_projects = [] | |||||
| project_url = "#{Redmine::Configuration['sync_forge_url']}" | |||||
| url = "#{project_url}/api/users/trustie_related_projects.json" #trustie上的相关路由 | |||||
| sync_params = { | |||||
| ids: project_ids, | |||||
| } | |||||
| uri = URI.parse(url) | |||||
| http = Net::HTTP.new(uri.hostname, uri.port) | |||||
| http.use_ssl = project_url.include?("forgeplus.trustie.net") | |||||
| response = http.send_request('GET', uri.path, sync_params.to_json, {'Content-Type' => 'application/json'}) | |||||
| if response.code == "200" | |||||
| all_group_projects = eval(response.body)[:projects] | |||||
| end | |||||
| return all_group_projects | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,15 @@ | |||||
| class HomesService | |||||
| def sync_count(type, sync_count) | |||||
| home = Home.first | |||||
| case type | |||||
| when "user" | |||||
| home.update_attributes!(users_count: home.users_count + sync_count) | |||||
| when "project" | |||||
| home.update_attributes!(projects_count: home.projects_count + sync_count) | |||||
| when 'school' | |||||
| home.update_attributes!(scholls_count: home.scholls_count + sync_count) | |||||
| when "practical_training_project" | |||||
| home.update_attributes!(practical_training_projects_count: home.practical_training_projects_count + sync_count) | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,29 @@ | |||||
| class SyncNewUserTask | |||||
| # 运行示例: bundle exec rails runner "SyncNewUserTask.new.call()" | |||||
| def call | |||||
| Rails.logger.info("##########_______sync_updated_users_start________###########") | |||||
| updated_time = "2020-04-20".to_date | |||||
| new_users = User.includes(:user_extensions).where("date(created_on) >= ?", updated_time) | |||||
| user_params = [] | |||||
| if new_users.present? | |||||
| new_users.each do |user| | |||||
| user_extension = user&.user_extensions&.as_json(:except => [:id, :user_id]) | |||||
| user_params.push({ | |||||
| user_params: user.as_json(:except => [:id]).values[0], | |||||
| user_extensions: user_extension | |||||
| }) | |||||
| end | |||||
| end | |||||
| if user_params.present? | |||||
| new_user_params = { | |||||
| users: user_params, | |||||
| token: "#{Redmine::Configuration['sync_token']}" | |||||
| } | |||||
| SyncNewUserJob.new.perform(new_user_params) | |||||
| else | |||||
| Rails.logger.info("##########_______no_updated_users________###########") | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,91 @@ | |||||
| # 同步自上一次同步的新的项目数据, 2020-04-20 | |||||
| # 运行示例: bundle exec rails runner "SyncProjectsForgeTask.new.call()" | |||||
| class SyncProjectsForgeTask | |||||
| def call | |||||
| Rails.logger.info("##########_______sync_updated_projects_start________###########") | |||||
| updated_time = "2020-04-20".to_date | |||||
| updated_projects = Project.select([:id, :updated_on]).where("date(updated_on) >= ?", updated_time).pluck(:id) #更新的项目 | |||||
| updated_project_scrores = ProjectScore.select([:id, :project_id, :updated_at]).where("DATE(updated_at) >= ?", updated_time).pluck(:project_id).uniq.map(&:to_i) | |||||
| g = Gitlab.client | |||||
| total_project_ids = (updated_projects + updated_project_scrores).uniq | |||||
| all_projects = Project.includes(:versions,:repository,:project_score, :issues, :members, :owner).where(id: total_project_ids) | |||||
| all_projects.each do |p| | |||||
| #仓库 | |||||
| g_project = p.gpid ? g.project(p.gpid) : nil | |||||
| identifier = p.repository.present? ? p.repository.try(:identifier) : p.try(:identifier) | |||||
| if g_project | |||||
| gitlab_branches = g.branches(p.gpid).map{|b| b.name} | |||||
| # identifier = p.repository.try(:identifier) | |||||
| repository_params = { | |||||
| id: p&.repository&.id, | |||||
| identifier: identifier, | |||||
| git_url: g_project.try(:http_url_to_repo), | |||||
| gitlab_branches: gitlab_branches | |||||
| } | |||||
| end | |||||
| #成员 | |||||
| member_ids = p.members.map(&:id) | |||||
| member_params = { | |||||
| ids: member_ids, | |||||
| count: member_ids.size | |||||
| } | |||||
| #工单及评论 | |||||
| issue_ids = p&.issues&.select(:id)&.pluck(:id) | |||||
| journal_ids = Journal.select([:id, :journalized_id, :journalized_type]).where(journalized_id: issue_ids).pluck(:id) | |||||
| issue_params = { | |||||
| ids: issue_ids, | |||||
| count: issue_ids.size, | |||||
| journals: { | |||||
| ids: journal_ids, | |||||
| count: journal_ids.size, | |||||
| } | |||||
| } | |||||
| #project_score | |||||
| project_score = p&.project_score.as_json(:except=>[:created_at, :updated_at, :project_id, :id])&.values[0] | |||||
| #里程碑 | |||||
| project_version_ids = p&.versions.select(:id)&.pluck(:id) | |||||
| project_versions = { | |||||
| ids: project_version_ids, | |||||
| count: project_version_ids.size | |||||
| } | |||||
| #关注者 | |||||
| project_watcher_ids = p.watchers.select(:id).pluck(:id) | |||||
| project_watchers = { | |||||
| ids: project_watcher_ids, | |||||
| count: project_watcher_ids.size | |||||
| } | |||||
| #点赞 | |||||
| praise_trend_ids = p.praise_tread.select(:id).pluck(:id) | |||||
| praise_trends = { | |||||
| ids: praise_trend_ids, | |||||
| count: praise_trend_ids.size | |||||
| } | |||||
| project_params = { | |||||
| id: p.id, | |||||
| name: p.try(:name), | |||||
| owner_login: p.owner.try(:login), | |||||
| fork_from_project_id: p.forked_from_project_id, | |||||
| identifier: identifier, | |||||
| is_public: p.try(:is_public), | |||||
| repository: repository_params, | |||||
| members: member_params, | |||||
| issues: issue_params, | |||||
| project_score: project_score, | |||||
| project_versions: project_versions, | |||||
| project_watchers: project_watchers, | |||||
| praise_trends: praise_trends, | |||||
| token: "#{Redmine::Configuration['sync_token']}" | |||||
| } | |||||
| SyncProjectsForgeJob.new.perform(project_params) | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,197 @@ | |||||
| #project的includes应该是包括(:versions, :project_score, :repository,:commits, issues: [:journals,:commit_issues]),但是repository表,commits表,commit_issues表没有,trustie上有。 | |||||
| # | |||||
| # 运行示例: bundle exec rails runner "SyncUserForgeTask.new.call()" | |||||
| class SyncUserForgeTask | |||||
| def call | |||||
| Rails.logger.info("##########_______sync_start________###########") | |||||
| all_users = User.where("login is not null and mail is not null and type = ?", "User") | |||||
| # 这里再把所有用户循环 | |||||
| all_users.each do |u| | |||||
| user_params = u.as_json | |||||
| user_extension_params = u.try(:user_extensions).as_json || [] | |||||
| target_params = [] | |||||
| user_projects = Project.includes(:versions,:repository,:project_score, issues: [journals: :details],owner: [:user_extensions], members: [roles: [:member_roles]]).where(user_id: u.id) | |||||
| if user_projects.present? | |||||
| user_projects.each do |p| | |||||
| identifier = p.try(:identifier) | |||||
| if p.repository.present? && p.repository.try(:identifier).present? | |||||
| identifier = p.repository.try(:identifier) | |||||
| end | |||||
| member_params = get_members(p.members,p) | |||||
| watchers_params = get_watchers(p.watchers) | |||||
| praise_trends_params = get_praises(p.id) | |||||
| issue_params = get_issues(p, u.id) | |||||
| project_params = p.as_json | |||||
| project_params["project"]["identifier"] = identifier | |||||
| project_params["project"]["watchers_count"] = watchers_params.size | |||||
| project_params["project"]["issues_count"] = issue_params.size | |||||
| project_params["project"]["praises_count"] = praise_trends_params.size | |||||
| versions_params = get_versions(p) | |||||
| project_score_params = get_scores(p) | |||||
| pull_request_params = get_prs(p.id) | |||||
| repo_params = get_repository(p) #repository的内容 | |||||
| commit_params = get_commits(p.id) | |||||
| relate_project_params = { | |||||
| project_params: project_params, | |||||
| member_params: member_params, | |||||
| issue_params: issue_params, | |||||
| versions_params: versions_params, | |||||
| project_score_params: project_score_params, | |||||
| pull_request_params: pull_request_params, | |||||
| repo_params: repo_params, | |||||
| commit_params: commit_params, | |||||
| watchers_params: watchers_params, | |||||
| praise_trends_params: praise_trends_params | |||||
| } | |||||
| target_params.push(relate_project_params) | |||||
| end | |||||
| end | |||||
| roles = Role.all.as_json | |||||
| sync_params = { | |||||
| user_params: {user_params: user_params, user_extension_params: user_extension_params}, | |||||
| target_params: target_params, | |||||
| platform: "trustie", | |||||
| roles: roles | |||||
| } | |||||
| SyncUserForgeJob.new.perform(sync_params.to_json) | |||||
| # Delayed::Job.enqueue(SyncUserForgeJob.new(sync_params.to_json)) | |||||
| end | |||||
| end | |||||
| #工单的内容 | |||||
| def get_issues(project, user_id) | |||||
| issues_params = [] | |||||
| issues = project.issues.includes(:journals) | |||||
| if issues.present? | |||||
| issues.find_each do |i| | |||||
| issue_json = i.as_json | |||||
| jours_params = get_issue_journal(i, user_id) | |||||
| commit_params = get_issue_commit(i) | |||||
| issues_params.push( | |||||
| {issue_params: issue_json, | |||||
| jours_params: jours_params, | |||||
| commit_params: commit_params | |||||
| } | |||||
| ) | |||||
| end | |||||
| end | |||||
| issues_params | |||||
| end | |||||
| #里程碑的内容 | |||||
| def get_versions(project) | |||||
| versions_params = [] | |||||
| versions = project.versions | |||||
| versions.find_each do |i| | |||||
| versions_params.push(i.as_json) | |||||
| end | |||||
| versions_params | |||||
| end | |||||
| #project_score的内容 | |||||
| def get_scores(project) | |||||
| project.try(:project_score).as_json || [] | |||||
| end | |||||
| def get_prs(project_id) | |||||
| pr_params = [] | |||||
| prs = PullRequest.where(project_id: project_id) | |||||
| prs.find_each do |i| | |||||
| pr_params.push(i.as_json) | |||||
| end | |||||
| pr_params | |||||
| end | |||||
| def get_commits(project_id) | |||||
| pr_params = [] | |||||
| prs = Commit.where(project_id: project_id) | |||||
| prs.find_each do |i| | |||||
| pr_params.push(i.as_json) | |||||
| end | |||||
| pr_params | |||||
| end | |||||
| #repository的内容 | |||||
| def get_repository(project) | |||||
| project.try(:repository).as_json || [] | |||||
| # repo_params = [] | |||||
| # repo = project.repository | |||||
| # repo_params.push(repo.as_json) if repo.present? | |||||
| # repo_params | |||||
| end | |||||
| def get_issue_journal(issue, user_id) | |||||
| jour_params = [] | |||||
| jours = issue.journals | |||||
| if jours.present? | |||||
| jours.find_each do |j| | |||||
| j_json = j.as_json | |||||
| j_details = j.details.as_json | |||||
| j_params = {journal: j_json, j_details: j_details} | |||||
| jour_params.push(j_params) | |||||
| end | |||||
| end | |||||
| jour_params | |||||
| end | |||||
| def get_issue_commit(issue) | |||||
| commit_params = [] | |||||
| commits = CommitIssues.where(issue_id: issue.id) | |||||
| if commits.present? | |||||
| commits.find_each do |j| | |||||
| commit_params.push(j.as_json) | |||||
| end | |||||
| end | |||||
| commit_params | |||||
| end | |||||
| def get_members(members,project) | |||||
| member_params = [] | |||||
| if members.present? | |||||
| members.includes(:member_roles,user: :user_extensions).find_each do |m| | |||||
| member_user = m.user.as_json | |||||
| member_extension = m.user.try(:user_extensions).as_json || [] | |||||
| member_role = m.member_roles.as_json | |||||
| # member_issues = get_issues(project, m.user_id) | |||||
| get_member = { | |||||
| member: m.as_json, | |||||
| member_user: member_user, | |||||
| member_extension: member_extension, | |||||
| member_roles: member_role | |||||
| # member_issues: member_issues | |||||
| } | |||||
| member_params.push(get_member) | |||||
| end | |||||
| end | |||||
| member_params | |||||
| end | |||||
| def get_watchers(watchers) | |||||
| watcher_params = [] | |||||
| if watchers.present? | |||||
| watchers.find_each do |m| | |||||
| watcher_params.push(m.as_json) | |||||
| end | |||||
| end | |||||
| watcher_params | |||||
| end | |||||
| def get_praises(project_id) | |||||
| prasie_params = [] | |||||
| praise_trends = PraiseTread.where(praise_tread_object_id: project_id, praise_tread_object_type: "Project") | |||||
| if praise_trends.present? | |||||
| praise_trends.find_each do |m| | |||||
| prasie_params.push(m.as_json) | |||||
| end | |||||
| end | |||||
| prasie_params | |||||
| end | |||||
| end | |||||
| @@ -1,488 +0,0 @@ | |||||
| <% if false %> | |||||
| <div> | |||||
| <div class="clearfix homepage_banner"> | |||||
| <p class="fl"> | |||||
| <span class="f32">Trustie</span> | |||||
| <span class="fw400 ml20" style="line-height: 70px">持续构建协同、共享、可信的软件创新生态系统</span> | |||||
| </p> | |||||
| <ul class="fr homepage_banner_nav"> | |||||
| <li> | |||||
| <a href="javascript:void(0)">开源托管平台</a> | |||||
| </li> | |||||
| <li> | |||||
| <a href="javascript:void(0)">智能学习平台</a> | |||||
| </li> | |||||
| <li> | |||||
| <a href="javascript:void(0)">资源共享平台</a> | |||||
| </li> | |||||
| <li> | |||||
| <a href="javascript:void(0)">众包学习平台</a> | |||||
| </li> | |||||
| </ul> | |||||
| </div> | |||||
| <div class="pr mt60 banner"> | |||||
| <ul class="img"> | |||||
| <li><a href="javascript:void(0)"><img src="/images/introduce/trustie8_01.jpg"/></a></li> | |||||
| </ul> | |||||
| </div> | |||||
| <div class="homepage_activity"> | |||||
| <div class="mr35"> | |||||
| <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2634306427,1511025022&fm=26&gp=0.jpg" class="mb25" width="592px" height="226px" /> | |||||
| <p class="f26 lh26 color-grey3 mb15">关于Trustie</p> | |||||
| <p class="f16 c_grey02 break_full_word"> | |||||
| Trustie社区力争打造全球领先的群体协同创新平台,已建成协同开发创新、资源汇聚评估与智能学习实践三大平台,持续激发汇聚互联网上自治分散的海量智力资源,为全球软件创新生态助力赋能。 | |||||
| Trustie社区及其核心技术,直接支持了国家9个软件园区创新平台的建设,服务于2500余家中小型软件企业研发和5000余个创新项目孵化,以及600多所大学软件开发人才培养, | |||||
| 已成为国家新一代人工智能发展规划重点开源社区和国家绿色计算基础软硬件开源社区的基础设施,直接推动了我国开源软件生态的快速构建。 | |||||
| </p> | |||||
| <a href="JavaScript:void(0)" class="homepage_activity_more">MORE<span>→</span></a> | |||||
| </div> | |||||
| <div> | |||||
| <p class="clearfix mb10"> | |||||
| <span class="f26 lh26 color-grey3 fl mt3">社区动态</span> | |||||
| <a href="javaScript:void(0)" class="fr fontGrey4 mt8">更多>></a> | |||||
| </p> | |||||
| <div class="homepage_activity_list"> | |||||
| <div class="homepage_activity_list_item"> | |||||
| <div> | |||||
| <p class="f18 mb15 lh20 color-grey3">工业互联网体系架构2.0</p> | |||||
| <p class="f13 mb8 c_grey02 task-hide-2" style="height: 38px;">网易考拉是网易在 2015 年 1 月上线公测的一项跨境电商业务,该业务一开始的品牌名称为 “考拉海购”。</p> | |||||
| <p> | |||||
| <span class="activity_tag">行业动态</span> | |||||
| <span class="fontGrey4 ml14 fl"><i class="iconfont icon-shijian f12 mr5 lh18 fl"></i>2019-10-09</span> | |||||
| </p> | |||||
| </div> | |||||
| <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2634306427,1511025022&fm=26&gp=0.jpg" class="ml20" width="158px" height="100px" /> | |||||
| </div> | |||||
| <div class="homepage_activity_list_item"> | |||||
| <div> | |||||
| <p class="f18 mb15 lh20 color-grey3">工业互联网体系架构2.0</p> | |||||
| <p class="f13 mb8 c_grey02 task-hide-2" style="height: 38px;">网易考拉是网易在 2015 年 1 月上线公测的一项跨境电商业务,该业务一开始的品牌名称为 “考拉海购”。</p> | |||||
| <p> | |||||
| <span class="activity_tag">行业动态</span> | |||||
| <span class="fontGrey4 ml14 fl"><i class="iconfont icon-shijian f12 mr5 lh18 fl"></i>2019-10-09</span> | |||||
| </p> | |||||
| </div> | |||||
| <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2634306427,1511025022&fm=26&gp=0.jpg" class="ml20" width="158px" height="100px" /> | |||||
| </div> | |||||
| <div class="homepage_activity_list_item"> | |||||
| <div> | |||||
| <p class="f18 mb15 lh20 color-grey3">工业互联网体系架构2.0</p> | |||||
| <p class="f13 mb8 c_grey02 task-hide-2" style="height: 38px;">网易考拉是网易在 2015 年 1 月上线公测的一项跨境电商业务,该业务一开始的品牌名称为 “考拉海购”。</p> | |||||
| <p> | |||||
| <span class="activity_tag">行业动态</span> | |||||
| <span class="fontGrey4 ml14 fl"><i class="iconfont icon-shijian f12 mr5 lh18 fl"></i>2019-10-09</span> | |||||
| </p> | |||||
| </div> | |||||
| <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2634306427,1511025022&fm=26&gp=0.jpg" class="ml20" width="158px" height="100px" /> | |||||
| </div> | |||||
| <div class="homepage_activity_list_item"> | |||||
| <div> | |||||
| <p class="f18 mb15 lh20 color-grey3">工业互联网体系架构2.0</p> | |||||
| <p class="f13 mb8 c_grey02 task-hide-2" style="height: 38px;">网易考拉是网易在 2015 年 1 月上线公测的一项跨境电商业务,该业务一开始的品牌名称为 “考拉海购”。</p> | |||||
| <p> | |||||
| <span class="activity_tag">行业动态</span> | |||||
| <span class="fontGrey4 ml14 fl"><i class="iconfont icon-shijian f12 mr5 lh18 fl"></i>2019-10-09</span> | |||||
| </p> | |||||
| </div> | |||||
| <img src="https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2634306427,1511025022&fm=26&gp=0.jpg" class="ml20" width="158px" height="100px" /> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div class="homepage_introduce"> | |||||
| <ul> | |||||
| <li class="active"> | |||||
| <div> | |||||
| <img src="/images/nav_logo.png" width="50" class="mb40"> | |||||
| <p class="f18">TrustieForge</p> | |||||
| </div> | |||||
| </li> | |||||
| <li> | |||||
| <div> | |||||
| <img src="/images/introduce/edulogo.png" width="50" class="mb15"> | |||||
| <p class="f18">TrustieEduCode</p> | |||||
| <p class="f16 mb20">智能学习平台</p> | |||||
| <p class="f12">实现实践教学的课程软件化、过程游戏化、<br/>环境生产化和评测全栈化</p> | |||||
| </div> | |||||
| </li> | |||||
| <li> | |||||
| <div> | |||||
| <p class="f28 mb50">OSSEAN</p> | |||||
| <p class="f18">TrustieOSSEAN</p> | |||||
| </div> | |||||
| </li> | |||||
| <li> | |||||
| <div> | |||||
| <p class="f18">TrustieCoderpedia</p> | |||||
| </div> | |||||
| </li> | |||||
| </ul> | |||||
| </div> | |||||
| <div class="homepage_introduce_content"> | |||||
| <div class="homepage_introduce_trustieForge homepage_introduce_content_item active"> | |||||
| <div class="cartoonTitle"> | |||||
| <p class="f20 mb20">协同开发平台</p> | |||||
| <p class="f16 color-grey3 mb50">支撑国家9个软件园区创新平台,服务2500余家中小型软件企业研发</p> | |||||
| </div> | |||||
| <ul class="cartoon"> | |||||
| <li class="plateContainer"> | |||||
| <div class="plate_before"> | |||||
| <div> | |||||
| <p><i class="iconfont icon-menu_date colorWhite f40"></i></p> | |||||
| <span class="content_span">项目管理</span> | |||||
| </div> | |||||
| </div> | |||||
| <div class="plate_back"> | |||||
| <div> | |||||
| <p><i class="iconfont icon-menu_date colorWhite f40"></i></p> | |||||
| <span class="f20 lh20 mt10">项目管理</span> | |||||
| <p class="lh20 mt60 mb80 f14 justify" style="height: 60px;">项目进程管理应用于研发管理、任务分配、目标跟踪等让项目管理流程高效完成。</p> | |||||
| <a href="javascript:void(0)" class="homepage_detailBtn">查看详情</a> | |||||
| </div> | |||||
| </div> | |||||
| </li> | |||||
| <li class="plateContainer"> | |||||
| <div class="plate_before"> | |||||
| <div> | |||||
| <p><i class="iconfont icon-menu_date colorWhite f40"></i></p> | |||||
| <span class="content_span">代码托管</span> | |||||
| </div> | |||||
| </div> | |||||
| <div class="plate_back"> | |||||
| <div> | |||||
| <p><i class="iconfont icon-menu_date colorWhite f40"></i></p> | |||||
| <span class="f20 lh20 mt10">代码托管</span> | |||||
| <p class="lh20 mt60 mb80 f14 justify" style="height: 60px;">基于Git的代码托管,提供高性能远端仓库,可保护分支、历史版本比对等高级功能。</p> | |||||
| <a href="javascript:void(0)" class="homepage_detailBtn">查看详情</a> | |||||
| </div> | |||||
| </div> | |||||
| </li> | |||||
| <li class="plateContainer"> | |||||
| <div class="plate_before"> | |||||
| <div> | |||||
| <p><i class="iconfont icon-menu_date colorWhite f40"></i></p> | |||||
| <span class="content_span">质量检测</span> | |||||
| </div> | |||||
| </div> | |||||
| <div class="plate_back"> | |||||
| <div> | |||||
| <p><i class="iconfont icon-menu_date colorWhite f40"></i></p> | |||||
| <span class="f20 lh20 mt10">质量检测</span> | |||||
| <p class="lh20 mt60 mb80 f14 justify" style="height: 60px;">采用一定检验测试手段和检查方法测定代码质量。</p> | |||||
| <a href="javascript:void(0)" class="homepage_detailBtn">查看详情</a> | |||||
| </div> | |||||
| </div> | |||||
| </li> | |||||
| <li class="plateContainer"> | |||||
| <div class="plate_before"> | |||||
| <div> | |||||
| <p><i class="iconfont icon-menu_date colorWhite f40"></i></p> | |||||
| <span class="content_span">交流社区</span> | |||||
| </div> | |||||
| </div> | |||||
| <div class="plate_back"> | |||||
| <div> | |||||
| <p><i class="iconfont icon-menu_date colorWhite f40"></i></p> | |||||
| <span class="f20 lh20 mt10">交流社区</span> | |||||
| <p class="lh20 mt60 mb80 f14 justify" style="height: 60px;">提供给IT开发者资源分享、学习交流、了解Trustie的社区。</p> | |||||
| <a href="javascript:void(0)" class="homepage_detailBtn">查看详情</a> | |||||
| </div> | |||||
| </div> | |||||
| </li> | |||||
| </ul> | |||||
| </div> | |||||
| <div class="homepage_introduce_trustieEduCode homepage_introduce_content_item"> | |||||
| <div class="trustieEduCode_container"> | |||||
| </div> | |||||
| </div> | |||||
| <div class="homepage_introduce_ossean homepage_introduce_content_item"></div> | |||||
| <div class="homepage_introduce_trustieCoderpedia homepage_introduce_content_item"></div> | |||||
| </div> | |||||
| </div> | |||||
| <%end %> | |||||
| <div class="content_Intruduce"> | |||||
| <div class="in_head"> | |||||
| <p class="in_head_rederect"> | |||||
| <% if User.current.logged? %> | |||||
| <a href="<%= user_path(User.current) %>" target="_blank" class="rightline">TrustieForge</a> | |||||
| <% else %> | |||||
| <a href="<%= signin_url() %>" target="_blank" class="rightline">TrustieForge</a> | |||||
| <% end %> | |||||
| <a href="http://ossean.trustie.net/" target="_blank" class="rightline">TrustieOSSEAN</a> | |||||
| <a href="http://www.educoder.net" target="_blank" class="rightline">TrustieEduCoder</a> | |||||
| <a href="http://codepedia.trustie.net/" target="_blank">TrustieCoderpedia</a> | |||||
| </p> | |||||
| </div> | |||||
| <div class="in_second in_panel"> | |||||
| <img src="/images/introduce/trustielogo_word.png" width="255px" height="45px" class="mb20"> | |||||
| <p class="f28 mb12">TruestieForge</p> | |||||
| <p class="mb30"><span class="blueUnderLine">协同开发平台</span></p> | |||||
| <p class="mb40 c_grey02 f16">支撑国家9个软件园区创新平台,服务2500余家中小型软件企业研发</p> | |||||
| <div class="forgeList"> | |||||
| <div class="inline"> | |||||
| <a href="<%= user_path(User.current) %>" target="_blank" class="forgeListItem"> | |||||
| <div> | |||||
| <div class="imgPart"> | |||||
| <div> | |||||
| <img src="/images/introduce/issue.png" width="52"> | |||||
| <p>项目管理</p> | |||||
| </div> | |||||
| </div> | |||||
| <p class="fontPanel"> | |||||
| <span>项目进程管理应用于研发管理、任务分配、目标跟踪等让项目管理流程高效完成。</span> | |||||
| </p> | |||||
| </div> | |||||
| </a> | |||||
| <a href="<%= user_path(User.current) %>" target="_blank" class="forgeListItem"> | |||||
| <div> | |||||
| <div class="imgPart"> | |||||
| <div> | |||||
| <img src="/images/introduce/lichengbei.png" width="52"> | |||||
| <p>代码托管</p> | |||||
| </div> | |||||
| </div> | |||||
| <p class="fontPanel"> | |||||
| <span>基于Git的代码托管,提供高性能远端仓库,可保护分支、历史版本比对等高级功能。</span> | |||||
| </p> | |||||
| </div> | |||||
| </a> | |||||
| <a href="<%= user_path(User.current) %>" target="_blank" class="forgeListItem"> | |||||
| <div> | |||||
| <div class="imgPart"> | |||||
| <div> | |||||
| <img src="/images/introduce/zhiliang.png" width="52"> | |||||
| <p>质量检测</p> | |||||
| </div> | |||||
| </div> | |||||
| <p class="fontPanel"> | |||||
| <span>采用一定检验测试手段和检查方法测定代码质量。</span> | |||||
| </p> | |||||
| </div> | |||||
| </a> | |||||
| <a href="<%= user_path(User.current) %>" target="_blank" class="forgeListItem"> | |||||
| <div> | |||||
| <div class="imgPart"> | |||||
| <div> | |||||
| <img src="/images/introduce/jiaoliu.png" width="52"> | |||||
| <p>交流社区</p> | |||||
| </div> | |||||
| </div> | |||||
| <p class="fontPanel"> | |||||
| <span>提供给IT开发者资源分享、学习交流、了解Trustie的社区。</span> | |||||
| </p> | |||||
| </div> | |||||
| </a> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div class="in_third"> | |||||
| <div> | |||||
| <img src="/images/nav_logo.png" width="50" class="mb20"> | |||||
| <img src="/images/introduce/edulogo.png" width="50" class="ml20 mb20"> | |||||
| <p class="f28 mb12 colorWhite">TrustieEduCoder</p> | |||||
| <p class="mb30"><span class="blueUnderLine" style="color: #fff;">智能学习平台</span></p> | |||||
| <p class="mb40 colorWhite f16">600多所大学参与共建共享,支持全技术栈的实验和实训教学</p> | |||||
| <div class="clearfix third_main_part"> | |||||
| <div class="img_box"> | |||||
| <img src="/images/introduce/computer.png" width="100%" class="img0"/> | |||||
| <img src="/images/introduce/lesson.png" width="100%" class="img1 none"/> | |||||
| <img src="/images/introduce/game.png" width="100%" class="img2 none"/> | |||||
| <img src="/images/introduce/homework.png" width="100%" class="img3 none"/> | |||||
| <img src="/images/introduce/Engineering.png" width="100%" class="img4 none"/> | |||||
| </div> | |||||
| <div class="introduce_box"> | |||||
| <a href="http://www.educoder.net" target="_blank" class="sub_box active"> | |||||
| <img src="/images/introduce/3-1-1.png" width="46" height="40" class="img1"/> | |||||
| <img src="/images/introduce/3-1-2.png" width="46" height="40" class="img2"/> | |||||
| <div class="sub_box_font"> | |||||
| <p class="mb10 f20">实训课程</p> | |||||
| <p><span>实现实践教学的课程软件化、过程游戏化、环境生产化和评测全栈化</span></p> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://www.educoder.net" target="_blank" class="sub_box"> | |||||
| <img src="/images/introduce/3-2-1.png" width="46" height="44" class="img1"/> | |||||
| <img src="/images/introduce/3-2-2.png" width="46" height="44" class="img2"/> | |||||
| <div class="sub_box_font"> | |||||
| <p class="mb10 f20">翻转课堂</p> | |||||
| <p><span>支持老师在线建立课堂,发布任务,学生完成任务,提交作业等各类教学场景</span></p> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://www.educoder.net" target="_blank" class="sub_box"> | |||||
| <img src="/images/introduce/3-3-1.png" width="43" height="41" class="img1"/> | |||||
| <img src="/images/introduce/3-3-2.png" width="43" height="41" class="img2"/> | |||||
| <div class="sub_box_font"> | |||||
| <p class="mb10 f20">竞赛活动</p> | |||||
| <p><span>汇集以高校竞赛为主,活动、社区为辅的竞赛活动平台</span></p> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://www.educoder.net" target="_blank" class="sub_box"> | |||||
| <img src="/images/introduce/3-4-1.png" width="39" height="39" class="img1"/> | |||||
| <img src="/images/introduce/3-4-2.png" width="39" height="39" class="img2"/> | |||||
| <div class="sub_box_font"> | |||||
| <p class="mb10 f20">作业查重</p> | |||||
| <p><span>把好学生“质量关”,为高校教师提供教学过程中课程作业的查重服务</span></p> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://www.educoder.net" target="_blank" class="sub_box"> | |||||
| <img src="/images/introduce/3-5-1.png" width="48" height="45" class="img1"/> | |||||
| <img src="/images/introduce/3-5-2.png" width="48" height="45" class="img2"/> | |||||
| <div class="sub_box_font"> | |||||
| <p class="mb10 f20">工程教育</p> | |||||
| <p><span>达成度自动计算,自评报告一键导出,切实提升相关工程技术人才从业教育质量</span></p> | |||||
| </div> | |||||
| </a> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div class="in_fourth"> | |||||
| <div> | |||||
| <img src="/images/introduce/trustielogo.png" width="50" class="mb20"> | |||||
| <p class="f28 mb12">TruestieOSSEAN</p> | |||||
| <p class="mb30"><span class="blueUnderLine">资源共享平台</span></p> | |||||
| <p class="mb40 c_grey02 f16">统计分析392个开源项目,汇聚超过600TB软件开发数据和应用数据</p> | |||||
| <div class="forgeList"> | |||||
| <div class="inline"> | |||||
| <a href="http://ossean.trustie.net/" target="_blank" class="osseanListItem"> | |||||
| <div class="df"> | |||||
| <p class="img-ring"><img src="/images/introduce/guanlian.png" width="60"></p> | |||||
| <div class="right_font"> | |||||
| <div style="width: 100%"> | |||||
| <p class="mb20 f22" style="color: #373D41">多源关联与反馈</p> | |||||
| <p class="c_grey02 f16"><span>对多源数据进行检测、关联、组合、反馈的过程</span></p> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://ossean.trustie.net/" target="_blank" class="osseanListItem"> | |||||
| <div class="df"> | |||||
| <p class="img-ring"><img src="/images/introduce/pinggu.png" width="60"></p> | |||||
| <div class="right_font"> | |||||
| <div style="width: 100%"> | |||||
| <p class="mb20 f22" style="color: #373D41">多维评估</p> | |||||
| <p class="c_grey02 f16"><span>从互联网到资源库,从主观到客观的多维度评估</span></p> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://ossean.trustie.net/" target="_blank" class="osseanListItem"> | |||||
| <div class="df"> | |||||
| <p class="img-ring"><img src="/images/introduce/ziyuan.png" width="60"></p> | |||||
| <div class="right_font"> | |||||
| <div style="width: 100%"> | |||||
| <p class="mb20 f22" style="color: #373D41">资源排行和推荐</p> | |||||
| <p class="c_grey02 f16"><span>开源软件排行榜及相关软件推荐</span></p> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://ossean.trustie.net/" target="_blank" class="osseanListItem"> | |||||
| <div class="df"> | |||||
| <p class="img-ring"><img src="/images/introduce/fenxi.png" width="60"></p> | |||||
| <div class="right_font"> | |||||
| <div style="width: 100%"> | |||||
| <p class="mb20 f22" style="color: #373D41">分析工具</p> | |||||
| <p class="c_grey02 f16"><span>结合缺陷检测、代码风格、测试覆盖率和注释率等整体分析</span></p> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </a> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div class="in_fifth"> | |||||
| <div> | |||||
| <img src="/images/nav_logo.png" width="50" class="mb20"> | |||||
| <p class="f28 mb12 colorWhite">TrustieCodepedia</p> | |||||
| <p class="mb30"><span class="whiteUnderLine" style="color: #fff;">众包学习平台</span></p> | |||||
| <p class="mb40 colorWhite f16">提供实验数据集给智能化软件开发技术研究和基准软件推荐</p> | |||||
| <div class="educoderList"> | |||||
| <a href="http://codepedia.trustie.net/" target="_blank" class="educoderItem"> | |||||
| <div> | |||||
| <span class="white_ring"><img src="/images/introduce/biaozhu.png" width="50"/></span> | |||||
| <p class="f22 colorWhite mb20">标注引导</p> | |||||
| <span style="color: #DDCDFF">高质量代码标注<br/>提升代码可理解性</span> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://codepedia.trustie.net/" target="_blank" class="educoderItem"> | |||||
| <div> | |||||
| <span class="white_ring"><img src="/images/introduce/qunti.png" width="50"/></span> | |||||
| <p class="f22 colorWhite mb20">群体标注</p> | |||||
| <span style="color: #DDCDFF">提供开源项目群体标注<br/>方便团队理解和查看</span> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://codepedia.trustie.net/" target="_blank" class="educoderItem"> | |||||
| <div> | |||||
| <span class="white_ring"><img src="/images/introduce/fankui.png" width="50"/></span> | |||||
| <p class="f22 colorWhite mb20">反馈修正</p> | |||||
| <span style="color: #DDCDFF">及时的反馈机制<br/>指出瑕疵并进行改进和修正</span> | |||||
| </div> | |||||
| </a> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <div class="in_sixth in_panel" style="padding-bottom: 40px;"> | |||||
| <p class="mb30 f28">合作机构</p> | |||||
| <div class="clearfix partnerInfo"> | |||||
| <a href="https://www.ccf.org.cn/" target="_blank"> | |||||
| <div> | |||||
| <span class="imgLoGO"><img src="/images/introduce/CCF.png" /></span> | |||||
| <span class="name">中国计算机学会</span> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://www.cmooc.cn/" target="_blank"> | |||||
| <div> | |||||
| <span class="imgLoGO"><img src="/images/introduce/MOOC.png" /></span> | |||||
| <span class="name">MOOC联盟</span> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://opengcc.org/" target="_blank"> | |||||
| <div> | |||||
| <span class="imgLoGO"><img src="/images/introduce/openGCC.png" /></span> | |||||
| <span class="name">绿色计算产业联盟</span> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://xgk.csia.org.cn/" target="_blank"> | |||||
| <div> | |||||
| <span class="imgLoGO"><img src="/images/introduce/EEE.png" /></span> | |||||
| <span class="name">新工科联盟</span> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://www.educg.net.cn/" target="_blank"> | |||||
| <div> | |||||
| <span class="imgLoGO"><img src="/images/introduce/CG.png" /></span> | |||||
| <span class="name">新一代人工智能</span> | |||||
| </div> | |||||
| </a> | |||||
| <a href="http://www.iscas.ac.cn/" target="_blank"> | |||||
| <div> | |||||
| <span class="imgLoGO"><img src="/images/introduce/ISCAS.png" style="margin-top: 26px;" /></span> | |||||
| <span class="name">中国科学院软件研究所</span> | |||||
| </div> | |||||
| </a> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <script> | |||||
| $(function(){ | |||||
| $(".sub_box").hover(function(){ | |||||
| $(".sub_box").removeClass("active"); | |||||
| $(this).addClass("active"); | |||||
| var index = $(this).index(); | |||||
| $(".img_box img").addClass("none"); | |||||
| $(".img_box").find(".img"+index).removeClass("none"); | |||||
| }) | |||||
| }) | |||||
| </script> | |||||
| @@ -133,7 +133,7 @@ | |||||
| <div class="new_login_con"> | <div class="new_login_con"> | ||||
| <div class="new_login_txt fl"> | <div class="new_login_txt fl"> | ||||
| <h3> 欢迎加入Trustie创新实践社区</h3> | <h3> 欢迎加入Trustie创新实践社区</h3> | ||||
| <p>在这里,您的创新意识和创新潜力将得到充分发挥!目前已有超过200所高校和科研机构在平台中开展在线协同开发、协同学习和协同研究。</p> | |||||
| <p>在这里,您的创新意识和创新潜力将得到充分发挥!目前已有超过600所高校和科研机构在平台中开展在线协同开发、协同学习和协同研究。</p> | |||||
| </div> | </div> | ||||
| <div class="new_login_box fr mr45 mt60"> | <div class="new_login_box fr mr45 mt60"> | ||||
| <% if @message %> | <% if @message %> | ||||
| @@ -225,4 +225,3 @@ | |||||
| <div class="cl"></div> | <div class="cl"></div> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| @@ -7,7 +7,7 @@ | |||||
| <%= hidden_field_tag 'token', @token.value %> | <%= hidden_field_tag 'token', @token.value %> | ||||
| <!--<input type="text" class="NomalInput " value="新密码" />--> | <!--<input type="text" class="NomalInput " value="新密码" />--> | ||||
| <%= password_field_tag 'new_password', nil, :size => 25,:placeholder=>'新密码',:style=>"width:308px; height:38px; border:1px solid #98a1a6; outline:none; color:#888888; font-size:14px; " %> | <%= password_field_tag 'new_password', nil, :size => 25,:placeholder=>'新密码',:style=>"width:308px; height:38px; border:1px solid #98a1a6; outline:none; color:#888888; font-size:14px; " %> | ||||
| <p style=" color:#F00 ;margin-bottom:5px;">至少需要 6 个字符</p> | |||||
| <p style=" color:#F00 ;margin-bottom:5px;">至少需要 8 个字符</p> | |||||
| <!--<input type="text" class="NomalInput mb20 " value="确定密码" />--> | <!--<input type="text" class="NomalInput mb20 " value="确定密码" />--> | ||||
| <%= password_field_tag 'new_password_confirmation', nil, :size => 25,:placeholder=>'确定密码',:style=>"width:308px; height:38px; border:1px solid #98a1a6; outline:none; color:#888888; font-size:14px;margin-bottom:20px; " %> | <%= password_field_tag 'new_password_confirmation', nil, :size => 25,:placeholder=>'确定密码',:style=>"width:308px; height:38px; border:1px solid #98a1a6; outline:none; color:#888888; font-size:14px;margin-bottom:20px; " %> | ||||
| <div style="width:315px; height:40px; background-color:#269ac9; font-size:14px; text-align:center; line-height:40px; vertical-align:middle;"><a href="javascript:void(0);" style=" color:#fff;display:block !important;" onclick="$(this).parent().parent().submit();">提交</a></div> | <div style="width:315px; height:40px; background-color:#269ac9; font-size:14px; text-align:center; line-height:40px; vertical-align:middle;"><a href="javascript:void(0);" style=" color:#fff;display:block !important;" onclick="$(this).parent().parent().submit();">提交</a></div> | ||||
| @@ -0,0 +1,66 @@ | |||||
| <table class="list" style="width: 100%;table-layout: fixed"> | |||||
| <thead> | |||||
| <tr> | |||||
| <th style="width: 15px;"> | |||||
| 序号 | |||||
| </th> | |||||
| <th style="width: 40px;"> | |||||
| 封面 | |||||
| </th> | |||||
| <th style="width: 60px;"> | |||||
| 标题 | |||||
| </th> | |||||
| <th style="width: 60px;" class = ""> | |||||
| 简介 | |||||
| </th> | |||||
| <th style="width: 60px;" class = ""> | |||||
| 所属分类 | |||||
| </th> | |||||
| <th style="width: 50px;"> | |||||
| 创建时间 | |||||
| </th> | |||||
| <th style="width: 80px;"> | |||||
| </th> | |||||
| </tr> | |||||
| </thead> | |||||
| <tbody> | |||||
| <% @count= @page * 15 %> | |||||
| <% @dynamic_news.each do |dynamic_new| %> | |||||
| <tr class="<%= cycle("odd", "even") %>"> | |||||
| <!td style="text-align:center;vertical-align: middle;"> | |||||
| <!%= dynamic_new.id %> | |||||
| <% @count +=1 %> | |||||
| <td align="center"> | |||||
| <%=@count %> | |||||
| </td> | |||||
| <td align="center"> | |||||
| <%= image_tag(dynamic_new.cover_url, width:40, height:40) %> | |||||
| <!%= dynamic_new.title %> | |||||
| </td> | |||||
| <td style="text-align:center;vertical-align: middle;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=dynamic_new.title%>'> | |||||
| <span> | |||||
| <%= link_to dynamic_new.title, dynamic_new.remote_url %> | |||||
| </span> | |||||
| </td> | |||||
| <td style="vertical-align: middle;text-align:center"> | |||||
| <%= truncate(dynamic_new.simple_intruduce, :length => 30) %> | |||||
| </td> | |||||
| <td style="vertical-align: middle;text-align:center"> | |||||
| <%= dynamic_new.category&.name %> | |||||
| </td> | |||||
| <td style="vertical-align: middle;text-align:center"> | |||||
| <%= format_time(dynamic_new.created_at) %> | |||||
| </td> | |||||
| <td class="buttons" style="vertical-align: middle;text-align:center"> | |||||
| <%= link_to("修改", edit_dynamic_news_path(dynamic_new), :class => 'icon icon-copy') %> | |||||
| <%= link_to(l(:button_delete), dynamic_news_path(dynamic_new), :method => :delete,:confirm => l(:text_are_you_sure), :class => 'icon icon-del') %> | |||||
| </td> | |||||
| </tr> | |||||
| <% end %> | |||||
| </tbody> | |||||
| </table> | |||||
| <div class="pagination"> | |||||
| <%= pagination_links_full @obj_pages, @obj_count ,:per_page_links => true, :remote => true, :flag => true, :is_new => true %> | |||||
| </div> | |||||
| @@ -0,0 +1,30 @@ | |||||
| <div class="contextual"> | |||||
| <%= link_to l(:label_dynamic_new), {:controller => 'dynamic_news', :action => 'new'}, :class => 'icon icon-add' %> | |||||
| </div> | |||||
| <h3> | |||||
| <%=l(:label_dynamic_new_plural)%> | |||||
| </h3> | |||||
| <%= form_tag({}, :method => :get) do %> | |||||
| <fieldset> | |||||
| <legend> | |||||
| <%= l(:label_filter_plural) %> | |||||
| </legend> | |||||
| <label for='status'> | |||||
| <%= l(:field_category) %> : | |||||
| </label> | |||||
| <%= select_tag 'category_id', dynamic_news_category_options_for_select(@category_id), :class => "small", :onchange => "this.form.submit(); return false;" %> | |||||
| <label for='name'> | |||||
| <%= l(:label_project) %>: | |||||
| </label> | |||||
| <%= text_field_tag 'title', params[:title], :size => 30, :placeholder => '输入新闻标题进行搜索' %> | |||||
| <%= submit_tag l(:button_apply), :class => "small", :name => nil %> | |||||
| <%= link_to l(:button_clear), {:controller => 'admin', :action => 'dynamic_news'}, :class => 'icon icon-reload' %> | |||||
| </fieldset> | |||||
| <% end %> | |||||
| | |||||
| <div class="autoscroll" id="admin_dynamic_news_list"> | |||||
| <%= render :partial => "dynamic_news" %> | |||||
| </div> | |||||
| @@ -0,0 +1 @@ | |||||
| $("#admin_dynamic_news_list").html("<%= escape_javascript(render :partial => 'dynamic_news') %>"); | |||||
| @@ -0,0 +1,32 @@ | |||||
| <h3>trustie首页</h3> | |||||
| <div class="tabs"> | |||||
| <ul> | |||||
| <li><%= link_to "首页定制", admin_home_path, class: "#{current_page?(admin_home_path)? 'selected' : nil }" %></li> | |||||
| <li><%= link_to "动态新闻", admin_dynamic_news_path, class: "#{current_page?(admin_dynamic_news_path)? 'selected' : nil }" %></li> | |||||
| <li><%= link_to "开源生态", web_footer_companies_path, class: "#{current_page?(web_footer_companies_path)? 'selected' : nil }" %></li> | |||||
| </div> | |||||
| <%= form_tag(:controller => 'admin', :action => 'home') do %> | |||||
| <h4>首页定制</h4> | |||||
| <p style="margin-left:60px;padding-right: 20px;"> | |||||
| <label for='attachments_fields'> 封面:</label> | |||||
| </p> | |||||
| <div style="margin-left: 82px;" id="avatar"> | |||||
| <%= render :partial=>"avatar/avatar_form",:style => "display:inline",:locals=> {source: @home} %> | |||||
| </div> | |||||
| <p style="margin-left:60px;padding-right: 20px;"> | |||||
| <label for='image_height' style="vertical-align: top"> 标题:</label> | |||||
| <%= text_field_tag 'home[name]', params[:name], :value => @home&.name, :style => "font-size:small;width:490px;margin-left:10px;" %> | |||||
| </p> | |||||
| <p style="margin-left:60px;padding-right: 20px;"> | |||||
| <label for='content' style="vertical-align: top"> 介绍:</label> | |||||
| <!-- <#%= text_area_tag 'content',@first_page.content,:rows => 8, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> --> | |||||
| <%= text_area 'home', 'content', :value => @home.content,:cols => 80, :rows => 15, :class => 'wiki-edit' %> | |||||
| <%= wikitoolbar_for 'home_content' %> | |||||
| </p> | |||||
| <%= submit_tag l(:button_save), :class => "small", :name => nil %> | |||||
| <% end %> | |||||
| @@ -24,7 +24,7 @@ | |||||
| <tr class="<%= cycle("odd", "even") %>"> | <tr class="<%= cycle("odd", "even") %>"> | ||||
| <td style="text-align:center;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=org.name%>'> | <td style="text-align:center;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;" class="name" title='<%=org.name%>'> | ||||
| <span> | <span> | ||||
| <%#= link_to org.name,home_path(:organization => org.id) %> | |||||
| <%#= link_to org.name,homes_path(:organization => org.id) %> | |||||
| <%= link_to org.name, organization_path(org) %> | <%= link_to org.name, organization_path(org) %> | ||||
| </span> | </span> | ||||
| </td> | </td> | ||||
| @@ -6,7 +6,7 @@ | |||||
| <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> | <%= text_field_tag 'web_title', params[:wbe_title],:value => @first_page.web_title, :size => 30,:style => "font-size:small;width:490px;margin-left:10px;" %> | ||||
| </p> | </p> | ||||
| <%= render 'tab_partial' %> | <%= render 'tab_partial' %> | ||||
| <div style="float:right"><%= link_to l(:label_cooperation_compnay), web_footer_companies_path %></div> | |||||
| <div style="float:right;"><%= link_to l(:label_cooperation_compnay), web_footer_companies_path %></div> | |||||
| <h4><%=l(:label_web_footer_page)%></h4> | <h4><%=l(:label_web_footer_page)%></h4> | ||||
| <p style="margin-left:60px;padding-right: 20px;"> | <p style="margin-left:60px;padding-right: 20px;"> | ||||
| @@ -21,8 +21,3 @@ | |||||
| </p> | </p> | ||||
| <%= submit_tag l(:button_save), :class => "small", :name => nil %> | <%= submit_tag l(:button_save), :class => "small", :name => nil %> | ||||
| <% end %> | <% end %> | ||||
| <div> | |||||
| </div> | |||||
| @@ -1,39 +1,55 @@ | |||||
| <div style="width:460px;"> | <div style="width:460px;"> | ||||
| <div class="sy_popup_top"> | |||||
| <div class="sy_popup_top clearfix"> | |||||
| <h3 class="fl">欢迎加入项目</h3> | <h3 class="fl">欢迎加入项目</h3> | ||||
| <a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a> | |||||
| <div class="cl"></div> | |||||
| <!-- <a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>--> | |||||
| </div> | </div> | ||||
| <div class="sy_popup_con" style="width:370px;"> | |||||
| <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => (@project.nil? ? nil : @project.id)), :remote => true, :id => 'project_applied_form') do %> | |||||
| <div class="sy_popup_con" style="width:400px;"> | |||||
| <%= form_tag( url_for(:controller => 'applied_project', :action => 'applied_project_info', :project_id => (@project.nil? ? nil : @project.id)), :remote => true, :id => 'project_applied_form_submit') do %> | |||||
| <ul class="sy_popup_add "> | <ul class="sy_popup_add "> | ||||
| <% if @is_teacher && @is_teacher == 1 %> | <% if @is_teacher && @is_teacher == 1 %> | ||||
| <li class="none"> | |||||
| <label >项目邀请码:</label> | |||||
| <input name="invite_code" class=" sy_input_txt fl" placeholder="请输入六位项目邀请码" value="<%=@project.invite_code %>" style="width:250px"/> | |||||
| <div class="cl"></div> | |||||
| <li class="none t-center"> | |||||
| <span class="inline"> | |||||
| <label >项目邀请码:</label> | |||||
| <input name="invite_code" class=" sy_input_txt fl" placeholder="请输入六位项目邀请码" value="<%=@project.invite_code %>" style="width:250px"/> | |||||
| <div class="cl"></div> | |||||
| </span> | |||||
| </li> | </li> | ||||
| <% else %> | <% else %> | ||||
| <li> | |||||
| <label >项目邀请码:</label> | |||||
| <input name="invite_code" class=" sy_input_txt fl" placeholder="请输入六位项目邀请码" style="width:250px"/> | |||||
| <div class="cl"></div> | |||||
| <li class="t-center"> | |||||
| <span class="inline"> | |||||
| <label >项目邀请码:</label> | |||||
| <input name="invite_code" class=" sy_input_txt fl" placeholder="请输入六位项目邀请码" style="width:250px"/> | |||||
| <div class="cl"></div> | |||||
| </span> | |||||
| </li> | </li> | ||||
| <% end %> | <% end %> | ||||
| <li> | |||||
| <label >身份:</label> | |||||
| <input name="member" value="member_manager" type="radio" class="ml5 mr5 " /><span class="mr10">管理人员</span> | |||||
| <input name="member" value="member_developer" type="radio" class="ml5 mr5 " /><span class="mr10">开发人员</span> | |||||
| <input name="member" value="member_reporter" type="radio" class="ml5 mr5 " /><span class="mr10">报告人员</span> | |||||
| <div class="cl"></div> | |||||
| <li class="mt10 text_c"> | |||||
| <span class="inline"> | |||||
| <label >身份:</label> | |||||
| <span class="fl mr10 mt3"> | |||||
| <input type="radio" class="magic-radio" name="member" value="member_manager" id="member_manager"/> | |||||
| <label for="member_manager" style="line-height: 28px">管理人员</label> | |||||
| </span> | |||||
| <span class="fl mr10 mt3"> | |||||
| <input type="radio" class="magic-radio" name="member" value="member_developer" id="member_developer"/> | |||||
| <label for="member_developer" style="line-height: 28px">开发人员</label> | |||||
| </span> | |||||
| <span class="fl mr10 mt3"> | |||||
| <input type="radio" class="magic-radio" name="member" value="member_reporter" id="member_reporter"/> | |||||
| <label for="member_reporter" style="line-height: 28px">报告人员</label> | |||||
| </span> | |||||
| <!-- <input name="member" value="member_manager" type="radio" class="ml5 mr5 " /><span class="mr10">管理人员</span>--> | |||||
| <!-- <input name="member" value="member_developer" type="radio" class="ml5 mr5 " /><span class="mr10">开发人员</span>--> | |||||
| <!-- <input name="member" value="member_reporter" type="radio" class="ml5 mr5 " /><span class="mr10">报告人员</span>--> | |||||
| </span> | |||||
| </li> | </li> | ||||
| <li> | |||||
| <label class="mr27"> </label> | |||||
| <a href="javascript:void(0);" class="sy_btn_blue fl" onclick="$('#project_applied_form').submit();hideModal()">确 定</a> | |||||
| <a href="javascript:void(0);" class="sy_btn_grey fl ml20" onclick="hideModal()">取 消</a> | |||||
| <div class="cl"></div> | |||||
| <li class="mt15 text_c" > | |||||
| <span class="inline"> | |||||
| <a href="javascript:void(0);" class="sy_btn_blue fl" onclick="$('#project_applied_form_submit').submit();hideModal()">确 定</a> | |||||
| <a href="javascript:void(0);" class="sy_btn_grey fl ml20" onclick="hideModal()">取 消</a> | |||||
| </span> | |||||
| </li> | </li> | ||||
| </ul> | </ul> | ||||
| <% end %> | <% end %> | ||||
| </div> | </div> | ||||
| </div> | |||||
| </div> | |||||
| @@ -12,28 +12,28 @@ | |||||
| </td> | </td> | ||||
| <td rowspan="2"> | <td rowspan="2"> | ||||
| <% if User.current.logged? %> | <% if User.current.logged? %> | ||||
| <% unless User.current.user_extensions.identity == 1 %> | |||||
| <%= link_to(l(:label_newtype_contest), {:controller => 'bids', :action => 'new_contest'}, :class => 'icon icon-add') %> | |||||
| <% end %> | |||||
| <% end %> | |||||
| <% unless User.current.user_extensions.identity == 1 %> | |||||
| <%= link_to(l(:label_newtype_contest), {:controller => 'bids', :action => 'new_contest'}, :class => 'icon icon-add') %> | |||||
| <% end %> | |||||
| <% end %> | |||||
| </td> | </td> | ||||
| <td rowspan="2" > | |||||
| <div class="project-search" style="float: right"> | |||||
| <td rowspan="2" > | |||||
| <div class="project-search" style="float: right"> | |||||
| <%= text_field_tag 'name', params[:name], :size => 30 %> | <%= text_field_tag 'name', params[:name], :size => 30 %> | ||||
| <%= hidden_field_tag 'project_type', params[:project_type] %> | <%= hidden_field_tag 'project_type', params[:project_type] %> | ||||
| <%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> | |||||
| </div> | |||||
| <%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> | |||||
| </div> | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td > | <td > | ||||
| <%=link_to l(:field_homepage), home_path %> > | |||||
| <%=link_to l(:field_homepage), homes_path %> > | |||||
| <a><%= l(:label_contest_innovate) %></a> | <a><%= l(:label_contest_innovate) %></a> | ||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| </table> | </table> | ||||
| <% end %> | <% end %> | ||||
| </div> | |||||
| </div> | |||||
| @@ -14,24 +14,24 @@ | |||||
| <td rowspan="2"> | <td rowspan="2"> | ||||
| <% if User.current.logged? %> | <% if User.current.logged? %> | ||||
| <%= link_to(l(:label_new_call), {:controller => 'bids', :action => 'new_bid'}, :class => 'icon icon-add') %> | <%= link_to(l(:label_new_call), {:controller => 'bids', :action => 'new_bid'}, :class => 'icon icon-add') %> | ||||
| <% end %> | |||||
| <% end %> | |||||
| </td> | </td> | ||||
| <td rowspan="2" > | |||||
| <td rowspan="2" > | |||||
| <div class="project-search" style="float: right"> | <div class="project-search" style="float: right"> | ||||
| <%= text_field_tag 'name', params[:name], :size => 28 %> | <%= text_field_tag 'name', params[:name], :size => 28 %> | ||||
| <%= hidden_field_tag 'reward_type', params[:reward_type] %> | <%= hidden_field_tag 'reward_type', params[:reward_type] %> | ||||
| <%= hidden_field_tag 'project_type', params[:project_type] %> | <%= hidden_field_tag 'project_type', params[:project_type] %> | ||||
| <%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> | <%= submit_tag l(:label_search), :class => "enterprise", :name => nil %> | ||||
| </div> | |||||
| </div> | |||||
| </td> | </td> | ||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td style="padding-left: 8px"><a><%= link_to request.host()+"/calls", :controller => 'bids', :action => 'index' %> </a></td> | <td style="padding-left: 8px"><a><%= link_to request.host()+"/calls", :controller => 'bids', :action => 'index' %> </a></td> | ||||
| <td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_requirement_enterprise), :controller => 'bids', :action => 'index' %></td> | |||||
| <td ><%=link_to l(:field_homepage), homes_path %> > <%=link_to l(:label_requirement_enterprise), :controller => 'bids', :action => 'index' %></td> | |||||
| </tr> | </tr> | ||||
| </table> | </table> | ||||
| <% end %> | <% end %> | ||||
| </div> | |||||
| </div> | |||||
| <% if @bids.size > 0 %> | <% if @bids.size > 0 %> | ||||
| <div id="bid-show"> | <div id="bid-show"> | ||||
| <%= sort_bid(@s_state, @project_type)%> | <%= sort_bid(@s_state, @project_type)%> | ||||
| @@ -42,4 +42,4 @@ | |||||
| <% end %> | <% end %> | ||||
| <% html_title l(:label_requirement_enterprise_list)%> | |||||
| <% html_title l(:label_requirement_enterprise_list)%> | |||||
| @@ -11,16 +11,50 @@ | |||||
| <a href="javascript:void(0)" class="linkBlue2 fr" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">评分</a> | <a href="javascript:void(0)" class="linkBlue2 fr" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">评分</a> | ||||
| <div class="cl"></div> | <div class="cl"></div> | ||||
| <% if @contestwork.work_detail_group.base_on_project %> | <% if @contestwork.work_detail_group.base_on_project %> | ||||
| <div class="pr"> | |||||
| <% project = student_work.get_project %> | |||||
| <div class="pr"> | |||||
| <span class="fl fontGrey2">关联项目:</span> | <span class="fl fontGrey2">关联项目:</span> | ||||
| <div class="fl projectName"> | <div class="fl projectName"> | ||||
| <% if project[:status].to_i != 9 && (project[:is_public] || project[:is_member] || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %> | |||||
| <%= link_to encoding_utf_name(project[:name]), "#{Redmine::Configuration['sync_forge_url']}/projects/#{project[:id]}", :class => 'link-blue fl hidden', :style => "max-width:550px;", :title => "项目名称", :target => "_blank" %> | |||||
| <% elsif project[:status].to_i != 9 %> | |||||
| <span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= encoding_utf_name(project[:name]) %></span> | |||||
| <% else %> | |||||
| <span class="fontGrey2 fr hidden" style="max-width:550px;" title="该项目已删除"><%= encoding_utf_name(project[:name]) %>(已删除)</span><% end %> | |||||
| <div class="score-tip none tl f12" style="width:300px; top:-48px; right:-372px;"> | |||||
| <em style="bottom:45px;"></em> | |||||
| <font style="bottom:45px;"></font> | |||||
| <p class="fb break_word mw280"><%= encoding_utf_name(project[:name]) %><%= project[:status].to_i == 9 ? "(已删除)" : ""%></p> | |||||
| <p class="mb10"> | |||||
| <span class="mr15">创建者:<%= encoding_utf_name(project[:owner][:name]) %></span><span>成员数量:<%= project[:members_count] %></span></p> | |||||
| <p>项目综合得分:<%= project[:status].to_i == 9 ? 0 : forge_static_project_score(project[:project_score]) %></p> | |||||
| <% if project[:status].to_i != 9 %> | |||||
| <p>= 代码提交得分 + issue得分 + 资源得分 + 帖子得分</p> | |||||
| <p>= <%= (project[:project_score][:changeset_num].to_i ||0) * 4 %> | |||||
| + <%= project[:project_score][:issue_num].to_i * 4 + project[:project_score][:issue_journal_num].to_i %> + <%= project[:project_score][:attach_num].to_i * 5 %> | |||||
| + <%= project[:project_score][:board_num].to_i * 2 + project[:project_score][:board_message_num].to_i %></p> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <% | |||||
| =begin%> | |||||
| <div class="pr"> | |||||
| <span class="fl fontGrey2">关联项目:</span> | |||||
| <div class="fl projectName"> | |||||
| <% if student_work.project.status != 9 && (student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %> | <% if student_work.project.status != 9 && (student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %> | ||||
| <%= link_to student_work.project.name, project_path(student_work.project.id), :class => 'link-blue fl hidden', :style => "max-width:550px;", :title => "项目名称", :target => "_blank" %> | <%= link_to student_work.project.name, project_path(student_work.project.id), :class => 'link-blue fl hidden', :style => "max-width:550px;", :title => "项目名称", :target => "_blank" %> | ||||
| <% elsif student_work.project.status != 9 %> | <% elsif student_work.project.status != 9 %> | ||||
| <span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= student_work.project.name %></span> | <span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= student_work.project.name %></span> | ||||
| <% else %> | <% else %> | ||||
| <span class="fontGrey2 fr hidden" style="max-width:550px;" title="该项目已删除"><%= student_work.project.name %>(已删除)</span><% end %> | <span class="fontGrey2 fr hidden" style="max-width:550px;" title="该项目已删除"><%= student_work.project.name %>(已删除)</span><% end %> | ||||
| <% project = student_work.project %> | |||||
| <% project = student_work.get_project %> | |||||
| <div class="score-tip none tl f12" style="width:300px; top:-48px; right:-372px;"> | <div class="score-tip none tl f12" style="width:300px; top:-48px; right:-372px;"> | ||||
| <em style="bottom:45px;"></em> | <em style="bottom:45px;"></em> | ||||
| <font style="bottom:45px;"></font> | <font style="bottom:45px;"></font> | ||||
| @@ -41,7 +75,9 @@ | |||||
| <% end %> | <% end %> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | |||||
| </div> | |||||
| <% | |||||
| =end%> | |||||
| <% end %> | <% end %> | ||||
| </div> | </div> | ||||
| <div class="cl"></div> | <div class="cl"></div> | ||||
| @@ -11,7 +11,40 @@ | |||||
| <a href="javascript:void(0)" class="linkBlue2 fr" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">查看</a> | <a href="javascript:void(0)" class="linkBlue2 fr" onclick="show_student_work('<%= contestant_work_path(student_work)%>');">查看</a> | ||||
| <div class="cl"></div> | <div class="cl"></div> | ||||
| <% if @contestwork.work_detail_group.base_on_project %> | <% if @contestwork.work_detail_group.base_on_project %> | ||||
| <div class="pr"> | |||||
| <% project = student_work.get_project %> | |||||
| <div class="pr"> | |||||
| <span class="fl fontGrey2">关联项目:</span> | |||||
| <div class="fl projectName"> | |||||
| <% if project[:status].to_i != 9 && (project[:is_public] || project[:is_member] || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %> | |||||
| <%= link_to encoding_utf_name(project[:name]), "#{Redmine::Configuration['sync_forge_url']}/projects/#{project[:id]}", :class => 'link-blue fl hidden', :style => "max-width:550px;", :title => "项目名称", :target => "_blank" %> | |||||
| <% elsif project[:status] != 9 %> | |||||
| <span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= encoding_utf_name(project[:name]) %></span> | |||||
| <% else %> | |||||
| <span class="fontGrey2 fr hidden" style="max-width:550px;" title="该项目已删除"><%= encoding_utf_name(project[:name]) %>(已删除)</span><% end %> | |||||
| <div class="score-tip none tl f12" style="width:300px; top:-48px; right:-372px;"> | |||||
| <em style="bottom:45px;"></em> | |||||
| <font style="bottom:45px;"></font> | |||||
| <p class="fb break_word mw280"><%= encoding_utf_name(project[:name]) %><%= project[:status].to_i == 9 ? "(已删除)" : ""%></p> | |||||
| <p class="mb10"> | |||||
| <span class="mr15">创建者:<%= encoding_utf_name(project[:owner][:name]) %></span><span>成员数量:<%= project[:members_count] %></span></p> | |||||
| <p>项目综合得分:<%= project[:status].to_i == 9 ? 0 : forge_static_project_score(project[:project_score]) %></p> | |||||
| <% if project[:status].to_i != 9 %> | |||||
| <p>= 代码提交得分 + issue得分 + 资源得分 + 帖子得分</p> | |||||
| <p>= <%= (project[:project_score][:changeset_num].to_i ||0) * 4 %> | |||||
| + <%= project[:project_score][:issue_num].to_i * 4 + project[:project_score][:issue_journal_num].to_i %> + <%= project[:project_score][:attach_num].to_i * 5 %> | |||||
| + <%= project[:project_score][:board_num].to_i * 2 + project[:project_score][:board_message_num].to_i %></p> | |||||
| <% end %> | |||||
| </div> | |||||
| </div> | |||||
| </div> | |||||
| <% | |||||
| =begin%> | |||||
| <div class="pr"> | |||||
| <span class="fl fontGrey2">关联项目:</span> | <span class="fl fontGrey2">关联项目:</span> | ||||
| <div class="fl projectName"> | <div class="fl projectName"> | ||||
| <% if student_work.project.status != 9 && (student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %> | <% if student_work.project.status != 9 && (student_work.project.is_public || User.current.member_of?(student_work.project) || User.current.admin? || User.current.admin_of_contest?(@contestwork.contest) || User.current.judge_of_contest?(@contestwork.contest)) %> | ||||
| @@ -20,7 +53,7 @@ | |||||
| <span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= student_work.project.name %></span> | <span class="fontBlue fr hidden" style="max-width:550px;" title="该项目是私有的"><%= student_work.project.name %></span> | ||||
| <% else %> | <% else %> | ||||
| <span class="fontGrey2 fr hidden" style="max-width:550px;" title="该项目已删除"><%= student_work.project.name %>(已删除)</span><% end %> | <span class="fontGrey2 fr hidden" style="max-width:550px;" title="该项目已删除"><%= student_work.project.name %>(已删除)</span><% end %> | ||||
| <% project = student_work.project %> | |||||
| <% project = student_work.get_project %> | |||||
| <div class="score-tip none tl f12" style="width:300px; top:-48px; right:-372px;"> | <div class="score-tip none tl f12" style="width:300px; top:-48px; right:-372px;"> | ||||
| <em style="bottom:45px;"></em> | <em style="bottom:45px;"></em> | ||||
| <font style="bottom:45px;"></font> | <font style="bottom:45px;"></font> | ||||
| @@ -41,7 +74,9 @@ | |||||
| <% end %> | <% end %> | ||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </div> | |||||
| </div> | |||||
| <% | |||||
| =end%> | |||||
| <% end %> | <% end %> | ||||
| </div> | </div> | ||||
| <div class="cl"></div> | <div class="cl"></div> | ||||
| @@ -132,13 +132,9 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| <% if @contestwork.work_type == 3 && @contestwork.work_detail_group.base_on_project %> | |||||
| <% if @is_group_project_homework %> | |||||
| <div class="undis" id="student_work_con3"> | <div class="undis" id="student_work_con3"> | ||||
| <% student_work_ids = @contestwork.contestant_works.has_committed.blank? ? "(-1)" : "(" + @contestwork.contestant_works.has_committed.map{|st| st.id}.join(",") + ")" %> | |||||
| <% student_work_projects = @contestwork.contestant_work_projects.where("contestant_work_id in #{student_work_ids} or contestant_work_id is null") %> | |||||
| <% project_ids = student_work_projects.blank? ? "(-1)" : "(" + student_work_projects.map{|pro| pro.project_id}.join(",") + ")" %> | |||||
| <% projects = Project.where("id in #{project_ids}").order("updated_on desc") %> | |||||
| <%= render :partial => "relate_projects", :locals => {:projects => projects}%> | |||||
| <%= render :partial => "student_work/new_related_projects", :locals => {:projects => @all_group_projects}%> | |||||
| </div> | </div> | ||||
| <% end %> | <% end %> | ||||
| </div> | </div> | ||||
| @@ -35,7 +35,7 @@ | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td > | <td > | ||||
| <%=link_to l(:field_homepage), home_path %> > | |||||
| <%=link_to l(:field_homepage), homes_path %> > | |||||
| <a href="http://<%= Setting.host_course%>" class="link_other_item"> | <a href="http://<%= Setting.host_course%>" class="link_other_item"> | ||||
| <%=l(:label_courses_management_platform)%> | <%=l(:label_courses_management_platform)%> | ||||
| </a> | </a> | ||||
| @@ -29,7 +29,7 @@ | |||||
| </tr> | </tr> | ||||
| <tr> | <tr> | ||||
| <td > | <td > | ||||
| <%=link_to l(:field_homepage), home_path %> > | |||||
| <%=link_to l(:field_homepage), homes_path %> > | |||||
| <a href="http://<%= Setting.host_course%>" class="link_other_item"> | <a href="http://<%= Setting.host_course%>" class="link_other_item"> | ||||
| <%=l(:label_courses_management_platform)%> | <%=l(:label_courses_management_platform)%> | ||||
| </a> | </a> | ||||
| @@ -37,7 +37,7 @@ | |||||
| </tr> | </tr> | ||||
| </table> | </table> | ||||
| <% end %> | <% end %> | ||||
| </div> | |||||
| </div> | |||||
| <% if @courses && !@courses.empty? %> | <% if @courses && !@courses.empty? %> | ||||
| <div id="courses-index"> | <div id="courses-index"> | ||||
| @@ -0,0 +1,70 @@ | |||||
| <%= form_for(@dynamic_new, :url=> { :action => params[:action] == 'new'? :create : :update }, :html => {:id =>'system_messages-form',:multipart => true }) do |f| %> | |||||
| <li> | |||||
| <%= image_tag(params[:action] == 'new' ? '' : @dynamic_new.cover_url, id: "avatar_image", :class=>"school_avatar dynamic_new_image" )%> | |||||
| <a type="button" onclick="$('#file').click();" style="margin: 86px 0 0 15px;float: left;padding: 2px 5px;border: 1px solid #eaeaea;cursor: pointer;text-decoration: none;width: 55px;">上传封面</a> | |||||
| <%= file_field_tag 'cover',:style => "display:none;", :id => "file", :onchange => "showPreview(this)"%> | |||||
| <div style="clear: both;"></div> | |||||
| </li> | |||||
| <li> | |||||
| <label><span class="">*</span> <%= l(:field_category) %> :</label> | |||||
| <%= f.select :category_id, options_for_select(Category.all.collect{|item| [item.name, item.id]}, @category_id), :class => "small" %> | |||||
| <p id="title_notice_span" class="ml55"></p> | |||||
| </li> | |||||
| <li> | |||||
| <label><span class="">*</span> <%= l(:field_title) %> :</label> | |||||
| <input type="text" name="dynamic_new[title]" class="hwork_input_news" id="dynamic_new_title" width="576px" onblur="regexTitle($(this));" maxlength="255" placeholder="255个字符以内" value="<%= @dynamic_new.title %>"> | |||||
| <p id="title_notice_span" class="ml55"></p> | |||||
| </li> | |||||
| <li> | |||||
| <label><span class="">*</span> <%= l(:field_summary) %> :</label> | |||||
| <input type="textarea" name="dynamic_new[simple_intruduce]" class="hwork_input_news" id="dynamic_new_simple_introduce" width="576px" onblur="regexTitle($(this));" maxlength="255" placeholder="255个字符以内" value="<%= @dynamic_new.simple_intruduce %>"> | |||||
| <p id="title_notice_span" class="ml55"></p> | |||||
| </li> | |||||
| <li> | |||||
| <label class="fl" > <span class="c_red"></span> <%= l(:field_content) %> :</label> | |||||
| <%= f.kindeditor :content,:width=>'87.5%',:editor_id=>'dynamic_new_editor' %> | |||||
| <p id="content_notice_span" class="ml55"></p> | |||||
| </li> | |||||
| <div> | |||||
| <p id="content_notice_span" class="ml55"></p> | |||||
| </div> | |||||
| <div class="cl"></div> | |||||
| <div class="actions"> | |||||
| <%= link_to l(:label_submit), "javascript:void(0)", :class => "btn_message_free", :onclick => "dynamic_new_editor.sync();submit_message($(this));" %> | |||||
| </div> | |||||
| <% end %> | |||||
| <script> | |||||
| function system_message_length() { | |||||
| var obj = dynamic_new_editor.html(); | |||||
| if (obj.length > 10000) { | |||||
| $("#content_notice_span").text("内容过长,超过10000个字符"); | |||||
| $("#content_notice_span").css('color', '#ff0000'); | |||||
| $("#content_notice_span").focus(); | |||||
| return false; | |||||
| } else { | |||||
| $("#content_notice_span").text("填写正确"); | |||||
| $("#content_notice_span").css('color', '#008000'); | |||||
| return true; | |||||
| } | |||||
| } | |||||
| function regexTitle(obj) { | |||||
| var title = obj.val(); | |||||
| if (title.length == 0) { | |||||
| $("#title_notice_span").text("标题不能为空").css("color", "#ff0000").focus(); | |||||
| return false; | |||||
| } else if (title.length > 255) { | |||||
| $("#title_notice_span").text("标题长度过长,不能超过255个字符").css("color", "#ff0000").focus(); | |||||
| return false; | |||||
| } else { | |||||
| $("#title_notice_span").text("填写正确").css("color", "#008000"); | |||||
| return true; | |||||
| } | |||||
| } | |||||
| function submit_message(dom) { | |||||
| if (system_message_length() && regexTitle($("#dynamic_new_title")) && regexTitle($("#dynamic_new_simple_introduce"))) { | |||||
| $("#system_messages-form").submit(); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| @@ -0,0 +1,23 @@ | |||||
| <script> | |||||
| function showPreview(source) { | |||||
| var file = source.files[0]; | |||||
| if (window.FileReader) { | |||||
| var fr = new FileReader(); | |||||
| fr.onloadend = function (e) { | |||||
| document.getElementById("avatar_image").src = e.target.result; | |||||
| }; | |||||
| fr.readAsDataURL(file); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| <%= content_for(:header_tags) do %> | |||||
| <%= import_ke(enable_at: false) %> | |||||
| <% end %> | |||||
| <h3 style="float: left"> | |||||
| <%=l(:label_new_dynamic_new)%> | |||||
| </h3><br/> | |||||
| <div style="padding-top: 20px; padding-left: 5px;"> | |||||
| <%= error_messages_for 'dynamic_new' %> | |||||
| <%= render 'form' %> | |||||
| </div> | |||||
| @@ -0,0 +1,2 @@ | |||||
| <h1>DynamicNew#index</h1> | |||||
| <p>Find me in app/views/dynamic_new/index.html.erb</p> | |||||
| @@ -0,0 +1,22 @@ | |||||
| <script> | |||||
| function showPreview(source) { | |||||
| var file = source.files[0]; | |||||
| if (window.FileReader) { | |||||
| var fr = new FileReader(); | |||||
| fr.onloadend = function (e) { | |||||
| document.getElementById("avatar_image").src = e.target.result; | |||||
| }; | |||||
| fr.readAsDataURL(file); | |||||
| } | |||||
| } | |||||
| </script> | |||||
| <%= content_for(:header_tags) do %> | |||||
| <%= import_ke(enable_at: false) %> | |||||
| <% end %> | |||||
| <h3 style="float: left"> | |||||
| <%=l(:label_new_dynamic_new)%> | |||||
| </h3><br/> | |||||
| <div style="padding-top: 20px; padding-left: 5px;"> | |||||
| <%= render 'form' %> | |||||
| </div> | |||||