diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 031f78277..ef6e20644 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -45,11 +45,45 @@ class FilesController < ApplicationController 'filename' => "#{Attachment.table_name}.filename", 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" + sort = "" if params[:project_id] @isproject = true - @containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] - @containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort + + if params[:sort] + params[:sort].split(",").each do |sort_type| + order_by = sort_type.split(":") + + case order_by[0] + when "filename" + attribute = "filename" + when "size" + attribute = "filesize" + when "attach_type" + attribute = "attachtype" + when "content_type" + attribute = "created_on" + when "field_file_dense" + attribute = "is_public" + when "downloads" + attribute = "downloads" + when "created_on" + attribute = "created_on" + end + + if order_by.count == 1 + sort += "#{Attachment.table_name}.#{attribute} desc " + elsif order_by.count == 2 + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + end + if sort_type != params[:sort].split(",").last + sort += "," + end + end + end + + @containers = [ Project.includes(:attachments).reorder(sort).find(@project.id)] + @containers += @project.versions.includes(:attachments).reorder(sort).all.sort show_attachments @containers @@ -57,7 +91,6 @@ class FilesController < ApplicationController elsif params[:course_id] @isproject = false - sort = "" if params[:sort] params[:sort].split(",").each do |sort_type| order_by = sort_type.split(":") diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index f92559903..35d8da952 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -3,9 +3,11 @@ <%= @project ? l(:label_news_new) : l(:bale_news_notice) %>
<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>
+<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;", :onblur => "regexTitle();" %>
+(60个字符以内)
-<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>
+<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;", :onblur => "regexDescription();" %>
+
<%= render :partial => 'attachments/form', :locals => {:container => @news} %>
- <% unless user.memberships.empty? %> - <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> - <% memberships = user.memberships.all(:conditions => cond) %> - <%= l(:label_x_contribute_to, :count => memberships.count) %> - <% for member in memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% else %> - <%= l(:label_x_contribute_to, :count => 0) %> + <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> + <% memberships = user.memberships.all(:conditions => cond) %> + <%= l(:label_x_contribute_to, :count => memberships.count) %> + <% for member in memberships %> + <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> <% end %>
- <% unless user.memberships.empty? %> - <% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %> - <% memberships = user.memberships.all(:conditions => cond) %> - <%= l(:label_x_course_contribute_to, :count => memberships.count) %> - <% for member in memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% else %> - <%= l(:label_x_course_contribute_to, :count => 0) %> + <% user_courses = user_courses_list(user) %> + <%= l(:label_x_course_contribute_to, :count => user_courses.count) %> + <% for course in user_courses %> + <%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : ',' %> <% end %>
<%= content_tag "div", link_to(user.name,user_path(user)), :class => "project_avatar_name" %>
+ <%= content_tag "div", link_to(user.name,user_path(user)), :class => "project_avatar_name" %>
|
| ||
- <% unless user.memberships.empty? %> + <%# unless user.memberships.empty? %> <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> <% memberships = user.memberships.all(:conditions => cond) %> <%= l(:label_x_contribute_to, :count => memberships.count) %> <% for member in memberships %> <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> <% end %> - <% end %> + <%# end %> - <% unless user.memberships.empty? %> - <% cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %> - <% memberships = user.memberships.all(:conditions => cond) %> - <%= l(:label_x_course_contribute_to, :count => memberships.count) %> - <% for member in memberships %> - <%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : ',' %> - <% end %> - <% end %> + <%# unless user.memberships.empty? %> + <% user_courses = user_courses_list(user) %> + <%= l(:label_x_course_contribute_to, :count => user_courses.count) %> + <% for course in user_courses %> + <%# if course.name != nil %> + <%= link_to course.name,{:controller => 'courses',:action => 'show',id:course.id, host: Setting.course_domain} %><%= (user_courses.last == course) ? '' : ',' %> + <%# end %> + <% end %> + <%# end %> - |
+