diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index dfe8b9b0..2b0ed762 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -20,6 +20,17 @@ class BidsController < ApplicationController include ApplicationHelper helper :projects helper :words + helper :welcome + + def homework_ajax_modal + @bid = Bid.find_by_id(params[:id]) + # find_bid + respond_to do |format| + format.js + end + end + + def index @project_type = params[:project_type] # Modified by nie diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7bdb1918..0ad4404d 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1474,8 +1474,20 @@ module ApplicationHelper def hadcommittedhomework(cur,curb) - attaches = HomeworkAttach.where(bid_id: curb) - attaches.map(&:user_id).include? cur + bid = Bid.find_by_id(curb) + return true if bid.nil? + + case bid.homework_type + when Bid::HomeworkFile + attaches = HomeworkAttach.where(bid_id: curb) + attaches.map(&:user_id).include? cur + when Bid::HomeworkProject + attaches = BidingProject.where(user_id: User.current, bid_id: bid) + attaches.count > 0 # > 0 则有提交记录 + else + true + end + end def render_dynamic_nav diff --git a/app/helpers/attachments_helper.rb b/app/helpers/attachments_helper.rb index 7d5db301..495c0508 100644 --- a/app/helpers/attachments_helper.rb +++ b/app/helpers/attachments_helper.rb @@ -70,15 +70,6 @@ module AttachmentsHelper User.current.logged? && (container.author == user || user.admin?) end - def hadcommittedhomework(cur,curb) - @attaches=HomeworkAttach.find_by_sql("select * from homework_attaches where(bid_id = #{curb})") - @attaches.each do |attach| - if attach.user_id == cur - retrun true - end - end - end - # this method is used to get all projects that tagged one tag # added by william def get_attachments_by_tag(tag_name) diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index b0f62bc9..27766e41 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -14,9 +14,7 @@ <%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %> <%# 提交作业按钮,上传文件的作业直接显示上传框,关联项目的作业跳转到新页面 %> - <%= link_to "模态窗口", '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id});" if Rails.env.development? %> - <%= link_to l(:label_commit_homework), 'javascript:void(0);', onclick: "$('#bid-submit-homework-#{bid.id}').toggle();" if bid.homework_type==Bid::HomeworkFile %> - <%= link_to(l(:label_commit_homework), respond_path(bid), :class => 'bid_path', target: "_blank") if bid.homework_type==Bid::HomeworkProject %> + <%= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if Rails.env.development? %> <% if (User.current.admin?||User.current.id==bid.author_id) %> <%= link_to( l(:button_edit), @@ -63,12 +61,7 @@ <%= bid.description %> - - <%# 提交作业partial %> - - <%= render partial: 'homeworkupload', locals: {bid: bid} %> - - + <%= l(:label_create_time) %> : <%=format_time bid.created_on %> <%= l(:field_deadline) %> : <%=bid.deadline %> diff --git a/app/views/bids/homework_ajax_modal.js.erb b/app/views/bids/homework_ajax_modal.js.erb new file mode 100644 index 00000000..c95e4aad --- /dev/null +++ b/app/views/bids/homework_ajax_modal.js.erb @@ -0,0 +1,3 @@ +$('#OpenWindow-content').html(' <%= + j(render partial: "projects/homeworkupload", locals: {bid: @bid}) + %>'); \ No newline at end of file diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index 6de055d0..422f2dbd 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -1,4 +1,5 @@ +