From 1cb1eeeb1dd7822f28e098396c96a7f29863bc21 Mon Sep 17 00:00:00 2001 From: z9hang Date: Tue, 17 Jun 2014 17:41:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=EF=BC=9A=E5=A7=93=E5=90=8D=E3=80=81=E5=B7=A5=E4=BD=9C=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=20=E8=AF=BE=E7=A8=8B=E4=B8=BB=E9=A1=B5=EF=BC=9A?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=90=8D=E7=A7=B0=E3=80=81=E6=95=99=E5=B8=88?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=20=E9=A1=B9=E7=9B=AE=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=EF=BC=9A=E9=A1=B9=E7=9B=AE=E5=90=8D=E7=A7=B0=20=E7=AB=9E?= =?UTF-8?q?=E8=B5=9B=E4=B8=BB=E9=A1=B5=EF=BC=9A=E7=AB=9E=E8=B5=9B=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=20=E4=B8=BB=E9=A1=B5=EF=BC=9A=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=88=97=3D>=E5=8D=95=E4=BD=8D=E5=90=8D=E7=A7=B0=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=83=A8=E5=88=86=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 5 +++++ app/views/layouts/base_courses.html.erb | 6 ++++-- app/views/layouts/base_newcontest.html.erb | 2 +- app/views/layouts/base_projects.html.erb | 2 +- app/views/layouts/base_users.html.erb | 11 ++++++++--- app/views/projects/_course.html.erb | 6 +++++- 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 494b8333f..ae5b18291 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -801,6 +801,11 @@ class UsersController < ApplicationController else @user = User.find(params[:id]) end + if @user.user_score.nil? + us = UserScore.new + us.user_id = @user.id + us.save + end rescue ActiveRecord::RecordNotFound render_404 end diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index dfdf0a102..adedb66c5 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -73,7 +73,8 @@ - + + - + + <% else %> diff --git a/app/views/layouts/base_newcontest.html.erb b/app/views/layouts/base_newcontest.html.erb index 91120feb8..a14f25cd6 100644 --- a/app/views/layouts/base_newcontest.html.erb +++ b/app/views/layouts/base_newcontest.html.erb @@ -62,7 +62,7 @@
<%= @project.name %><%= link_to @project.name,project_path(@project) %>
@@ -180,7 +181,8 @@ <% unless @course.teacher.user_extensions.nil? %>
<%= l(:label_teacher_work_unit) %> :<%= @course.teacher.user_extensions.school %><%= link_to @course.teacher.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @course.teacher.user_extensions.school.id}, html_options={:method => 'get'} %>
- + <% if User.current.login? %> diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 433e8aae6..bd15b128e 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -57,7 +57,7 @@
<%= h @contest.name %><%= link_to @contest.name, show_contest_contest_path(@contest) %>
<%= image_tag(url_to_avatar(@project), :class => 'avatar2') %>
- <%= @project.name %> + <%= link_to @project.name, project_path(@project)%>
diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 8c9531b55..193171e69 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -56,7 +56,9 @@
- @@ -92,7 +94,8 @@ <% comments_score = comments_count * 0.1 %> <% finall_influence_score = news_score + wiki_contents_score + comments_score %> <% finall_user_score = finall_messages_score + finall_user_project_score + finall_activity_score + finall_influence_score %> - + + + diff --git a/app/views/projects/_course.html.erb b/app/views/projects/_course.html.erb index 6ea802037..6c4bfe9a6 100644 --- a/app/views/projects/_course.html.erb +++ b/app/views/projects/_course.html.erb @@ -18,7 +18,11 @@ <%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%> <%# unless @project.course_extra.school.nil? %> - <%= @project.course_extra.teacher.user_extensions.school.try(:name) %> + + <% unless @project.course_extra.teacher.user_extensions.school.nil? %> + <%= link_to @project.course_extra.teacher.user_extensions.school.try(:name),options={:controller => 'welcome',:action => 'course',:school_id => @project.course_extra.teacher.user_extensions.school.id}, html_options={:method => 'get'}%> + <% end %> + <%# end %> <% end %>

From 9b707f2b5ac96d5f89043b9c957de17a0baf6ac4 Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 17 Jun 2014 18:03:50 +0800 Subject: [PATCH 2/3] a --- app/controllers/zipdown_controller.rb | 6 +++--- app/views/bids/_homework.html.erb | 2 +- app/views/bids/_homework_list.html.erb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/zipdown_controller.rb b/app/controllers/zipdown_controller.rb index 808df65dc..4fddec103 100644 --- a/app/controllers/zipdown_controller.rb +++ b/app/controllers/zipdown_controller.rb @@ -27,7 +27,7 @@ class ZipdownController < ApplicationController else logger.error "[ZipDown#assort] ===> #{obj.class.to_s.to_sym} unKown !!" end - send_file zipfile, :filename => obj.name, :type => detect_content_type(zipfile) if zipfile + send_file zipfile, :filename => obj.name+".zip", :type => detect_content_type(zipfile) if zipfile #rescue NameError, ActiveRecord::RecordNotFound => e #logger.error "[ZipDown] ===> #{e}" @@ -39,7 +39,7 @@ class ZipdownController < ApplicationController homework = HomeworkAttach.find params[:homework] if homework != nil && (User.current.admin? || User.current.member_of?(homework.bid.courses.first)) zipfile = zip_homework_by_user homework - send_file zipfile, :filename => homework.name, :type => detect_content_type(zipfile) if zipfile + send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile else render_403 :message => :notice_not_authorized end @@ -88,7 +88,7 @@ class ZipdownController < ApplicationController #length = attach.storage_path.length homeworks_attach_path << attach.diskfile#.to_s.slice((length+1)..-1) end - zipping "#{homeattach.user.name.to_s}.zip", homeworks_attach_path, OUTPUT_FOLDER, true + zipping "#{homeattach.user.name.to_s}_#{Time.now.to_i}.zip", homeworks_attach_path, OUTPUT_FOLDER, true #user_attaches_paths end diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index 4e2681ba6..1a55dc243 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -27,7 +27,7 @@ (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0) && cur_user_homework_for_bid(@bid).count == 0 %>
- + <%#= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %> <%= link_to l(:label_course_new_homework),new_homework_attach_path %>
<% end %> diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 18778f5e9..c49013cbf 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -8,7 +8,7 @@
<%= h (@user.name) %> + + + <%= link_to h (@user.name) %> <%= image_tag(gender_avatar_uri(@user), weight:"25px", height:"25px") if (@user.user_extensions && (@user.user_extensions.identity != 2) )%>
<%= l(:label_user_grade)%>: <%= link_to(format("%.2f" , @user.user_score.total_score).to_f, {:controller => 'users', @@ -102,6 +105,7 @@ }, :style => 'color :#E8770D;') %>
<%= l(:label_user_grade)%>: <%= link_to(format("%.2f" , finall_user_score).to_f, {:controller => 'users', @@ -174,12 +178,13 @@ --> + <% unless @user.user_extensions.nil? %> <% unless @user.user_extensions.identity == 2 %>
<%= l(:field_occupation) %>: <% unless @user.user_extensions.school.nil? %> - <%= @user.user_extensions.school.name %> + <%= link_to @user.user_extensions.school.name, options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %> <% end %>
<%= l(:label_task_plural)%>(<%= @homework_list.count%>) - <%= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if( + <%#= link_to "作业打包下载", zipdown_assort_path(obj_class: @bid.class, obj_id: @bid), remote: false, class: "button_submit button_submit_font_white", style: "margin: 5px 10px;line-height: 20px;height: 20px;display: inline-block;" if( User.current.admin? || !(User.current.roles_for_project(@bid.courses.first).map(&:id) & ([7,9])).empty? ) || (Rails.env.development?) %> From 8840a11a9996225612ad55659a238fcd98780465 Mon Sep 17 00:00:00 2001 From: yanxd Date: Tue, 17 Jun 2014 18:38:13 +0800 Subject: [PATCH 3/3] attachments error --- app/controllers/attachments_controller.rb | 2 ++ public/file_not_found.html | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 public/file_not_found.html diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 99160b0c0..65206350e 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -59,6 +59,8 @@ class AttachmentsController < ApplicationController :type => detect_content_type(@attachment), :disposition => (@attachment.image? ? 'inline' : 'attachment') end + rescue => e + redirect_to "http://forge.trustie.net/file_not_found.html" end #更新资源文件类型 diff --git a/public/file_not_found.html b/public/file_not_found.html new file mode 100644 index 000000000..80b0e3dde --- /dev/null +++ b/public/file_not_found.html @@ -0,0 +1,23 @@ + + +文件未找到 + + +

文件已经损坏

+

抱歉,因文件已经损坏,请重新上传此文件.

+

Back

+ +