diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 7d7861c1..aeaf19b4 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -715,13 +715,20 @@ class BidsController < ApplicationController end def add_homework - # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) - # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) - @homework = HomeworkAttach.new - @homework.bid_id = @bid.id - @homework.user_id = User.current.id - @homework.save_attachments(params[:attachments]) - @homework.save + 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) + # homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id) + # homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads])) + @homework = HomeworkAttach.new + @homework.bid_id = @bid.id + @homework.user_id = User.current.id + @homework.save_attachments(params[:attachments]) + @homework.save + if @homework.attachments.empty? + @homework.delete + flash[:error] = l(:no_attachmens_allowed) + # else + end + end @homework_list = @bid.homeworks end diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 0140d667..cfda02be 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -1311,6 +1311,8 @@ zh: button_bidding: 我要参加 field_enterprise: '企业:' + no_attachmens_allowed: 提交作业不能为空 + button_bidding_homework: 参加竞标 #huang field_homework_type: 提交形式 #bai label_homework_respond: 作业情况