Merge remote-tracking branch 'origin/szzh' into szzh

This commit is contained in:
sw 2014-05-17 11:15:40 +08:00
commit 4c6b514d03
12 changed files with 74 additions and 48 deletions

View File

@ -276,10 +276,18 @@ class AccountController < ApplicationController
set_autologin_cookie(user) set_autologin_cookie(user)
end end
call_hook(:controller_account_success_authentication_after, {:user => user }) call_hook(:controller_account_success_authentication_after, {:user => user })
#by young
# redirect_back_or_default my_page_path code = /\d*/
redirect_back_or_default User.current #根据home_url生产正则表达式
# redirect_to User.current 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 end
def set_autologin_cookie(user) def set_autologin_cookie(user)

View File

@ -18,6 +18,8 @@ class BidsController < ApplicationController
helper :attachments helper :attachments
include AttachmentsHelper include AttachmentsHelper
include ApplicationHelper include ApplicationHelper
include BidsHelper
helper :projects helper :projects
helper :words helper :words
helper :welcome helper :welcome
@ -503,10 +505,12 @@ class BidsController < ApplicationController
#删除已提交的项目作业(不删项目) #删除已提交的项目作业(不删项目)
def delete def delete
binding_project = params[:binding_project] binding_project = params[:binding_project]
if BidingProject.delete(binding_project) if can_delete_project_homework(BidingProject.find(binding_project),User.current)
redirect_to project_for_bid_path if BidingProject.delete(binding_project)
else redirect_to project_for_bid_path
redirect_to 403; else
redirect_to 403;
end
end end
end end
## 新建留言 ## 新建留言
@ -728,9 +732,9 @@ class BidsController < ApplicationController
def update def update
@bid = Bid.find(params[:id]) @bid = Bid.find(params[:id])
@project = @bid.courses.first#Project.find(params[:course_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) flash[:notice] = l(:label_update_homework_succeed)
#@project = Project.find(params[:course_id])
redirect_to project_homework_path(@project) redirect_to project_homework_path(@project)
else else
@bid.safe_attributes = params[:bid] @bid.safe_attributes = params[:bid]

View File

@ -151,4 +151,8 @@ module BidsHelper
tmp tmp
end end
def can_delete_project_homework bind_project,current_user
current_user.id == bind_project.user.id || current_user.admin
end
end end

View File

@ -1,10 +1,10 @@
<span id="attachments_fields"> <span id="attachments_fields">
<% if defined?(container) && container && container.saved_attachments %> <% if defined?(container) && container && container.saved_attachments %>
<% container.saved_attachments.each_with_index do |attachment, i| %> <% container.attachments.each_with_index do |attachment, i| %>
<span id="attachments_p<%= i %>"> <span id="attachments_p<%= i %>" class="attachment">
<span style="width:100px;"><%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename', :maxlength => 10)%> <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
</span>
<%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 155, :placeholder => l(:label_optional_description), :class => 'description') + <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 255, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") +
link_to('&nbsp;'.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') %> link_to('&nbsp;'.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}" %> <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
</span> </span>

View File

@ -37,5 +37,5 @@
<p><%= hidden_field_tag 'course_id', @project_id %> <p><%= hidden_field_tag 'course_id', @project_id %>
</p> </p>
<fieldset><legend><%= l(:label_attachment_plural) %></legend> <fieldset><legend><%= l(:label_attachment_plural) %></legend>
<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p> <p><%= render :partial => 'attachments/form', :locals => {:container => @bid} %></p>
</fieldset> </fieldset>

View File

@ -154,9 +154,9 @@
<% end %> <% end %>
</td> </td>
<td align="right"> <td align="right">
<% 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 %> <% end %>
</td> </td>
</tr> </tr>

View File

@ -5,21 +5,32 @@
<%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %> <%= form_tag(project_files_path(project), :multipart => true, :class => "tabular") do %>
<div class="box"> <div class="box">
<% if versions.any? %> <p>
<p><label for="version_id"><%=l(:field_version)%></label> <table>
<%= select_tag "version_id", content_tag('option', '') + <tr>
options_from_collection_for_select(versions, "id", "name") %></p> <% if versions.any? %>
<% end %> <td><p><%= l(:field_version) %></p></td>
<td>
<%= select_tag "version_id", content_tag('option', '') +
options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %>
</td>
<% end %>
<% if attachmenttypes.any? %> <% if attachmenttypes.any? %>
<p> <label for="attachment_type"><%=l(:attachment_type)%></label> <td><%= l(:attachment_type) %></label></td>
<%= select_tag "attachment_type", <td>
options_from_collection_for_select(attachmenttypes, "id", <%= select_tag "attachment_type",
"typeName") %> options_from_collection_for_select(attachmenttypes, "id",
</p> "typeName", 2), {style: 'width:100px'} %>
<% end %> </td>
<% end %>
</tr>
</table>
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
</p>
<p><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
</div> </div>
<%= submit_tag l(:button_add) %> <%= submit_tag l(:button_add) %>
<% end %> <% end %>

View File

@ -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('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('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('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('tags', :caption => l(:label_tag), :id => "vzebra-tag") %>
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> --> <!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
</tr> </tr>
</thead> </thead>
@ -51,15 +52,14 @@
<%= link_to(image_tag('delete.png'), attachment_path(file), <%= link_to(image_tag('delete.png'), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</td> </td>
</tr> <td class='filename' style="font-size: 13px; ">
<tr>
<td class='description' colspan="6">
<div class="tags_area"> <div class="tags_area">
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
<div class="tags_gradint"></div> <div class="tags_gradint"></div>
</div> </div>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div> <div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a>
</div>
</td> </td>
</tr> </tr>
<% end -%> <% end -%>

View File

@ -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('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('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('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
<%= sort_header_tag('tags', :caption => l(:label_tag), :id => "vzebra-tag") %>
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> --> <!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
</tr> </tr>
</thead> </thead>
@ -47,17 +48,15 @@
<%= link_to(image_tag('delete.png'), attachment_path(file), <%= link_to(image_tag('delete.png'), attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
</td> </td>
</tr> <td class='filename' style="font-size: 13px; ">
<tr> <div class="tags_area">
<td class='description' colspan="6"> <%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
<div class="tags_area"> <%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %> <div class="tags_gradint"></div>
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %> </div>
<div class="tags_gradint"></div> <div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a>
</div> </div>
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a> </td>
</div>
</td>
</tr> </tr>
<% end -%> <% end -%>
<% end -%> <% end -%>

View File

@ -143,7 +143,7 @@ zh:
attachment_all: "全部" attachment_all: "全部"
attachment_sufix_browse: "文件类型" attachment_sufix_browse: "文件类型"
attachment_browse: "内容类型" attachment_browse: "内容类型"
attachment_type: '资源分类' attachment_type: '分类'
general_text_No: '否' general_text_No: '否'
general_text_Yes: '是' general_text_Yes: '是'
general_text_no: '否' general_text_no: '否'

BIN
public/images/edit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 B

View File

@ -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.size { text-align: right; font-size: 90%; }
tr.entry td.revision, tr.entry td.author { text-align: center; } tr.entry td.revision, tr.entry td.author { text-align: center; }
tr.entry td.age { text-align: right; } 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.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;} tr span.expander {background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;}