From e2eaae63f4df72fdb858eb3ef4bc4617f9d6e3b8 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 31 Mar 2015 09:34:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=A8=A1=E5=9D=97=EF=BC=8C?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=8C=89=E6=97=B6=E9=97=B4=E9=99=8D=E5=BA=8F?= =?UTF-8?q?=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 16 ++++++++-------- app/views/files/_project_file_list.html.erb | 2 +- app/views/files/_show_all_attachment.html.erb | 4 ++-- app/views/files/index.html.erb | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 0d459e3ba..21d2254c1 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -134,6 +134,8 @@ class FilesController < ApplicationController attribute = "created_on" when "quotes" attribute = "quotes" + else + attribute = "created_on" end @sort = order_by[0] @order = order_by[1] @@ -148,15 +150,9 @@ class FilesController < ApplicationController sort += "," end end - # if order_by.count == 1 - # sort += "#{Attachment.table_name}.#{attribute} asc " if attribute - # elsif order_by.count == 2 - # sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " if attribute && order_by[1] - # end - # if sort_type != params[:sort].split(",").last - # sort += "," - # end end + else + sort = "#{Attachment.table_name}.created_on desc" end @containers = [ Project.includes(:attachments).find(@project.id)] @@ -198,6 +194,8 @@ class FilesController < ApplicationController attribute = "created_on" when "quotes" attribute = "quotes" + else + attribute = "created_on" end @sort = order_by[0] @order = order_by[1] @@ -213,6 +211,8 @@ class FilesController < ApplicationController end end end + else + sort = "#{Attachment.table_name}.created_on desc" end @containers = [ Course.includes(:attachments).reorder(sort).find(@course.id)] diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb index 60675194b..136be38e1 100644 --- a/app/views/files/_project_file_list.html.erb +++ b/app/views/files/_project_file_list.html.erb @@ -20,7 +20,7 @@
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> <% if User.current.logged? %> - <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> + <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %> <%= link_to(l(:label_slected_to_other_project),quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %> <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %> diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index 6935c186f..729f0a483 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -24,8 +24,8 @@ - <% if @curse_attachments != nil %> - <% @curse_attachments.each do |file| %> + <% if @obj_attachments != nil %> + <% @obj_attachments.each do |file| %> <%if file.is_public == 0 && !User.current.member_of?(@project)%> <%next%> <%end%> diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb index aefa1a5a9..4b6df47cb 100644 --- a/app/views/files/index.html.erb +++ b/app/views/files/index.html.erb @@ -1,6 +1,6 @@
<% if @isproject %> - <%= render :partial => 'project_file_new', locals: {project: @project} %> + <%= render :partial => 'project_file', locals: {project: @project} %> <% else %> <%= render :partial => 'course_file', locals: {course: @course} %> <% end %>