diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 64bfe5c40..18da32d81 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -18,7 +18,7 @@ class HomeworkAttachController < ApplicationController end def create - if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (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) + #if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (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) user_id = params[:user_id] bid_id = params[:bid_id] sta = 0 @@ -46,7 +46,7 @@ class HomeworkAttachController < ApplicationController format.json { render json: @homework.errors, status: :unprocessable_entity } end end - end + #end end def new @@ -66,7 +66,7 @@ class HomeworkAttachController < ApplicationController def update @homework = HomeworkAttach.find(params[:id]) respond_to do |format| - if @post.update_attributes(params[:homework]) + if @homework.update_attributes(params[:homework]) format.html { redirect_to @homework, notice: 'Homework was successfully updated.' } format.json { head :no_content } else @@ -77,12 +77,12 @@ class HomeworkAttachController < ApplicationController end def destroy - @homework = HomeworkAttach.find(params([:id])) - @homework.destroy - respond_to do |format| - format.html {render @homework} - format.json {render json: @homework} - end + #@homework = HomeworkAttach.find(params([:id])) + #@homework.destroy + #respond_to do |format| + # format.html {render @homework} + # format.json {render json: @homework} + #end end #显示作业信息 diff --git a/app/helpers/homework_attach_helper.rb b/app/helpers/homework_attach_helper.rb new file mode 100644 index 000000000..1abac35d6 --- /dev/null +++ b/app/helpers/homework_attach_helper.rb @@ -0,0 +1,10 @@ +module HomeworkAttachHelper + def attach_delete(project) + if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, project.bid.courses.first.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0) || project.user_id == User.current.id) + true + else + false + end + + end +end \ No newline at end of file diff --git a/app/views/bids/_homework.html.erb b/app/views/bids/_homework.html.erb index eb6b9bbf5..d9ce738d8 100644 --- a/app/views/bids/_homework.html.erb +++ b/app/views/bids/_homework.html.erb @@ -25,7 +25,8 @@ <% if User.current.logged? && (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (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) %>
+ |
作业 :
- <% attachments = homework.attachments.map %>
- <% for attachment in attachments %>
- <% if attachments.count > 1 && attachment != attachments.first %>
- - <% for item in 1..7 %> - + <% if homework.name == nil || homework.name == "" %> + <% attachments = homework.attachments.map %> + <% for attachment in attachments %> + <% if attachments.count > 1 %> + <% homework_filename = attachment.filename + "等" + attachments.count.to_s + "个文件" %> + <% else %> + <% homework_filename = attachment.filename %> <% end %> + <% end %> - <%= link_to_attachment attachment , :download => true -%> + <%= homework_filename %> + <% else %> + <%= homework.name %> <% end %> |
@@ -76,12 +87,21 @@ | |
+ | <% if is_cur_course_user? @bid %> <%= l(:label_bidding_user_studentcode) %> : <%= homework.user.user_extensions.student_id%> <% end %> | ++ <% if (User.current == homework.user) || (!Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',3,7, 9)).size >0) %> + <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> + <%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => homework}, + :remote => true, :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %> + <% end %> + |
<%=raw l(:label_new_homework)%>
++ 标 题: + <%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;"%> +
++ 描 述: + + <%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> + +
++
+ ++ + <%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%> + +
+ <% end %> +<%=raw l(:label_new_homework)%>
-- 标题: +
+ 标 题: <%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
-- 描述: +
+ 描 述: <%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
- - - <%= submit_tag t(:label_new), :sta => 0, :class => "enterprise"%> - <%= submit_tag t(:label_memo_create), :sta => 1, :class => "enterprise"%> ++
+ ++ + <%= submit_tag t(:label_button_ok), :sta => 0, :class => "enterprise"%>
<% end %> diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 9c39e84f1..2b2ec5cce 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -25,7 +25,6 @@ 发布人员:<%= link_to @homework.user, user_path(@homework.user)%>