From 5d1d56fbb3b7371e55465f8b691380959475ad82 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 8 Mar 2016 16:44:03 +0800 Subject: [PATCH 001/102] =?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 002/102] =?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 003/102] =?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" %> - <% 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" %> + <% 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 %> - <% 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 %>
<% end %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index a8504ee1e..55d3eefad 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1170,7 +1170,8 @@ function getRootPath(){ //获取主机地址,如: http://localhost:8083 var localhostPaht=curWwwPath.substring(0,pos); //获取带"/"的项目名,如:/uimcardprj - var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); +// var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1); + var projectName=""; return(localhostPaht+projectName); } From c0edd91c3dff0f702ea62b09cf24626e92772687 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 14 Mar 2016 18:20:19 +0800 Subject: [PATCH 030/102] =?UTF-8?q?=E7=99=BB=E9=99=86=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E6=94=B9=E4=B8=BAwww.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_unlogin_header.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb index 2f0d2732b..12b77c365 100644 --- a/app/views/layouts/_unlogin_header.html.erb +++ b/app/views/layouts/_unlogin_header.html.erb @@ -77,10 +77,10 @@
From 15dfaf67b22e51d2a159790b066e4f9bf3e622dd Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 14 Mar 2016 18:29:50 +0800 Subject: [PATCH 031/102] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E7=89=88=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=EF=BC=8C=E7=99=BB=E9=99=86=E6=B3=A8=E5=86=8C=E6=94=B9?= =?UTF-8?q?=E6=88=90https://test.forge.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 20 ++++++++++++++++++++ app/views/layouts/_unlogin_header.html.erb | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 31decde59..ca8e0fc28 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2961,3 +2961,23 @@ def logout_url_without_domain return "https://www.trustie.net/logout" end end + +def signin_url_without_domain + if Rails.env.development? + return "http://localhost:3000/login?login=true" + elsif Rails.env.test? + return "https://test.forge.trustie.net/login?login=true" + else + return "https://www.trustie.net/login?login=true" + end +end + +def register_url_without_domain + if Rails.env.development? + return "http://localhost:3000/login?login=false" + elsif Rails.env.test? + return "https://test.forge.trustie.net/login?login=false" + else + return "https://www.trustie.net/login?login=false" + end +end diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb index 12b77c365..0675c8a4a 100644 --- a/app/views/layouts/_unlogin_header.html.erb +++ b/app/views/layouts/_unlogin_header.html.erb @@ -77,10 +77,10 @@
From 402b0e9c24fc613f642d086f08f7f4ff4149fe7b Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 14 Mar 2016 23:15:08 +0800 Subject: [PATCH 032/102] =?UTF-8?q?=E5=9F=9F=E5=90=8D=E9=83=BD=E4=BD=BF?= =?UTF-8?q?=E7=94=A8Setting.host=5Fname=E8=8E=B7=E5=8F=96=E4=B8=BB?= =?UTF-8?q?=E6=9C=BA=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 31decde59..1aca4fb0b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2943,21 +2943,9 @@ int main(int argc, char** argv){ end def user_url_in_org(user_id) - if Rails.env.development? - return "http://localhost:3000/users/" + user_id.to_s - elsif Rails.env.test? - return "https://www.test.forge.trustie.net/users/" + user_id.to_s - else - return "https://www.trustie.net/users/" + user_id.to_s - end + return Setting.host_name + "/users/" + user_id.to_s end def logout_url_without_domain - if Rails.env.development? - return "http://localhost:3000/logout" - elsif Rails.env.test? - return "https://test.forge.trustie.net/logout" - else - return "https://www.trustie.net/logout" - end + return Setting.host_name + "/logout" end From 2b21213b7fc40141d25db150621a83498cb06544 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 15 Mar 2016 09:26:26 +0800 Subject: [PATCH 033/102] =?UTF-8?q?=E5=85=AC=E5=85=B1=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=BA=93=EF=BC=8C=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 233 ++++++++++-------- app/helpers/users_helper.rb | 2 +- app/views/users/_user_resource_info.html.erb | 15 +- .../users/_user_resource_tip_list.html.erb | 33 +++ app/views/users/resource_search.js.erb | 11 +- app/views/users/user_resource.html.erb | 8 - app/views/users/user_resource.js.erb | 1 + app/views/users/user_resource_create.js.erb | 1 - public/stylesheets/public.css | 5 +- 9 files changed, 178 insertions(+), 131 deletions(-) create mode 100644 app/views/users/_user_resource_tip_list.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7fe146926..682d79424 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -817,18 +817,18 @@ class UsersController < ApplicationController # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") #全部 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids) + @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids) + @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id] + @attachments = get_attch_resources params[:id], params[:order] elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id] + @attachments = get_principal_resources params[:id], params[:order] elsif params[:type] == "6" # 公共资源 # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) end @type = params[:type] @limit = 7 @@ -938,12 +938,7 @@ class UsersController < ApplicationController return end # 自己访问自己的页面才更新消息状态 - if User.current == @user - journals_messages = UserFeedbackMessage.where("user_id =? and journals_for_message_type =? and viewed =?", User.current.id, "JournalsForMessage", 0) - journals_messages.each do |journals_message| - journals_message.update_attributes(:viewed => true) - end - end + UserFeedbackMessage.where("user_id =? and viewed =? and journals_for_message_type =? ", User.current.id, 0, "JournalsForMessage").update_all(:viewed => true) # end @page = params[:page] ? params[:page].to_i + 1 : 0 if params[:type].present? @@ -1551,37 +1546,37 @@ class UsersController < ApplicationController if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 if params[:status] == 2 - @attachments = get_course_resources(params[:id], user_course_ids) + @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) elsif params[:status] == "3" - @attachments = get_project_resources(params[:id], user_project_ids) + @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) elsif params[:status] == "4" - @attachments = get_attch_resources params[:id] + @attachments = get_attch_resources params[:id], params[:order] elsif params[:status] == "5" - @attachments = get_principal_resources params[:id] + @attachments = get_principal_resources params[:id], params[:order] else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) end elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids) + @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids) + @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id] + @attachments = get_attch_resources params[:id], params[:order] elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id] + @attachments = get_principal_resources params[:id], params[:order] elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids) + @attachments = get_course_resources_public( user_course_ids, params[:order]) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids) + @attachments = get_project_resources_public(user_project_ids, params[:order]) elsif params[:status] == "4" - @attachments = get_attch_resources_public + @attachments = get_attch_resources_public params[:order] elsif params[:status] == "5" - @attachments = get_principal_resources_public + @attachments = get_principal_resources_public params[:order] else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) end end @status = params[:status] @@ -1613,37 +1608,37 @@ class UsersController < ApplicationController if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 if params[:status] == 2 - @attachments = get_course_resources(params[:id], user_course_ids) + @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) elsif params[:status] == "3" - @attachments = get_project_resources(params[:id], user_project_ids) + @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) elsif params[:status] == "4" - @attachments = get_attch_resources params[:id] + @attachments = get_attch_resources params[:id], params[:order] elsif params[:status] == "5" - @attachments = get_principal_resources params[:id] + @attachments = get_principal_resources params[:id], params[:order] else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) end elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids) + @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids) + @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id] + @attachments = get_attch_resources params[:id], params[:order] elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id] + @attachments = get_principal_resources params[:id], params[:order] elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids) + @attachments = get_course_resources_public( user_course_ids, params[:order]) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids) + @attachments = get_project_resources_public(user_project_ids, params[:order]) elsif params[:status] == "4" - @attachments = get_attch_resources_public + @attachments = get_attch_resources_public params[:order] elsif params[:status] == "5" - @attachments = get_principal_resources_public + @attachments = get_principal_resources_public params[:order] else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) end end @status = params[:status] @@ -2331,61 +2326,70 @@ class UsersController < ApplicationController end # 获取公共资源 - def get_public_resources user_course_ids, user_project_ids + def get_public_resources user_course_ids, user_project_ids, order attachments = Attachment.where("(is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + - "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("created_on desc") + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 获取我的资源 - def get_my_resources author_id, user_course_ids, user_project_ids + def get_my_resources author_id, user_course_ids, user_project_ids, order, score attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + - "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("created_on desc") + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + end + + # 获取我的资源查询结果 + def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search) + @attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的课程资源 - def get_course_resources author_id, user_course_ids - attchments = Attachment.where("(author_id = #{author_id} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc") + def get_course_resources author_id, user_course_ids, order + attchments = Attachment.where("(author_id = #{author_id} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 获取公共资源课程 - def get_course_resources_public user_course_ids - attchments = Attachment.where("(container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc") + def get_course_resources_public user_course_ids, order + attchments = Attachment.where("(container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 获取我的项目资源 - def get_project_resources author_id, user_project_ids - attchments = Attachment.where("(author_id = #{author_id} and container_type = 'Project') or (container_type = 'Course' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1) ").order("created_on desc") + def get_project_resources author_id, user_project_ids, order + attchments = Attachment.where("(author_id = #{author_id} and container_type = 'Project') or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1) ").order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 获取公共资源的项目资源 - def get_project_resources_public user_project_ids - attchments = Attachment.where("(container_type = 'Project') or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1) ").order("created_on desc") + def get_project_resources_public user_project_ids, order + attchments = Attachment.where("(container_type = 'Project') or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1) ").order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 获取我上传的附件 - def get_attch_resources author_id - attchments = Attachment.where("author_id = #{author_id} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") + def get_attch_resources author_id, order + attchments = Attachment.where("author_id = #{author_id} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 获取公共资源中我上传的附件 - def get_attch_resources_public - attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") + def get_attch_resources_public order + attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 获取我的用户类型资源 - def get_principal_resources author_id - attchments = Attachment.where("author_id = #{author_id} and container_type = 'Principal'").order("created_on desc") + def get_principal_resources author_id, order + attchments = Attachment.where("author_id = #{author_id} and container_type = 'Principal'").order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 获取我的用户类型资源 - def get_principal_resources_public - attchments = Attachment.where("container_type = 'Principal'").order("created_on desc") + def get_principal_resources_public order + attchments = Attachment.where("container_type = 'Principal'").order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end # 资源库 分为全部 课程资源 项目资源 附件 def user_resource + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" # 别人的资源库是没有权限去看的 if User.current.id.to_i != params[:id].to_i render_403 @@ -2397,37 +2401,37 @@ class UsersController < ApplicationController if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 if params[:status] == "2" - @attachments = get_course_resources(params[:id], user_course_ids) + @attachments = get_course_resources(params[:id], user_course_ids, @order) elsif params[:status] == "3" - @attachments = get_project_resources(params[:id], user_project_ids) + @attachments = get_project_resources(params[:id], user_project_ids, @order) elsif params[:status] == "4" - @attachments = get_attch_resources params[:id] + @attachments = get_attch_resources params[:id], @order elsif params[:status] == "5" - @attachments = get_principal_resources params[:id] + @attachments = get_principal_resources params[:id], @order else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) end elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids) + @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids) + @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id] + @attachments = get_attch_resources params[:id], params[:order] elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id] + @attachments = get_principal_resources params[:id], params[:order] elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = get_course_resources_public( user_course_ids) + @attachments = get_course_resources_public( user_course_ids, params[:order]) elsif params[:status] == "3" - @attachments = get_project_resources_public(user_project_ids) + @attachments = get_project_resources_public(user_project_ids, params[:order]) elsif params[:status] == "4" - @attachments = get_attch_resources_public + @attachments = get_attch_resources_public params[:order] elsif params[:status] == "5" - @attachments = get_principal_resources_public + @attachments = get_principal_resources_public params[:order] else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) end end @status = params[:status] @@ -2457,10 +2461,10 @@ class UsersController < ApplicationController # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) elsif params[:type] == "6" # 公共资源 # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) end @type = params[:type] @limit = 10 @@ -2493,10 +2497,10 @@ class UsersController < ApplicationController # user_org_ids = User.current.organizations.map {|o| o.id} @attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + - "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("created_on desc") + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{params[:order].nil? ? 'created_on' : params[:order]} desc") elsif params[:type] == "6" # 公共资源 # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) end @type = params[:type] @limit = 10 @@ -2566,57 +2570,74 @@ class UsersController < ApplicationController # 根据资源关键字进行搜索 def resource_search - search = "%#{params[:search].strip.downcase}%" + @order, @b_sort = params[:order] || "created_on", params[:sort] || "desc" + @score = @b_sort == "desc" ? "asc" : "desc" + @user = User.current + switch_search = params[:search].nil? ? " " : params[:search] + search = "%#{switch_search.strip.downcase}%" user_course_ids = User.current.courses.map { |c| c.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} - if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 - if User.current.id.to_i == params[:id].to_i - - @attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + - "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("created_on desc") + if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部 + if params[:status] == "2" + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + elsif params[:status] == "3" + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + elsif params[:status] == "4" + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + elsif params[:status] == "5" + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 - @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + - " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ - " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + - " and (filename like :p) ",:p=>search).order("created_on desc") + # 公共资源库:所有公开资源或者我上传的私有资源 + get_my_resources_search(@user.id, user_course_ids, user_project_ids, @order, @score, search) end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("created_on desc") + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ - " and (filename like :p) ",:p=>search).order("created_on desc") + " and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end - elsif params[:type] == "3" #项目资源 + elsif params[:type] == "3" # 项目资源 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like :p) ",:p=>search).order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end - elsif params[:type] == "4" #附件 + elsif params[:type] == "4" # 附件 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end - elsif params[:type] == "5" #用户资源 + elsif params[:type] == "5" # 用户资源 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + end + elsif params[:type] == "6" # 全部资源 + if params[:status] == "2" + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + elsif params[:status] == "3" + @attachments = Attachment.where("container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + elsif params[:status] == "4" + @attachments = Attachment.where("container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + elsif params[:status] == "5" + @attachments = Attachment.where("container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + else + # 公共资源库:所有公开资源或者我上传的私有资源 + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = Attachment.where("((is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) "+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") end - elsif params[:type] == "6" #全部资源 - # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = Attachment.where("((is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) "+ - "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + - "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("created_on desc") end + @status = params[:status] + @type = params[:type] @type = params[:type] @limit = 25 @is_remote = true diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 44b919121..bdd34d80d 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -62,7 +62,7 @@ module UsersHelper when 'Course' result = current_time_and_term_resource content when 'Project' - result = content.name + result = content.name + "(" + content.id.to_s + ")" when 'Issue' result = content.subject when 'Message' diff --git a/app/views/users/_user_resource_info.html.erb b/app/views/users/_user_resource_info.html.erb index 6eddf1e05..bea78130a 100644 --- a/app/views/users/_user_resource_info.html.erb +++ b/app/views/users/_user_resource_info.html.erb @@ -1,21 +1,11 @@
- <%= render :partial => 'users/resource_search_form',:locals => {:user => @user, :type => @type} %> + <%= render :partial => 'users/resource_search_form',:locals => {:user => @user, :type => @type, :order => @order, :sort => @score, :status => @status} %>
-
    -
  • -
  • 资源名称
  • -
  • 上传时间
  • -
  • 引用数
  • -
  • 下载数
  • -
  • 大小
  • -
  • 上传者
  • -
  • 类别
  • -
  • 来源
  • -
+<%= render :partial => 'users/user_resource_tip_list', :locals => { :type => @type, :status => @status} %>
@@ -23,7 +13,6 @@
-
diff --git a/app/views/users/_user_resource_tip_list.html.erb b/app/views/users/_user_resource_tip_list.html.erb new file mode 100644 index 000000000..5d5876ac8 --- /dev/null +++ b/app/views/users/_user_resource_tip_list.html.erb @@ -0,0 +1,33 @@ +
    +
  • +
  • 资源名称
  • +
  • + <%= link_to "上传时间", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "created_on", :search => " "), :class => "fl", :remote => true %> + <% if @order == "created_on" %> + <%= link_to "", user_resource_user_path(:type => @type, :status => @status, :sort => @score, :order => "created_on", :search => " "), :class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt16", :remote => true %> + <% end %> +
  • +
  • + <%= link_to "引用数", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "quotes"), :class => "fl", :remote => true %> + <% if @order == "quotes" %> + <%= link_to "", user_resource_user_path(:type => @type, :status => @status, :sort => @score, :order => "quotes"), :class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt16", :remote => true %> + <% end %> +
  • +
  • + <%= link_to "下载数", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "downloads"), :class => "fl", :remote => true %> + <% if @order == "downloads" %> + <%= link_to "", user_resource_user_path(:type => @type, :status => @status, :sort => @score, :order => "downloads"), :class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt16", :remote => true %> + <% end %> +
  • +
  • +
    + <%= link_to "大小", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "filesize"), :class => "fl", :remote => true %> + <% if @order == "filesize" %> + <%= link_to "", user_resource_user_path(:type => @type, :status => @status, :sort => @score, :order => "filesize"), :class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt16", :remote => true %> + <% end %> +
    +
  • +
  • 上传者
  • +
  • 类别
  • +
  • 来源
  • +
\ No newline at end of file diff --git a/app/views/users/resource_search.js.erb b/app/views/users/resource_search.js.erb index d295ce003..38e80e75b 100644 --- a/app/views/users/resource_search.js.erb +++ b/app/views/users/resource_search.js.erb @@ -1,5 +1,14 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); +$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>'); $("#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); \ No newline at end of file +$("#checkboxAll").attr('checked',false); +//更新状态 +$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6', :status => @status) %>'); +$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1', :status => @status) %>'); +$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1) %>'); +$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2) %>'); +$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3) %>'); +$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5) %>'); +$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4) %>'); \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index f45eb11c2..751f0a48f 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -21,14 +21,6 @@ $("#resource_search_form").submit(); } - function show_public_resource(){ - $("#resource_remote").html('<%= escape_javascript( render :partial => 'user_resource_info' ,:locals => { :tpye => 6}) %>'); - } - - function show_public_resource(){ - $("#resource_remote").html('<%= escape_javascript( render :partial => 'user_resource_info' ,:locals => { :tpye => 1}) %>'); - } - function closeModal() { hideModal($(".uploadBoxContainer")); diff --git a/app/views/users/user_resource.js.erb b/app/views/users/user_resource.js.erb index 4ba186579..370b84711 100644 --- a/app/views/users/user_resource.js.erb +++ b/app/views/users/user_resource.js.erb @@ -1,4 +1,5 @@ $("#search_div").html('<%= escape_javascript( render :partial => 'resource_search_form', :locals => {:user => @user, :type => @type} ) %>'); +$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status} ) %>'); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' , :locals => { :attachments => @attachments}) %>'); $("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>'); $("#res_count").html(0); diff --git a/app/views/users/user_resource_create.js.erb b/app/views/users/user_resource_create.js.erb index f69057273..5ce547fbf 100644 --- a/app/views/users/user_resource_create.js.erb +++ b/app/views/users/user_resource_create.js.erb @@ -1,4 +1,3 @@ - closeModal(); $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>'); //这里不能将翻页的更新 diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index b84fb040e..3780723b9 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -117,6 +117,7 @@ h4{ font-size:14px; color:#3b3b3b;} .mt6{ margin-top:6px;} .mt8{ margin-top:8px;} .mt10{ margin-top:10px !important;} +.mt16{ margin-top:16px !important;} .mt20{margin-top: 20px;} .mt30{ margin-top: 30px;} .mt40{ margin-top: 40px;} @@ -1131,4 +1132,6 @@ a.resource-tab-active {color:#fff; background-color:#269ac9; border-bottom:1px s a.group-btn{ background: url(../images/course/hwork_icon.png) -2px -58px no-repeat !important; height:20px; display:block; padding-left:23px; color:#888888; -moz-transition :all 0s linear 0s; -webkit-transition :all 0s linear 0s; -o-transition:all 0s linear 0s; transition:all 0s linear 0s;} a.program-btn{background: url(../images/homepage_icon.png) -86px -393px no-repeat; width:30px; height:20px; display:block; padding-left:23px; color:#888888;} - +/*排序样式*/ +a.st_up{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 0 no-repeat; margin-top:5px; margin-left:3px;} +a.st_down{ display: block; width:8px; float:left; height:13px; background:url(../images/pic_up.png) 0 -22px no-repeat; margin-top:5px; margin-left:3px;} \ No newline at end of file From 5476016b799605ad06f289f5bd753023be6868df Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 15 Mar 2016 09:47:58 +0800 Subject: [PATCH 034/102] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A2=98=E5=BA=93?= =?UTF-8?q?=E9=AB=98=E5=BA=A6=E4=B8=8E=E8=B5=84=E6=BA=90=E5=BA=93=E4=B8=80?= =?UTF-8?q?=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 14 +++++++------- .../users/_homework_repository_detail.html.erb | 2 +- app/views/users/user_homeworks.html.erb | 2 +- public/stylesheets/new_user.css | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1a04ce5fe..73d391f08 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -387,12 +387,12 @@ class UsersController < ApplicationController @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") end @type = params[:type] - @limit = 15 + @limit = 25 @is_remote = true @hw_count = @homeworks.count @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @offset ||= @hw_pages.offset - @homeworks = paginateHelper @homeworks,15 + @homeworks = paginateHelper @homeworks,25 respond_to do |format| format.js format.html {render :layout => 'static_base'} @@ -546,13 +546,13 @@ class UsersController < ApplicationController end @type = params[:type] @property = params[:property] - @limit = 15 + @is_import = params[:is_import] + @limit = params[:is_import].to_i == 1 ? 15 : 25 @is_remote = true @hw_count = @homeworks.count @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @offset ||= @hw_pages.offset - @homeworks = paginateHelper @homeworks,15 - @is_import = params[:is_import] + @homeworks = paginateHelper @homeworks,@limit respond_to do |format| format.js end @@ -608,12 +608,12 @@ class UsersController < ApplicationController end =end @type = params[:type] - @limit = 15 + @limit = params[:is_import].to_i == 1 ? 15 : 25 @is_remote = true @hw_count = @homeworks.count @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @offset ||= @hw_pages.offset - @homeworks = paginateHelper @homeworks,15 + @homeworks = paginateHelper @homeworks,@limit @is_import = params[:is_import] @property = params[:property] @search = search diff --git a/app/views/users/_homework_repository_detail.html.erb b/app/views/users/_homework_repository_detail.html.erb index 2472d71f5..efbf24955 100644 --- a/app/views/users/_homework_repository_detail.html.erb +++ b/app/views/users/_homework_repository_detail.html.erb @@ -2,7 +2,7 @@
题目信息
<% if homework.nil? %> - 本题库遵循创作共用许可证

+ 本题库遵循创作共用许可证
教师给学生出题本质上是一种创作行为,题目的作者通常为此付出大量时间和精力。好的题目不仅能加深学生对知识点的理解,还能激发学生兴趣,提升学习效率。为此,本网站的题库许可证基于创作共用许可证( Creative Commons License )建立,其核心条款包括:

diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb index 144b40066..683cb7019 100644 --- a/app/views/users/user_homeworks.html.erb +++ b/app/views/users/user_homeworks.html.erb @@ -33,7 +33,7 @@
-
+
  • 公共题库 diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 3572fc654..23c4296f3 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1466,13 +1466,13 @@ a.choose-active {background-color:#269ac9; color:#ffffff;} .whiteSettingIcon:hover {background:url(../images/homepage_icon.png) -93px -44px no-repeat;} /*20160301新题库样式*/ -.subject-list-banner {width:685px; height:34px; background-color:#f1f1f1; border-top:1px solid #eaeaea; color:#7a7a7a; font-size:14px;} -.subject-list-banner li {height:34px; line-height:34px; vertical-align:middle;} +.subject-list-banner {width:685px; height:40px; background-color:#f1f1f1; border-top:1px solid #eaeaea; color:#7a7a7a; font-size:14px;} +.subject-list-banner li {height:40px; line-height:40px; vertical-align:middle;} .subject-list-name {width:260px; padding-left:10px; padding-right:10px;} .subject-list-publisher {width:80px; text-align:center;} .subject-list-date {width:70px; text-align:center;} -.subject-list-row {width:685px; height:30px; color:#7a7a7a; font-size:12px;} -.subject-list-row li {height:30px; line-height:30px; vertical-align:middle;} +.subject-list-row {width:685px; height:40px; color:#7a7a7a; font-size:12px;} +.subject-list-row li {height:40px; line-height:40px; vertical-align:middle;} .subject-list-search {border:1px solid #dddddd; height:32px; width:250px;} .subject-list-info {width:385px; background-color:#f1f1f1; border:1px solid #dddddd; height:32px; line-height:32px; vertical-align:middle; text-align:center; color:#7a7a7a;} .subject-list-wrap {border:1px solid #dddddd; border-top:none; padding:10px; width:365px; height:460px; overflow-y:auto;} From 2a46d60433d5b180af5c94c428368ab0a7c34a2e Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 15 Mar 2016 11:19:03 +0800 Subject: [PATCH 035/102] =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E7=9A=84host=5Fname=E5=9D=87=E4=BD=BF?= =?UTF-8?q?=E7=94=A8Setting.host=5Fname?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 144 +++--------------- .../_org_course_homework.html.erb | 16 +- .../organizations/_org_course_poll.html.erb | 2 +- .../users/_watch_btn_for_picture.html.erb | 4 +- 4 files changed, 29 insertions(+), 137 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8c5d4acea..e35d0cebe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2897,183 +2897,75 @@ int main(int argc, char** argv){ end def user_url_in_org(user_id) - if Rails.env.development? - return "http://localhost:3000/users/" + user_id.to_s - elsif Rails.env.test? - return "https://www.test.forge.trustie.net/users/" + user_id.to_s - else - return "https://www.trustie.net/users/" + user_id.to_s - end + Setting.host_name + "/users/" + user_id.to_s 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 + Setting.host_name + "/projects/" + project_id.to_s + "/issues" 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 + Setting.host_name + "/issues/" + id.to_s 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 + Setting.host_name + "/projects/" + id.to_s + "/boards" 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 + Setting.host_name + "/boards/" + board_id.to_s + "/topics/" + message_id.to_s 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 + Setting.host_name + "/projects/" + id.to_s 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 + Setting.host_name + "/homework_common?course=" + course_id.to_s 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 + Setting.host_name + "/student_work?homework=" + homework_id.to_s end def course_url_in_org(course_id) - if Rails.env.development? - return "http://localhost:3000/courses/" + course_id.to_s - elsif Rails.env.test? - return "https://test.forge.trustie.net/courses/" + course_id.to_s - else - return "https://www.trustie.net/courses/" + course_id.to_s - end + Setting.host_name + "/courses/" + course_id.to_s end def user_watchlist_url_in_org(id) - if Rails.env.development? - return "http://localhost:3000/users/" + id.to_s + "/user_watchlist" - elsif Rails.env.test? - return "https://test.forge.trustie.net/users/" + id.to_s + "/user_watchlist" - else - return "https://www.trustie.net/users/" + id.to_s + "/user_watchlist" - end + Setting.host_name + "/users/" + id.to_s + "/user_watchlist" end def user_fanslist_url_in_org(id) - if Rails.env.development? - return "http://localhost:3000/users/" + id.to_s + "/user_fanslist" - elsif Rails.env.test? - return "https://test.forge.trustie.net/users/" + id.to_s + "/user_fanslist" - else - return "https://www.trustie.net/users/" + id.to_s + "/user_fanslist" - end + Setting.host_name + "/users/" + id.to_s + "/user_fanslist" end def user_blogs_url_in_org(user_id) - if Rails.env.development? - return "http://localhost:3000/users/" + user_id.to_s + "/blogs" - elsif Rails.env.test? - return "https://test.forge.trustie.net/users/" + user_id.to_s + "/blogs" - else - return "https://www.trustie.net/users/" + user_id.to_s + "/blogs" - end + Setting.host_name + "/users/" + user_id.to_s + "/blogs" end def feedback_url_in_org(user_id) - if Rails.env.development? - return "http://localhost:3000/users/" + user_id.to_s + "/user_newfeedback" - elsif Rails.env.test? - return "https://test.forge.trustie.net/users/" + user_id.to_s + "/user_newfeedback" - else - return "https://www.trustie.net/users/" + user_id.to_s + "/user_newfeedback" - end + Setting.host_name + "/users/" + user_id.to_s + "/user_newfeedback" end def user_activities_url_in_org(user_id) - if Rails.env.development? - return "http://localhost:3000/users/" + user_id.to_s + "/user_activities" - elsif Rails.env.test? - return "http://test.forge.trustie.net/users/" + user_id.to_s + "/user_activities" - else - return "http://www.trustie.net/users/" + user_id.to_s + "/user_activities" - end + Setting.host_name + "/users/" + user_id.to_s + "/user_activities" end def course_news_index_url_in_org(course_id) - if Rails.env.development? - return "http://localhost:3000/courses/" + course_id.to_s + "/news" - elsif Rails.env.test? - return "https://test.forge.trustie.net/courses/" + course_id.to_s + "/news" - else - return "https://www.trustie.net/courses/" + course_id.to_s + "/news" - end + Setting.host_name + "/courses/" + course_id.to_s + "/news" end def news_url_in_org(news_id) - if Rails.env.development? - return "http://localhost:3000/news/" + news_id.to_s - elsif Rails.env.test? - return "https://test.forge.trustie.net/news/" + news_id.to_s - else - return "https://www.trustie.net/news/" + news_id.to_s - end + Setting.host_name + "/news/" + news_id.to_s end def course_boards_url_in_org(course_id) - if Rails.env.development? - return "http://localhost:3000/courses/" + course_id.to_s + "/boards" - elsif Rails.env.test? - return "https://test.forge.trustie.net/courses/" + course_id.to_s + "/boards" - else - return "https://www.trustie.net/courses/" + course_id.to_s + "/boards" - end + Setting.host_name + "/courses/" + course_id.to_s + "/boards" end def logout_url_without_domain - if Rails.env.development? - return "http://localhost:3000/logout" - elsif Rails.env.test? - return "https://test.forge.trustie.net/logout" - else - return "https://www.trustie.net/logout" - end + Setting.host_name + "/logout" end #判断是否为默认的组织栏目 diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 6900cbd34..2bc00d6b1 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -194,7 +194,7 @@
    <% if project.is_public || User.current.member_of?(project) || User.current.admin? %> - <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像" %> + <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_url_in_org(project.id),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像" %> <% else %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像") %> <% end %> @@ -227,17 +227,17 @@
    • - <%= link_to l(:button_edit),edit_homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity), :class => "postOptionLink"%> + <%= link_to l(:button_edit),Setting.host_name + "/homework_common/" + activity.id.to_s + "/edit?", :class => "postOptionLink"%>
    • - <%= link_to(l(:label_bid_respond_delete), homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity),:method => 'delete', :confirm => l(:text_are_you_sure), :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("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => 0),:class => "postOptionLink", :remote => true) %> + <%= 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) %>
    • <% if activity.anonymous_comment == 0 %>
    • - <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> + <%= 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%>
    • <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %> @@ -245,17 +245,17 @@ <% end %> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
    • - <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", + <%= link_to("禁用匿评", Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_forbidden_anonymous_comment?user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品",:remote => true)%>
    • <% end %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
    • - <%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> + <%= 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)%>
    • <% elsif activity.is_open == 1 %>
    • - <%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> + <%= 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)%>
    • <% end %>
    diff --git a/app/views/organizations/_org_course_poll.html.erb b/app/views/organizations/_org_course_poll.html.erb index c124e829f..fff50786e 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+" | 问卷", poll_index_path(:polls_type => "Course", :polls_group_id => activity.polls_group_id), :class => "newsBlue ml15" %> + <%= 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" %>
diff --git a/app/views/users/_watch_btn_for_picture.html.erb b/app/views/users/_watch_btn_for_picture.html.erb index e604be318..be8673468 100644 --- a/app/views/users/_watch_btn_for_picture.html.erb +++ b/app/views/users/_watch_btn_for_picture.html.erb @@ -2,8 +2,8 @@ <%= link_to("编辑资料", my_account_path, :class => "fl UsersEditBtn") %> <% else %> <%if(user.watched_by?(User.current))%> - <%= link_to "取消关注",watch_path(:object_type=> 'user',:object_id=>user.id,:target_id=>user.id),:class => "userFollow mr27 fl", :method => "delete",:remote => "true", :title => "取消关注"%> + <%= link_to "取消关注",Setting.host_name + "/watch?object_type=user&object_id="+user.id.to_s + "&target_id="+user.id.to_s,:class => "userFollow mr27 fl", :method => "delete",:remote => "true", :title => "取消关注"%> <% else %> - <%= link_to "添加关注",watch_path(:object_type=> 'user',:object_id=>user.id,:target_id=>user.id),:class => "userFollow mr27 fl", :method => "post",:remote => "true", :title => "添加关注"%> + <%= link_to "添加关注",Setting.host_name + "/watch?object_type=user&object_id="+user.id.to_s + "&target_id="+user.id.to_s,:class => "userFollow mr27 fl", :method => "post",:remote => "true", :title => "添加关注"%> <% end %> <% end %> \ No newline at end of file From b716e593b57ffe94e32e2496b353ba32c2ceb0b5 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 15 Mar 2016 13:49:44 +0800 Subject: [PATCH 036/102] =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=B8=8B=E7=9A=84?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 7 +++++++ app/views/layouts/base_org.html.erb | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 83fb8c4e1..16445ff81 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -3014,6 +3014,13 @@ def logout_url_without_domain Setting.host_name + "/logout" end +def signin_url_without_domain + Setting.host_name + "/login?login=true" +end + +def register_url_without_domain + Setting.host_name + "/login?login=false" +end #判断是否为默认的组织栏目 def is_default_field? field (field.name == 'activity' || field.name == 'course' || field.name == 'project') && field.field_type == 'default' diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 4a8e00c96..f2ece1f35 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -44,14 +44,14 @@ <% if User.current.logged? %> <% else %> - - + + <% end %>
From 22ce591c36b9cc3b1157482411543f1ce31f0784 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 15 Mar 2016 15:42:20 +0800 Subject: [PATCH 038/102] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=90=9C=E7=B4=A2=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 128 ++++++++++-------- .../users/_user_resource_type_filter.html.erb | 10 +- app/views/users/resource_search.js.erb | 14 +- app/views/users/user_resource.html.erb | 10 +- app/views/users/user_resource.js.erb | 2 +- 5 files changed, 87 insertions(+), 77 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9a005cf16..d9219d50e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2339,6 +2339,11 @@ class UsersController < ApplicationController attachments = Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取公共资源搜索 + def get_public_resources_search user_course_ids, user_project_ids, order, score, search + attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 获取我的资源 def get_my_resources author_id, user_course_ids, user_project_ids, order, score attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @@ -2348,7 +2353,7 @@ class UsersController < ApplicationController # 获取我的资源查询结果 def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search) - @attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ + @attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end @@ -2360,11 +2365,23 @@ class UsersController < ApplicationController and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}") end - # 获取公共资源课程 + # 获取我的课程资源中搜索结果 + def get_course_resources_search author_id, user_course_ids, order, score, search + attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+ + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) + and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + end + + # 获取公共资源中课程资源 def get_course_resources_public user_course_ids, order, score attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取公共资源中课程资源搜索结果 + def get_course_resources_public_search user_course_ids, order, score, search + attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 获取我的项目资源 def get_project_resources author_id, user_project_ids, order, score attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ @@ -2372,25 +2389,55 @@ class UsersController < ApplicationController and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取我的项目资源搜索 + def get_project_resources_search author_id, user_project_ids, order, score, search + attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+ + "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) + and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 获取公共资源的项目资源 def get_project_resources_public user_project_ids, order, score attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取公共资源的项目资源搜索 + def get_project_resources_public_search user_project_ids, order, score, search + attchments = Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 获取我上传的附件 def get_attch_resources author_id, order, score attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', - 'Document','Message','News','StudentWorkScore','HomewCommon')) ").order("#{order.nil? ? 'created_on' : order} #{score}") + 'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}") + end + + # 获取我上传的附件搜索结果 + def get_attch_resources_search author_id, order, score, search + attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue', + 'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取公共资源中我上传的附件 def get_attch_resources_public order, score - attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') + and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") + end + + # 获取公共资源中我上传的附件 + def get_attch_resources_public_search order, score, search + attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') + and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源 def get_principal_resources author_id, order, score - attchments = Attachment.where("author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") + attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}") + end + + # 获取我的用户类型资源搜索 + def get_principal_resources_search author_id, order, score, search + attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") end # 获取我的用户类型资源 @@ -2398,6 +2445,11 @@ class UsersController < ApplicationController attchments = Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}") end + # 获取我的用户类型资源 + def get_principal_resources_public_search order, score, search + attchments = Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}") + end + # 资源库 分为全部 课程资源 项目资源 附件 def user_resource @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" @@ -2424,14 +2476,6 @@ class UsersController < ApplicationController # 公共资源库:所有公开资源或者我上传的私有资源 @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) end - elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order], @score) - elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids, params[:order], @score) - elsif params[:type] == "4" #附件 - @attachments = get_attch_resources(params[:id], params[:order], @score) - elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources(params[:id], params[:order], @score) elsif params[:type] == "6" # 公共资源 if params[:status] == "2" @attachments = get_course_resources_public( user_course_ids, params[:order], @score) @@ -2585,69 +2629,39 @@ class UsersController < ApplicationController @order, @b_sort = params[:order] || "created_on", params[:sort] || "desc" @score = @b_sort == "desc" ? "asc" : "desc" @user = User.current - switch_search = params[:search].nil? ? " " : params[:search] - search = "%#{switch_search.strip.downcase}%" - user_course_ids = User.current.courses.map { |c| c.id} + @switch_search = params[:search].nil? ? " " : params[:search] + search = "%#{@switch_search.strip.downcase}%" + user_course_ids = User.current.courses.map {|c| c.id} user_project_ids = User.current.projects.map {|p| p.id} - # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部 if params[:status] == "2" - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search) elsif params[:status] == "3" - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_project_resources_search(params[:id], user_project_ids, @order, @score, search) elsif params[:status] == "4" - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_attch_resources_search(params[:id], @order, @score, search) elsif params[:status] == "5" - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_principal_resources_search(params[:id], @order, @score, search) else # 公共资源库:所有公开资源或者我上传的私有资源 - get_my_resources_search(@user.id, user_course_ids, user_project_ids, @order, @score, search) + @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search) end - elsif params[:type] == "2" #课程资源 - if User.current.id.to_i == params[:id].to_i - user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - else - user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 - @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ - "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ - " and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - end - elsif params[:type] == "3" # 项目资源 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - end - elsif params[:type] == "4" # 附件 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - end - elsif params[:type] == "5" # 用户资源 - if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") - end - elsif params[:type] == "6" # 全部资源 + elsif params[:type] == "6" # 公共资源 if params[:status] == "2" - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_course_resources_public_search(user_course_ids, @order, @score, search) elsif params[:status] == "3" - @attachments = Attachment.where("container_type = 'Project' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_project_resources_public_search(user_project_ids, @order, @score, search) elsif params[:status] == "4" - @attachments = Attachment.where("container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_attch_resources_public_search(@order, @score, search) elsif params[:status] == "5" - @attachments = Attachment.where("container_type = 'Principal' and (filename like :p)",:p=>search).order("#{params[:order].nil? ? 'created_on' : params[:order]} #{@score}") + @attachments = get_principal_resources_public_search(@order, @score, search) else # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("created_on desc") + @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search) end end @status = params[:status] @type = params[:type] - @type = params[:type] @limit = 25 @is_remote = true @atta_count = @attachments.count diff --git a/app/views/users/_user_resource_type_filter.html.erb b/app/views/users/_user_resource_type_filter.html.erb index 9a1fad552..6e5ed51c3 100644 --- a/app/views/users/_user_resource_type_filter.html.erb +++ b/app/views/users/_user_resource_type_filter.html.erb @@ -2,24 +2,24 @@
    • - 全部 + 全部
    • - 课程资源 + 课程资源 <%#= link_to '课程资源' ,user_resource_user_path(:id => @user.id, :type => 2), id="resource_type_course", :remote => true, :method => 'get', :class=> 'homepagePostTypeAssignment postTypeGrey' %>
    • - 项目资源 + 项目资源 <%#= link_to '项目资源' ,user_resource_user_path(:id => @user.id, :type => 3), id="resource_type_project", :remote => true, :method => 'get', :class => 'homepagePostTypeQuiz postTypeGrey' %>
    • - 用户资源 + 用户资源 <%#= link_to '用户资源' ,user_resource_user_path(:id=>@user.id,:type=>5), id="resource_type_user", :remote=>true,:method => 'get', :class=>'resourcesTypeUser resourcesGrey' %>
    • <% if @type != "6" %>
    • - 附件 + 附件 <%#= link_to '附件' ,user_resource_user_path(:id=>@user.id,:type=>4), id="resource_type_file", :remote=>true,:method => 'get',:class=>'resourcesTypeAtt resourcesGrey' %>
    • <% end %> diff --git a/app/views/users/resource_search.js.erb b/app/views/users/resource_search.js.erb index 38e80e75b..9583274c6 100644 --- a/app/views/users/resource_search.js.erb +++ b/app/views/users/resource_search.js.erb @@ -5,10 +5,10 @@ $("#res_all_count").html(<%= @atta_count%>); $("#res_count").html(0); $("#checkboxAll").attr('checked',false); //更新状态 -$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6', :status => @status) %>'); -$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1', :status => @status) %>'); -$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1) %>'); -$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2) %>'); -$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3) %>'); -$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5) %>'); -$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4) %>'); \ No newline at end of file +$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>'); +$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>'); +$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>'); +$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>'); +$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>'); +$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>'); +$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>'); \ No newline at end of file diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb index cfaa0228c..80167db56 100644 --- a/app/views/users/user_resource.html.erb +++ b/app/views/users/user_resource.html.erb @@ -1,12 +1,8 @@ -<%= javascript_include_tag 'bootstrap'%> +<%= javascript_include_tag 'bootstrap' %> <%= stylesheet_link_tag 'project' %> <%= stylesheet_link_tag 'leftside' %> -<%= javascript_include_tag 'attachments'%> - - - - - +<%= javascript_include_tag 'attachments' %> + -->

      @@ -66,7 +71,7 @@ <% end %>
      - 确定 + 确定 <%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%>
      @@ -96,23 +101,129 @@ } function popupRegex(){ - if(regexStudentWorkName()&®exStudentWorkDescription()) - { - if($("#group_member_ids").length > 0) { - if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { - $('#ajax-modal').html("

      作品信息完整性校验中,请稍等...

      "); - showModal('ajax-modal', '500px'); - $('#ajax-modal').siblings().remove(); - $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); - $('#ajax-modal').parent().addClass("anonymos"); - } - } else { + if($("#group_member_ids").length > 0) { + if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) { $('#ajax-modal').html("

      作品信息完整性校验中,请稍等...

      "); showModal('ajax-modal', '500px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().addClass("anonymos"); } + } else { + $('#ajax-modal').html("

      作品信息完整性校验中,请稍等...

      "); + showModal('ajax-modal', '500px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); + $('#ajax-modal').parent().addClass("anonymos"); + } + } + + function nh_check_field(params){ + var result=true; + if(!regexStudentWorkName()) { + result=false; + return result; + } + if(params.content!=undefined){ + if(params.content.isEmpty()){ + result=false; + } + if(params.content.html()!=params.textarea.html() || params.issubmit==true){ + params.textarea.html(params.content.html()); + params.content.sync(); + + if(params.content.isEmpty()){ + params.contentmsg.html('作品描述不能为空'); + }else{ + params.contentmsg.html(''); + } + } } + return result; + } + function init_homework_form(params){ + params.form.submit(function(){ + params.textarea.html(params.editor.html()); + params.editor.sync(); + var flag = false; + if(params.form.attr('data-remote') != undefined ){ + flag = true + } + var is_checked = nh_check_field({ + issubmit:true, + content:params.editor, + contentmsg:params.contentmsg, + textarea:params.textarea + }); + + if(is_checked){ + if(flag){ + popupRegex(); + return true; + }else{ + $(this)[0].submit(); + $("#ajax-indicator").hide(); + return false; + } + } + return false; + }); + } + function init_homework_editor(params){ + params.textarea.removeAttr('placeholder'); + var editor = params.kindutil.create(params.textarea, { + resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px", + items : ['code','emoticons','fontname', + 'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|', + 'formatblock', 'fontsize', '|','indent', 'outdent', + '|','imagedirectupload','table', 'media', 'preview',"more" + ], + afterChange:function(){//按键事件 + var edit = this.edit; + var body = edit.doc.body; + //paramsHeight = params.kindutil.removeUnit(this.height); + edit.iframe.height(150); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150)); + }, + afterCreate:function(){ + //init + var edit = this.edit; + var body = edit.doc.body; + edit.iframe[0].scroll = 'no'; + body.style.overflowY = 'hidden'; + //reset height + var edit = this.edit; + var body = edit.doc.body; + edit.html(params.textarea.innerHTML); + //paramsHeight = params.kindutil.removeUnit(this.height); + edit.iframe.height(150); + this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); + + } + }).loadPlugin('paste'); + return editor; } + KindEditor.ready(function(K){ + $("div[nhname='student_work_form']").each(function(){ + var params = {}; + params.kindutil = K; + params.div_form = $(this); + params.form = $("form",params.div_form); + if(params.form==undefined || params.form.length==0){ + return; + } + params.textarea = $("textarea[nhname='student_work_textarea']",params.div_form); + params.contentmsg = $("#student_work_description_textarea"); + params.submit_btn = $("#new_message_submit_btn"); + if(params.textarea.data('init') == undefined) { + params.editor = init_homework_editor(params); + init_homework_form(params); + params.submit_btn.click(function () { + params.form.submit(); + $("#ajax-indicator").hide(); + }); + params.textarea.data('init', 1); + } + }); + }); \ No newline at end of file diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 9391aab37..15958d870 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -1,4 +1,9 @@ +<% content_for :header_tags do %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> + <%= javascript_include_tag 'homework','baiduTemplate' %> +<% end %> +
      @@ -110,7 +220,7 @@
      -
      +
      <%= form_for(@student_work, :html => { :multipart => true }, :url => {:controller => 'student_work', @@ -132,11 +242,12 @@

      - <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%> - -->

      @@ -167,9 +278,9 @@
      -->
      - 提交 + 提交 - <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id), :class => "fr mr10 mt3"%> + <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id),:id => 'new_message_cancel_btn', :class => "fr mr10 mt3"%>
      <% end%> From e97690e2f2f43ae10e613fe6ea16894c99835826 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 15 Mar 2016 16:47:57 +0800 Subject: [PATCH 041/102] =?UTF-8?q?=E2=80=9C=E5=AF=BC=E5=85=A5=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E2=80=9D=E6=94=B9=E4=B8=BA=E2=80=9C=E4=BB=8E=E9=A2=98?= =?UTF-8?q?=E5=BA=93=E9=80=89=E7=94=A8=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_homework_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 8b72ec781..100ef0d37 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -150,7 +150,7 @@
      - <%= link_to("导入作业", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%> + <%= link_to("从题库选用", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%> <% unless edit_mode %> <% end %> From 879f9a0ad5d58698225cf47c8a2c55ebdde7688e Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 15 Mar 2016 17:21:12 +0800 Subject: [PATCH 042/102] =?UTF-8?q?=E5=AF=B9=E5=B7=B2=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E7=9A=84=E4=BD=9C=E4=B8=9A=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=B0=83=E6=95=B4=E6=97=B6,=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E4=BD=9C=E4=B8=9A=E6=88=AA=E6=AD=A2=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E5=A4=A7=E4=BA=8E=E7=AD=89=E4=BA=8E=E5=8C=BF=E8=AF=84=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E6=97=B6=E9=97=B4=E4=B8=94=E5=8C=BF=E8=AF=84=E8=BF=98?= =?UTF-8?q?=E6=9C=AA=E5=BC=80=E5=90=AF=E5=88=99=E5=8C=BF=E8=AF=84=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E6=97=B6=E9=97=B4=E5=92=8C=E7=BB=93=E6=9D=9F=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=83=BD=E7=9B=B8=E5=BA=94=E5=BE=80=E5=90=8E=E6=8E=A8?= =?UTF-8?q?=E8=BF=9F7=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 8 +++++--- app/views/users/_user_homework_form.html.erb | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index ba6c136bb..3532a9e4c 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -73,9 +73,11 @@ class HomeworkCommonController < ApplicationController if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 homework_detail_manual.comment_status = 1 end - homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start] - homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] - + eval_start = homework_detail_manual.evaluation_start + if eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1 + homework_detail_manual.evaluation_start = @homework.end_time + 7 + homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7 + end @homework.save_attachments(params[:attachments]) render_attachment_warning_if_needed(@homework) diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index 100ef0d37..f1f29b0da 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -159,7 +159,7 @@ <% end %>
      - <% if homework.homework_detail_manual.comment_status.to_i < 3 %> + <% if homework.homework_detail_manual.comment_status.to_i < 2 %> <%= calendar_for('homework_end_time')%> <% end %>
      From 2ce2134f0bcc0ba5324a913881f8388ebd0bad77 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 15 Mar 2016 17:25:46 +0800 Subject: [PATCH 043/102] =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8tab=E7=9A=84?= =?UTF-8?q?title=EF=BC=8C=E6=98=BE=E7=A4=BA=E7=94=A8=E6=88=B7=E5=A7=93?= =?UTF-8?q?=E5=90=8D=EF=BC=8C=E4=B8=8D=E6=98=AF=E7=99=BB=E5=BD=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 477e18f41..29886b8ac 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1044,9 +1044,9 @@ module ApplicationHelper elsif @organization title << @organization.name elsif @user - title << @user.login + title << @user.try(:realname) else - title << User.current.login + title << User.current.try(:realname) end if first_page.nil? || first_page.web_title.nil? title << Setting.app_title unless Setting.app_title == title.last From 9aab10c05a6dbe3d2f8eef8495dc3fd7ed3dea88 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 15 Mar 2016 17:29:37 +0800 Subject: [PATCH 044/102] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 57 +++++++++++++++++------------ 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d1979bc84..68accdfd0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -824,20 +824,33 @@ class UsersController < ApplicationController user_course_ids = User.current.courses.map { |c| c.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} - if(params[:type].blank? || params[:type] == "1") #全部 + if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) - elsif params[:type] == "2" # 课程资源 - @attachments = get_course_resources(params[:id], user_course_ids, params[:order]) - elsif params[:type] == "3" # 项目资源 - @attachments = get_project_resources(params[:id], user_project_ids, params[:order]) - elsif params[:type] == "4" #附件 - @attachments = get_attch_resources params[:id], params[:order] - elsif params[:type] == "5" #用户资源 - @attachments = get_principal_resources params[:id], params[:order] + if params[:status] == "2" + @attachments = get_course_resources(params[:id], user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources(params[:id], user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources(params[:id], @order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources(params[:id], @order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) + end elsif params[:type] == "6" # 公共资源 - # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + if params[:status] == "2" + @attachments = get_course_resources_public( user_course_ids, @order, @score) + elsif params[:status] == "3" + @attachments = get_project_resources_public(user_project_ids, @order, @score) + elsif params[:status] == "4" + @attachments = get_attch_resources_public(@order, @score) + elsif params[:status] == "5" + @attachments = get_principal_resources_public(@order, @score) + else + # 公共资源库:所有公开资源或者我上传的私有资源 + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) + end end @type = params[:type] @limit = 7 @@ -2503,16 +2516,19 @@ class UsersController < ApplicationController render_403 return end + @user = User.find(params[:id]) + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" user_course_ids = User.current.courses.map { |c| c.id} - user_project_ids = User.current.projects.map {|p| p.id} - # user_org_ids = User.current.organizations.map {|o| o.id} + user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 - @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, params[:order]) + @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score) elsif params[:type] == "6" # 公共资源 # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score) end + @status = params[:status] @type = params[:type] @limit = 10 @is_remote = true @@ -2534,20 +2550,15 @@ class UsersController < ApplicationController render_403 return end - user_course_ids = User.current.courses.map { |c| c.id} - user_project_ids = User.current.projects.map {|p| p.id} - # user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].blank? || params[:type] == "1") # 我的资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 user_course_ids = User.current.courses.map { |c| c.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id} - @attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + - "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{params[:order].nil? ? 'created_on' : params[:order]} desc") + @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search) elsif params[:type] == "6" # 公共资源 # 公共资源库:所有公开资源或者我上传的私有资源 - @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order]) + @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search) end @type = params[:type] @limit = 10 From 9bac560906abd2bc2016caf11fc3d33eae6b6dfe Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 16 Mar 2016 10:00:21 +0800 Subject: [PATCH 045/102] =?UTF-8?q?=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=9C=89=E7=BC=96=E8=BE=91=E5=92=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E7=9A=84=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/blog_comments_controller.rb | 8 ++++++-- app/views/blog_comments/edit.html.erb | 11 +++++------ app/views/blog_comments/show.html.erb | 6 +++--- app/views/blogs/_article.html.erb | 6 +++--- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb index f5e3314bb..7220eec27 100644 --- a/app/controllers/blog_comments_controller.rb +++ b/app/controllers/blog_comments_controller.rb @@ -91,8 +91,12 @@ class BlogCommentsController < ApplicationController def edit @article = BlogComment.find(params[:id]) - respond_to do |format| - format.html {render :layout=>'new_base_user'} + if User.current.admin? || User.current.id == @article.author_id + respond_to do |format| + format.html { render :layout => 'new_base_user' } + end + else + render_403 end end diff --git a/app/views/blog_comments/edit.html.erb b/app/views/blog_comments/edit.html.erb index 704342fc0..1e29d0a14 100644 --- a/app/views/blog_comments/edit.html.erb +++ b/app/views/blog_comments/edit.html.erb @@ -1,6 +1,5 @@ -<% if User.current.logged? && User.current.id == @user.id %> - <%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id, :is_homepage => params[:is_homepage],:in_act => params[:in_act]},:method=>'PUT', - :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> - <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %> - <% end %> -<% end %> \ No newline at end of file + +<%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id, :is_homepage => params[:is_homepage],:in_act => params[:in_act]},:method=>'PUT', + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %> +<% end %> diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index c80274db4..de7f1647d 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -38,7 +38,7 @@ <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
      - <% if @article.author.id == User.current.id%> + <% if @article.author.id == User.current.id || User.current.admin? %>
      - <% if activity.author.id == User.current.id%> + <% if activity.author.id == User.current.id || User.current.admin? %> <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %> + + + +
      <%# 局部刷新:修改xissue属性 %> <% if User.current.member_of?(activity.project) %> <% unless params[:action] == "index" %> @@ -59,10 +63,7 @@
      <% end %> <% end %> -
      - - -
      +
      <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
      From 4d82f0c959e2f3c0f7793bc6389894a359a8dd9b Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Wed, 16 Mar 2016 16:03:53 +0800 Subject: [PATCH 051/102] =?UTF-8?q?=E5=9C=A8=E4=B8=AA=E4=BA=BA=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E3=80=81=E9=A1=B9=E7=9B=AE=E5=8A=A8=E6=80=81=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E9=A1=B9=E7=9B=AE=E9=97=AE=E9=A2=98=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E3=80=8Aissue=E5=8A=A8=E6=80=81=E8=A6=81?= =?UTF-8?q?=E5=8F=B3=E4=B8=8A=E8=A7=92=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E3=80=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 3 +++ app/views/issues/show.html.erb | 3 +++ app/views/users/_project_issue.html.erb | 17 +++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index eb78c4c5b..f0148fc71 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -118,6 +118,9 @@ class IssuesController < ApplicationController end def show + # 打开编辑内容 + @is_edit = true unless params[:edit].nil? + # 当前用户查看指派给他的缺陷消息,则设置消息为已读 query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first query.update_attribute(:viewed, true) unless query.nil? diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index b9d463855..4b82f8665 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -9,6 +9,9 @@ $(function(){ $("#RSide").removeAttr("id"); $("#Container").css("width","1000px"); + if(<%= @is_edit %>) { + issueEditShow(); + } });
      diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 7f3d5b177..090098722 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -13,6 +13,23 @@ <% end %> TO <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%>
      +
      +
        +
      • +
          +
        • + <%= link_to l(:button_edit), issue_path(activity.id, :edit => 'true'), :class => 'postOptionLink', :accesskey => accesskey(:edit) if activity.editable? && User.current.allowed_to?(:edit_issues, activity.project) %> +
        • +
        • + <%= link_to l(:button_delete), issue_path(activity.id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> +
        • +
        • + <%= link_to l(:button_copy), project_copy_issue_path(activity.project, activity), :class => 'postOptionLink' if User.current.allowed_to?(:add_issues, activity.project) %> +
        • +
        +
      • +
      +
      <% case activity.tracker_id %> <% when 1%> From 0a881f14e81e7ff356465f6128abafb494f724c7 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 16 Mar 2016 17:06:11 +0800 Subject: [PATCH 052/102] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 10 ++++-- .../users/_import_resource_info.html.erb | 34 ++++++------------- .../users/_user_import_resource_list.html.erb | 19 +++++++++++ .../_user_import_resource_search.html.erb | 29 ++++++++++++++++ .../users/import_resources_search.js.erb | 28 ++------------- 5 files changed, 69 insertions(+), 51 deletions(-) create mode 100644 app/views/users/_user_import_resource_list.html.erb create mode 100644 app/views/users/_user_import_resource_search.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 7ba756806..cf591d6a8 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2544,7 +2544,11 @@ class UsersController < ApplicationController end def import_resources_search - search = "%#{params[:search].strip.downcase}%" + @order, @b_sort = params[:order] || "created_on", params[:sort] || "asc" + @score = @b_sort == "desc" ? "asc" : "desc" + @user = User.current + @switch_search = params[:name].nil? ? " " : params[:name] + search = "%#{@switch_search.strip.downcase}%" # 别人的资源库是没有权限去看的 if User.current.id.to_i != params[:id].to_i render_403 @@ -2567,10 +2571,10 @@ class UsersController < ApplicationController @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @offset ||= @atta_pages.offset #@curse_attachments_all = @all_attachments[@offset, @limit] - @attachments = paginateHelper @attachments,10 + @attachments = paginateHelper @attachments, 10 respond_to do |format| format.js - format.html {render :layout => 'new_base'} + # format.html {render :layout => 'new_base'} end end diff --git a/app/views/users/_import_resource_info.html.erb b/app/views/users/_import_resource_info.html.erb index bc1152ce4..4ea56ad9f 100644 --- a/app/views/users/_import_resource_info.html.erb +++ b/app/views/users/_import_resource_info.html.erb @@ -26,11 +26,14 @@ 公共资源 我的资源 <% end %> - <%#= form_tag( url_for(:controller => 'users', :action => 'import_resources_search', :id => User.current.id, :type => 1), - :remote => true , :method => 'get', :id => 'resource_search_form') do %> + + - <%#= hidden_field_tag(:type,type.nil? ? 1 : type) %> - <%# end %> + + +
      @@ -42,25 +45,10 @@
    • 上传者
    • 上传时间
    - <%= form_tag( url_for({:controller => 'users', :action => 'import_into_container', - :mul_id => params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id], - :mul_type => params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"}), - :method => 'post', :id => 'resource_import_container_form') do %> - <% @attachments.each do |attach| %> -
      - -
    • <%= 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) %>
    • -
    - <% end %> - <% end %> +
    + <%= render :partial => 'users/user_import_resource_list',:locals => {:project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} %> +
    +
  • diff --git a/app/views/users/_user_import_resource_list.html.erb b/app/views/users/_user_import_resource_list.html.erb new file mode 100644 index 000000000..57dac6ad0 --- /dev/null +++ b/app/views/users/_user_import_resource_list.html.erb @@ -0,0 +1,19 @@ +<%= form_tag( url_for({:controller => 'users', :action => 'import_into_container', + :mul_id => project_id.nil? ? (course_id.nil? ? subfield_file_id : course_id) : project_id, + :mul_type => project_id.nil? ? (course_id.nil? ? "SubfieldFile" : "Course") : "Project"}), + :method => 'post', :id => 'resource_import_container_form') do %> + <% @attachments.each do |attach| %> +
      + +
    • <%= 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) %>
    • +
    + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/users/_user_import_resource_search.html.erb b/app/views/users/_user_import_resource_search.html.erb new file mode 100644 index 000000000..b048675dd --- /dev/null +++ b/app/views/users/_user_import_resource_search.html.erb @@ -0,0 +1,29 @@ + + \ 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 053/102] =?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 054/102] =?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 055/102] =?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 056/102] =?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 057/102] =?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 058/102] =?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 059/102] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93bytes?= =?UTF-8?q?=E6=94=B9=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 a4e2fd741e671fb4e5d0320f5b174e44a0f8e185 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Thu, 17 Mar 2016 14:13:29 +0800 Subject: [PATCH 060/102] =?UTF-8?q?=E5=88=A0=E9=99=A4issue=EF=BC=8C?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E9=A1=B5=E9=9D=A2=E4=B8=8D=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 1 + app/controllers/issues_controller.rb | 9 ++++++++- app/helpers/routes_helper.rb | 14 +++++++++++--- app/views/projects/_project_activities.html.erb | 2 +- app/views/users/_project_issue.html.erb | 8 +++++++- app/views/users/_user_activities.html.erb | 2 +- app/views/users/show.html.erb | 3 +-- 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index c739e1085..645c7b849 100644 --- a/Gemfile +++ b/Gemfile @@ -36,6 +36,7 @@ gem 'chinese_pinyin' # gem 'progress_bar' gem 'ansi' +gem 'debugger' gem 'kaminari' gem 'elasticsearch-model' gem 'elasticsearch-rails' diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index f0148fc71..44f0d15f4 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -390,6 +390,9 @@ class IssuesController < ApplicationController end def destroy + # 增加删除页面类型,如果是个人主页,则返回该主页,项目动态则返回项目动态页眉 + page_classify = params[:page_classify] unless params[:page_classify].nil? + page_id = params[:page_id] unless params[:page_id].nil? @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f if @hours > 0 case params[:todo] @@ -418,7 +421,11 @@ class IssuesController < ApplicationController end end respond_to do |format| - format.html { redirect_back_or_default _project_issues_path(@project) } + if page_classify + format.html { redirect_back_or_default _project_issues_path(@project, page_classify, page_id) } + else + format.html { redirect_back_or_default _project_issues_path(@project) } + end format.api { render_api_ok } end end diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb index 15c809964..8d08f22da 100644 --- a/app/helpers/routes_helper.rb +++ b/app/helpers/routes_helper.rb @@ -22,10 +22,18 @@ module RoutesHelper # Returns the path to project issues or to the cross-project # issue list if project is nil def _project_issues_path(project, *args) - if project - project_issues_path(project, *args) + if args[0].to_s.include? '_page' + if args[0].to_s == "user_page" + user_activities_path(args[1].to_i) + else + project_path(project) + end else - issues_path(*args) + if project + project_issues_path(project, *args) + else + issues_path(*args) + end end end diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index c036633a5..dd9935634 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -66,7 +66,7 @@ <%= render :partial => 'projects/project_create', :locals => {:activity => activity, :user_activity_id => activity.id} %> <% when "Issue" %> - <%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id} %> + <%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %> <% when "Message" %> diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb index 090098722..5d472497d 100644 --- a/app/views/users/_project_issue.html.erb +++ b/app/views/users/_project_issue.html.erb @@ -21,7 +21,13 @@ <%= link_to l(:button_edit), issue_path(activity.id, :edit => 'true'), :class => 'postOptionLink', :accesskey => accesskey(:edit) if activity.editable? && User.current.allowed_to?(:edit_issues, activity.project) %>
  • - <%= link_to l(:button_delete), issue_path(activity.id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% if !defined?(project_id) && !defined?(user_id) %> + <%= link_to l(:button_delete), issue_path(activity.id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% elsif defined?(project_id) %> + <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "project_page", :page_id => project_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% elsif defined?(user_id) %> + <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "user_page", :page_id => user_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %> + <% end %>
  • <%= link_to l(:button_copy), project_copy_issue_path(activity.project, activity), :class => 'postOptionLink' if User.current.allowed_to?(:add_issues, activity.project) %> diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 0e55c246c..01711ace3 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -89,7 +89,7 @@ <% if act %> <% case user_activity.act_type.to_s %> <% when 'Issue' %> - <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id} %> + <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id, :user_id => user_id} %> <% when 'Message' %> <%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %> <% when 'ProjectCreateInfo'%> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index a56ca7b48..fa4eaacbe 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -45,5 +45,4 @@ <% homepage = BlogComment.find(@user.blog.homepage_id) %> <%= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %> <% end %> - -<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type} %> +<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type, :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id)} %> From 9265186307db170492b41d7f181a4d394673fd47 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Thu, 17 Mar 2016 14:36:05 +0800 Subject: [PATCH 061/102] =?UTF-8?q?=E4=BF=AE=E6=94=B9user=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E4=B8=ADissue=E8=A1=8C=E9=AB=98=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E4=B9=8B=E4=B8=8Eproject=E4=B8=AD=E7=9A=84=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/new_user.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 4669d043e..8aa15d0f7 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -845,7 +845,7 @@ a.sortArrowActiveU {background:url(images/post_image_list.png) -17px -20px no-re .postDetailTitle {width:580px; max-width:580px; margin-bottom:5px;} .postDetailDes {width:580px; max-width:580px; margin-bottom:6px; color:#888888;display:block;overflow:hidden;word-break:keep-all;text-overflow:ellipsis;} .postDetailDes p,div,em{word-break: break-all;word-wrap: break-word;} -.homepagePostIntro p,.homepagePostIntro div,.homepagePostIntro em, .homepagePostIntro span{text-align: justify; text-justify:inter-ideograph; word-break: normal !important; word-wrap: break-word !important; line-height: 23px !important;} +.homepagePostIntro p,.homepagePostIntro div,.homepagePostIntro em, .homepagePostIntro span{text-align: justify; text-justify:inter-ideograph; word-break: normal !important; word-wrap: break-word !important; line-height: 18px !important;} .postDetailCreater {color:#888888; font-size:12px; float:left; margin-right:25px;} .postDetailDate {color:#888888; font-size:12px; float:left;} .postDetailReply { margin-top:28px; color:#888888; float:right;display: inline} From 84470af2ff68b41e9e9780590050900435ee9c42 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Mar 2016 14:47:14 +0800 Subject: [PATCH 062/102] =?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 a8780be9b4a5f18437ceca9359c3885cb756404c Mon Sep 17 00:00:00 2001 From: cxt Date: Thu, 17 Mar 2016 15:03:34 +0800 Subject: [PATCH 063/102] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E3=80=81=E6=8F=90=E4=BA=A4=E4=BD=9C=E4=B8=9A=E3=80=81=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E8=AF=BE=E7=A8=8B=E5=B8=96=E5=AD=90=E3=80=81=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=96=87=E7=AB=A0=E5=AE=9E=E7=8E=B0=E6=AF=8F=E9=9A=94?= =?UTF-8?q?10=E7=A7=92=E8=87=AA=E5=8A=A8=E4=BF=9D=E5=AD=98=E5=B8=96?= =?UTF-8?q?=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_new.html.erb | 129 +++++++++++++++++- app/views/boards/_course_show.html.erb | 2 + app/views/messages/edit.html.erb | 3 +- app/views/org_document_comments/_new.html.erb | 2 + app/views/org_document_comments/edit.html.erb | 2 + app/views/org_document_comments/new.html.erb | 2 + app/views/student_work/edit.html.erb | 5 +- app/views/student_work/new.html.erb | 9 +- app/views/users/_user_homework_form.html.erb | 5 +- public/javascripts/application.js | 47 +++++++ public/javascripts/des_kindEditor.js | 4 +- 11 files changed, 199 insertions(+), 11 deletions(-) diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 31cdf41eb..3deb04f6c 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,7 +1,123 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: true, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> <% end %> - + <%= error_messages_for 'message' %>
    @@ -25,7 +141,7 @@ <%= text_area :quote,:quote,:style => 'display:none' %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :content, :editor_id => 'message_content_editor', + <%#= f.kindeditor :content, :editor_id => 'message_content_editor', :owner_id => topic.nil? ? 0: topic.id, :owner_type => OwnerTypeHelper::MESSAGE, :width => '100%', @@ -37,8 +153,11 @@ :maxlength => 5000 }, at_id: topic.id, at_type: topic.class.to_s %> +

    +

    +

    @@ -49,11 +168,11 @@
    <%if !edit_mode %> - 确定 + 确定 取消 <% else %> - 确定 + 确定 <%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%> <% end %> diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 16b4fcd3d..d33b75f82 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -25,11 +25,13 @@ 课程问答区
    +
    <% if User.current.logged? %> <%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> <%= render :partial => 'course_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :course => @board.course} %> <% end %> <% end %> +
    <%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %>
    diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index 89fe71c65..324b1edf1 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -12,6 +12,7 @@ <% end %> <% elsif @message.course %> +
    <%= form_for @message, { :as => :message, :url => {:action => 'edit',:is_course=>@is_course,:is_board=>@is_board}, @@ -22,7 +23,7 @@ <%= render :partial => 'boards/course_message_edit', :locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %> <% end %> - +
    <% elsif @message.board.org_subfield %> <%= form_for @message, { :as => :message, diff --git a/app/views/org_document_comments/_new.html.erb b/app/views/org_document_comments/_new.html.erb index 9e77d3fa8..f462df2c9 100644 --- a/app/views/org_document_comments/_new.html.erb +++ b/app/views/org_document_comments/_new.html.erb @@ -50,6 +50,8 @@
  • +

    +

    diff --git a/app/views/org_document_comments/edit.html.erb b/app/views/org_document_comments/edit.html.erb index ed7413850..3ad388bd2 100644 --- a/app/views/org_document_comments/edit.html.erb +++ b/app/views/org_document_comments/edit.html.erb @@ -39,6 +39,8 @@

    +

    +

    diff --git a/app/views/org_document_comments/new.html.erb b/app/views/org_document_comments/new.html.erb index 2a261bd5f..fea89459b 100644 --- a/app/views/org_document_comments/new.html.erb +++ b/app/views/org_document_comments/new.html.erb @@ -46,6 +46,8 @@

    +

    +

    diff --git a/app/views/student_work/edit.html.erb b/app/views/student_work/edit.html.erb index 14da74a34..8e1a2a546 100644 --- a/app/views/student_work/edit.html.erb +++ b/app/views/student_work/edit.html.erb @@ -58,6 +58,8 @@ -->

    +

    +

    @@ -198,7 +200,7 @@ //paramsHeight = params.kindutil.removeUnit(this.height); edit.iframe.height(150); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); - + elocalStorage(editor2,'student_work_<%=@work.id %>'); } }).loadPlugin('paste'); return editor; @@ -217,6 +219,7 @@ params.submit_btn = $("#new_message_submit_btn"); if(params.textarea.data('init') == undefined) { params.editor = init_homework_editor(params); + editor2 = params.editor; init_homework_form(params); params.submit_btn.click(function () { params.form.submit(); diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb index 15958d870..c43482299 100644 --- a/app/views/student_work/new.html.erb +++ b/app/views/student_work/new.html.erb @@ -79,6 +79,10 @@ } } + var KE = { + MDU: "1234455",//当前文章标识符 + }; + function nh_check_field(params){ var result=true; if(!regexStudentWorkName()) { @@ -159,7 +163,7 @@ //paramsHeight = params.kindutil.removeUnit(this.height); edit.iframe.height(150); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); - + elocalStorage(editor2,'student_work_<%=@homework.id %>'); } }).loadPlugin('paste'); return editor; @@ -178,6 +182,7 @@ params.submit_btn = $("#new_message_submit_btn"); if(params.textarea.data('init') == undefined) { params.editor = init_homework_editor(params); + editor2 = params.editor; init_homework_form(params); params.submit_btn.click(function () { params.form.submit(); @@ -250,6 +255,8 @@ -->

    +

    +

    diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb index f1f29b0da..f23d01d3c 100644 --- a/app/views/users/_user_homework_form.html.erb +++ b/app/views/users/_user_homework_form.html.erb @@ -16,7 +16,6 @@ $("#GroupPopupBox a.group_save_btn").click(); <% end %> }); - var homework_description_editor; function checked_val() { if ($("#anonymous_comment").is(":checked")) { $("#anonymous_comment").val(1); @@ -106,7 +105,7 @@ //paramsHeight = params.kindutil.removeUnit(this.height); edit.iframe.height(150); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150)); - + elocalStorage(homework_description_editor,'homework_<%=User.current.id %>'); } }).loadPlugin('paste'); return editor; @@ -199,6 +198,8 @@ <%= select_tag :course_id, options_for_select(get_as_teacher_courses(User.current), homework.course_id), {:class => "InputBox w709",:value => "请选择发布作业的课程"} %>

    +

    +

    diff --git a/public/javascripts/application.js b/public/javascripts/application.js index fe829f7a8..e481dae32 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -1152,3 +1152,50 @@ function disable_down(source, des, hint){ } } + +//自动保存草稿 +var editor2; +function elocalStorage(editor,mdu){ + if (window.sessionStorage){ + editor2 = editor; + var oc = window.sessionStorage.getItem('content'+mdu); + if(oc !== null ){ + var h = '您上次有已保存的数据,是否恢复 ? / 不恢复'; + $('#e_tips').html(h); + } + setInterval(function() { + d = new Date(); + var h = d.getHours(); + var m = d.getMinutes(); + var s = d.getSeconds(); + h = h < 10 ? '0' + h : h; + m = m < 10 ? '0' + m : m; + s = s < 10 ? '0' + s : s; + if(!editor.isEmpty()){ + add_data("content",mdu,editor.html()); + $('#e_tip').html(" 数据已于 " + h + ':' + m + ':' + s +" 保存 "); + $('#e_tips').html(""); + } + },10000); + + }else{ + $('.ke-edit').after('您的浏览器不支持localStorage.无法开启自动保存草稿服务,请升级浏览器!'); + } +} +function add_data(k,mdu,d){ + window.sessionStorage.setItem(k+mdu,d); +} +function rec_data(k,mdu){ + if(window.sessionStorage.getItem(k+mdu) !== null){ + editor2.html(window.sessionStorage.getItem(k+mdu)); + clear_data(k,mdu); + } +} +function clear_data(k,mdu){ + window.sessionStorage.removeItem(k+mdu); + if(k == 'content'){ + $("#e_tips").html(""); + }else{ + $("#e_tip").html(""); + } +} diff --git a/public/javascripts/des_kindEditor.js b/public/javascripts/des_kindEditor.js index f8aff0be7..3a05c909d 100644 --- a/public/javascripts/des_kindEditor.js +++ b/public/javascripts/des_kindEditor.js @@ -1,3 +1,4 @@ +var editor2; function init_des_editor(params){ // var minHeight; //最小高度 var paramsHeight = params.height; //设定的高度 @@ -32,7 +33,7 @@ function init_des_editor(params){ paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight; edit.iframe.height(paramsHeight); this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight), paramsHeight)); - + elocalStorage(editor2,'org_document'); } }).loadPlugin('paste'); return editor; @@ -123,6 +124,7 @@ function init_des_data(){ params.width = width; if (params.textarea.data('init') == undefined) { params.editor = init_des_editor(params); + editor2 = params.editor; init_form(params); params.cancel_btn.click(function () { nh_reset_form(params); From 8e41b19563c392533e62eb39a8bc128b3ba7cdbb Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Thu, 17 Mar 2016 15:09:08 +0800 Subject: [PATCH 064/102] =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8F=96=E6=B6=88tip?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_at_message.html.erb | 12 +- app/views/users/_user_message_course.html.erb | 147 ++++++++++-------- app/views/users/_user_message_forge.html.erb | 75 +++++---- app/views/users/_user_message_forum.html.erb | 14 +- app/views/users/_user_message_system.html.erb | 7 +- .../_user_message_userfeedaback.html.erb | 6 +- 6 files changed, 143 insertions(+), 118 deletions(-) diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb index d8649cabe..089171c3d 100644 --- a/app/views/users/_user_at_message.html.erb +++ b/app/views/users/_user_at_message.html.erb @@ -8,15 +8,15 @@ <% if ma.at_message_type == "Message" && !ma.at_message.course.nil? %> <%= link_to ma.subject.html_safe, course_boards_path(ma.at_message.course, :parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id), - :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> + :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}" %> + + <% elsif ma.at_message_type == "Message" && !ma.at_message.project.nil? %> <%= link_to ma.subject.html_safe, project_boards_path(ma.at_message.project, :parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id), - :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %> + :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}" %> + + <% else %> <%= link_to ma.subject.html_safe, ma.url, :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %> <% end %> diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 62568d505..458ba4551 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -5,9 +5,10 @@
  • <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">发布了通知:
  • <%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id }, - :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", - :onmouseover =>"message_titile_show($(this),event)", - :onmouseout => "message_titile_hide($(this))" %>
  • + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %> + + +