From 5fb1b220e570222d78f2d71f6544b1f8b16d0de7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Mon, 18 Aug 2014 16:46:34 +0800 Subject: [PATCH 1/5] =?UTF-8?q?#1369=20=E4=BF=AE=E5=A4=8D=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E4=BD=9C=E4=B8=9A=E5=88=97=E8=A1=A8=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index be27a71ea..047f7103e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -488,6 +488,11 @@ class BidsController < ApplicationController if @bid.homework_type @homework = HomeworkAttach.new + if @bid.proportion + teacher_proportion = @bid.proportion * 1.0 / 100 + else + teacher_proportion = 1.0 + end #@homework_list = @bid.homeworks #增加作业按评分排序, #@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC") @@ -495,7 +500,7 @@ class BidsController < ApplicationController (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id = #{@bid.author_id}) AS t_score, (SELECT AVG(stars) FROM seems_rateable_rates WHERE rateable_type = 'HomeworkAttach' AND rateable_id = homework_attaches.id AND rater_id <> #{@bid.author_id}) AS s_score FROM homework_attaches WHERE bid_id = #{@bid.id} ORDER BY - (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{@bid.proportion * 1.0 / 100} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - @bid.proportion * 1.0 / 100} END) DESC,created_at ASC") + (CASE WHEN t_score IS NULL THEN 0 ELSE t_score * #{teacher_proportion} END + CASE WHEN s_score IS NULL THEN 0 ELSE s_score * #{1 - teacher_proportion} END) DESC,created_at ASC") if params[:student_id].present? @temp = [] @homework_list.each do |pro| From c13eeee56d81b3b60d84e258c269c4892d95cf7e Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 20 Aug 2014 15:51:35 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E9=94=99=E8=AF=AF=202.=E6=B3=A8=E9=87=8A?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/news/_course_form.html.erb | 2 +- app/views/news/_form.html.erb | 5 ++--- app/views/news/_news.html.erb | 10 +++++----- app/views/news/new.html.erb | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb index 1f2198a3b..ad2c7835c 100644 --- a/app/views/news/_course_form.html.erb +++ b/app/views/news/_course_form.html.erb @@ -5,7 +5,7 @@

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

- +

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

<%= render :partial => 'attachments/form', :locals => {:container => @news} %>

diff --git a/app/views/news/_form.html.erb b/app/views/news/_form.html.erb index 0601ee25b..f92559903 100644 --- a/app/views/news/_form.html.erb +++ b/app/views/news/_form.html.erb @@ -1,11 +1,10 @@ <%= error_messages_for @news %>
- <% str = @project ? l(:bale_news_notice) : l(:label_news_new) %> - <%= str %> + <%= @project ? l(:label_news_new) : l(:bale_news_notice) %>

<%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %>

- +

<%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %>

<%= render :partial => 'attachments/form', :locals => {:container => @news} %>

diff --git a/app/views/news/_news.html.erb b/app/views/news/_news.html.erb index 704e0eef3..7684a5949 100644 --- a/app/views/news/_news.html.erb +++ b/app/views/news/_news.html.erb @@ -1,9 +1,9 @@ - + <%# unless news.summary.blank? %><%#=h news.summary %><%# end %> +<%#= authoring news.created_on, news.author %>

--> diff --git a/app/views/news/new.html.erb b/app/views/news/new.html.erb index 68fad17f2..836d3b6ed 100644 --- a/app/views/news/new.html.erb +++ b/app/views/news/new.html.erb @@ -1,4 +1,4 @@ - + <% if @project %> <%= labelled_form_for @news, :url => project_news_index_path(@project), :html => {:id => 'news-form', :multipart => true} do |f| %> From 136c991060adcba8af9e86df0ad5a60b56c999dc Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 20 Aug 2014 16:28:04 +0800 Subject: [PATCH 3/5] =?UTF-8?q?#1413=20=E4=BF=AE=E5=A4=8D=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E5=90=8D=E7=A7=B0=E8=BF=87=E9=95=BF=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=E9=A6=96=E9=A1=B5=E4=BC=9A?= =?UTF-8?q?=E8=B6=85=E5=87=BA=E8=BE=B9=E7=95=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/show.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index a3412142b..366ec0c39 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -1,6 +1,6 @@ <% if @events_by_day != nil && @events_by_day.size >0 %>
- +

<%#= l(:label_date_from_to, :start => format_date(@date_from), :end => format_date(@date_to - 1)) %>

@@ -29,7 +29,7 @@ <%= l(:label_new_activity) %> - <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %> + <%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url,:style => "word-break:break-all;" %>
From 3343e1c4135f29a07a70df51c75690fa92fb3ae2 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 Aug 2014 10:24:23 +0800 Subject: [PATCH 4/5] =?UTF-8?q?#1203=20=E4=BF=AE=E5=A4=8D=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=AF=84=E5=AE=A1=E5=BF=AB=E9=80=9F=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E6=96=B0=E5=BB=BAISSUE=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../views/code_review/_issues_show_details_bottom.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/redmine_code_review/app/views/code_review/_issues_show_details_bottom.html.erb b/plugins/redmine_code_review/app/views/code_review/_issues_show_details_bottom.html.erb index e60198fff..480119ca7 100644 --- a/plugins/redmine_code_review/app/views/code_review/_issues_show_details_bottom.html.erb +++ b/plugins/redmine_code_review/app/views/code_review/_issues_show_details_bottom.html.erb @@ -46,8 +46,8 @@ review = issue.code_review %> <%= l(:label_revision) + " "%> <%= link_to_revision(assignment.revision, repo) %> - <% elsif assignment.attachment %> - <%= link_to(assignment.attachment.filename, :controller => 'attachments', :action => 'show', :id => attachment.id) %> + <% elsif assignment.respond_to?("attachment") && assignment.attachment %> + <%= link_to(assignment.attachment.filename.to_s, :controller => 'attachments', :action => 'show', :id => assignment.attachment.id) %> <% end %> From 16d86a1fbd2596a9e3381a84b5980c82cf85788a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 21 Aug 2014 10:37:53 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E3=80=81=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=A8=A1=E5=9D=97=E5=A2=9E=E5=8A=A0=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 23 +++++ app/models/attachment.rb | 6 +- .../_course_show_all_attachment.html.erb | 94 ++++++++++--------- app/views/files/_show_all_attachment.html.erb | 26 +++-- 4 files changed, 95 insertions(+), 54 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c80ce6d69..666c39d30 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -38,6 +38,17 @@ class FilesController < ApplicationController @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 + + all_attachments = [] + @containers.each do |container| + all_attachments += container.attachments + end + @limit = 10 + @feedback_count = all_attachments.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @curse_attachments = all_attachments[@offset, @limit] + render :layout => !request.xhr? elsif params[:course_id] @isproject = false @@ -67,6 +78,18 @@ class FilesController < ApplicationController else @containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on desc").find(@course.id)] end + + all_attachments = [] + @containers.each do |container| + all_attachments += container.attachments + end + + @limit = 10 + @feedback_count = all_attachments.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @curse_attachments = all_attachments[@offset, @limit] + render :layout => 'base_courses' end end diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 8f3d68d02..e25434e6e 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -29,9 +29,9 @@ class Attachment < ActiveRecord::Base include UserScoreHelper validates_presence_of :filename, :author - validates_length_of :filename, :maximum => 255 - validates_length_of :disk_filename, :maximum => 255 - validates_length_of :description, :maximum => 255 + validates_length_of :filename, :maximum => 254 + validates_length_of :disk_filename, :maximum => 254 + validates_length_of :description, :maximum => 254 validate :validate_max_file_size diff --git a/app/views/files/_course_show_all_attachment.html.erb b/app/views/files/_course_show_all_attachment.html.erb index 76112bc78..f70142a05 100644 --- a/app/views/files/_course_show_all_attachment.html.erb +++ b/app/views/files/_course_show_all_attachment.html.erb @@ -25,60 +25,70 @@ - <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% if container.is_a?(Version) -%> - + <%# @containers.each do |container| %> + <%# next if container.attachments.empty? -%> + <%# if container.is_a?(Version) -%> + - - --> + <%# end -%> + <% if @curse_attachments != nil %> + <% @curse_attachments.each do |file| %> + <%if file.is_public == 0 && !User.current.member_of_course?(@course)%> + <%next%> + <%end%> + "> + + + + - - + + - - - - - - - - <% end -%> - <% reset_cycle %> + + + + + + + + <% end -%> + <% end %> + <%# reset_cycle %> + <%# end -%> + +
<%= number_to_human_size(file.filesize) %> - <%= file.attachmentstype.typeName unless file.attachmentstype.nil? %> +
<%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %><%= number_to_human_size(file.filesize) %> + <%= file.attachmentstype.typeName unless file.attachmentstype.nil? %> <%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %> - <%= file.show_suffix_type %> - <%= file.file_dense_str %> -   + <%= file.show_suffix_type %> + <%= file.file_dense_str %> +   <%= render :partial => 'course_file_dense_edit', :locals => {:file_dense_list => file.file_dense_list, :attachment => file} %> - <%= file.downloads %> - <%= link_to(image_tag('delete.png'), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> -
-
- <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> - <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> -
-
- -
<%= file.downloads %> + <%= link_to(image_tag('delete.png'), attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> +
+
+ <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> +
+
+ +
+ + diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index 838153c78..043fe1183 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -25,16 +25,17 @@ - <% @containers.each do |container| %> - <% next if container.attachments.empty? -%> - <% if container.is_a?(Version) -%> - + <%# @containers.each do |container| %> + <%# next if container.attachments.empty? -%> + <%# if container.is_a?(Version) -%> + + <%# end -%> + <% if @curse_attachments != nil %> + <% @curse_attachments.each do |file| %> <%if file.is_public == 0 && !User.current.member_of?(@project)%> <%next%> <%end%> @@ -75,10 +76,17 @@ <% end -%> - <% reset_cycle %> + <%# reset_cycle %> <% end -%> + + +