From b77b63bbf17d240ab257560a0ebc5cede213114c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 7 Mar 2016 10:29:37 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=A7=81=E6=9C=89?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=A0=8F=E7=9B=AE=E9=80=9A=E8=BF=87url?= =?UTF-8?q?=E8=83=BD=E8=AE=BF=E9=97=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 12 ++- app/controllers/org_subfields_controller.rb | 102 ++++++++++---------- 2 files changed, 61 insertions(+), 53 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index ca37e445c..16fee2dae 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -406,10 +406,14 @@ class FilesController < ApplicationController @container_type = 2 @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] @organization = Organization.find(@containers.first.organization_id) - show_attachments @containers - @tag_list = attachment_tag_list @all_attachments - @page = params[:page] || 1 - render :layout => 'base_org' + if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization) + show_attachments @containers + @tag_list = attachment_tag_list @all_attachments + @page = params[:page] || 1 + render :layout => 'base_org' + else + render_403 + end # @subfield = params[:org_subfield_id] end diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 2a4bcf9c8..9337c5fd2 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -33,61 +33,65 @@ class OrgSubfieldsController < ApplicationController domain = Secdomain.where("subname=?", request.subdomain).first @organization = Organization.find(domain.pid) end - @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ - "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ - " org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first - if @org_subfield.field_type == 'Post' + if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization) + @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ + "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ + " org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first + if @org_subfield.field_type == 'Post' @org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0 @org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10) #redirect_to organization_path(@organization, :org_subfield_id => @org_subfield.id) - else - if params[:sort] - params[:sort].split(",").each do |sort_type| - order_by = sort_type.split(":") - case order_by[0] - when "filename" - attribute = "filename" - when "size" - attribute = "filesize" - when "attach_type" - attribute = "attachtype" - when "content_type" - attribute = "created_on" - when "field_file_dense" - attribute = "is_public" - when "downloads" - attribute = "downloads" - when "created_on" - attribute = "created_on" - when "quotes" - attribute = "quotes" - else - attribute = "created_on" - end - @sort = order_by[0] - @order = order_by[1] - if order_by.count == 1 && attribute - sort += "#{Attachment.table_name}.#{attribute} asc " - if sort_type != params[:sort].split(",").last - sort += "," - end - elsif order_by.count == 2 && order_by[1] - sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " - if sort_type != params[:sort].split(",").last - sort += "," - end - end - end else - sort = "#{Attachment.table_name}.created_on desc" + if params[:sort] + params[:sort].split(",").each do |sort_type| + order_by = sort_type.split(":") + case order_by[0] + when "filename" + attribute = "filename" + when "size" + attribute = "filesize" + when "attach_type" + attribute = "attachtype" + when "content_type" + attribute = "created_on" + when "field_file_dense" + attribute = "is_public" + when "downloads" + attribute = "downloads" + when "created_on" + attribute = "created_on" + when "quotes" + attribute = "quotes" + else + attribute = "created_on" + end + @sort = order_by[0] + @order = order_by[1] + if order_by.count == 1 && attribute + sort += "#{Attachment.table_name}.#{attribute} asc " + if sort_type != params[:sort].split(",").last + sort += "," + end + elsif order_by.count == 2 && order_by[1] + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + if sort_type != params[:sort].split(",").last + sort += "," + end + end + end + else + sort = "#{Attachment.table_name}.created_on desc" + end + @container_type = 2 + @containers = [OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] + @organization = Organization.find(@containers.first.organization_id) + show_attachments @containers + @tag_list = attachment_tag_list @all_attachments end - @container_type = 2 - @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] - @organization = Organization.find(@containers.first.organization_id) - show_attachments @containers - @tag_list = attachment_tag_list @all_attachments + @page = params[:page] || 1 + else + render_403 end - @page = params[:page] || 1 #render :layout => 'base_org' end From ef05867e6e2fbca46a45040d8b0f580df6ea4814 Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 7 Mar 2016 10:58:41 +0800 Subject: [PATCH 02/22] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/schema.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 9b2b6e942..2781c7614 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -99,6 +99,8 @@ ActiveRecord::Schema.define(:version => 20160303103231) do t.integer "quotes" t.integer "version" t.integer "attachment_id" + t.integer "is_publish", :default => 1 + t.date "publish_time" end create_table "attachments", :force => true do |t| @@ -1277,7 +1279,6 @@ ActiveRecord::Schema.define(:version => 20160303103231) do t.text "description" t.integer "creator_id" t.integer "home_id" - t.string "domain" t.boolean "is_public" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false @@ -1385,7 +1386,6 @@ ActiveRecord::Schema.define(:version => 20160303103231) do t.integer "changeset_num", :default => 0 t.integer "board_message_num", :default => 0 t.integer "board_num", :default => 0 - t.integer "act_num", :default => 0 t.integer "attach_num", :default => 0 t.datetime "commit_time" end From 319f286a65be012e32f063b77b8a0c8054ea2d83 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 7 Mar 2016 12:19:48 +0800 Subject: [PATCH 03/22] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9A1.=E7=BB=84=E7=BB=87=E7=9A=84?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=9A=84=E5=BC=95=E7=94=A8=E8=AE=A1=E6=95=B0?= =?UTF-8?q?=E4=B8=8D=E4=BC=9A=E5=A2=9E=E5=8A=A0=EF=BC=9B2.=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E8=B5=84=E6=BA=90=E6=A0=8F=E7=9B=AE=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E5=AE=BD=E5=BA=A6=E4=B8=8D=E5=90=88?= =?UTF-8?q?=E9=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 18 +++++++++--------- app/views/files/_org_subfield_list.html.erb | 4 ++-- .../users/add_exist_file_to_course.js.erb | 3 ++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1d328c1e9..49281f7b7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1693,17 +1693,17 @@ class UsersController < ApplicationController @flag = true if params[:send_id].present? send_id = params[:send_id] - ori = Attachment.find_by_id(send_id) + @ori = Attachment.find_by_id(send_id) course_ids = params[:course_ids] if course_ids.nil? @flag = false end unless course_ids.nil? course_ids.each do |id| - next if ori.blank? + next if @ori.blank? @exist = false Course.find(id).attachments.each do |att| #如果课程中包含该资源 - if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from + if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from att.created_on = Time.now att.save @exist = true @@ -1711,21 +1711,21 @@ class UsersController < ApplicationController end end next if @exist - attach_copied_obj = ori.copy - attach_copied_obj.tag_list.add(ori.tag_list) # tag关联 + attach_copied_obj = @ori.copy + attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联 attach_copied_obj.container = Course.find(id) attach_copied_obj.created_on = Time.now attach_copied_obj.author_id = User.current.id attach_copied_obj.is_public = 0 - attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from + attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from if attach_copied_obj.attachtype == nil attach_copied_obj.attachtype = 4 end if attach_copied_obj.save # 更新引用次数 - quotes = ori.quotes.to_i + 1 - ori.update_attribute(:quotes, quotes) unless ori.nil? - ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) + quotes = @ori.quotes.to_i + 1 + @ori.update_attribute(:quotes, quotes) unless @ori.nil? + @ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now) end @save_message = attach_copied_obj.errors.full_messages end diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index 38ff40ed3..641029bf2 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -8,7 +8,7 @@
- <%= link_to truncate(file.filename,length: 35, omission: '...'), + <%= link_to file.is_public? ? truncate(file.filename, length: 70) : truncate(file.filename,length: 50, omission: '...'), download_named_attachment_path(file.id, file.filename), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %> <%= file_preview_eye(file, class: 'preview') %> @@ -25,7 +25,7 @@ 上传类型:<%= file.tag_list[0] %> <% end %>

文件大小:<%= number_to_human_size(file.filesize) %>

-

下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

+

下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

diff --git a/app/views/users/add_exist_file_to_course.js.erb b/app/views/users/add_exist_file_to_course.js.erb index 57fe9d42d..c05a2ebd0 100644 --- a/app/views/users/add_exist_file_to_course.js.erb +++ b/app/views/users/add_exist_file_to_course.js.erb @@ -4,7 +4,8 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_ $("#res_count").html(0); $("#checkboxAll").attr('checked',false); $("#res_all_count").html(<%= @atta_count%>); +$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>"); hideModal(); -alert("发送成功") +alert("发送成功"); <% else%> <% end %> \ No newline at end of file From a0363b551126b33cfebf2e716b2425a0d7a1424d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 7 Mar 2016 12:57:24 +0800 Subject: [PATCH 04/22] =?UTF-8?q?=E7=BB=84=E7=BB=87=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=90=8E=EF=BC=8C=E5=8F=91=E9=80=81=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E5=8A=A8=E6=80=81=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 ++ app/views/users/add_exist_file_to_org.js.erb | 5 ++++- app/views/users/add_exist_file_to_project.js.erb | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 49281f7b7..98660d614 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1837,6 +1837,7 @@ class UsersController < ApplicationController Project.find(project_id).project_score.attach_num + 1) end end + @ori = ori end elsif params[:send_ids].present? send_ids = params[:send_ids].split(" ") @@ -1941,6 +1942,7 @@ class UsersController < ApplicationController end end end + @ori = ori elsif params[:send_ids].present? send_ids = params[:send_ids].split(" ") subfield_id = params[:subfield] diff --git a/app/views/users/add_exist_file_to_org.js.erb b/app/views/users/add_exist_file_to_org.js.erb index 57fe9d42d..9bfe1230a 100644 --- a/app/views/users/add_exist_file_to_org.js.erb +++ b/app/views/users/add_exist_file_to_org.js.erb @@ -4,7 +4,10 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_ $("#res_count").html(0); $("#checkboxAll").attr('checked',false); $("#res_all_count").html(<%= @atta_count%>); +<% if @ori.present? and @ori.quotes.present? %> + $("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>"); +<% end %> hideModal(); -alert("发送成功") +alert("发送成功"); <% else%> <% end %> \ No newline at end of file diff --git a/app/views/users/add_exist_file_to_project.js.erb b/app/views/users/add_exist_file_to_project.js.erb index 57fe9d42d..ed38fa066 100644 --- a/app/views/users/add_exist_file_to_project.js.erb +++ b/app/views/users/add_exist_file_to_project.js.erb @@ -4,7 +4,10 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_ $("#res_count").html(0); $("#checkboxAll").attr('checked',false); $("#res_all_count").html(<%= @atta_count%>); +<% if @ori and @ori.quotes.present? %> + $("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>"); +<% end %> hideModal(); -alert("发送成功") +alert("发送成功"); <% else%> <% end %> \ No newline at end of file From f8ce6d48d3030592c92b13d9a7e365ee7d989324 Mon Sep 17 00:00:00 2001 From: cxt Date: Mon, 7 Mar 2016 14:31:58 +0800 Subject: [PATCH 05/22] =?UTF-8?q?=E6=A8=A1=E6=8B=9F=E7=AD=94=E9=A2=98?= =?UTF-8?q?=E7=9A=84=E8=BF=94=E5=9B=9E=E6=8C=89=E9=92=AE=E5=BA=94=E8=AF=A5?= =?UTF-8?q?=E5=9B=9E=E5=88=B0=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/new_user_commit_homework.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb index 02bfc9203..3c0c4969b 100644 --- a/app/views/users/new_user_commit_homework.html.erb +++ b/app/views/users/new_user_commit_homework.html.erb @@ -97,7 +97,7 @@
测试代码 <% if @is_test %> - <%=link_to '返 回',course_path(@course),:class=>'fr mt6' %> + <%=link_to '返 回',homework_common_index_path(:course => @course.id),:class=>'fr mt6' %> <% else @is_test %> 提交代码 <% end %> From 0df34dd3ee16bf3dbe60c72be3d93e7690d8ebf7 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 7 Mar 2016 16:14:44 +0800 Subject: [PATCH 06/22] =?UTF-8?q?=E7=BB=84=E7=BB=87=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=A0=8F=E7=9B=AE=EF=BC=8C=E8=BF=87=E6=BB=A4=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E2=80=9C=E5=85=B6=E4=BB=96=E2=80=9D=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 5ad93f8db..57cadc10b 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -863,7 +863,15 @@ class FilesController < ApplicationController q = "%#{@q.strip}%" @result = find_org_subfield_attache q,@org_subfield,sort @result = visable_attachemnts @result - @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank? + if params[:other] + @result = @result.select{|attachment| + attachment.tag_list.exclude?('软件') && + attachment.tag_list.exclude?('媒体') && + attachment.tag_list.exclude?('代码') + } + else + @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank? + end @searched_attach = paginateHelper @result,10 @tag_list = get_org_subfield_tag_list @org_subfield From 56372fbdd5d9272bfc39a239982cf918847b544a Mon Sep 17 00:00:00 2001 From: Tim Date: Mon, 7 Mar 2016 16:50:30 +0800 Subject: [PATCH 07/22] =?UTF-8?q?=E7=A7=AF=E5=88=86=E8=A7=84=E5=88=99?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/base_courses.html.erb | 34 +++++++++++++------------ public/stylesheets/courses.css | 7 +++-- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 2a44f2980..59ed3ad39 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -143,18 +143,19 @@ <% unless contributor_course_scor(@course.id).count == 0 %>

    课程活跃度 - 积分规则 + 积分规则

    -