diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb
index cf39898fe..af8487868 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 206421e5d..2273de4e4 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
## 新建留言
@@ -728,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/app/helpers/bids_helper.rb b/app/helpers/bids_helper.rb
index bd39d6c28..38b32e692 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/attachments/_form.html.erb b/app/views/attachments/_form.html.erb
index f34a0e4e7..f05c4e9b0 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 fe6f35fb3..6d9230a91 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
diff --git a/app/views/bids/_list_projects.html.erb b/app/views/bids/_list_projects.html.erb
index e51314c48..ce24a4457 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 %>
diff --git a/app/views/files/_new.html.erb b/app/views/files/_new.html.erb
index 4c1b97fa1..9d62ca37e 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? %>
-
<%=l(:field_version)%>
-<%= select_tag "version_id", content_tag('option', '') +
- options_from_collection_for_select(versions, "id", "name") %>
-<% end %>
+
+
+
+ <% if versions.any? %>
+ <%= l(:field_version) %>
+
+ <%= select_tag "version_id", content_tag('option', '') +
+ options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %>
+
+ <% end %>
+
+ <% if attachmenttypes.any? %>
+ <%= l(:attachment_type) %>
+
+ <%= select_tag "attachment_type",
+ options_from_collection_for_select(attachmenttypes, "id",
+ "typeName", 2), {style: 'width:100px'} %>
+
+ <% end %>
+
+
+
- <% if attachmenttypes.any? %>
-
<%=l(:attachment_type)%>
- <%= select_tag "attachment_type",
- options_from_collection_for_select(attachmenttypes, "id",
- "typeName") %>
-
- <% end %>
+
-
<%=l(:label_attachment_plural)%> <%= render :partial => 'attachments/form' %>
+
<%=l(:label_attachment_plural)%><%= render :partial => 'attachments/form' %>
<%= submit_tag l(:button_add) %>
<% end %>
diff --git a/app/views/files/_show_all_attachment.html.erb b/app/views/files/_show_all_attachment.html.erb
index 07dc6a27f..d34f95f78 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 %>
-
-
-
+
-
+
<% end -%>
diff --git a/app/views/files/_sort_by_attachtypel.html.erb b/app/views/files/_sort_by_attachtypel.html.erb
index 01c57c490..9df26d7ed 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 %>
-
-
-
-
-
-
+
+
+
+
<% end -%>
<% end -%>
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index 3d8a0e54e..666b28740 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/images/edit.png b/public/images/edit.png
new file mode 100644
index 000000000..8335716fd
Binary files /dev/null and b/public/images/edit.png differ
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 7b0a0099c..d786101b1 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;}