From c331e5a9c8933064f8460de75e6cbec8a5805b42 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 17:42:41 +0800 Subject: [PATCH 001/130] =?UTF-8?q?=E8=BD=AChtml=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E8=BD=ACpdf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 13 ++++++++++--- lib/trustie/utils/office.rb | 9 ++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index c8b6a6fda..9c3b624af 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -62,6 +62,10 @@ class AttachmentsController < ApplicationController render :action => 'file' end + def pdf?(file) + file.downcase.end_with?(".pdf") + end + def download # modify by nwb # 下载添加权限设置 @@ -69,9 +73,12 @@ class AttachmentsController < ApplicationController if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) - convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".html") - if File.exist?(convered_file) - send_file convered_file, :type => 'text/html; charset=utf-8', :disposition => 'inline' + convered_file = @attachment.disk_filename + unless pdf?(convered_file) + convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".pdf") + end + if File.exist?(convered_file) && pdf?(convered_file) + send_file convered_file, :type => 'application/pdf; charset=utf-8', :disposition => 'inline' else send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), :type => detect_content_type(@attachment), diff --git a/lib/trustie/utils/office.rb b/lib/trustie/utils/office.rb index 1bc18cb84..adfa3fb5c 100644 --- a/lib/trustie/utils/office.rb +++ b/lib/trustie/utils/office.rb @@ -7,7 +7,7 @@ module Trustie end def office? - %w(doc docx ppt pptx xls xlsx pdf).any?{|word| @file.downcase.end_with?(word)} + %w(doc docx ppt pptx xls xlsx).any?{|word| @file.downcase.end_with?(word)} end def conver(saved_file, force=false) @@ -21,8 +21,11 @@ module Trustie :open_timeout => -1 ) req = resource.post :txtDes => File.new(@file, 'rb') - File.open(saved_file, "wb+") do |f| - f.write(req.body) + File.delete(saved_file) if File.exist?(saved_file) + if req.body.length > 10 && !req.body.eql?('转换出错') + File.open(saved_file, "wb+") do |f| + f.write(req.body) + end end return true rescue =>e From 9ecb119aa46354f9e1de47166d6c79857c83499a Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 17:43:42 +0800 Subject: [PATCH 002/130] =?UTF-8?q?task=E4=B8=AD=E4=B9=9F=E6=94=B9?= =?UTF-8?q?=E4=B8=BApdf?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/office.rake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tasks/office.rake b/lib/tasks/office.rake index 3e4c0a286..ce2d3a221 100644 --- a/lib/tasks/office.rake +++ b/lib/tasks/office.rake @@ -10,7 +10,7 @@ namespace :office do unless Dir.exist?(saved_path) Dir.mkdir(saved_path) end - convered_file = File.join(saved_path, a.disk_filename + ".html") + convered_file = File.join(saved_path, a.disk_filename + ".pdf") office = Trustie::Utils::Office.new(a.diskfile) if office.conver(convered_file) puts "process ok: #{convered_file} " From e4d68e988ea2b95b06d5d842f9369b8aaa5200ce Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 17:52:59 +0800 Subject: [PATCH 003/130] =?UTF-8?q?=E5=8A=A0=E4=B8=8Autf8=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 +- lib/tasks/office.rake | 2 ++ lib/trustie/utils/office.rb | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 9c3b624af..d3781d747 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -73,7 +73,7 @@ class AttachmentsController < ApplicationController if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) - convered_file = @attachment.disk_filename + convered_file = @attachment.diskfile unless pdf?(convered_file) convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".pdf") end diff --git a/lib/tasks/office.rake b/lib/tasks/office.rake index ce2d3a221..c6ee8b4dd 100644 --- a/lib/tasks/office.rake +++ b/lib/tasks/office.rake @@ -1,3 +1,5 @@ +#coding=utf-8 + namespace :office do desc "conver any files to html" task :conver => :environment do diff --git a/lib/trustie/utils/office.rb b/lib/trustie/utils/office.rb index adfa3fb5c..61d6b9d4c 100644 --- a/lib/trustie/utils/office.rb +++ b/lib/trustie/utils/office.rb @@ -1,3 +1,5 @@ +#coding=utf-8 + module Trustie module Utils class Office From 3cc6fc1a64663df304b07a8059361dc994162069 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 18:15:08 +0800 Subject: [PATCH 004/130] =?UTF-8?q?=E5=88=A0=E6=8E=89additional=5Fenvirome?= =?UTF-8?q?nt.rb?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/additional_environment.rb | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 config/additional_environment.rb diff --git a/config/additional_environment.rb b/config/additional_environment.rb deleted file mode 100644 index 5c73f6aab..000000000 --- a/config/additional_environment.rb +++ /dev/null @@ -1,3 +0,0 @@ -if Rails.env.production? - config.cache_store = :redis_store, 'redis://localhost:6379/0/cache', { expires_in: 90.minutes } -end \ No newline at end of file From f86acbb10f08b99175f722536476a54209dcde05 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 18:30:49 +0800 Subject: [PATCH 005/130] =?UTF-8?q?=E9=9C=80=E8=A6=81=E8=BF=81=E7=A7=BB?= =?UTF-8?q?=E7=9A=84=E9=A2=84=E8=A7=88=E6=96=87=E4=BB=B6=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tasks/office.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/office.rake b/lib/tasks/office.rake index c6ee8b4dd..8bfc0c0ea 100644 --- a/lib/tasks/office.rake +++ b/lib/tasks/office.rake @@ -3,9 +3,9 @@ namespace :office do desc "conver any files to html" task :conver => :environment do - all_count = Attachment.count + all_count = Attachment.where(["container_type IN (?)", %w(Project Course)]).count i = 0 - Attachment.find_each do |a| + Attachment.where(["container_type IN (?)", %w(Project Course)]).find_each do |a| i += 1 puts "process [#{i}/#{all_count}] => id #{a.id}" saved_path = File.join(Rails.root, "files", "convered_office") From d2eb51bbb6f47644d64e156b54c3e8e26535326b Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 18:47:23 +0800 Subject: [PATCH 006/130] =?UTF-8?q?=E5=8F=AA=E5=A4=84=E7=90=86=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=BA=93=E7=9A=84=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 1e477ed04..4a6580a7a 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -259,11 +259,12 @@ class Attachment < ActiveRecord::Base end def office_conver + return unless %w(Project Course).included? (self.container_type) saved_path = File.join(Rails.root, "files", "convered_office") unless Dir.exist?(saved_path) Dir.mkdir(saved_path) end - convered_file = File.join(saved_path, self.disk_filename + ".html") + convered_file = File.join(saved_path, self.disk_filename + ".pdf") OfficeConverTask.new.conver(self.diskfile, convered_file) end From 3f9c5764e96f82e57c4438296c4e166df9959bfa Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 18:50:26 +0800 Subject: [PATCH 007/130] . --- app/models/attachment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 4a6580a7a..380e98e02 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -259,7 +259,7 @@ class Attachment < ActiveRecord::Base end def office_conver - return unless %w(Project Course).included? (self.container_type) + return unless %w(Project Course).include? (self.container_type) saved_path = File.join(Rails.root, "files", "convered_office") unless Dir.exist?(saved_path) Dir.mkdir(saved_path) From d3baada893c2ceba398dfc399518d2cb6ee05d31 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 3 Jun 2015 18:57:05 +0800 Subject: [PATCH 008/130] =?UTF-8?q?=E5=9C=A8=E6=9B=B4=E6=96=B0Attachments?= =?UTF-8?q?=E6=97=B6=E4=B9=9F=E8=A6=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 380e98e02..1f1d61581 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -72,8 +72,8 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - after_create :office_conver, :be_user_score ,:act_as_forge_activity# user_score - after_update :be_user_score + after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score + after_update :office_conver, :be_user_score after_destroy :delete_from_disk,:down_user_score # add by nwb From 444658d0b3a8ef46431396bd9ec7ffb3f6df8364 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 4 Jun 2015 10:24:05 +0800 Subject: [PATCH 009/130] =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E5=8F=98=E4=B8=BA?= =?UTF-8?q?=E6=97=A2=E6=97=B6=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 33 ++++++++++++++------- app/models/attachment.rb | 15 +++++----- app/views/files/_project_file_list.html.erb | 5 ++-- lib/trustie/utils/office.rb | 13 ++++---- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index d3781d747..8ad48c9b2 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -66,6 +66,12 @@ class AttachmentsController < ApplicationController file.downcase.end_with?(".pdf") end + def direct_download + send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), + :type => detect_content_type(@attachment), + :disposition => 'attachment' #inline can open in browser + end + def download # modify by nwb # 下载添加权限设置 @@ -73,23 +79,30 @@ class AttachmentsController < ApplicationController if candown || User.current.admin? || User.current.id == @attachment.author_id @attachment.increment_download if stale?(:etag => @attachment.digest) - convered_file = @attachment.diskfile - unless pdf?(convered_file) - convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".pdf") - end - if File.exist?(convered_file) && pdf?(convered_file) - send_file convered_file, :type => 'application/pdf; charset=utf-8', :disposition => 'inline' + if params[:force] == 'true' + direct_download else - send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename), - :type => detect_content_type(@attachment), - :disposition => 'attachment' #inline can open in browser + convered_file = @attachment.diskfile + #如果本身不是pdf文件,则先寻找是不是已转换化,如果没有则转化 + unless pdf?(convered_file) + convered_file = File.join(Rails.root, "files", "convered_office", @attachment.disk_filename + ".pdf") + unless File.exist?(convered_file) + office = Trustie::Utils::Office.new(@attachment.diskfile) + office.conver(convered_file) + end + end + if File.exist?(convered_file) && pdf?(convered_file) + send_file convered_file, :type => 'application/pdf; charset=utf-8', :disposition => 'inline' + else + direct_download + end end end else render_403 :message => :notice_not_authorized end rescue => e - redirect_to "http: //" + (Setting.host_name.to_s) +"/file_not_found.html" + redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html" end #更新资源文件类型 diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 1f1d61581..f999e27d6 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -259,13 +259,14 @@ class Attachment < ActiveRecord::Base end def office_conver - return unless %w(Project Course).include? (self.container_type) - saved_path = File.join(Rails.root, "files", "convered_office") - unless Dir.exist?(saved_path) - Dir.mkdir(saved_path) - end - convered_file = File.join(saved_path, self.disk_filename + ".pdf") - OfficeConverTask.new.conver(self.diskfile, convered_file) + # 不在这里做后台转换,换为点击时做转换 + # return unless %w(Project Course).include? (self.container_type) + # saved_path = File.join(Rails.root, "files", "convered_office") + # unless Dir.exist?(saved_path) + # Dir.mkdir(saved_path) + # end + # convered_file = File.join(saved_path, self.disk_filename + ".pdf") + # OfficeConverTask.new.conver(self.diskfile, convered_file) end # Copies the temporary file to its final location diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index 35aa36195..a5152ecdc 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -30,6 +30,7 @@ <% else %> <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% end %> + <%= link_to '下载',download_named_attachment_path(file.id, file.filename, force: true),class: 'f_l re_open' %> <% end %>
@@ -37,7 +38,7 @@文件大小:<%= number_to_human_size(file.filesize) %>
<%= link_to( l(:button_delete), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if manage_allowed && file.container_id == project.id && file.container_type == "Project"%> -<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
+<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
<% if reply.attachments.any?%>
<% options = {:author => true, :deletable => reply.deleted_attach_able_by?(User.current) } %>
@@ -183,4 +183,4 @@
});
};
$("img").removeAttr("align");
-
\ No newline at end of file
+
diff --git a/config/application.rb b/config/application.rb
index 9e7a2ba81..83ba21b05 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -67,6 +67,8 @@ module RedmineApp
# Do not include all helpers
config.action_controller.include_all_helpers = false
+ config.action_view.sanitized_allowed_tags = 'div', 'p', 'span', 'img', 'embed'
+
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
end
diff --git a/db/schema.rb b/db/schema.rb
index 42c743588..1a59ccc86 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -606,6 +606,13 @@ ActiveRecord::Schema.define(:version => 20150602055730) do
t.datetime "updated_at", :null => false
end
+ create_table "invite_lists", :force => true do |t|
+ t.integer "project_id"
+ t.integer "user_id"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "issue_categories", :force => true do |t|
t.integer "project_id", :default => 0, :null => false
t.string "name", :limit => 30, :default => "", :null => false
From cd8f3bdea3394e00b6abb18247cb3e7e81ee2184 Mon Sep 17 00:00:00 2001
From: yutao <283765470@qq.com>
Date: Thu, 4 Jun 2015 17:49:53 +0800
Subject: [PATCH 012/130] ...
---
app/views/courses/show.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb
index 0feca0d1b..63285a2cd 100644
--- a/app/views/courses/show.html.erb
+++ b/app/views/courses/show.html.erb
@@ -35,7 +35,7 @@
:class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type,
'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link",
'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%>
- <%if @controller_name=='ActivityNotifys' && !e.get_notify_is_read%>
+ <%if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%>
<%end%>
From 2f2d0a79422de47a883ba4982d138193c8774ce5 Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 5 Jun 2015 09:37:56 +0800
Subject: [PATCH 013/130] =?UTF-8?q?bid=E5=B7=B2=E7=BB=8F=E5=BA=9F=E5=BC=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
spec/factories/homeworks.rb | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/spec/factories/homeworks.rb b/spec/factories/homeworks.rb
index 208255a8d..d7fb1cab6 100644
--- a/spec/factories/homeworks.rb
+++ b/spec/factories/homeworks.rb
@@ -2,16 +2,16 @@
#
#:author_id, :budget, :deadline, :name, :description, :homework_type, :password
-FactoryGirl.define do
- factory :homework, class: Bid do
- name "test homework"
- budget 0
- deadline {(Time.now+1.days).strftime('%Y-%m-%d')}
- description "description"
- homework_type 3
- reward_type 3
- end
-
- factory :homework_attach, class: HomeworkAttach do
- end
-end
+# FactoryGirl.define do
+# factory :homework, class: Bid do
+# name "test homework"
+# budget 0
+# deadline {(Time.now+1.days).strftime('%Y-%m-%d')}
+# description "description"
+# homework_type 3
+# reward_type 3
+# end
+#
+# factory :homework_attach, class: HomeworkAttach do
+# end
+# end
From d2c51f27b6c79baebf815d8c6a031789c3450e0a Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Fri, 5 Jun 2015 09:48:23 +0800
Subject: [PATCH 014/130] =?UTF-8?q?Bid=E5=8A=9F=E8=83=BD=E5=B7=B2=E7=BB=8F?=
=?UTF-8?q?=E5=BA=9F=E5=BC=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/bids_controller.rb | 2193 ++++++++++++++--------------
1 file changed, 1097 insertions(+), 1096 deletions(-)
diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb
index 35236414f..7db03aca1 100644
--- a/app/controllers/bids_controller.rb
+++ b/app/controllers/bids_controller.rb
@@ -1,1096 +1,1097 @@
-# fq
-class BidsController < ApplicationController
- #Added by young
- menu_item l(:label_homework), :only => [:edit, :udpate]
- menu_item :respond
- menu_item :course, :only => :show_courseEx
- menu_item :project, :only => [:show_project,:show_results, :new_submit_homework]
- menu_item :homework_respond, :only => :homework_respond
- menu_item :homework_statistics, :only => :homework_statistics
- menu_item :edit, :only => :edit
-
- before_filter :auth_login1, :only => [:show_courseEx]
-
- before_filter :can_show_course,only: []
- before_filter :can_show_contest,only: []
- #Ended by young
- before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork,
- :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings]
- # added by fq
- before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest]
- # end
- before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ]
-
- #before_filter :memberAccess, only: :show_project
-
- helper :watchers
- helper :attachments
- include AttachmentsHelper
- include ApplicationHelper
- include BidsHelper
-
- helper :projects
- helper :words
- helper :welcome
- helper :project_score
-
- def find_project_by_bid_id
- @bid = Bid.find(params[:id])
- @project = @bid.courses[0]
- rescue ActiveRecord::RecordNotFound
- render_404
- end
-
- def homework_ajax_modal
- @bid = Bid.find_by_id(params[:id])
- # find_bid
- respond_to do |format|
- format.js
- end
- end
-
-
- def index
- @project_type = params[:project_type]
- # Modified by nie
- # @requirement_title = "4"
- @offset, @limit = api_offset_and_limit({:limit => 10})
- if @project_type == '1'
- @bids = Bid.visible.where('reward_type = ?', 3)
- # elsif
- # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
- else
- @bids = Bid.visible.where('reward_type = ?', 1)
- end
-
- @bids = @bids.like(params[:name]) if params[:name].present?
- @bid_count = @bids.count
- @bid_pages = Paginator.new @bid_count, @limit, params['page']
-
- @offset ||= @bid_pages.reverse_offset
- #added by nie
- if params[:bid_sort_type].present?
- case params[:bid_sort_type]
- when '0'
- unless @offset == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.offset(@offset).limit(limit).all.reverse
- end
- @s_state = 0
- when '1'
- unless @offset == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
- end
- @s_state = 1
- when '2'
- unless @offset == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- end
- @s_state = 0
- end
- else
- unless @offset == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
- end
- @s_state = 1
- end
- #end
- end
- #huang
- def contest
-
- # Modified by nie
- # @requirement_title = "4"
- @offset, @limit = api_offset_and_limit({:limit => 10})
-
- @bids = Bid.visible.where('reward_type = ?', 2)
-
- # elsif
- # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
- @bids = @bids.like(params[:name]) if params[:name].present?
- @bid_count = @bids.count
- @bid_pages = Paginator.new @bid_count, @limit, params['page']
-
- @offset ||= @bid_pages.reverse_offset
- #added by nie
- if params[:contest_sort_type].present?
- case params[:contest_sort_type]
- when '0'
- unless @offset == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.offset(@offset).limit(limit).all.reverse
- end
- @s_state = 0
- when '1'
- unless @offset == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
- end
- @s_state = 1
- when '2'
- unless @offset == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.offset(@offset).limit(@limit).all.reverse
- end
- @s_state = 0
- end
- else
- unless @offset == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse
- else
- limit = @bid_count % @limit
- limit = @limit if limit == 0
- @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse
- end
- @s_state = 1
- end
- #end
- end
-
- def fork
- @courses = []
- @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
- @membership.each do |membership|
- if membership.project.project_type == 1
- @courses << membership.project
- end
- end
- end
-
- #将某个企业外包需求选为作业,目前此功能已放弃
- def create_fork
- @homework = Bid.new
- @homework.name = params[:bid][:name]
- @homework.description = params[:bid][:description]
- @homework.reward_type = 3
- # @bid.budget = params[:bid][:budget]
- @homework.deadline = params[:bid][:deadline]
- @homework.budget = 0
- @homework.author_id = User.current.id
- @homework.commit = 0
- @homework.homework_type = 1
- @homework.is_evaluation = params[:bid][:is_evaluation]
- @homework.parent_id = @bid.id
- @homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
- # @bid.
- if @homework.save
- HomeworkForCourse.create(:course_id => params[:course], :bid_id => @homework.id)
- unless @bid.watched_by?(User.current)
- if @bid.add_watcher(User.current)
- flash[:notice] = l(:label_bid_succeed)
- end
- end
- redirect_to course_for_bid_path(@homework)
- else
- @bid.safe_attributes = params[:bid]
- @courses = []
- @membership = User.current.coursememberships.all#(:conditions => Project.visible_condition(User.current))
- @membership.each do |membership|
- @courses << membership.course
- end
- render :action => 'fork'
- end
- end
-
- #有两个路由链接到此方法:/bids/:id /calls/:id但是貌似这两个路由都不能访问。。方法作用有待确认
- def show
- @user = @bid.author
- @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
- @limit = 10
- @feedback_count = @jours.count
- @feedback_pages = Paginator.new @feedback_count, @limit, params['page']
- @offset ||= @feedback_pages.offset
- @jour = @jours[@offset, @limit]
- @state = false
-
- respond_to do |format|
- layout_file = ''
- case @bid.reward_type
- when 3
- html_title(l(:label_question_student))
- layout_file = 'base_homework'
- when 1
- layout_file = 'base_bids'
- else
- layout_file = 'base_contest'
- end
- format.html {
- render :layout => layout_file
- }
- format.api
- end
- end
-
- def join_in_contest
- if @bid.reward_type == 2 && params[:course_password] == @bid.password
- JoinInContest.create(:user_id => User.current.id, :bid_id => @bid.id)
- @state = 0
- else
- @state = 1
- end
- respond_to do |format|
- format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
- end
- end
-
- def unjoin_in_contest
- joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id)
- joined.each do |join|
- join.delete
- end
- respond_to do |format|
- format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} }
- end
- end
-
- def new_join
-
- end
-
- # added by bai 增加了参与者和竞赛设置
- def show_participator
- render :layout => 'base_contest'
- end
-
- #配置竞赛
- def settings
- if @bid.author.id == User.current.id
- if @bid.reward_type == 2
- @contest = Bid.find_by_reward_type(@bid.reward_type)
- render :layout => 'base_contest'
- end
- else
- render_403 :message => :notice_not_contest_setting_authorized
- end
- end
- #end
-
- # 显示课程作业,但是好像已经废弃
- def show_course
- bids = Bid.where('parent_id = ?', @bid.id)
- @courses = []
- for bid in bids
- @courses << bid.courses.first
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
-
- end
- end
-
- def show_bid_project
- bids = Bid.where('parent_id = ?', @bid.id)
- @projects = []
- for bid in bids
- @projects += bid.biding_projects
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
-
- end
- end
-
- def show_bid_user
- bids = Bid.where('parent_id = ?', @bid.id)
- @users = []
- for bid in bids
- for project in bid.projects
- @users += project.users
- end
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
-
- end
- end
-
- def show_project
- # flash[:notice] = ""
- @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
- @option = []
- @membership.each do |membership|
- unless(membership.project.project_type==1)
- if membership.user.allowed_to?(:quote_project,membership.project)
- @option << membership.project
- end
- end
- end
-
- # a = [1]
- # @project = Project.where("id in []", a)
- @user = @bid.author
- @bidding_project = @bid.biding_projects.all
- if params[:student_id].present?
- @temp = []
- @bidding_project.each do |pro|
- if pro.project && pro.project.project_status
- if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
- @temp << pro
- end
- end
- @temp
- end
- @bidding_project = @temp
- else
- #added by nie
- @temp = []
- @bidding_project.each do |pro|
- if pro.project && pro.project.project_status
- @temp << pro
- end
- @temp
- end
- if @temp.size > 0
- @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
- end
- #ended
- end
-
- if @bid.homework_type == 1
- @homework = HomeworkAttach.new
- #@homework_list = @bid.homeworks
- #增加作业按评分排序,
- @homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
- if params[:student_id].present?
- @temp = []
- @homework_list.each do |pro|
- if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
- @temp << pro
- end
- @temp
- end
- @homework_list = @temp
- end
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
- end
- end
-
- # 显示作业课程
- # add by nwb
- def show_courseEx
-
- if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?))
- @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
- @user = @bid.author
- @bidding_project = @bid.biding_projects.all
-
- if params[:student_id].present?
- @temp = []
- @bidding_project.each do |pro|
- if pro.project && pro.project.project_status
- if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
- @temp << pro
- end
- end
- @temp
- end
- @bidding_project = @temp
- else
- #added by nie
- @temp = []
- @bidding_project.each do |pro|
- if pro.project && pro.project.project_status
- @temp << pro
- end
- @temp
- end
- if @temp.size > 0
- @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
- end
- #ended
- end
-
- if @bid.homework_type
- @homework = HomeworkAttach.new
- @is_teacher = is_course_teacher(User.current,@bid.courses.first)
- if @is_teacher
- all_homework_list = HomeworkAttach.find_by_sql("SELECT * FROM (SELECT homework_attaches.*,
- (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score,
- (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score
- FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1
- WHERE table1.t_score IS NULL")
- @not_batch_homework = true
- @cur_type = 1
- else
- all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*,
- (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score,
- (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score,
- (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = #{@is_teacher ? 1 : 0}) AS m_score
- FROM homework_attaches
- INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id
- WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC")
- @is_student_batch_homework = true
- @cur_type = 4
- end
-
- @cur_page = params[:page] || 1
- # @homework_list = paginateHelper all_homework_list,10
- @homework_list = all_homework_list
- @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count
- if params[:student_id].present?
- @temp = []
- @homework_list.each do |pro|
- if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
- @temp << pro
- end
- @temp
- end
- @homework_list = @temp
- end
- end
-
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- html_title(l(:label_homework_info))
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
- end
- else
- render_403 :message => :notice_not_authorized
- end
- end
-
- ##### by huang
- def show_project_homework
- # flash[:notice] = ""
- @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
- @option = []
- @membership.each do |membership|
- end
- # a = [1]
- # @project = Project.where("id in []", a)
- @user = @bid.author
- @bidding_project = @bid.biding_projects
- respond_to do |format|
- if @bid.reward_type == 3
- format.html {
- render :layout => 'base_homework'
- }
- elsif @bid.reward_type == 1
- format.html {
- render :layout => 'base_bids'
- }
- else
- format.html {
- render :layout => 'base_contest'
- }
- end
- format.api
- end
- end
-
- ###添加应标项目
- def add
- project = Project.find(params[:bid])
- bid_message = params[:bid_for_save][:bid_message]
- if BidingProject.where("project_id = ? and bid_id = ?", project.id, @bid.id).size == 0
- if BidingProject.cerate_bidding(@bid.id, project.id, bid_message)
-
- # added by bai type ==1 需求,type==2 竞赛, type==3 作业
- if @bid.reward_type == 1
- flash.now[:notice] = l(:label_bidding_succeed)
-
- elsif @bid.reward_type == 2
- flash.now[:notice] = l(:label_bidding_contest_succeed)
-
- else @bid.reward_type == 3
- flash.now[:notice] = l(:label_bidding_homework_succeed)
- end
- # end
-
- end
- else
- if @bid.reward_type == 3
- flash.now[:error] = l(:label_bidding_homework_fail)
- else
- flash.now[:error] = l(:label_bidding_fail)
- end
- end
- @bidding_project = @bid.biding_projects
- respond_to do |format|
- # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
- # format.html
- format.html { redirect_to :back }
- format.js
- #format.api { render_api_ok }
- end
- end
-
- #删除已提交的项目作业(不删项目)
- def delete
- binding_project = params[:binding_project]
- if can_delete_project_homework(BidingProject.find(binding_project),User.current)
- if BidingProject.delete(binding_project)
- redirect_to project_for_bid_url
- else
- render_403;
- end
- end
- end
- ## 新建留言
- def create
-
- if params[:bid_message][:message].size>0
- if params[:reference_content]
- message = params[:bid_message][:message] + "\n" + params[:reference_content]
- else
- message = params[:bid_message][:message]
- @m = message
- end
- refer_user_id = params[:bid_message][:reference_user_id].to_i
- @bid.add_jour(User.current, message, refer_user_id)
- end
- @user = @bid.author
- @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
- @jour = paginateHelper @jours,10
- @bid.set_commit(@feedback_count)
- respond_to do |format|
- format.js
- #format.api { render_api_ok }
- end
-
- end
-
- ##删除留言
- def destroy
- @user = @bid.author
- if User.current.admin? || User.current.id == @user.id
- JournalsForMessage.delete_message(params[:object_id])
- end
- @jours = @bid.journals_for_messages.reverse
- @limit = 10
- @feedback_count = @jours.count
- @feedback_pages = Paginator.new @feedback_count, @limit, params['page']
- @offset ||= @feedback_pages.offset
- @jour = @jours[@offset, @limit]
-
- @bid.set_commit(@feedback_count)
- # if a_message.size > 5
- # @message = a_message[-5, 5]
- # else
- # @message = a_message
- # end
- # @message_count = a_message.count
-
- respond_to do |format|
- # format.html
- format.js
- #format.api { render_api_ok }
- end
- end
-
- #删除作业
- #by xianbo
- def homework_destroy
- @bid_to_destroy = Bid.find params[:id]
- course_url = course_homework_path(@bid_to_destroy.courses.first)
- (render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_id
- @bid_to_destroy.destroy
- respond_to do |format|
- format.html { redirect_to course_url }
- format.js
- #format.api { render_api_ok }
- end
- end
-
- #end by xianbo
- ##引用
- def new
- @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id]
- if @jour
- user = @jour.user
- text = @jour.notes
- else
- user = @bid.author
- text = @bid.description
- end
- # Replaces pre blocks with [...]
- text = text.to_s.strip.gsub(%r{
((.|\s)*?)}m, '[...]') - @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> " - @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" - @id = user.id - rescue ActiveRecord::RecordNotFound - render_404 - end - - ##新建需求 - def new_bid - @bid = Bid.new - @bid.safe_attributes = params[:bid] - end - - #huang - def create_contest - @bid = Bid.new - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.reward_type = 2 - @bid.budget = params[:bid][:budget] - @bid.deadline = params[:bid][:deadline] - @bid.password = params[:bid][:password] #added by bai - @bid.author_id = User.current.id - @bid.commit = 0 - if @bid.save - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to respond_url(@bid) - else - @bid.safe_attributes = params[:bid] - render :action => 'new_bid' - end - end - - # added by bai - def update_contest - @bid = Bid.find(params[:id]) - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.reward_type = 2 - @bid.budget = params[:bid][:budget] - @bid.deadline = params[:bid][:deadline] - @bid.password = params[:bid][:password] - @bid.author_id = User.current.id - @bid.commit = 0 - if @bid.save - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to respond_url(@bid) - else - @bid.safe_attributes = params[:bid] - render :action => 'new_bid' - end - end - #huang - def new_contest - @bid = Bid.new - @bid.safe_attributes = params[:bid] - end - - def create_bid - @bid = Bid.new - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.reward_type = 1 - @bid.budget = params[:bid][:budget] - @bid.deadline = params[:bid][:deadline] - @bid.author_id = User.current.id - @bid.commit = 0 - if @bid.save - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to respond_url(@bid) - else - @bid.safe_attributes = params[:bid] - render :action => 'new_bid' - end - end - - def create_homework - @bid = Bid.new - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.is_evaluation = params[:bid][:is_evaluation] - @bid.proportion = params[:bid][:proportion] - @bid.evaluation_num = params[:bid][:evaluation_num] - params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 - @bid.reward_type = 3 - # @bid.budget = params[:bid][:budget] - @bid.deadline = params[:bid][:deadline] - @bid.budget = 0 - @bid.author_id = User.current.id - @bid.commit = 0 - @bid.homework_type = 1 - @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - # @bid. - if @bid.save - HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id) - unless @bid.watched_by?(User.current) - if @bid.add_watcher(User.current) - flash[:notice] = l(:label_bid_succeed) - end - end - redirect_to course_homework_url(params[:course_id]) - else - @bid.safe_attributes = params[:bid] - @homework = @bid - @course = Course.find_by_id(params[:course_id]) - @course_id = @course.id - #respond_to do |format| - # format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'} - # format.api { render_validation_errors(@bid) } - #end - render file: 'courses/new_homework', layout: 'base_courses' - end - end - - # modify by nwb\ - # 编辑作业 - def edit - @bid = Bid.find(params[:bid_id]) - if (User.current.admin?||User.current.allowed_to?(:as_teacher,@bid.courses.first)) - @course_id = params[:course_id] - respond_to do |format| - format.html { - @course = Course.find(params[:course_id]) - @user= User.find(User.current.id) - render :layout => 'base_courses' - } - end - else - render_403 - end - end - - def update - @bid = Bid.find(params[:id]) - @course = @bid.courses.first#Project.find(params[:course_id]) - @bid.name = params[:bid][:name] - @bid.description = params[:bid][:description] - @bid.is_evaluation = params[:bid][:is_evaluation] - @bid.proportion = params[:bid][:proportion] - @bid.evaluation_num = params[:bid][:evaluation_num] - params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 - @bid.reward_type = 3 - @bid.deadline = params[:bid][:deadline] - @bid.budget = 0 - #@bid.author_id = User.current.id - @bid.commit = 0 - @bid.homework_type = 1 - @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - if @bid.save - flash[:notice] = l(:label_update_homework_succeed) - redirect_to course_homework_url(@course) - else - @bid.safe_attributes = params[:bid] - render :action => 'edit', :layout =>'base_courses' - end - end - - def new_submit_homework - #render html to prepare create submit homework - find_bid - find_bid - render :layout => 'base_homework' - end - - def add_homework - if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) - # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) - # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - - if hadcommittedhomework(User.current.id, @bid.id) == true - @homework_flag = l(:label_bidding_homework_committed) - else - @homework = HomeworkAttach.new - @homework.safe_attributes = params[:homeworkattach] - @homework.bid_id = @bid.id - @homework.user_id = User.current.id - @homework.save_attachments(params[:attachments]) - - render_attachment_warning_if_needed(@homework) - - @homework_flag = if @homework.save - l(:label_bidding_homework_succeed) - else - l(:label_bidding_homework_failed) - end - - if @homework.attachments.empty? - @homework.delete - #flash[:error] = l(:no_attachmens_allowed) - @homework_flag = l(:no_attachmens_allowed) - # else - end - end - end - - @homework_list = @bid.homeworks - respond_to do |format| - format.html{ - #redirect_to project_for_bid_path, notice: @homework_flag.to_s - flash[:notice] = @homework_flag.to_s - redirect_back_or_default(project_for_bid_path) - } - format.js - end - - end - - # 作业统计 - def homework_statistics - @course = @bid.courses.first - @member = [] - @course.memberships.each do |member| - unless (member.roles && Role.where('id = ? ', 3)).empty? - @member.push member - end - end - if @bid.homework_type = 1 - @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id) - @homework_type = true - else - - @homework_type = false - end - @user = @bid.author - render :layout => 'base_homework' - end - - def homework_respond - @user = @bid.author - render :layout => 'base_homework' - end - - def more - @jour = @bid.journals_for_messages - @jour.each_with_index {|j,i| j.indice = i+1} - @state = true - - respond_to do |format| - format.html { redirect_to :back } - format.js - #format.api { render_api_ok } - end - end - - def back - @jour = @bid.journals_for_messages - @jour.each_with_index {|j,i| j.indice = i+1} - @state = false - - respond_to do |format| - format.html { redirect_to :back } - format.js - #format.api { render_api_ok } - end - end - - #added by william - #used to set the bidding project reward - def set_reward - @b_p = nil - @biding_project_id = nil - - if params[:set_reward][:reward]&&((User.current.id==@bid.author_id)||User.current.admin) - # @bid_id = params[:id] - @biding_project_id = params[:set_reward][:b_id] - @b_p = BidingProject.find_by_id(@biding_project_id) - - # 把字段存进表中 - @b_p.update_reward(params[:set_reward][:reward].to_s) - end - - respond_to do |format| - format.js - end - end - - # added by william - # used to manage the bid and end the bid - def manage - - end - - # 启动匿评 - def start_anonymous_comment - @bid = Bid.find(params[:id]) - @course = @bid.courses.first - if(@bid.comment_status == 0) - homeworks = @bid.homeworks - if(homeworks && homeworks.size >= 2) - homeworks.each_with_index do |homework, index| - user = homework.user - n = @bid.evaluation_num - n = n < homeworks.size ? n : homeworks.size - 1 - assigned_homeworks = get_assigned_homeworks(homeworks, n, index) - assigned_homeworks.each do |h| - @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id) - @homework_evaluation.save - end - end - @bid.update_column('comment_status', 1) - @statue = 1 - else - @statue = 2 - end - else - @statue = 3 - end - - respond_to do |format| - format.js - end - end - - def stop_anonymous_comment - @bid = Bid.find(params[:id]) - - @bid.update_column('comment_status', 2) - - respond_to do |format| - format.js - end - end - - def alert_anonymous_comment - @bid = Bid.find params[:id] - @course = @bid.courses.first - @cur_size = 0 - @totle_size = 0 - if @bid.comment_status == 0 - @totle_size = searchStudent(@course).size - @cur_size = @bid.homeworks.size - elsif @bid.comment_status == 1 - @bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count} - @cur_size = 0 - @bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.is_teacher_score = 0").count} - end - @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) - respond_to do |format| - format.js - end - end - - private - - def get_assigned_homeworks(homeworks, n, index) - homeworks += homeworks - homeworks[index + 1 .. index + n] - end - - def find_bid - if params[:id] - @bid = Bid.find(params[:id], :include => [{:homeworks => :user}]) - @user = @bid.author - end - rescue - render_404 - end - - def memberAccess - # 是课程,则判断当前用户是否参加了课程 - return true if current_user.admin? - #return 0 if @bid.courses.first.project_type == Project::ProjectType_project - currentUser = User.current - render_403 unless currentUser.member_of_course?(@bid.courses.first) - end - - #验证是否显示课程 - def can_show_course - @first_page = FirstPage.find_by_page_type('project') - if @first_page.show_course == 2 - render_404 - end - end - - #验证是否显示竞赛 - def can_show_contest - @first_page = FirstPage.find_by_page_type('project') - if @first_page.show_contest == 2 - render_404 - end - end -end - +# # fq +#Bid功能已经废弃 +# class BidsController < ApplicationController +# #Added by young +# menu_item l(:label_homework), :only => [:edit, :udpate] +# menu_item :respond +# menu_item :course, :only => :show_courseEx +# menu_item :project, :only => [:show_project,:show_results, :new_submit_homework] +# menu_item :homework_respond, :only => :homework_respond +# menu_item :homework_statistics, :only => :homework_statistics +# menu_item :edit, :only => :edit +# +# before_filter :auth_login1, :only => [:show_courseEx] +# +# before_filter :can_show_course,only: [] +# before_filter :can_show_contest,only: [] +# #Ended by young +# before_filter :find_bid, :only => [:show, :show_project, :create,:destroy,:more,:back,:add,:delete,:new,:show_results,:set_reward, :add_homework, :fork, :create_fork, +# :show_course, :show_courseEx,:show_bid_project, :show_bid_user, :join_in_contest, :unjoin_in_contest, :new_join,:show_participator, :settings] +# # added by fq +# before_filter :require_login, :only => [:join_in_contest, :unjoin_in_contest] +# # end +# before_filter :require_login,:only => [:set_reward, :destroy, :add, :new, ] +# +# #before_filter :memberAccess, only: :show_project +# +# helper :watchers +# helper :attachments +# include AttachmentsHelper +# include ApplicationHelper +# include BidsHelper +# +# helper :projects +# helper :words +# helper :welcome +# helper :project_score +# +# def find_project_by_bid_id +# @bid = Bid.find(params[:id]) +# @project = @bid.courses[0] +# rescue ActiveRecord::RecordNotFound +# render_404 +# end +# +# def homework_ajax_modal +# @bid = Bid.find_by_id(params[:id]) +# # find_bid +# respond_to do |format| +# format.js +# end +# end +# +# +# def index +# @project_type = params[:project_type] +# # Modified by nie +# # @requirement_title = "4" +# @offset, @limit = api_offset_and_limit({:limit => 10}) +# if @project_type == '1' +# @bids = Bid.visible.where('reward_type = ?', 3) +# # elsif +# # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) +# else +# @bids = Bid.visible.where('reward_type = ?', 1) +# end +# +# @bids = @bids.like(params[:name]) if params[:name].present? +# @bid_count = @bids.count +# @bid_pages = Paginator.new @bid_count, @limit, params['page'] +# +# @offset ||= @bid_pages.reverse_offset +# #added by nie +# if params[:bid_sort_type].present? +# case params[:bid_sort_type] +# when '0' +# unless @offset == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.offset(@offset).limit(limit).all.reverse +# end +# @s_state = 0 +# when '1' +# unless @offset == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse +# end +# @s_state = 1 +# when '2' +# unless @offset == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# end +# @s_state = 0 +# end +# else +# unless @offset == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse +# end +# @s_state = 1 +# end +# #end +# end +# #huang +# def contest +# +# # Modified by nie +# # @requirement_title = "4" +# @offset, @limit = api_offset_and_limit({:limit => 10}) +# +# @bids = Bid.visible.where('reward_type = ?', 2) +# +# # elsif +# # @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4) +# @bids = @bids.like(params[:name]) if params[:name].present? +# @bid_count = @bids.count +# @bid_pages = Paginator.new @bid_count, @limit, params['page'] +# +# @offset ||= @bid_pages.reverse_offset +# #added by nie +# if params[:contest_sort_type].present? +# case params[:contest_sort_type] +# when '0' +# unless @offset == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.offset(@offset).limit(limit).all.reverse +# end +# @s_state = 0 +# when '1' +# unless @offset == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse +# end +# @s_state = 1 +# when '2' +# unless @offset == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.offset(@offset).limit(@limit).all.reverse +# end +# @s_state = 0 +# end +# else +# unless @offset == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(@limit).all.reverse +# else +# limit = @bid_count % @limit +# limit = @limit if limit == 0 +# @bids = @bids.reorder('bids.commit').offset(@offset).limit(limit).all.reverse +# end +# @s_state = 1 +# end +# #end +# end +# +# def fork +# @courses = [] +# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) +# @membership.each do |membership| +# if membership.project.project_type == 1 +# @courses << membership.project +# end +# end +# end +# +# #将某个企业外包需求选为作业,目前此功能已放弃 +# def create_fork +# @homework = Bid.new +# @homework.name = params[:bid][:name] +# @homework.description = params[:bid][:description] +# @homework.reward_type = 3 +# # @bid.budget = params[:bid][:budget] +# @homework.deadline = params[:bid][:deadline] +# @homework.budget = 0 +# @homework.author_id = User.current.id +# @homework.commit = 0 +# @homework.homework_type = 1 +# @homework.is_evaluation = params[:bid][:is_evaluation] +# @homework.parent_id = @bid.id +# @homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) +# # @bid. +# if @homework.save +# HomeworkForCourse.create(:course_id => params[:course], :bid_id => @homework.id) +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to course_for_bid_path(@homework) +# else +# @bid.safe_attributes = params[:bid] +# @courses = [] +# @membership = User.current.coursememberships.all#(:conditions => Project.visible_condition(User.current)) +# @membership.each do |membership| +# @courses << membership.course +# end +# render :action => 'fork' +# end +# end +# +# #有两个路由链接到此方法:/bids/:id /calls/:id但是貌似这两个路由都不能访问。。方法作用有待确认 +# def show +# @user = @bid.author +# @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') +# @limit = 10 +# @feedback_count = @jours.count +# @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] +# @offset ||= @feedback_pages.offset +# @jour = @jours[@offset, @limit] +# @state = false +# +# respond_to do |format| +# layout_file = '' +# case @bid.reward_type +# when 3 +# html_title(l(:label_question_student)) +# layout_file = 'base_homework' +# when 1 +# layout_file = 'base_bids' +# else +# layout_file = 'base_contest' +# end +# format.html { +# render :layout => layout_file +# } +# format.api +# end +# end +# +# def join_in_contest +# if @bid.reward_type == 2 && params[:course_password] == @bid.password +# JoinInContest.create(:user_id => User.current.id, :bid_id => @bid.id) +# @state = 0 +# else +# @state = 1 +# end +# respond_to do |format| +# format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } +# end +# end +# +# def unjoin_in_contest +# joined = JoinInContest.where('bid_id = ? and user_id = ?', @bid.id, User.current.id) +# joined.each do |join| +# join.delete +# end +# respond_to do |format| +# format.js { render :partial => 'set_join', :locals => {:user => User.current, :object_id => params[:id]} } +# end +# end +# +# def new_join +# +# end +# +# # added by bai 增加了参与者和竞赛设置 +# def show_participator +# render :layout => 'base_contest' +# end +# +# #配置竞赛 +# def settings +# if @bid.author.id == User.current.id +# if @bid.reward_type == 2 +# @contest = Bid.find_by_reward_type(@bid.reward_type) +# render :layout => 'base_contest' +# end +# else +# render_403 :message => :notice_not_contest_setting_authorized +# end +# end +# #end +# +# # 显示课程作业,但是好像已经废弃 +# def show_course +# bids = Bid.where('parent_id = ?', @bid.id) +# @courses = [] +# for bid in bids +# @courses << bid.courses.first +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# +# end +# end +# +# def show_bid_project +# bids = Bid.where('parent_id = ?', @bid.id) +# @projects = [] +# for bid in bids +# @projects += bid.biding_projects +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# +# end +# end +# +# def show_bid_user +# bids = Bid.where('parent_id = ?', @bid.id) +# @users = [] +# for bid in bids +# for project in bid.projects +# @users += project.users +# end +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# +# end +# end +# +# def show_project +# # flash[:notice] = "" +# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) +# @option = [] +# @membership.each do |membership| +# unless(membership.project.project_type==1) +# if membership.user.allowed_to?(:quote_project,membership.project) +# @option << membership.project +# end +# end +# end +# +# # a = [1] +# # @project = Project.where("id in []", a) +# @user = @bid.author +# @bidding_project = @bid.biding_projects.all +# if params[:student_id].present? +# @temp = [] +# @bidding_project.each do |pro| +# if pro.project && pro.project.project_status +# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id +# @temp << pro +# end +# end +# @temp +# end +# @bidding_project = @temp +# else +# #added by nie +# @temp = [] +# @bidding_project.each do |pro| +# if pro.project && pro.project.project_status +# @temp << pro +# end +# @temp +# end +# if @temp.size > 0 +# @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} +# end +# #ended +# end +# +# if @bid.homework_type == 1 +# @homework = HomeworkAttach.new +# #@homework_list = @bid.homeworks +# #增加作业按评分排序, +# @homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC") +# if params[:student_id].present? +# @temp = [] +# @homework_list.each do |pro| +# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id +# @temp << pro +# end +# @temp +# end +# @homework_list = @temp +# end +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# end +# end +# +# # 显示作业课程 +# # add by nwb +# def show_courseEx +# +# if (User.current.logged? && (User.current.member_of_course?(@bid.courses.first) || User.current.admin?)) +# @membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current)) +# @user = @bid.author +# @bidding_project = @bid.biding_projects.all +# +# if params[:student_id].present? +# @temp = [] +# @bidding_project.each do |pro| +# if pro.project && pro.project.project_status +# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id +# @temp << pro +# end +# end +# @temp +# end +# @bidding_project = @temp +# else +# #added by nie +# @temp = [] +# @bidding_project.each do |pro| +# if pro.project && pro.project.project_status +# @temp << pro +# end +# @temp +# end +# if @temp.size > 0 +# @bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade} +# end +# #ended +# end +# +# if @bid.homework_type +# @homework = HomeworkAttach.new +# @is_teacher = is_course_teacher(User.current,@bid.courses.first) +# if @is_teacher +# all_homework_list = HomeworkAttach.find_by_sql("SELECT * FROM (SELECT homework_attaches.*, +# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, +# (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score +# FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY s_score DESC,created_at ASC) AS table1 +# WHERE table1.t_score IS NULL") +# @not_batch_homework = true +# @cur_type = 1 +# else +# all_homework_list = HomeworkAttach.find_by_sql("SELECT homework_attaches.*, +# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 1 AND stars IS NOT NULL ORDER BY updated_at DESC limit 0,1) AS t_score, +# (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND is_teacher_score = 0) AS s_score, +# (SELECT stars FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{User.current.id} AND is_teacher_score = #{@is_teacher ? 1 : 0}) AS m_score +# FROM homework_attaches +# INNER JOIN homework_evaluations ON homework_evaluations.homework_attach_id = homework_attaches.id +# WHERE homework_attaches.bid_id = #{@bid.id} AND homework_evaluations.user_id = #{User.current.id} ORDER BY s_score DESC") +# @is_student_batch_homework = true +# @cur_type = 4 +# end +# +# @cur_page = params[:page] || 1 +# # @homework_list = paginateHelper all_homework_list,10 +# @homework_list = all_homework_list +# @jours_count = @bid.journals_for_messages.where('m_parent_id IS NULL').count +# if params[:student_id].present? +# @temp = [] +# @homework_list.each do |pro| +# if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id +# @temp << pro +# end +# @temp +# end +# @homework_list = @temp +# end +# end +# +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# html_title(l(:label_homework_info)) +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# end +# else +# render_403 :message => :notice_not_authorized +# end +# end +# +# ##### by huang +# def show_project_homework +# # flash[:notice] = "" +# @membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current)) +# @option = [] +# @membership.each do |membership| +# end +# # a = [1] +# # @project = Project.where("id in []", a) +# @user = @bid.author +# @bidding_project = @bid.biding_projects +# respond_to do |format| +# if @bid.reward_type == 3 +# format.html { +# render :layout => 'base_homework' +# } +# elsif @bid.reward_type == 1 +# format.html { +# render :layout => 'base_bids' +# } +# else +# format.html { +# render :layout => 'base_contest' +# } +# end +# format.api +# end +# end +# +# ###添加应标项目 +# def add +# project = Project.find(params[:bid]) +# bid_message = params[:bid_for_save][:bid_message] +# if BidingProject.where("project_id = ? and bid_id = ?", project.id, @bid.id).size == 0 +# if BidingProject.cerate_bidding(@bid.id, project.id, bid_message) +# +# # added by bai type ==1 需求,type==2 竞赛, type==3 作业 +# if @bid.reward_type == 1 +# flash.now[:notice] = l(:label_bidding_succeed) +# +# elsif @bid.reward_type == 2 +# flash.now[:notice] = l(:label_bidding_contest_succeed) +# +# else @bid.reward_type == 3 +# flash.now[:notice] = l(:label_bidding_homework_succeed) +# end +# # end +# +# end +# else +# if @bid.reward_type == 3 +# flash.now[:error] = l(:label_bidding_homework_fail) +# else +# flash.now[:error] = l(:label_bidding_fail) +# end +# end +# @bidding_project = @bid.biding_projects +# respond_to do |format| +# # format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}} +# # format.html +# format.html { redirect_to :back } +# format.js +# #format.api { render_api_ok } +# end +# end +# +# #删除已提交的项目作业(不删项目) +# def delete +# binding_project = params[:binding_project] +# if can_delete_project_homework(BidingProject.find(binding_project),User.current) +# if BidingProject.delete(binding_project) +# redirect_to project_for_bid_url +# else +# render_403; +# end +# end +# end +# ## 新建留言 +# def create +# +# if params[:bid_message][:message].size>0 +# if params[:reference_content] +# message = params[:bid_message][:message] + "\n" + params[:reference_content] +# else +# message = params[:bid_message][:message] +# @m = message +# end +# refer_user_id = params[:bid_message][:reference_user_id].to_i +# @bid.add_jour(User.current, message, refer_user_id) +# end +# @user = @bid.author +# @jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') +# @jour = paginateHelper @jours,10 +# @bid.set_commit(@feedback_count) +# respond_to do |format| +# format.js +# #format.api { render_api_ok } +# end +# +# end +# +# ##删除留言 +# def destroy +# @user = @bid.author +# if User.current.admin? || User.current.id == @user.id +# JournalsForMessage.delete_message(params[:object_id]) +# end +# @jours = @bid.journals_for_messages.reverse +# @limit = 10 +# @feedback_count = @jours.count +# @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] +# @offset ||= @feedback_pages.offset +# @jour = @jours[@offset, @limit] +# +# @bid.set_commit(@feedback_count) +# # if a_message.size > 5 +# # @message = a_message[-5, 5] +# # else +# # @message = a_message +# # end +# # @message_count = a_message.count +# +# respond_to do |format| +# # format.html +# format.js +# #format.api { render_api_ok } +# end +# end +# +# #删除作业 +# #by xianbo +# def homework_destroy +# @bid_to_destroy = Bid.find params[:id] +# course_url = course_homework_path(@bid_to_destroy.courses.first) +# (render_403; return false) unless User.current.admin?||User.current.id==@bid_to_destroy.author_id +# @bid_to_destroy.destroy +# respond_to do |format| +# format.html { redirect_to course_url } +# format.js +# #format.api { render_api_ok } +# end +# end +# +# #end by xianbo +# ##引用 +# def new +# @jour = JournalsForMessage.find(params[:journal_id]) if params[:journal_id] +# if @jour +# user = @jour.user +# text = @jour.notes +# else +# user = @bid.author +# text = @bid.description +# end +# # Replaces pre blocks with [...] +# text = text.to_s.strip.gsub(%r{
((.|\s)*?)}m, '[...]') +# @content = "> #{ll(User.current.language, :text_user_wrote, user)}\n> " +# @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" +# @id = user.id +# rescue ActiveRecord::RecordNotFound +# render_404 +# end +# +# ##新建需求 +# def new_bid +# @bid = Bid.new +# @bid.safe_attributes = params[:bid] +# end +# +# #huang +# def create_contest +# @bid = Bid.new +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.reward_type = 2 +# @bid.budget = params[:bid][:budget] +# @bid.deadline = params[:bid][:deadline] +# @bid.password = params[:bid][:password] #added by bai +# @bid.author_id = User.current.id +# @bid.commit = 0 +# if @bid.save +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to respond_url(@bid) +# else +# @bid.safe_attributes = params[:bid] +# render :action => 'new_bid' +# end +# end +# +# # added by bai +# def update_contest +# @bid = Bid.find(params[:id]) +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.reward_type = 2 +# @bid.budget = params[:bid][:budget] +# @bid.deadline = params[:bid][:deadline] +# @bid.password = params[:bid][:password] +# @bid.author_id = User.current.id +# @bid.commit = 0 +# if @bid.save +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to respond_url(@bid) +# else +# @bid.safe_attributes = params[:bid] +# render :action => 'new_bid' +# end +# end +# #huang +# def new_contest +# @bid = Bid.new +# @bid.safe_attributes = params[:bid] +# end +# +# def create_bid +# @bid = Bid.new +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.reward_type = 1 +# @bid.budget = params[:bid][:budget] +# @bid.deadline = params[:bid][:deadline] +# @bid.author_id = User.current.id +# @bid.commit = 0 +# if @bid.save +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to respond_url(@bid) +# else +# @bid.safe_attributes = params[:bid] +# render :action => 'new_bid' +# end +# end +# +# def create_homework +# @bid = Bid.new +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.is_evaluation = params[:bid][:is_evaluation] +# @bid.proportion = params[:bid][:proportion] +# @bid.evaluation_num = params[:bid][:evaluation_num] +# params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 +# @bid.reward_type = 3 +# # @bid.budget = params[:bid][:budget] +# @bid.deadline = params[:bid][:deadline] +# @bid.budget = 0 +# @bid.author_id = User.current.id +# @bid.commit = 0 +# @bid.homework_type = 1 +# @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) +# # @bid. +# if @bid.save +# HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id) +# unless @bid.watched_by?(User.current) +# if @bid.add_watcher(User.current) +# flash[:notice] = l(:label_bid_succeed) +# end +# end +# redirect_to course_homework_url(params[:course_id]) +# else +# @bid.safe_attributes = params[:bid] +# @homework = @bid +# @course = Course.find_by_id(params[:course_id]) +# @course_id = @course.id +# #respond_to do |format| +# # format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'} +# # format.api { render_validation_errors(@bid) } +# #end +# render file: 'courses/new_homework', layout: 'base_courses' +# end +# end +# +# # modify by nwb\ +# # 编辑作业 +# def edit +# @bid = Bid.find(params[:bid_id]) +# if (User.current.admin?||User.current.allowed_to?(:as_teacher,@bid.courses.first)) +# @course_id = params[:course_id] +# respond_to do |format| +# format.html { +# @course = Course.find(params[:course_id]) +# @user= User.find(User.current.id) +# render :layout => 'base_courses' +# } +# end +# else +# render_403 +# end +# end +# +# def update +# @bid = Bid.find(params[:id]) +# @course = @bid.courses.first#Project.find(params[:course_id]) +# @bid.name = params[:bid][:name] +# @bid.description = params[:bid][:description] +# @bid.is_evaluation = params[:bid][:is_evaluation] +# @bid.proportion = params[:bid][:proportion] +# @bid.evaluation_num = params[:bid][:evaluation_num] +# params[:bid][:open_anonymous_evaluation] ? @bid.open_anonymous_evaluation = 1 : @bid.open_anonymous_evaluation = 0 +# @bid.reward_type = 3 +# @bid.deadline = params[:bid][:deadline] +# @bid.budget = 0 +# #@bid.author_id = User.current.id +# @bid.commit = 0 +# @bid.homework_type = 1 +# @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) +# if @bid.save +# flash[:notice] = l(:label_update_homework_succeed) +# redirect_to course_homework_url(@course) +# else +# @bid.safe_attributes = params[:bid] +# render :action => 'edit', :layout =>'base_courses' +# end +# end +# +# def new_submit_homework +# #render html to prepare create submit homework +# find_bid +# find_bid +# render :layout => 'base_homework' +# end +# +# def add_homework +# if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) +# # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) +# # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) +# +# if hadcommittedhomework(User.current.id, @bid.id) == true +# @homework_flag = l(:label_bidding_homework_committed) +# else +# @homework = HomeworkAttach.new +# @homework.safe_attributes = params[:homeworkattach] +# @homework.bid_id = @bid.id +# @homework.user_id = User.current.id +# @homework.save_attachments(params[:attachments]) +# +# render_attachment_warning_if_needed(@homework) +# +# @homework_flag = if @homework.save +# l(:label_bidding_homework_succeed) +# else +# l(:label_bidding_homework_failed) +# end +# +# if @homework.attachments.empty? +# @homework.delete +# #flash[:error] = l(:no_attachmens_allowed) +# @homework_flag = l(:no_attachmens_allowed) +# # else +# end +# end +# end +# +# @homework_list = @bid.homeworks +# respond_to do |format| +# format.html{ +# #redirect_to project_for_bid_path, notice: @homework_flag.to_s +# flash[:notice] = @homework_flag.to_s +# redirect_back_or_default(project_for_bid_path) +# } +# format.js +# end +# +# end +# +# # 作业统计 +# def homework_statistics +# @course = @bid.courses.first +# @member = [] +# @course.memberships.each do |member| +# unless (member.roles && Role.where('id = ? ', 3)).empty? +# @member.push member +# end +# end +# if @bid.homework_type = 1 +# @student = User.where("id in (select DISTINCT user_id from #{HomeworkAttach.table_name} where bid_id = ? )", @bid.id) +# @homework_type = true +# else +# +# @homework_type = false +# end +# @user = @bid.author +# render :layout => 'base_homework' +# end +# +# def homework_respond +# @user = @bid.author +# render :layout => 'base_homework' +# end +# +# def more +# @jour = @bid.journals_for_messages +# @jour.each_with_index {|j,i| j.indice = i+1} +# @state = true +# +# respond_to do |format| +# format.html { redirect_to :back } +# format.js +# #format.api { render_api_ok } +# end +# end +# +# def back +# @jour = @bid.journals_for_messages +# @jour.each_with_index {|j,i| j.indice = i+1} +# @state = false +# +# respond_to do |format| +# format.html { redirect_to :back } +# format.js +# #format.api { render_api_ok } +# end +# end +# +# #added by william +# #used to set the bidding project reward +# def set_reward +# @b_p = nil +# @biding_project_id = nil +# +# if params[:set_reward][:reward]&&((User.current.id==@bid.author_id)||User.current.admin) +# # @bid_id = params[:id] +# @biding_project_id = params[:set_reward][:b_id] +# @b_p = BidingProject.find_by_id(@biding_project_id) +# +# # 把字段存进表中 +# @b_p.update_reward(params[:set_reward][:reward].to_s) +# end +# +# respond_to do |format| +# format.js +# end +# end +# +# # added by william +# # used to manage the bid and end the bid +# def manage +# +# end +# +# # 启动匿评 +# def start_anonymous_comment +# @bid = Bid.find(params[:id]) +# @course = @bid.courses.first +# if(@bid.comment_status == 0) +# homeworks = @bid.homeworks +# if(homeworks && homeworks.size >= 2) +# homeworks.each_with_index do |homework, index| +# user = homework.user +# n = @bid.evaluation_num +# n = n < homeworks.size ? n : homeworks.size - 1 +# assigned_homeworks = get_assigned_homeworks(homeworks, n, index) +# assigned_homeworks.each do |h| +# @homework_evaluation = HomeworkEvaluation.new(user_id: user.id, homework_attach_id: h.id) +# @homework_evaluation.save +# end +# end +# @bid.update_column('comment_status', 1) +# @statue = 1 +# else +# @statue = 2 +# end +# else +# @statue = 3 +# end +# +# respond_to do |format| +# format.js +# end +# end +# +# def stop_anonymous_comment +# @bid = Bid.find(params[:id]) +# +# @bid.update_column('comment_status', 2) +# +# respond_to do |format| +# format.js +# end +# end +# +# def alert_anonymous_comment +# @bid = Bid.find params[:id] +# @course = @bid.courses.first +# @cur_size = 0 +# @totle_size = 0 +# if @bid.comment_status == 0 +# @totle_size = searchStudent(@course).size +# @cur_size = @bid.homeworks.size +# elsif @bid.comment_status == 1 +# @bid.homeworks.map { |homework| @totle_size += homework.homework_evaluations.count} +# @cur_size = 0 +# @bid.homeworks.map { |homework| @cur_size += homework.rates(:quality).where("seems_rateable_rates.is_teacher_score = 0").count} +# end +# @percent = format("%.2f",(@cur_size.to_f / ( @totle_size == 0 ? 1 : @totle_size)) * 100) +# respond_to do |format| +# format.js +# end +# end +# +# private +# +# def get_assigned_homeworks(homeworks, n, index) +# homeworks += homeworks +# homeworks[index + 1 .. index + n] +# end +# +# def find_bid +# if params[:id] +# @bid = Bid.find(params[:id], :include => [{:homeworks => :user}]) +# @user = @bid.author +# end +# rescue +# render_404 +# end +# +# def memberAccess +# # 是课程,则判断当前用户是否参加了课程 +# return true if current_user.admin? +# #return 0 if @bid.courses.first.project_type == Project::ProjectType_project +# currentUser = User.current +# render_403 unless currentUser.member_of_course?(@bid.courses.first) +# end +# +# #验证是否显示课程 +# def can_show_course +# @first_page = FirstPage.find_by_page_type('project') +# if @first_page.show_course == 2 +# render_404 +# end +# end +# +# #验证是否显示竞赛 +# def can_show_contest +# @first_page = FirstPage.find_by_page_type('project') +# if @first_page.show_contest == 2 +# render_404 +# end +# end +# end +# From 59c4e04e37101bac8a6ad373f3c6afcb3e386514 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 09:57:33 +0800 Subject: [PATCH 015/130] =?UTF-8?q?=E5=88=A0=E9=99=A4bid=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 2 +- config/routes.rb | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 7db03aca1..aa1c369a0 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -1,5 +1,5 @@ # # fq -#Bid功能已经废弃 +#Bid功能已经废弃,代码参考用 # class BidsController < ApplicationController # #Added by young # menu_item l(:label_homework), :only => [:edit, :udpate] diff --git a/config/routes.rb b/config/routes.rb index e166e37e5..d2c21f6ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -257,7 +257,6 @@ RedmineApp::Application.routes.draw do post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' # boards end - # delete 'bids/homework', :to => 'bids#homework_destroy' # Misc issue routes. TODO: move into resources match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues' @@ -764,7 +763,6 @@ RedmineApp::Application.routes.draw do delete 'attachment/:id', :to => 'attachments#delete_homework' match 'new_join', :to => 'courses#new_join', :as => 'try_join' match 'new_join_group', :to => 'courses#new_join_group', :as => 'try_join_group' - # match 'new_join_in_contest', :to => 'bids#new_join', :as => 'try_join_in_contest' match 'projects/:id/respond', :to => 'projects#project_respond', :via => :post ######################## From 523dc9b343dae770e1ae6ed9ab38b32917790438 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 5 Jun 2015 10:06:30 +0800 Subject: [PATCH 016/130] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E3=80=81=E5=8F=91=E5=B8=96=E5=9B=9E=E5=B8=96=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 9e36d15f4..c3cb3d8c9 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -94,8 +94,8 @@ class MessagesController < ApplicationController update_kindeditor_assets_owner ids,@message.id,OwnerTypeHelper::MESSAGE end # 与我相关动态的记录add start - if(@board.course_id>0) #项目的先不管 - teachers = searchTeacherAndAssistant(@board.course); + if(@board && @board.course) #项目的先不管 + teachers = searchTeacherAndAssistant(@board.course) for teacher in teachers if(teacher.user_id != User.current.id) notify = ActivityNotify.new() @@ -178,7 +178,7 @@ class MessagesController < ApplicationController end # 与我相关动态的记录add start - if(@board.course_id>0) #项目的先不管 + if(@board && @board.course) #项目的先不管 notifyto_arr = {} notifyto_arr[@topic.author_id] = @topic.author_id if( params[:parent_topic] != nil && params[:parent_topic] != '') From d9dd744fb1f20781c23bb5e9aabe0993bfc275d8 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 5 Jun 2015 10:16:16 +0800 Subject: [PATCH 017/130] ... --- app/controllers/messages_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index c3cb3d8c9..b1da35cfc 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -99,7 +99,7 @@ class MessagesController < ApplicationController for teacher in teachers if(teacher.user_id != User.current.id) notify = ActivityNotify.new() - if(@board.course_id>0) + if(@board.course) notify.activity_container_id = @board.course_id notify.activity_container_type = 'Course' else @@ -188,7 +188,7 @@ class MessagesController < ApplicationController notifyto_arr.each do |k,user_id| if(user_id != User.current.id) notify = ActivityNotify.new() - if(@board.course_id>0) + if(@board.course) notify.activity_container_id = @board.course_id notify.activity_container_type = 'Course' else From 8fcf7ac7a815bfed361a1fc617a5dc52802fd14f Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 5 Jun 2015 10:25:42 +0800 Subject: [PATCH 018/130] ... --- app/views/courses/show.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 63285a2cd..60134381f 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -49,6 +49,8 @@ <% end%> <% end%> +<% elsif @controller_name=='ActivityNotifys' %> +
<%= l(:label_no_data) %>
<% end%> <% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %>
<%= l(:lebel_homework_commit)%>
From 54abe5d85820c3d6c8f991804563c3f1ca6589e8 Mon Sep 17 00:00:00 2001
From: huang <%= @subject %> <%= link_to @project_url, @project_url%> 点击链接后,将自动为您注册账号 <%= @subject %> 点击链接激活账号,系统会依据给出的密码和账号自动登录Trustie平台。 <%= link_to @project_url, @project_url%> 您的账号为:<%= @email %> 密码为: <%= @password %> <%= @subject %> 点击链接激活账号,系统会依据给出的密码和账号自动登录Trustie平台。 点击下面的链接即可激活账号,系统会根据给出的密码和账号自动登录Trustie平台。 <%= link_to @project_url, @project_url%> 您的账号为:<%= @email %> 密码为: <%= @password %> <%= l(:mail_body_wiki_content_added, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
:author => h(@wiki_content.author)).html_safe %>
<% @inviter_lists.each do |inviter_list| %>
<% unless inviter_list.user.member_of?(@project) %>
From a148c49fa9ba5a44a948342d1578d854b2608bc0 Mon Sep 17 00:00:00 2001
From: huang
-<%=h @wiki_content.comments %>
<%= l(:mail_body_wiki_content_added, :id => link_to(h(@wiki_content.page.pretty_title), @wiki_content_url),
:author => h(@wiki_content.author)).html_safe %>
-<%=h @wiki_content.comments.html_safe? %>
'+$('a',div).filter(':first').html()+' 写到:'; + var str = '
'+$("input[nhname='nh_content_val']",div).val()+'
'+$('a',div).filter(':first').html()+' 写到:'; return str; } nh_init_board(params); diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb index f6b41b53f..525869901 100644 --- a/app/views/boards/_form_project.html.erb +++ b/app/views/boards/_form_project.html.erb @@ -47,6 +47,7 @@
'+$("input[nhname='nh_content_val']",div).val()+'
'+$('a',div).filter(':first').html()+' 写到:'; + var str = '
'+$("input[nhname='nh_content_val']",div).val()+'
'+$('a',div).filter(':first').html()+' 写到:'; return str; } nh_init_board(params); From 3c515dd07727e075baddf38eff08ef3e8a9410a1 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 12 Jun 2015 10:52:15 +0800 Subject: [PATCH 079/130] ... --- app/views/boards/show.html.erb | 7 +++++-- app/views/courses/_courses_jours.html.erb | 7 +++++-- app/views/projects/_project_jours.html.erb | 7 +++++-- app/views/users/_user_jours.html.erb | 7 +++++-- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index d7a02e326..196e7f097 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -185,8 +185,11 @@ function nh_init_board(params){ if(params.quote_input!=undefined)params.quote_input.empty(); }else{ if(params.type=='reply'){ - params.jumphref.attr('href','#'+params.form.attr('id')); - params.jumphref[0].click(); + params.textarea.show(); + params.textarea.focus(); + params.textarea.hide(); + //params.jumphref.attr('href','#'+params.form.attr('id')); + //params.jumphref[0].click(); }else params.inputsubject.focus(); } }); diff --git a/app/views/courses/_courses_jours.html.erb b/app/views/courses/_courses_jours.html.erb index 07d065901..a097a2286 100644 --- a/app/views/courses/_courses_jours.html.erb +++ b/app/views/courses/_courses_jours.html.erb @@ -168,8 +168,11 @@ params.cancel_btn.click(); setTimeout(function(){ if(!params.div_form.is(':hidden')){ - $("#nhjump").attr('href','#'+params.div_form.attr('id')); - $("#nhjump")[0].click(); + params.textarea.show(); + params.textarea.focus(); + params.textarea.hide(); +// $("#nhjump").attr('href','#'+params.div_form.attr('id')); +// $("#nhjump")[0].click(); } },300); params.textarea.data('init',1); diff --git a/app/views/projects/_project_jours.html.erb b/app/views/projects/_project_jours.html.erb index e7aebac43..d530a7199 100644 --- a/app/views/projects/_project_jours.html.erb +++ b/app/views/projects/_project_jours.html.erb @@ -162,8 +162,11 @@ params.cancel_btn.click(); setTimeout(function(){ if(!params.div_form.is(':hidden')){ - $("#nhjump").attr('href','#'+params.div_form.attr('id')); - $("#nhjump")[0].click(); + params.textarea.show(); + params.textarea.focus(); + params.textarea.hide(); +// $("#nhjump").attr('href','#'+params.div_form.attr('id')); +// $("#nhjump")[0].click(); } },300); params.textarea.data('init',1); diff --git a/app/views/users/_user_jours.html.erb b/app/views/users/_user_jours.html.erb index 061632194..56b9a883b 100644 --- a/app/views/users/_user_jours.html.erb +++ b/app/views/users/_user_jours.html.erb @@ -190,8 +190,11 @@ params.cancel_btn.click(); setTimeout(function(){ if(!params.div_form.is(':hidden')){ - $("#nhjump").attr('href','#'+params.div_form.attr('id')); - $("#nhjump")[0].click(); + params.textarea.show(); + params.textarea.focus(); + params.textarea.hide(); +// $("#nhjump").attr('href','#'+params.div_form.attr('id')); +// $("#nhjump")[0].click(); } },300); params.textarea.data('init',1); From dbb6c9f54cab48b30ebeedd1a487909777b94bf4 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 12 Jun 2015 11:21:49 +0800 Subject: [PATCH 080/130] ... --- public/assets/kindeditor/kindeditor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index 74228d3ea..5ebe96a32 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -5620,7 +5620,8 @@ _plugin('core', function(K) { afterUpload : function(data) { if (data.error === 0) { var url = K.formatUrl(data.url, 'absolute'); - self.exec('insertimage', url, 'image','','','1','left'); + //self.exec('insertimage', url, 'image','','','1','left'); + self.insertHtml('
'+$("input[nhname='nh_content_val']",div).val()+'
<%= l(:label_bids_form_contest_new_description) %>
-<%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_name)}" %>
- -<%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;", :maxlength => Bid::DESCRIPTION_LENGTH_LIMIT, :placeholder => "#{l(:label_contest_description)}" %>
- -<%= f.text_field :password, :size => 60, :style => "width:488px;margin-left: 10px;" %>
- -- <%= f.text_field :budget, :required => true, :size => 60, :style => "width:350px;", :placeholder => l(:label_bids_reward_what) %> - - -
- -<%= f.text_field :deadline, :required => true, :size => 60, :style => "width:150px;", :readonly => true, :placeholder => "#{l(:label_deadline)}" %><%= calendar_for('bid_deadline')%>
From 94877bb353d2cc8f818d7378c170f867c0834baa Mon Sep 17 00:00:00 2001 From: huang# | -- | - | <%= l(:label_date) %> | -<%= l(:field_author) %> | -<%= l(:field_comments) %> | -
---|---|---|---|---|---|
<%= radio_button_tag('rev', changeset.identifier, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('#cbto-#{line_num+1}').attr('checked',true);") if show_diff && (line_num < revisions.size) %> | -<%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('#cb-#{line_num}').attr('checked')) {$('#cb-#{line_num-1}').attr('checked',true);}") if show_diff && (line_num > 1) %> | -<%= format_time(changeset.committed_on) %> | -<%= h truncate(changeset.author.to_s, :length => 30) %> | -<%= textilizable(truncate_at_line_break(changeset.comments)) %> | -
+ {:controller => 'repositories', :action => 'diff', :id => project, + :repository_id => @repository.identifier_param, :path => to_path_param(path)}, + :method => :get + ) do %> +
# | ++ | + | <%= l(:label_date) %> | +<%= l(:field_author) %> | +<%= l(:field_comments) %> | +
---|---|---|---|---|---|
<%= radio_button_tag('rev', changeset.identifier, (line_num==1), :id => "cb-#{line_num}", :onclick => "$('#cbto-#{line_num+1}').attr('checked',true);") if show_diff && (line_num < revisions.size) %> | +<%= radio_button_tag('rev_to', changeset.identifier, (line_num==2), :id => "cbto-#{line_num}", :onclick => "if ($('#cb-#{line_num}').attr('checked')) {$('#cb-#{line_num-1}').attr('checked',true);}") if show_diff && (line_num > 1) %> | +<%= format_time(changeset.committed_on) %> | +<%= h truncate(changeset.author.to_s, :length => 30) %> | +<%= textilizable(truncate_at_line_break(changeset.comments)) %> | +
<%= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %> -
- + <% end %> diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index 1cb5942bf..a128f917a 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -5,9 +5,8 @@项目代码请设置好正确的编码方式(utf-8),否则中文会出现乱码。
通过cmd命令提示符进入代码对应文件夹的根目录,假设当前用户的登录名为user,版本库名称为demo,需要操作的版本库分支为branch。 - 如果是首次提交代码,执行如下命令:
+ 如果是首次提交代码,执行如下命令:git init
@@ -53,7 +52,7 @@git push -u origin branch:branch
已经有本地库,还没有配置远程地址,打开命令行执行如下:
git push -u origin branch:branch
已有远程地址,创建一个远程分支,并切换到该分支,打开命令行执行如下:
git push origin branch_name
从网上获取别人的开源版本库,转交到trustie网站上,打开命令行执行如下:
李海提供
+ <% has_branches = (!@repository.branches.nil? && @repository.branches.length > 0) + sep = '' %> + <% if @repository.supports_all_revisions? && @path.blank? %> + <%= link_to l(:label_view_all_revisions), {:action => 'revisions', :id => @project, + :repository_id => @repository.identifier_param}, + :class => "orange_u_btn" %> + <% sep = '|' %> <% end %> -
- <% has_branches = (!@repository.branches.nil? && @repository.branches.length > 0) - sep = '' %> - <% if @repository.supports_all_revisions? && @path.blank? %> - <%= link_to l(:label_view_all_revisions), {:action => 'revisions', :id => @project, - :repository_id => @repository.identifier_param}, - :class => "orange_u_btn" %> - <% sep = '|' %> - <% end %> - <% if @repository.supports_directory_revisions? && (has_branches || !@path.blank? || !@rev.blank?) %> - <%= sep %> - <%= link_to l(:label_view_revisions), - {:action => 'changes', - :path => to_path_param(@path), - :id => @project, - :repository_id => @repository.identifier_param, - :rev => @rev}, - :class => "orange_u_btn" %> - <% end %> -
- <% if @repository.supports_all_revisions? %> - <% content_for :header_tags do %> - <%= auto_discovery_link_tag( - :atom, params.merge( - {:format => 'atom', :action => 'revisions', - :id => @project, :page => nil, :key => User.current.rss_key})) %> - <% end %> + <% if @repository.supports_directory_revisions? && (has_branches || !@path.blank? || !@rev.blank?) %> + <%= sep %> + <%= link_to l(:label_view_revisions), + {:action => 'changes', + :path => to_path_param(@path), + :id => @project, + :repository_id => @repository.identifier_param, + :rev => @rev}, + :class => "orange_u_btn" %> <% end %> - <% end %> + + <% if @repository.supports_all_revisions? %> + <% content_for :header_tags do %> + <%= auto_discovery_link_tag( + :atom, params.merge( + {:format => 'atom', :action => 'revisions', + :id => @project, :page => nil, :key => User.current.rss_key})) %> + <% end %> + <% end %> +<% end %> - -查看如何提交代码: - <%= link_to(l(:label_how_commit_code_chinese), ch_usage_path, :class => "c_blue") %> - <%= link_to('English', en_usage_path, :class => "c_blue") %> + +
查看如何提交代码: + <%= link_to(l(:label_how_commit_code_chinese), ch_usage_path, :class => "c_blue") %> + <%= link_to('English', en_usage_path, :class => "c_blue") %> -
+ <% content_for :header_tags do %> <%= stylesheet_link_tag "scm" %> From 482df88d70d3ff1f6fba15f17cc6d8b2fcce2829 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 12 Jun 2015 16:52:49 +0800 Subject: [PATCH 094/130] ... --- app/views/projects/_history.html.erb | 3 ++- app/views/users/_history.html.erb | 3 ++- app/views/words/_journal_reply_items.html.erb | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/views/projects/_history.html.erb b/app/views/projects/_history.html.erb index d85906a2c..54dda7b28 100644 --- a/app/views/projects/_history.html.erb +++ b/app/views/projects/_history.html.erb @@ -9,7 +9,8 @@ <%= link_to journal.user, user_path(journal.user), :class => 'c_blue fb fl mb10', :target => "_blank" %> <%= format_time(journal.created_on) %> -<%= textilizable journal.notes%>
+ +<%=journal.notes.html_safe%>
<%= textilizable journal.notes%>
+ +<%=journal.notes.html_safe%>
- <%= reply.notes %> + <%= reply.notes.html_safe %>
<%= format_time reply.created_on %> From 2a2b93c97df190329af0e710ab0f3dea2d59d304 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 12 Jun 2015 16:58:43 +0800 Subject: [PATCH 095/130] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=A4=9A=E8=A1=8C=E4=B8=BB=E8=A7=82=E7=9A=84?= =?UTF-8?q?=E7=AD=94=E6=A1=88=E6=9C=89html=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 73650a782..a222314ab 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -464,7 +464,7 @@ class PollController < ApplicationController sheet1[count_row + 1,0] = l(:label_poll_subtotal) sheet1[count_row + 2,0] = l(:label_poll_proportion) poll_question.poll_answers.each_with_index do |poll_answer,i| - sheet1[count_row, i + 1] = poll_answer.answer_text + sheet1[count_row, i + 1] = poll_answer.answer_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") sheet1[count_row + 1, i + 1] = poll_answer.poll_votes.count sheet1[count_row + 2, i + 1] = statistics_result_percentage(poll_answer.poll_votes.count, total_answer(poll_question.id)).to_s + "%" end @@ -477,7 +477,7 @@ class PollController < ApplicationController sheet1[count_row,1] = poll_question.question_title count_row += 1 poll_question.poll_votes.each do |poll_vote| - sheet1[count_row,0] = poll_vote.vote_text + sheet1[count_row,0] = poll_vote.vote_text.gsub(/<\/?.*?>/,"").gsub(/ /," ") count_row += 1 end count_row += 1 From cd7bb85f2f777807576a1e6d4035080625aad22e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 12 Jun 2015 17:25:39 +0800 Subject: [PATCH 096/130] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=A4=9A=E4=BA=86=E4=B8=80=E4=B8=AAc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/stores/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/stores/index.html.erb b/app/views/stores/index.html.erb index 84116a561..6fab364b5 100644 --- a/app/views/stores/index.html.erb +++ b/app/views/stores/index.html.erb @@ -35,7 +35,7 @@ <%= c1.downloads %>