From 03850139051be65f1a7a4d0f4167e8c868820c18 Mon Sep 17 00:00:00 2001 From: z9hang Date: Thu, 15 May 2014 19:16:36 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=20=E5=8E=BB=E9=99=A4=E8=80=81=E5=B8=88?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=A1=B9=E7=9B=AE=E5=9E=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/account_controller.rb | 16 ++++++++++++---- app/controllers/bids_controller.rb | 12 ++++++++---- app/helpers/bids_helper.rb | 4 ++++ app/views/bids/_list_projects.html.erb | 4 ++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index cf39898f..af848786 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -276,10 +276,18 @@ class AccountController < ApplicationController set_autologin_cookie(user) end call_hook(:controller_account_success_authentication_after, {:user => user }) - #by young -# redirect_back_or_default my_page_path - redirect_back_or_default User.current -# redirect_to User.current + + code = /\d*/ + #根据home_url生产正则表达式 + eval("code = " + "/^" + home_url.gsub(/\//,"\\\/") + "\\\/*(welcome)?\\\/*(\\\/index\\\/*.*)?\$/") + if code=~params[:back_url] + redirect_to user_activities_path(user) + else + #by young + #redirect_back_or_default my_page_path + redirect_back_or_default User.current + #redirect_to User.current + end end def set_autologin_cookie(user) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 206421e5..1ae04fa0 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -18,6 +18,8 @@ class BidsController < ApplicationController helper :attachments include AttachmentsHelper include ApplicationHelper + include BidsHelper + helper :projects helper :words helper :welcome @@ -503,10 +505,12 @@ class BidsController < ApplicationController #删除已提交的项目作业(不删项目) def delete binding_project = params[:binding_project] - if BidingProject.delete(binding_project) - redirect_to project_for_bid_path - else - redirect_to 403; + if can_delete_project_homework(BidingProject.find(binding_project),User.current) + if BidingProject.delete(binding_project) + redirect_to project_for_bid_path + else + redirect_to 403; + end end end ## 新建留言 diff --git a/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb index bd39d6c2..38b32e69 100644 --- a/app/helpers/bids_helper.rb +++ b/app/helpers/bids_helper.rb @@ -151,4 +151,8 @@ module BidsHelper tmp end + def can_delete_project_homework bind_project,current_user + current_user.id == bind_project.user.id || current_user.admin + end + end \ No newline at end of file diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb index e51314c4..ce24a445 100644 --- a/app/views/bids/_list_projects.html.erb +++ b/app/views/bids/_list_projects.html.erb @@ -154,9 +154,9 @@ <% end %> - <% if b_project.user.id == User.current.id || User.current.id == b_project.bid.author.id + <% if can_delete_project_homework b_project,User.current %> - <%= link_to image_tag('delete.png'),{ :action => "delete", :binding_project => b_project}, :confirm => "Are you sure?" %> + <%= link_to image_tag('delete.png'),{ :action => "delete", :binding_project => b_project}, :confirm => l(:text_are_you_sure) %> <% end %> From 5c71d7e8bed4792c3ff59ea033bc4ff50b2dcf25 Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 16 May 2014 15:30:32 +0800 Subject: [PATCH 2/5] =?UTF-8?q?1.=E8=B5=84=E6=BA=90=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E8=AF=BE=E4=BB=B6=202.=E8=B0=83=E6=95=B4=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_new.html.erb | 2 +- app/views/files/_show_all_attachment.html.erb | 8 +++---- app/views/files/_sort_by_attachtypel.html.erb | 21 +++++++++---------- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index 4c1b97fa..6e9e1853 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -15,7 +15,7 @@

<%= select_tag "attachment_type", options_from_collection_for_select(attachmenttypes, "id", - "typeName") %> + "typeName",2) %>

<% end %> diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb index 07dc6a27..d34f95f7 100644 --- a/app/views/files/_show_all_attachment.html.erb +++ b/app/views/files/_show_all_attachment.html.erb @@ -20,6 +20,7 @@ <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %> <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> + <%= sort_header_tag('tags', :caption => l(:label_tag), :id => "vzebra-tag") %> @@ -51,15 +52,14 @@ <%= 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"} %>
- + <% end -%> diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb index 01c57c49..9df26d7e 100644 --- a/app/views/files/_sort_by_attachtypel.html.erb +++ b/app/views/files/_sort_by_attachtypel.html.erb @@ -20,6 +20,7 @@ <%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%> <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %> <%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %> + <%= sort_header_tag('tags', :caption => l(:label_tag), :id => "vzebra-tag") %> @@ -47,17 +48,15 @@ <%= 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"} %> -
-
- - + +
+ <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> + <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> +
+
+ + <% end -%> <% end -%> From 8f153520b4a4ef6f3662c20b7cb3da2d923f6ade Mon Sep 17 00:00:00 2001 From: nwb Date: Fri, 16 May 2014 16:29:01 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/files/_new.html.erb | 37 +++++++++++++++++++----------- config/locales/zh.yml | 2 +- public/stylesheets/application.css | 2 +- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb index 6e9e1853..9d62ca37 100644 --- a/app/views/files/_new.html.erb +++ b/app/views/files/_new.html.erb @@ -5,21 +5,32 @@ <%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %>
-<% if versions.any? %> -

-<%= select_tag "version_id", content_tag('option', '') + - options_from_collection_for_select(versions, "id", "name") %>

-<% end %> +

+ + + <% if versions.any? %> + + + <% end %> - <% if attachmenttypes.any? %> -

- <%= select_tag "attachment_type", - options_from_collection_for_select(attachmenttypes, "id", - "typeName",2) %> -

- <% end %> + <% if attachmenttypes.any? %> + + + <% end %> + +

<%= l(:field_version) %>

+ <%= select_tag "version_id", content_tag('option', '') + + options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %> + <%= l(:attachment_type) %> + <%= select_tag "attachment_type", + options_from_collection_for_select(attachmenttypes, "id", + "typeName", 2), {style: 'width:100px'} %> +
-

<%= render :partial => 'attachments/form' %>

+ +

+ +

<%=l(:label_attachment_plural)%><%= render :partial => 'attachments/form' %>

<%= submit_tag l(:button_add) %> <% end %> diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 3d8a0e54..666b2874 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -143,7 +143,7 @@ zh: attachment_all: "全部" attachment_sufix_browse: "文件类型" attachment_browse: "内容类型" - attachment_type: '资源分类' + attachment_type: '分类' general_text_No: '否' general_text_Yes: '是' general_text_no: '否' diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index 7b0a0099..d786101b 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -1319,7 +1319,7 @@ tr.entry td.filename_no_report { width: 70%; } tr.entry td.size { text-align: right; font-size: 90%; } tr.entry td.revision, tr.entry td.author { text-align: center; } tr.entry td.age { text-align: right; } -tr.entry.file td.filename a { margin-left: 16px; } +tr.entry.file td.filename a { margin-center: 16px; } tr.entry.file td.filename_no_report a { margin-left: 16px; } tr span.expander {background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;} From 5d153494823085b76df4ef3e84907c21c7e83f64 Mon Sep 17 00:00:00 2001 From: z9hang Date: Fri, 16 May 2014 17:45:20 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=97=B6=E6=98=BE=E7=A4=BA=E5=B7=B2=E6=B7=BB=E5=8A=A0=E7=9A=84?= =?UTF-8?q?=E9=99=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_form.html.erb | 10 +++++----- app/views/bids/_homework_form.html.erb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index f34a0e4e..f05c4e9b 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -1,10 +1,10 @@ <% if defined?(container) && container && container.saved_attachments %> - <% container.saved_attachments.each_with_index do |attachment, i| %> - - <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename', :maxlength => 10)%> - - <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 155, :placeholder => l(:label_optional_description), :class => 'description') + + <% container.attachments.each_with_index do |attachment, i| %> + + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%> + + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") + link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> diff --git a/app/views/bids/_homework_form.html.erb b/app/views/bids/_homework_form.html.erb index fe6f35fb..6d9230a9 100644 --- a/app/views/bids/_homework_form.html.erb +++ b/app/views/bids/_homework_form.html.erb @@ -37,5 +37,5 @@

<%= hidden_field_tag 'course_id', @project_id %>

<%= l(:label_attachment_plural) %> -

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

+

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

\ No newline at end of file From 63af60d7b676ae28ce16254bc880246e10d8d5fa Mon Sep 17 00:00:00 2001 From: yanxd Date: Sat, 17 May 2014 10:44:01 +0800 Subject: [PATCH 5/5] =?UTF-8?q?edit=20=E5=9B=BE=E6=A0=87=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=20bid=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 4 ++-- public/images/edit.png | Bin 0 -> 522 bytes 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 public/images/edit.png diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 1ae04fa0..2273de4e 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -732,9 +732,9 @@ class BidsController < ApplicationController def update @bid = Bid.find(params[:id]) @project = @bid.courses.first#Project.find(params[:course_id]) - if @bid.update_attributes(params[:bid]) + @bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) + if @bid.update_attributes(params[:bid]) && @bid.save flash[:notice] = l(:label_update_homework_succeed) - #@project = Project.find(params[:course_id]) redirect_to project_homework_path(@project) else @bid.safe_attributes = params[:bid] diff --git a/public/images/edit.png b/public/images/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..8335716fd5f9994eca802b8b14fb43c667bcc034 GIT binary patch literal 522 zcmV+l0`>igP)Pft(g&!0d4|DQhl|Nrg@{~ubrZp3Q+~ymoxxm8*H4N^pv1Yip)*8iT zxaN1O|Nnnp_5bP)+t({+c&Ek2#xlS#b^{t;j635SH*4VjT z*<#CZXO|5F$dCp79t`2(;b06m;ObIawo8j`bN;_O^Zx&%B%tP+|GVZnojSDGvFh|1 zI|h&eGrK(D8Zitwy}-`$|HbSB|394j|NrT#ubU=2AKo#?$-T4Mhhb8qH-<(G1NP2z zY6WXP6?Ab`x9hCl3ZDR=0#P6q#-$m>03hf8sxH@A9c8}B$+01(K)x;zYXPwd5c2~u zFA#G9F$WN{0Wk{@GZRe8Kt+l`EDOYvKr8~p0zk|SGl-(B3^afV01ba!p4w(>hyVZp M07*qoM6N<$f^G@~i~s-t literal 0 HcmV?d00001