From cf808598d230d2fe80e3c320f822d8d7fe96b38e Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 21 Nov 2014 14:57:10 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E4=B8=8D=E5=9C=A8=E6=90=9C=E7=B4=A2=E9=9D=9E=E6=9C=AC=E4=BA=BA?= =?UTF-8?q?=E7=9A=84=E7=A7=81=E6=9C=89=E8=B5=84=E6=BA=90=EF=BC=8C=E4=B8=94?= =?UTF-8?q?=E4=BB=96=E4=BA=BA=E7=9A=84=E5=85=AC=E5=BC=80=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E4=BA=A6=E4=B8=8D=E8=83=BD=E4=BF=AE=E6=94=B9=E5=85=B6=E5=85=AC?= =?UTF-8?q?=E5=BC=80=E7=A7=81=E6=9C=89=E5=B1=9E=E6=80=A72=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=81=E7=A7=BB=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 2 +- app/views/files/_course_list.html.erb | 3 ++- .../20141120091234_add_column_copyfrom_to_attachment.rb | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index ca7f8e040..6de800efc 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -69,7 +69,7 @@ class FilesController < ApplicationController # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。 # 现在还木有思路 药丸 - resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%"). + resultSet = Attachment.where("attachments.container_type IS NOT NULL AND (is_public = 1 OR author_id = #{User.current.id}) AND filename LIKE :like ", like: "%#{keywords}%"). reorder("created_on DESC") end diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 554a3aea5..df0e837f2 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -21,12 +21,13 @@
<%= link_to_attachment file, :download => true, :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 is_course_teacher(User.current,@course) %> + <% if is_course_teacher(User.current,@course) && User.current.id == file.author_id %> <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> <% else %> + <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> <% end %>
diff --git a/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb b/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb new file mode 100644 index 000000000..cc8444f6d --- /dev/null +++ b/db/migrate/20141120091234_add_column_copyfrom_to_attachment.rb @@ -0,0 +1,5 @@ +class AddColumnCopyfromToAttachment < ActiveRecord::Migration + def change + add_column("attachments","copy_from",:integer) + end +end From ba11fe25b5db9ac93d82646c241b637514c750af Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 21 Nov 2014 15:02:34 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E5=85=A8=E7=AB=99=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=90=8E=E5=88=97=E8=A1=A8=E4=B8=AD=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E5=88=A0=E9=99=A4=E5=BD=93=E5=89=8D=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E7=9A=84=E8=B5=84=E6=BA=90=EF=BC=8C=E4=B8=94=E9=9C=80=E6=9C=89?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=B5=84=E6=BA=90=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/views/files/_course_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index df0e837f2..fced58604 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -35,7 +35,7 @@

文件大小:<%= number_to_human_size(file.filesize) %>

<%= link_to( l(:button_delete), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed %> + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%>

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用0

From 42e0b47a67649bee5ecdbc8e740bdb4795bb0897 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 21 Nov 2014 15:23:54 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E7=9A=84=E7=A7=81=E6=9C=89=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_course_list.html.erb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index fced58604..023cb23d2 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -21,13 +21,17 @@
<%= link_to_attachment file, :download => true, :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 is_course_teacher(User.current,@course) && User.current.id == file.author_id %> + <% if is_course_teacher(User.current,@course) %> <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> - - <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> - + <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> + + <%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %> + + <% else %> + <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> + <% end %> + <% else %> - <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> <% end %>
From 1007134ced6683bbb30b711dbdb06ca17cdb7eb4 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 21 Nov 2014 15:35:08 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E8=BF=87=E9=95=BF=E7=9A=84=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_course_list.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 023cb23d2..fa22c404d 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -20,7 +20,7 @@ <%end%>
- <%= link_to_attachment file, :download => true, :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" %> + <%= 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 is_course_teacher(User.current,@course) %> <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> <% if delete_allowed && file.container_id == @course.id && file.container_type == "Course" %> From ac6305cddb101a300111fb39dafe71a3458275db Mon Sep 17 00:00:00 2001 From: zhuhao Date: Fri, 21 Nov 2014 15:49:21 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?= =?UTF-8?q?=E5=8C=BA=E5=8F=91=E5=B8=96=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/boards/_course_show.html.erb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index fd1dd3e00..cde2019a1 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -19,8 +19,9 @@ <%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => false, :id => 'message-form'} do |f| %> <%= render :partial => 'messages/form', :locals => {:f => f} %>

- - <%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' ,:class => 'whiteButton m3p10' %> + + <%= l(:button_submit)%> + <%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' ,:class => 'ButtonColor m3p10' %>

<% end %>
From 2348e063d1ad581af450445ac35ca430182fab1a Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 21 Nov 2014 15:54:29 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=80=89=E5=85=A5?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=BC=B9=E6=A1=86=E4=B8=AD=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/files_helper.rb | 4 ++-- app/views/files/_show_quote_resource.html.erb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 9a0a1127f..4f3f401c9 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -44,10 +44,10 @@ module FilesHelper File.new(zipfile_name,'w+') end - def courses_check_box_tags(name,courses,current_course) + def courses_check_box_tags(name,courses,current_course,attachment) s = '' courses.each do |course| - if course.id != current_course.id && is_course_teacher(User.current,course) + if !(attachment.container_type && attachment.container_id == course.id) && is_course_teacher(User.current,course) s << "
" end end diff --git a/app/views/files/_show_quote_resource.html.erb b/app/views/files/_show_quote_resource.html.erb index 8041802a5..ef907f40f 100644 --- a/app/views/files/_show_quote_resource.html.erb +++ b/app/views/files/_show_quote_resource.html.erb @@ -8,7 +8,7 @@ remote: true, id: "relation_file_form" do %> <%= hidden_field_tag(:file_id, file.id) %> - <%= content_tag('div', courses_check_box_tags('courses[course][]', User.current.courses,course), :id => 'courses')%> + <%= content_tag('div', courses_check_box_tags('courses[course][]', User.current.courses,course,file), :id => 'courses')%> 引  用取  消 <% end -%>
From 3317ca4a975c80afbf5b2f59e7f04f59f67cf943 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 21 Nov 2014 16:27:20 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug:=20<=E8=B5=84?= =?UTF-8?q?=E6=96=99=E4=BF=AE=E6=94=B9--=E7=99=BB=E5=BD=95=E5=90=8D?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E7=BC=96=E8=BE=91>=20<=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E6=97=B6=E7=99=BB=E5=BD=95=E5=90=8D=E8=A2=AB=E6=A0=87=E8=AF=86?= =?UTF-8?q?=E4=B8=BA=E5=8F=AA=E8=83=BD=E6=98=AF=E8=8B=B1=E6=96=87=EF=BC=8C?= =?UTF-8?q?=E4=BD=86=E6=98=AF=E5=8F=AF=E4=BB=A5=E4=B8=BA=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E7=9A=84>=20<=E5=90=8E=E5=8F=B0=E9=85=8D=E7=BD=AE=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E6=9C=80=E7=9F=AD10=E4=B8=AA=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=EF=BC=8C=E6=B3=A8=E5=86=8C=E6=97=B6=E8=BE=93=E5=85=A5=E5=AF=86?= =?UTF-8?q?=E7=A0=81=E5=B0=91=E4=BA=8E10=E4=B8=AA=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B9=9F=E7=BB=99=E5=87=BA=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E2=80=9C=E5=AF=86=E7=A0=81=E8=AE=BE=E7=BD=AE=E6=88=90=E5=8A=9F?= =?UTF-8?q?=E2=80=9D>=20<=E9=82=AE=E7=AE=B1=E6=BF=80=E6=B4=BB=E2=80=9D?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E4=BF=AE=E6=94=B9=E8=8B=A5=E5=B9=B2=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE>=20Signed-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/account/email_valid.html.erb | 16 ++++++---------- app/views/account/register.html.erb | 21 +++++++++++++++++++-- app/views/my/account.html.erb | 2 +- config/locales/zh.yml | 5 +++-- 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/app/views/account/email_valid.html.erb b/app/views/account/email_valid.html.erb index 6f4de1197..c77c0294e 100644 --- a/app/views/account/email_valid.html.erb +++ b/app/views/account/email_valid.html.erb @@ -11,7 +11,7 @@ <% email = @user.mail.split("@")[1] %> -
+

邮箱激活

@@ -19,9 +19,10 @@
-

请在24小时内点击邮件中的链接继续完成注册

-
- 邮件已发送到邮箱 +

请在24小时内点击邮件中的链接继续完成注册

+
+
+ 邮件已发送到邮箱 <%= @user.mail %>

@@ -33,12 +34,7 @@ padding: 10px 16px; line-height: 1.33;" target="_blank">立即查收邮件

- - 没收到邮件? - -
- - 请先检查是否在垃圾邮件中 +
diff --git a/app/views/account/register.html.erb b/app/views/account/register.html.erb index 21bdd8fa7..0bebfdf5f 100644 --- a/app/views/account/register.html.erb +++ b/app/views/account/register.html.erb @@ -19,7 +19,7 @@

<%= f.text_field :login, :size => 25, :required => true %> <%= l(:label_max_number) %>

-

<%= f.password_field :password, :size => 25, :required => true %> +

<%= f.password_field :password, :size => 25, :required => true %> <%= l(:text_caracters_minimum, :count => Setting.password_min_length) %>

<%= f.password_field :password_confirmation, :size => 25, :required => true %>

@@ -56,10 +56,12 @@

<%= custom_field_tag_with_label :user, value %>

<% end %>
+<% password_min_length = Setting.password_min_length %>
@@ -25,8 +39,8 @@
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search f_l",:remote=>true) do %> <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> - <%= submit_tag "课内搜索", :class => "re_schbtn b_dblue",:name => "incourse"%> - <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite" %> + <%= submit_tag "课内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onclick => "presscss('incourse')"%> + <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onclick => "presscss('insite')" %> <% end %> <% if is_course_teacher(User.current,@course) %> 上传资源 diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index fa22c404d..cb776aeb7 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -37,7 +37,7 @@
-

文件大小:<%= number_to_human_size(file.filesize) %>

+

文件大小:<%= number_to_human_size(file.filesize) %>

<%= link_to( l(:button_delete), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%>

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用0

diff --git a/app/views/tags/_tag_add.html.erb b/app/views/tags/_tag_add.html.erb index 14f2dc965..0b59015f2 100644 --- a/app/views/tags/_tag_add.html.erb +++ b/app/views/tags/_tag_add.html.erb @@ -1,13 +1,14 @@ <%= link_to '+ 添加标签', 'javascript:void(0);', :class => "yellowBtn f_l", :onclick=>"$('#add_tag_#{obj.id}').slideToggle();" if User.current.logged? %> - \ No newline at end of file diff --git a/public/stylesheets/resource.css b/public/stylesheets/resource.css index 1046429be..fc6b74b75 100644 --- a/public/stylesheets/resource.css +++ b/public/stylesheets/resource.css @@ -12,11 +12,12 @@ a:hover{ text-decoration:underline;} .b_lblue{ background:#64bdd9 !important;} .b_dblue{ background:#55a1b9 !important; cursor:pointer !important;} .f_b{ font-weight: bold !important;} -.c_blue{ color:#64bdd9;} +.c_blue{ color:#64bdd9 !important;} .c_grey{ color:#999999 !important;} .c_grey02{ color:#666666 !important;} +.font{ font-size: 12px;} .f_14{ font-size:14px ;} -.c_dblue{ color:#3e6d8e;} +.c_dblue{ color:#3e6d8e !important;} .w90{width:90px;} .ml10{margin-left:10px;} .ml5{margin-left:5px;} @@ -46,14 +47,14 @@ a:hover{ text-decoration:underline;} text-shadow: none !important; } a.re_fabu { display:block; width:90px; height:35px; font-size:14px; color:#fff; text-align:center; padding-top:5px; margin:5px; } -a:hover.re_fabu{background:#55a1b9;} +a:hover.re_fabu{background:#55a1b9 !important;} /****列表***/ .re_con{ margin:5px; width:683px;} .re_con_top{color:#494949; } .re_con_top span{ color:#999999; font-weight:bold;} a.re_select{ display:block; width:88px; height:22px; background:url(images/pic_select01.png) 0 0 no-repeat; color:#fff; font-weight:bold; margin-left:10px;} a:hover.re_select{background:url(images/pic_select02.png) 0 0 no-repeat;} -.re_open{display:block; width:46px; height:22px; background:url(images/pic_open01.png) 0 0 no-repeat; color:#fff; font-weight:bold; margin-left:10px;} +.re_open{display:block; width:46px; height:22px; background:url(images/pic_open01.png) 0 0 no-repeat; color:#fff !important; font-weight:bold; margin-left:10px;} a:hover.re_open{background:url(images/pic_open02.png) 0 0 no-repeat;} a.re_de{ color:#6883b6; margin-left:15px;} .re_con_box{ border-bottom:1px dashed #dadada; padding:10px 0;} @@ -76,7 +77,6 @@ a.yellowBtn{ display:inline-block;color:#0d90c3; height:22px;} margin-top:2px !important; margin-left:3px !important; border:none !important; - margin-left:0px !important; box-shadow: none !important; padding: 0px !important; border-radius: 0 !important; From 70e8c4ebe733b75552440df7a577d2b1e9325b73 Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Fri, 21 Nov 2014 19:11:40 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug<=E6=B3=A8=E5=86=8C?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E7=94=A8=E6=88=B7=E7=AC=AC=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E7=99=BB=E9=99=86=E9=83=BD=E5=BE=97=E8=BD=AC=E5=88=B0=E3=80=8A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99=E3=80=8B=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?>=20Signed-off-by:=20alan=20<547533434@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 15 ++++++++++----- app/controllers/application_controller.rb | 2 +- app/models/user.rb | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index 2c4929019..b5975e452 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -234,7 +234,7 @@ class AccountController < ApplicationController end def password_authentication - user = User.try_to_login(params[:username], params[:password]) + user, last_login_on = User.try_to_login(params[:username], params[:password]) if user.nil? invalid_credentials @@ -244,7 +244,7 @@ class AccountController < ApplicationController onthefly_creation_failed(user, {:login => user.login, :auth_source_id => user.auth_source_id }) else # Valid user - successful_authentication(user) + successful_authentication(user, last_login_on) end end @@ -291,7 +291,7 @@ class AccountController < ApplicationController end end - def successful_authentication(user) + def successful_authentication(user, last_login_on) logger.info "Successful authentication for '#{user.login}' from #{request.remote_ip} at #{Time.now.utc}" # Valid user self.logged_user = user @@ -304,13 +304,18 @@ class AccountController < ApplicationController code = /\d*/ #根据home_url生产正则表达式 eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") - if code=~params[:back_url] + if code=~params[:back_url] && last_login_on != '' redirect_to user_activities_path(user) else + if last_login_on == '' + redirect_to my_account_url + else #by young #redirect_back_or_default my_page_path - redirect_back_or_default User.current + #sredirect_back_or_default User.current + redirect_to my_account_url #redirect_to User.current + end end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 67948a8e1..d1465574f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -124,7 +124,7 @@ class ApplicationController < ActionController::Base else # HTTP Basic, either username/password or API key/random authenticate_with_http_basic do |username, password| - user = User.try_to_login(username, password) || User.find_by_api_key(username) + user = User.try_to_login(username, password)[0] || User.find_by_api_key(username) end end # Switch user if requested by an admin user diff --git a/app/models/user.rb b/app/models/user.rb index ff627763a..a9d73bd31 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -359,8 +359,9 @@ class User < Principal end end end + last_login_on = user.last_login_on.nil? ? '' : user.last_login_on.to_s user.update_column(:last_login_on, Time.now) if user && !user.new_record? - user + [user, last_login_on] rescue => text raise text end From 0049f921b94d7ddb2359e63664837b86dc28827e Mon Sep 17 00:00:00 2001 From: alan <547533434@qq.com> Date: Sat, 22 Nov 2014 09:51:41 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug=E3=80=8A=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=89=88--=E8=AF=BE=E7=A8=8B/=E9=A1=B9=E7=9B=AE--?= =?UTF-8?q?=E9=85=8D=E7=BD=AE--=E6=88=90=E5=91=98=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=EF=BC=9A=E5=A6=82=E5=9B=BE=EF=BC=8C=E7=94=A8=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=B8=AD=E5=90=84=E7=94=A8=E6=88=B7=E7=9A=84=E9=82=AE?= =?UTF-8?q?=E7=AE=B1=E5=85=A8=E9=83=A8=E4=B8=BA=E7=A9=BA=E4=BA=86=E3=80=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: alan <547533434@qq.com> --- app/models/user.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index a9d73bd31..fe6222359 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -230,7 +230,12 @@ class User < Principal #选择项目成员时显示的用户信息文字 def userInfo - info=self.nickname + ' (' + self.realname + ')'; + if self.realname.gsub(' ','') == "" || self.realname.nil? + info = self.nickname; + else + info=self.nickname + ' (' + self.realname + ')'; + end + info end ###添加留言 fq From 36e7b222bb5d2da7d8654cbd7da0739a42522466 Mon Sep 17 00:00:00 2001 From: z9hang Date: Sat, 22 Nov 2014 10:06:56 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=85=AC=E5=BC=80=E7=9A=84=E4=B9=9F?= =?UTF-8?q?=E9=9C=80=E7=99=BB=E5=BD=95=E6=89=8D=E8=83=BD=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 2 ++ app/controllers/attachments_controller.rb | 2 +- app/helpers/files_helper.rb | 7 ++++++- app/models/role.rb | 2 +- app/views/files/_course_list.html.erb | 11 ++++++----- app/views/files/_show_quote_resource.html.erb | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 67948a8e1..cab5ada7c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -267,6 +267,8 @@ class ApplicationController < ActionController::Base end when "contest" return true + when "Course" + allowed = User.current.allowed_to?(:course_attachments_download, @course, :global => false) else return true end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index a57b5f8a5..b28fda55b 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -76,7 +76,7 @@ class AttachmentsController < ApplicationController candown = User.current.member_of?(project) || (project.is_public && @attachment.is_public == 1) elsif (@attachment.container.has_attribute?(:course) ||@attachment.container.has_attribute?(:course_id) ) && @attachment.container.course course = @attachment.container.course - candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) + candown = User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) elsif @attachment.container.is_a?(Course) course = @attachment.container candown= User.current.member_of_course?(course) || (course.is_public==1 && @attachment.is_public == 1) diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index 4f3f401c9..f1f4f06f4 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -72,5 +72,10 @@ module FilesHelper result end - + def get_qute_number attachment + if attachment.copy_from.nil? + return 0 + end + count = Attachment.find_by_sql("select count(*) from attachments where copy_from = #{attachment.copy_from}") + end end \ No newline at end of file diff --git a/app/models/role.rb b/app/models/role.rb index 57fccd53c..f363b52bf 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -161,7 +161,7 @@ class Role < ActiveRecord::Base if action.is_a? Hash allowed_actions.include? "#{action[:controller]}/#{action[:action]}" else - allowed_permissions.include? action + allowed_permissions.include? action end end diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index cb776aeb7..51091caae 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -1,8 +1,8 @@ <% delete_allowed = User.current.allowed_to?(:manage_files, course) %>

共有 <%= User.current.member_of_course?(course) ? all_attachments.count : 0 %> 个资源

- + <#% end %>--> + 资源列表的多样化排序将在下周上线... +

<% curse_attachments.each do |file| %> @@ -40,7 +41,7 @@

文件大小:<%= number_to_human_size(file.filesize) %>

<%= link_to( l(:button_delete), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%> -

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用0

+

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%=get_qute_number file %>

diff --git a/app/views/files/_show_quote_resource.html.erb b/app/views/files/_show_quote_resource.html.erb index ef907f40f..58b0edda0 100644 --- a/app/views/files/_show_quote_resource.html.erb +++ b/app/views/files/_show_quote_resource.html.erb @@ -1,8 +1,8 @@
-

将此课件引入我的课程资源库

+
<%= form_tag course_attach_relations_path, method: :post, remote: true, From 436cf1175f85291016b3039cd36dbe84d5967484 Mon Sep 17 00:00:00 2001 From: z9hang Date: Sat, 22 Nov 2014 13:45:17 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=A8=A1=E5=9D=97=E7=9B=B8=E5=85=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/attachments_controller.rb | 2 +- app/controllers/files_controller.rb | 10 ++++--- app/helpers/files_helper.rb | 10 +++++++ app/views/files/_course_list.html.erb | 20 +++++++------- app/views/tags/_tag_list.html.erb | 6 ++--- config/locales/en.yml | 3 ++- config/locales/zh.yml | 1 + public/stylesheets/resource.css | 33 +++++++++++++++++++---- 8 files changed, 62 insertions(+), 23 deletions(-) diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index b28fda55b..5c3503718 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -366,7 +366,7 @@ class AttachmentsController < ApplicationController end rescue NoMethodError @save_flag = false - @save_message = [] << l(:error_attachment_empty) + @save_message = [] << l(:label_course_empty_select) respond_to do |format| format.js end diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 6de800efc..251496e30 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -26,13 +26,15 @@ class FilesController < ApplicationController helper :sort include SortHelper + include FilesHelper helper :project_score def show_attachments obj - @all_attachments = [] + @attachments = [] obj.each do |container| - @all_attachments += container.attachments + @attachments += container.attachments end + @all_attachments = visable_attachemnts(@attachments) @limit = 10 @feedback_count = @all_attachments.count @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] @@ -48,9 +50,11 @@ class FilesController < ApplicationController #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank? if params[:insite] @result = find_public_attache q + @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 else @result = find_course_attache q,@course + @result = visable_attachemnts @result @searched_attach = paginateHelper @result,10 end @@ -69,7 +73,7 @@ class FilesController < ApplicationController # StoresController#search 将每条文件都查出来,再次进行判断过滤。---> resultSet.to_a.map # 此时内容不多速度还可,但文件增长,每条判断多则进行3-4次表连接。 # 现在还木有思路 药丸 - resultSet = Attachment.where("attachments.container_type IS NOT NULL AND (is_public = 1 OR author_id = #{User.current.id}) AND filename LIKE :like ", like: "%#{keywords}%"). + resultSet = Attachment.where("attachments.container_type IS NOT NULL AND filename LIKE :like ", like: "%#{keywords}%"). reorder("created_on DESC") end diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb index f1f4f06f4..cd7603c65 100644 --- a/app/helpers/files_helper.rb +++ b/app/helpers/files_helper.rb @@ -72,6 +72,16 @@ module FilesHelper result end + def visable_attachemnts attachments + result = [] + attachments.each do |attachment| + if attachment.is_public? || attachment.author_id == User.current.id + result << attachment + end + end + result + end + def get_qute_number attachment if attachment.copy_from.nil? return 0 diff --git a/app/views/files/_course_list.html.erb b/app/views/files/_course_list.html.erb index 51091caae..b8d0ad098 100644 --- a/app/views/files/_course_list.html.erb +++ b/app/views/files/_course_list.html.erb @@ -1,6 +1,6 @@ <% delete_allowed = User.current.allowed_to?(:manage_files, course) %>
-

共有 <%= User.current.member_of_course?(course) ? all_attachments.count : 0 %> 个资源

+

共有 <%= all_attachments.count%> 个资源

<% end %> - + <% else %> + <%= link_to "选入我的课程",quote_resource_show_course_file_path(@course,file),:class => "f_l re_select",:remote => true %> + <% end %> <% else %> - <%= link_to (file.is_public? ? "公开":"私有"),"javascript:void(0)",:class=>"f_l re_open" %> <% end %>

@@ -41,7 +41,7 @@

文件大小:<%= number_to_human_size(file.filesize) %>

<%= link_to( l(:button_delete), attachment_path(file), :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if delete_allowed && file.container_id == @course.id && file.container_type == "Course"%> -

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%=get_qute_number file %>

+

<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  

diff --git a/app/views/tags/_tag_list.html.erb b/app/views/tags/_tag_list.html.erb index c815d71f8..549ed1751 100644 --- a/app/views/tags/_tag_list.html.erb +++ b/app/views/tags/_tag_list.html.erb @@ -14,7 +14,7 @@ <% end %> <% else %> - -    <%= l(:label_tags_no) %> - + + <% end %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 94272b1fd..22b0df023 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1851,4 +1851,5 @@ en: label_teacher_comments: Teacher comments label_anonymous_comments: Anonymous comments label_anonymous: Anonymous - label_submit_comments: Submit_comments \ No newline at end of file + label_submit_comments: Submit_comments + label_course_empty_select: You have not selected course! \ No newline at end of file diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 3f4267b76..bad27274f 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -2204,3 +2204,4 @@ zh: field_evaluation_num: 匿评分配数量 label_my_score: 我的评分 field_open_anonymous_evaluation: 是否开启匿评 + label_course_empty_select: 尚未选择课程! diff --git a/public/stylesheets/resource.css b/public/stylesheets/resource.css index fc6b74b75..86ff85825 100644 --- a/public/stylesheets/resource.css +++ b/public/stylesheets/resource.css @@ -1,4 +1,4 @@ -body{ font-size:12px; font-family:"微软雅黑","宋体"; line-height:1.9; background:#fff; font-style:normal;} +body{ font-size:12px !important; font-family:"微软雅黑","宋体" !important; line-height:1.9 !important; background:#fff !important; font-style:normal !important;} div,html,img,ul,li,p,body,h1,h2,h3,h4,p,a,table,tr,td,fieldset,input,form,span,textarea{ margin:0; padding:0;} div,img,tr,td,textarea{ border:0;} table,tr,td{border:0; cellspacing:0; cellpadding:0;} @@ -52,10 +52,33 @@ a:hover.re_fabu{background:#55a1b9 !important;} .re_con{ margin:5px; width:683px;} .re_con_top{color:#494949; } .re_con_top span{ color:#999999; font-weight:bold;} -a.re_select{ display:block; width:88px; height:22px; background:url(images/pic_select01.png) 0 0 no-repeat; color:#fff; font-weight:bold; margin-left:10px;} -a:hover.re_select{background:url(images/pic_select02.png) 0 0 no-repeat;} -.re_open{display:block; width:46px; height:22px; background:url(images/pic_open01.png) 0 0 no-repeat; color:#fff !important; font-weight:bold; margin-left:10px;} -a:hover.re_open{background:url(images/pic_open02.png) 0 0 no-repeat;} +a.re_select{ + display: block; + height: 22px; + border: 1px solid #ff9900; + color: #ff9900; + margin-left: 10px; + padding-left: 10px; + padding-right: 10px; +} +a:hover.re_select{ + background: #ff9900; + color: #fff; + text-decoration: none;} +.re_open{ + display: block !important; + width: 46px !important; + height: 22px !important; + border: 1px solid #64bdd9 !important; + color: #64bdd9 !important; + margin-left: 10px !important; +} +a:hover.re_open +{ + background: #64bdd9; + color: #fff !important; + text-decoration: none !important; +} a.re_de{ color:#6883b6; margin-left:15px;} .re_con_box{ border-bottom:1px dashed #dadada; padding:10px 0;} /****翻页***/