From 5d1d56fbb3b7371e55465f8b691380959475ad82 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 8 Mar 2016 16:44:03 +0800 Subject: [PATCH 01/36] =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=B8=8B=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E6=94=B9=E6=88=90https://www.=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 70 +++++++++++++++++++ .../_org_course_homework.html.erb | 4 +- .../organizations/_org_project_issue.html.erb | 4 +- .../organizations/_project_create.html.erb | 10 +-- .../organizations/_project_message.html.erb | 7 +- .../organizations/_show_org_document.html.erb | 2 +- app/views/users/_show_detail_info.html.erb | 2 +- 7 files changed, 84 insertions(+), 15 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c19c44935..2233aeb16 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2905,3 +2905,73 @@ def user_url_in_org(user_id) return "https://www.trustie.net/users/" + user_id.to_s end end + +def project_issues_url_in_org(project_id) + if Rails.env.development? + return "http://localhost:3000/projects/" + project_id.to_s + "/issues" + elsif Rails.env.test? + return "https://www.test.forge.trustie.net/projects/" + project_id.to_s + "/issues" + else + return "https://www.trustie.net/projects/" + project_id.to_s + "/issues" + end +end + +def issue_url_in_org(id) + if Rails.env.development? + return "http://localhost:3000/issues/" + id.to_s + elsif Rails.env.test? + return "https://www.test.forge.trustie.net/issues/" + id.to_s + else + return "https://www.trustie.net/issues/" + id.to_s + end +end + +def project_boards_url_in_org(id) + if Rails.env.development? + return "http://localhost:3000/projects/" + id.to_s + "/boards" + elsif Rails.env.test? + return "https://www.test.forge.trustie.net/projects/" + id.to_s + "/boards" + else + return "https://www.trustie.net/projects/" + id.to_s + "/boards" + end +end + +def board_message_url_in_org(board_id, message_id) + if Rails.env.development? + return "http://localhost:3000/boards/" + board_id.to_s + "/topics/" + message_id.to_s + elsif Rails.env.test? + return "https://www.test.forge.trustie.net/boards/" + board_id.to_s + "/topics/" + message_id.to_s + else + return "https://www.trustie.net/boards/" + board_id.to_s + "/topics/" + message_id.to_s + end +end + +def project_url_in_org(id) + if Rails.env.development? + return "http://localhost:3000/projects/" + id.to_s + elsif Rails.env.test? + return "https://test.forge.trustie.net/projects/" + id.to_s + else + return "https://www.trustie.net/projects/" + id.to_s + end +end + +def homework_common_index_url_in_org(course_id) + if Rails.env.development? + return "http://localhost:3000/homework_common?course=" + course_id.to_s + elsif Rails.env.test? + return "https://test.forge.trustie.net/homework_common?course=" + course_id.to_s + else + return "https://www.trustie.net/homework_common?course=" + course_id.to_s + end +end + +def student_work_index_url_in_org(homework_id) + if Rails.env.development? + return "http://localhost:3000/student_work?homework=" + homework_id.to_s + elsif Rails.env.test? + return "https://test.forge.trustie.net/student_work?homework=" + course_id.to_s + else + return "https://www.trustie.net/student_work?homework=" + course_id.to_s + end +end diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 0dd9fb725..8b28c7a60 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -12,10 +12,10 @@ <% else %> <%= link_to activity.try(:user).try(:realname), user_url_in_org(activity.user_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%> + <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_url_in_org(activity.course.id), :class => "newsBlue ml15"%> <% if activity.homework_detail_manual%> <% if activity.homework_detail_manual.comment_status == 1%> diff --git a/app/views/organizations/_org_project_issue.html.erb b/app/views/organizations/_org_project_issue.html.erb index 855a8053c..9b7dbfa8f 100644 --- a/app/views/organizations/_org_project_issue.html.erb +++ b/app/views/organizations/_org_project_issue.html.erb @@ -11,10 +11,10 @@ <% else %> <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%> + <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_url_in_org(activity.project.id), :class => "newsBlue ml15"%>
- <%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> + <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :class => "postGrey" %> <%#= get_issue_priority(activity.priority_id)[1] %> diff --git a/app/views/organizations/_project_create.html.erb b/app/views/organizations/_project_create.html.erb index e13f4128b..5003fd0e2 100644 --- a/app/views/organizations/_project_create.html.erb +++ b/app/views/organizations/_project_create.html.erb @@ -3,21 +3,21 @@
- <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user), :alt => "用户头像" %> + <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user.id), :alt => "用户头像" %> <%= render :partial => 'users/show_detail_info', :locals => {:user => user} %>
<% if user.try(:realname) == ' ' %> - <%= link_to user, user_url_in_org(user), :class => "newsBlue mr15" %> + <%= link_to user, user_url_in_org(user.id), :class => "newsBlue mr15" %> <% else %> - <%= link_to user.try(:realname), user_url_in_org(user), :class => "newsBlue mr15" %> + <%= link_to user.try(:realname), user_url_in_org(user.id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to project.to_s+" | 项目", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> + <%= link_to project.to_s+" | 项目", project_url_in_org(project.id), :class => "newsBlue ml15" %>
- <%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %> + <%= link_to project.name, project_url_in_org(project.id), :class => "postGrey" %>
创建时间:<%= format_time(project.created_on) %> diff --git a/app/views/organizations/_project_message.html.erb b/app/views/organizations/_project_message.html.erb index 3b459f366..a818939d6 100644 --- a/app/views/organizations/_project_message.html.erb +++ b/app/views/organizations/_project_message.html.erb @@ -12,16 +12,15 @@ <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%> + <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_url_in_org(activity.project.id), :class => "newsBlue ml15 mr5"%>
<% if activity.parent_id.nil? %> - <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" + <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board.id,activity.id), :class=> "postGrey" %> <% else %> - <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" - %> + <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board.id,activity.id), :class=> "postGrey" %> <% end %>
diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 2584e4209..e3ed492a0 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -111,7 +111,7 @@
- <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_url_in_org(User.current) %> + <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_url_in_org(User.current.id) %>
diff --git a/app/views/users/_show_detail_info.html.erb b/app/views/users/_show_detail_info.html.erb index f2a2faeb3..3ebcab21e 100644 --- a/app/views/users/_show_detail_info.html.erb +++ b/app/views/users/_show_detail_info.html.erb @@ -1,6 +1,6 @@
- <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user), :alt => "用户头像", :target => '_blank' %> + <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user.id), :alt => "用户头像", :target => '_blank' %> <%#= image_tag(url_to_avatar(user), :width => "50", :height => "50") %>
From 713c28c0b59155c772c5e59a00aeb386d5c56849 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 9 Mar 2016 10:25:57 +0800 Subject: [PATCH 02/36] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=BF=AB=E6=8D=B7=E6=93=8D=E4=BD=9C=E8=AF=BE=E7=A8=8B/?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=9A=84=E8=AE=BE=E7=BD=AE=E5=85=AC=E5=BC=80?= =?UTF-8?q?/=E7=A7=81=E6=9C=89=E5=B1=9E=E6=80=A7=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E5=AE=9A=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=E8=A6=81?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/private_or_public.js.erb | 4 ++-- app/views/projects/set_public_or_private.js.erb | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/courses/private_or_public.js.erb b/app/views/courses/private_or_public.js.erb index 10b787dd4..4e512a6a0 100644 --- a/app/views/courses/private_or_public.js.erb +++ b/app/views/courses/private_or_public.js.erb @@ -9,10 +9,10 @@ } <% else %> <% if @course.is_public? %> - $("#set_course_public_<%= @course.id %>").text("设为私有"); $("#show_course_<%= @course.id %>").attr("title","公开课程:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)"); <% else %> - $("#set_course_public_<%= @course.id %>").text("设为公开"); $("#show_course_<%= @course.id %>").attr("title","私有课程:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)"); <% end %> + $("#set_course_public_<%= @course.id %>").replaceWith('<%= escape_javascript(link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => "courses", :action => "private_or_public", :id => @course,:user_page => true}, + :id => "set_course_public_#{@course.id.to_s}",:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗") %>'); <% end %> \ No newline at end of file diff --git a/app/views/projects/set_public_or_private.js.erb b/app/views/projects/set_public_or_private.js.erb index dbca3f65c..282a17091 100644 --- a/app/views/projects/set_public_or_private.js.erb +++ b/app/views/projects/set_public_or_private.js.erb @@ -1,7 +1,7 @@ <% if @project.is_public? %> - $("#set_project_public_<%= @project.id %>").text("设为私有"); $("#show_project_<%= @project.id %>").attr("title","公开项目:<%= @project.name %>"); <% else %> - $("#set_project_public_<%= @project.id %>").text("设为公开"); $("#show_project_<%= @project.id %>").attr("title","私有项目:<%= @project.name %>"); -<% end %> \ No newline at end of file +<% end %> +$("#set_project_public_<%= @project.id %>").replaceWith('<%= escape_javascript(link_to @project.is_public? ? "设为私有" : "设为公开", {:controller => "projects", :action => "set_public_or_private", :id => @project.id,:user_page => true}, + :id => "set_project_public_"+ @project.id.to_s,:method => "post",:remote=>true,:confirm=>"您确定要设置为"+(@project.is_public? ? "私有" : "公开")+"吗") %>'); \ No newline at end of file From a51ca428be3e06b4c9222f8246d335b8103bace5 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 9 Mar 2016 18:06:28 +0800 Subject: [PATCH 03/36] =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=B8=AD=EF=BC=8C?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=B0=83=E6=95=B4=E6=A0=8F=E7=9B=AE=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=A1=BA=E5=BA=8F=E7=9A=84=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_subfields_controller.rb | 11 +- app/helpers/organizations_helper.rb | 4 + app/models/org_subfield.rb | 8 ++ app/models/organization.rb | 6 +- app/views/org_subfields/create.js.erb | 3 +- app/views/org_subfields/destroy.js.erb | 3 +- .../org_subfields/update_priority.js.erb | 2 + .../_org_left_subfield_list.html.erb | 129 +++++++++--------- .../organizations/_subfield_list.html.erb | 118 ++++++++++------ app/views/organizations/setting.html.erb | 3 +- config/routes.rb | 1 + ...09022930_set_priority_for_org_subfields.rb | 24 ++++ public/stylesheets/org.css | 1 + 13 files changed, 201 insertions(+), 112 deletions(-) create mode 100644 app/views/org_subfields/update_priority.js.erb create mode 100644 db/migrate/20160309022930_set_priority_for_org_subfields.rb diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 9337c5fd2..ba4c1f18f 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -5,9 +5,8 @@ class OrgSubfieldsController < ApplicationController def create if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0 @res = true - @subfield = OrgSubfield.create(:name => params[:name]) @organization = Organization.find(params[:organization_id]) - @organization.org_subfields << @subfield + @subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id],:priority => @organization.org_subfields.order("priority").last.priority + 1) if !params[:sub_dir].blank? sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" @@ -15,7 +14,7 @@ class OrgSubfieldsController < ApplicationController SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir]) end end - @subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type]) + @subfield.update_attributes(:field_type => params[:field_type]) else @res = false end @@ -125,6 +124,12 @@ class OrgSubfieldsController < ApplicationController end end + def update_priority + @org_subfield = OrgSubfield.find(params[:id]) + @org_subfield.update_attribute(:priority, params[:priority].to_i) + @organization = @org_subfield.organization + end + def show_attachments obj @attachments = [] obj.each do |container| diff --git a/app/helpers/organizations_helper.rb b/app/helpers/organizations_helper.rb index 69c355313..2f98e6783 100644 --- a/app/helpers/organizations_helper.rb +++ b/app/helpers/organizations_helper.rb @@ -28,4 +28,8 @@ module OrganizationsHelper end end + def is_default_field? field + (field.name == 'activity' || field.name == 'course' || field.name == 'project') && field.field_type == 'default' + end + end diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index c62cbf4f8..8cec49686 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -9,6 +9,7 @@ class OrgSubfield < ActiveRecord::Base has_many :news, :dependent => :destroy acts_as_attachable after_create :create_board_sync + after_destroy :update_priority # 创建资源栏目讨论区 def create_board_sync @board = self.boards.build @@ -25,4 +26,11 @@ class OrgSubfield < ActiveRecord::Base def project end + + def update_priority + OrgSubfield.where("organization_id=? and priority>?", self.organization_id, self.priority).each do |field| + field.decrement(:priority) + field.save + end + end end \ No newline at end of file diff --git a/app/models/organization.rb b/app/models/organization.rb index fcb777fb6..248783a26 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -16,8 +16,8 @@ class Organization < ActiveRecord::Base end def add_default_subfields - OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default') - OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default') - OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default') + OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default', :priority => 1) + OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default', :priority => 2) + OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default', :priority => 3) end end diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb index d035ab5cd..84b69717a 100644 --- a/app/views/org_subfields/create.js.erb +++ b/app/views/org_subfields/create.js.erb @@ -1,8 +1,7 @@ <% if @res %> $("#org_subfield_list").html(""); $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', - :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), - :subfields => @organization.org_subfields.where("field_type != 'default'") }) %>"); + :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); $("#sub_field_left_lists").html(""); $("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); $("#subfield_name").val(""); diff --git a/app/views/org_subfields/destroy.js.erb b/app/views/org_subfields/destroy.js.erb index 2ba03fc36..d069b1cd8 100644 --- a/app/views/org_subfields/destroy.js.erb +++ b/app/views/org_subfields/destroy.js.erb @@ -1,6 +1,5 @@ $("#org_subfield_list").html(""); $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', - :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), - :subfields => @organization.org_subfields.where("field_type != 'default'") }) %>"); + :locals => {:subfields => @organization.org_subfields.order("priority") }) %>"); $("#sub_field_left_lists").html(""); $("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/org_subfields/update_priority.js.erb b/app/views/org_subfields/update_priority.js.erb new file mode 100644 index 000000000..4f269da8f --- /dev/null +++ b/app/views/org_subfields/update_priority.js.erb @@ -0,0 +1,2 @@ +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields.order("priority")}) %>"); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>") \ No newline at end of file diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 449d95f4c..3db6ffb13 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -34,71 +34,76 @@ }) }) -<% org_activity_field = organization.org_subfields.where('field_type="default" and name="activity" and field_type="default"').first %> -<% org_course_field = organization.org_subfields.where('field_type="default" and name="course" and field_type="default"').first %> -<% org_project_field = organization.org_subfields.where('field_type="default" and name="project" and field_type="default"').first %> -
- <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %> -
-
-
- 项目 - <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> - <% end %> -
-
-
    - <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> -
-
-
-
-
- 课程 - <% if User.current.logged? and User.current.admin_of_org?(organization) %> - <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> - <% end %> -
-
-
    - <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> -
-
-
-<% organization.org_subfields.where("field_type != 'default'").each do |field| %> -
- <% if field.field_type == "Post" %> - <% if !field.subfield_subdomain_dir.nil? %> - <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> - <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> +<% organization.org_subfields.order("priority").each do |field| %> + <% if is_default_field?(field) %> + <% case field.name %> + <% when 'activity' %> +
+ <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %> +
+ <% when 'course' %> +
+
+ 课程 + <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <% end %> +
+
+
    + <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
+
+
+ <% when 'project' %> +
+
+ 项目 + <% if User.current.logged? and User.current.admin_of_org?(organization) %> + <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> + <% end %> +
+
+
    + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
+
+
+ <% end %> + <% else %> +
+ <% if field.field_type == "Post" %> + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <% else %> + <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <% end %> <% else %> - <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> + <% end %> + <% if User.current.member_of_org?organization %> + <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> <% end %> <% else %> - <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> + <% if !field.subfield_subdomain_dir.nil? %> + <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> + <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <% else %> + <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> + <% end %> + <% else %> + <%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %> + <% end %> + <% if User.current.member_of_org?organization %> + <%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %> + + <% end %> + <% end %> - <% if User.current.member_of_org?organization %> - <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> - <% end %> - <% else %> - <% if !field.subfield_subdomain_dir.nil? %> - <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> - <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> - <% else %> - <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> - <% end %> - <% else %> - <%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %> - <% end %> - <% if User.current.member_of_org?organization %> - <%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %> - - <% end %> - - <% end %> -
- +
+ + <% end %> <% end %> \ No newline at end of file diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index eed0dabf6..b90ba7565 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -1,4 +1,5 @@
    +
  • 顺序
  • 已有栏目
  • 状态
  • 类型
  • @@ -6,48 +7,64 @@
-<% default_fields.each do |field| %> - <% name = get_default_name(field) %> - -<% end %> - <% subfields.each do |field| %> -
    -
  • -
    <%= field.name %>
    - -
  • -
  • 新增
  • -
  • <%= field.field_type == "Post" ? "帖子" : "资源" %>
  • -
+ <% end %> <% end %> --> +<%= javascript_include_tag 'attachments' %> + \ No newline at end of file diff --git a/app/views/users/import_resources_search.js.erb b/app/views/users/import_resources_search.js.erb index 549cf6329..ea527ab6b 100644 --- a/app/views/users/import_resources_search.js.erb +++ b/app/views/users/import_resources_search.js.erb @@ -1,25 +1,3 @@ -//$("#resources_list").html('<%#= escape_javascript( render :partial => 'users/import_resource_info' ,:locals=>{ :attachments => @attachments, :type => @type})%>'); -//$("#pages").html('<%#= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); -//$("#res_all_count").html(<%#= @atta_count%>); -//$("#res_count").html(0); -//$("#checkboxAll").attr('checked',false); - - -<% if params[:project_id] %> -$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :project_id => params[:project_id]} ) %>'); -<% elsif params[:course_id] %> -$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :course_id => params[:course_id]} ) %>'); -<% elsif params[:subfield_file_id] %> -$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => 1, :subfield_file_id => params[:subfield_file_id]} ) %>'); -<% end %> -showModal('ajax-modal', '615px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); -<% if params[:project_id] %> -$('#ajax-modal').parent().css("top","10%").css("left","34%").css("border","3px solid #269ac9"); -<% else %> -$('#ajax-modal').parent().css("top","20%").css("left","42%").css("border","3px solid #269ac9"); -<% end %> -$('#ajax-modal').parent().addClass("popbox_polls"); - - +$("#import_resource_info_list").html('<%= escape_javascript( render :partial => 'user_import_resource_list', + :locals => {:user => @user, :type => @type, :project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} ) %>'); +$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); From 805784a8583ede2d014c3370a96a804562230351 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 17 Mar 2016 10:52:19 +0800 Subject: [PATCH 27/36] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E7=9A=84?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E5=8A=A0=E4=B8=8ASetting.protocol?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organizations/_org_course_homework.html.erb | 12 ++++++------ app/views/organizations/_org_course_poll.html.erb | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 2bc00d6b1..e6af795a9 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -227,17 +227,17 @@
    • - <%= link_to l(:button_edit),Setting.host_name + "/homework_common/" + activity.id.to_s + "/edit?", :class => "postOptionLink"%> + <%= link_to l(:button_edit),Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/edit?", :class => "postOptionLink"%>
    • - <%= link_to(l(:label_bid_respond_delete), Setting.host_name + "/homework_common/" + activity.id.to_s + "?is_in_course=-1&course_activity=" + course_activity.to_s,:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> + <%= link_to(l(:label_bid_respond_delete), Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "?is_in_course=-1&course_activity=" + course_activity.to_s,:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
    • - <%= link_to("评分设置", Setting.host_name + "/homework_common/" + activity.id.to_s + "/score_rule_set?is_in_course=0&user_activity_id=" + user_activity_id.to_s,:class => "postOptionLink", :remote => true) %> + <%= link_to("评分设置", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/score_rule_set?is_in_course=0&user_activity_id=" + user_activity_id.to_s,:class => "postOptionLink", :remote => true) %>
    • <% if activity.anonymous_comment == 0 %>
    • - <%= link_to("匿评设置", Setting.host_name + "/homework_common/" + activity.id.to_s + "/start_evaluation_set",:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> + <%= link_to("匿评设置", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/start_evaluation_set",:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%>
    • <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %> @@ -251,11 +251,11 @@ <% end %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
    • - <%= link_to("公开作品", Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_open_student_works?is_in_course=-1&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :remote => true)%> + <%= link_to("公开作品", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_open_student_works?is_in_course=-1&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :remote => true)%>
    • <% elsif activity.is_open == 1 %>
    • - <%= link_to("取消公开", Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_open_student_works?is_in_course=-1&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :remote => true)%> + <%= link_to("取消公开", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_open_student_works?is_in_course=-1&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :remote => true)%>
    • <% end %>
    diff --git a/app/views/organizations/_org_course_poll.html.erb b/app/views/organizations/_org_course_poll.html.erb index fff50786e..cfd2fcb65 100644 --- a/app/views/organizations/_org_course_poll.html.erb +++ b/app/views/organizations/_org_course_poll.html.erb @@ -16,7 +16,7 @@ <%= link_to activity.try(:user).try(:realname), user_url_in_org(activity.user_id), :class => "newsBlue mr15" %> <% end %> TO - <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", Setting.host_name + "/poll?polls_type=Course&polls_group_id=" + activity.polls_group_id.to_s, :class => "newsBlue ml15" %> + <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", Setting.protocol + "://" + Setting.host_name + "/poll?polls_type=Course&polls_group_id=" + activity.polls_group_id.to_s, :class => "newsBlue ml15" %>
  • From 7ff946e488476d01e6fc77e6b465a84c8d803d49 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 12:37:05 +0800 Subject: [PATCH 28/36] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=BA=93=E6=8F=90=E4=BE=9B=E5=8E=86=E5=8F=B2=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 9 ++++++ .../_attachment_history_download.html.erb | 31 +++++++++++++++++++ .../attachment_history_download.js.erb | 7 +++++ app/views/files/_resource_detail.html.erb | 27 +++++++++------- app/views/layouts/base_courses.html.erb | 2 +- config/routes.rb | 1 + public/javascripts/course.js | 1 + 7 files changed, 66 insertions(+), 12 deletions(-) create mode 100644 app/views/attachments/_attachment_history_download.html.erb create mode 100644 app/views/attachments/attachment_history_download.js.erb diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index b878a14ac..e974f26b4 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -572,6 +572,15 @@ class AttachmentsController < ApplicationController end end + #找到文件的所有的历史版本及当前版本 + def attachment_history_download + @attachment = Attachment.find(params[:id]) + @attachment_histories = @attachment.attachment_histories + respond_to do |format| + format.js + end + end + private def find_project @attachment = Attachment.find(params[:id]) diff --git a/app/views/attachments/_attachment_history_download.html.erb b/app/views/attachments/_attachment_history_download.html.erb new file mode 100644 index 000000000..bdef2077c --- /dev/null +++ b/app/views/attachments/_attachment_history_download.html.erb @@ -0,0 +1,31 @@ + +选择版本 +

    注:该文件有历史版本,请选择您需要的文件,点击文件名下载。

    +

    版本及序号

    + +
    + + <%= link_to truncate(@attachment.filename,length: 35, omission: '...'), + download_named_attachment_path(@attachment.id, @attachment.filename), + :title => @attachment.filename+"\n"+@attachment.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %> + + 版本号:当前 + + <% @attachment_histories.each do |history| %> + + <%= link_to truncate(history.filename,length: 35, omission: '...'), + download_history_attachment_path(history.id, history.filename), + :title => history.filename+"\n"+history.description.to_s, + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %> + + + 版本号:<%= history.version %> +
    + <% end %> +
    diff --git a/app/views/attachments/attachment_history_download.js.erb b/app/views/attachments/attachment_history_download.js.erb new file mode 100644 index 000000000..352a2ef93 --- /dev/null +++ b/app/views/attachments/attachment_history_download.js.erb @@ -0,0 +1,7 @@ +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/attachment_history_download' )%>'); +showModal('ajax-modal', '452px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","40%").css("left","50%"); +$('#ajax-modal').parent().addClass("resourceUploadPopup"); +$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px"); \ No newline at end of file diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb index 317bb7dd8..20ffb1e50 100644 --- a/app/views/files/_resource_detail.html.erb +++ b/app/views/files/_resource_detail.html.erb @@ -6,9 +6,17 @@
    - <%= link_to truncate(file.filename,length: 35, 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" %> + <%# 如果有历史版本则提供历史版本下载 %> + <% if file.attachment_histories.count == 0 %> + <%= link_to truncate(file.filename,length: 35, 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" %> + <% else %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id), + :title => file.filename+"\n"+file.description.to_s, + :class => "linkGrey3 f_14", + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %> + <% end %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> @@ -38,31 +46,28 @@ <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
    -
    • <% if User.current.logged? %> - <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
        -
      • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
      • <%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %>
      • <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
      • <% if @course.is_public? %>
      • - - <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> - + + <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> +
      • <%end%>
      • <%= link_to( '删除资源', attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %> + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %>
      - <% end %> <%else%>
        diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index f382a433c..7b19d2f9b 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -319,7 +319,7 @@ } }) - + //资源库上传附件 function course_files_upload(){ $('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/upload_course_files',:locals => {:course => @course,:course_attachment_type => 1}) %>'); showModal('ajax-modal', '513px'); diff --git a/config/routes.rb b/config/routes.rb index bde12fa59..114fb6f96 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -876,6 +876,7 @@ RedmineApp::Application.routes.draw do # additional routes for having the file name at the end of url get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment' get 'attachments/attachment_versions/:id',:to=>'attachments#attachment_versions',:as=>'attachments_versions' + get 'attachments/attachment_history_download/:id',:to=>'attachments#attachment_history_download',:as=>'attachment_history_download' post 'attachments/upload_attachment_version',:to=>'attachments#upload_attachment_version',:as=>'upload_attachment_version' get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment' get 'attachments/download_history/:id/:filename', :to => 'attachments#download_history', :id => /\d+/, :filename => /.*/, :as => 'download_history_attachment' diff --git a/public/javascripts/course.js b/public/javascripts/course.js index fff30dec5..544c2bc33 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -1432,3 +1432,4 @@ function submit_course_feedback() { function show_more_tool(){ $('#navContentCourse').css('display', 'block'); } + From b3faef601b4faad63fee58d7cfcd766e3f601c0b Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 12:43:35 +0800 Subject: [PATCH 29/36] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=BA=93=E6=A0=B7=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_attachment_history_download.html.erb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/views/attachments/_attachment_history_download.html.erb b/app/views/attachments/_attachment_history_download.html.erb index bdef2077c..c805960f0 100644 --- a/app/views/attachments/_attachment_history_download.html.erb +++ b/app/views/attachments/_attachment_history_download.html.erb @@ -16,15 +16,14 @@ :title => @attachment.filename+"\n"+@attachment.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %> 版本号:当前 - +
        <% @attachment_histories.each do |history| %> - + <%= link_to truncate(history.filename,length: 35, omission: '...'), - download_history_attachment_path(history.id, history.filename), - :title => history.filename+"\n"+history.description.to_s, - :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %> - - + download_history_attachment_path(history.id, history.filename), + :title => history.filename+"\n"+history.description.to_s, + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %> + 版本号:<%= history.version %>
        <% end %> From c8eb2d9c954b8a10cfc1c50980d5dcadb88ec1c9 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 12:49:00 +0800 Subject: [PATCH 30/36] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E3=80=81=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=B7=BB=E5=8A=A0=E8=B5=84=E6=BA=90=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_org_subfield_list.html.erb | 14 +++++++++++--- app/views/files/_project_list.html.erb | 14 +++++++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index 90ae3516d..b839128da 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -9,9 +9,17 @@
    - <%= 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" %> + <%# 如果有历史版本则提供历史版本下载 %> + <% if file.attachment_histories.count == 0 %> + <%= link_to truncate(file.filename,length: 35, 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" %> + <% else %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id), + :title => file.filename+"\n"+file.description.to_s, + :class => "linkGrey3 f_14", + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %> + <% end %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb index a2a1670d1..2ee726d77 100644 --- a/app/views/files/_project_list.html.erb +++ b/app/views/files/_project_list.html.erb @@ -8,9 +8,17 @@
    - <%= link_to truncate(file.filename,length: 35, 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" %> + <%# 如果有历史版本则提供历史版本下载 %> + <% if file.attachment_histories.count == 0 %> + <%= link_to truncate(file.filename,length: 35, 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" %> + <% else %> + <%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id), + :title => file.filename+"\n"+file.description.to_s, + :class => "linkGrey3 f_14", + :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %> + <% end %> <%= file_preview_eye(file, class: 'preview') %> <% if file.is_public? == false%> From ab3fc0fb2cbb6606addb6764a50b4e3afdb4c234 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 13:02:32 +0800 Subject: [PATCH 31/36] =?UTF-8?q?=E6=88=90=E5=91=98=E6=8F=90=E4=BE=9B?= =?UTF-8?q?=E7=9C=9F=E5=AE=9E=E5=A7=93=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/settings/_new_members.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/settings/_new_members.html.erb b/app/views/projects/settings/_new_members.html.erb index e82062e9b..733eacab4 100644 --- a/app/views/projects/settings/_new_members.html.erb +++ b/app/views/projects/settings/_new_members.html.erb @@ -21,7 +21,7 @@ <%= call_hook(:view_projects_settings_members_table_header, :project => @project) %> <% members.each do |member| %>
  • - <%= link_to_user_header member.principal,false,:class => "w140_h c_setting_blue fl" %> + <%= link_to_user_header member.principal, true, :class => "w140_h c_setting_blue fl" %> <% if User.current.language == "zh" %> From 0d1fc409d1b15641506558ab6080e4cc30058283 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 13:58:55 +0800 Subject: [PATCH 32/36] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E5=90=8C=E4=B8=80=E9=AB=98=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/projects/settings/_new_repositories.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index 07b2896eb..be6330d9b 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -4,6 +4,9 @@ $("#pro_st_edit_ku").toggle(); } +<% unless @project.repositories.any? %> +

    温馨提示:<%= l(:label_repository_no_data) %>

    +<% end %> <%= str = error_messages_for 'repository' %> <% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %> <% ip = RepositoriesHelper::REPO_IP_ADDRESS %> @@ -87,8 +90,6 @@ <% end %> -<% else %> -

    温馨提示:<%= l(:label_repository_no_data) %>

    <% end %> From ee40255d7edb65824fcf8dcd849aea2d867c2fea Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 14:09:13 +0800 Subject: [PATCH 33/36] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93bytes=E6=94=B9?= =?UTF-8?q?=E6=88=90b?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_resources_list.html.erb | 2 +- app/views/users/_user_import_resource_list.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb index f679f9c8c..a545038f1 100644 --- a/app/views/users/_resources_list.html.erb +++ b/app/views/users/_resources_list.html.erb @@ -16,7 +16,7 @@
  • <%= attach.quotes.nil? ? 0 : attach.quotes %>
  • <%= attach.downloads %>
  • <%= attach.author_id %>
  • -
  • <%= number_to_human_size(attach.filesize) %>
  • +
  • <%= (number_to_human_size(attach.filesize)).gsub("ytes", "") %>
  • <%= get_resource_type(attach.container_type)%>
  • diff --git a/app/views/users/_user_import_resource_list.html.erb b/app/views/users/_user_import_resource_list.html.erb index 57dac6ad0..af4f951e0 100644 --- a/app/views/users/_user_import_resource_list.html.erb +++ b/app/views/users/_user_import_resource_list.html.erb @@ -11,7 +11,7 @@
  • <%= get_resource_type(attach.container_type)%>
  • - +
  • <%=User.find(attach.author_id).realname.blank? ? User.find(attach.author_id).nickname : User.find(attach.author_id).realname %>
  • <%= format_date(attach.created_on) %>
  • From 84470af2ff68b41e9e9780590050900435ee9c42 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 14:47:14 +0800 Subject: [PATCH 34/36] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=9A=84=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=92=8C=E9=A1=B9=E7=9B=AE=E4=B8=8D=E5=9C=A8=E5=8F=91?= =?UTF-8?q?=E9=80=81=E4=B8=AD=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index cf591d6a8..06b2df862 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1674,10 +1674,10 @@ class UsersController < ApplicationController if !params[:search].nil? search = "%#{params[:search].to_s.strip.downcase}%" @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search) - .select { |course| @user.allowed_to?(:as_teacher,course)} + .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 } else @course = @user.courses - .select { |course| @user.allowed_to?(:as_teacher,course)} + .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 } end @search = params[:search] #这里仅仅是传递需要发送的资源id @@ -1695,7 +1695,7 @@ class UsersController < ApplicationController search = "%#{params[:search].to_s.strip.downcase}%" @projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search) else - @projects = @user.projects + @projects = @user.projects.visible end @search = params[:search] #这里仅仅是传递需要发送的资源id From 03597b85ff6d88973d4030d6e77e4ee85489b43c Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 16:02:36 +0800 Subject: [PATCH 35/36] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E8=A2=AB=E6=B7=B9=E6=B2=A1=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 6 +++--- app/views/projects/_project_activities.html.erb | 2 +- app/views/projects/show.html.erb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 1cc0d3b7a..714da9920 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -90,8 +90,8 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - after_save :act_as_course_activity - after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index + after_save :act_as_course_activity,:act_as_forge_activity + after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score @@ -606,7 +606,7 @@ class Attachment < ActiveRecord::Base # Author lizanle # Description 上传该项目的文档资料也要保存一份在公共表中 def act_as_forge_activity - if self.container_type == 'Project' + if self.container_type == 'Project' && self.forge_acts.empty? self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.container_id) end diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index c036633a5..73163521e 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -78,7 +78,7 @@ <% end %> <% when "Attachment" %> - <%= render :partial => 'projects/attachment_acts', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> + <%= render :partial => 'users/course_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index a58aeb281..f2b6cadeb 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -18,7 +18,7 @@
  • <%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %>
  • <%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %>
  • - +
  • <%= link_to "资源库动态", {:controller => "projects", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey" %>
  • <%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %>
  • From 22ed0c1b6c7df6a0b187f7d2b8643defa9f171be Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 16:12:06 +0800 Subject: [PATCH 36/36] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=8A=E7=BA=BFgem?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Gemfile b/Gemfile index 645c7b849..c739e1085 100644 --- a/Gemfile +++ b/Gemfile @@ -36,7 +36,6 @@ gem 'chinese_pinyin' # gem 'progress_bar' gem 'ansi' -gem 'debugger' gem 'kaminari' gem 'elasticsearch-model' gem 'elasticsearch-rails'