如果当前用户已经提交过作业就不显示新增作业按钮

This commit is contained in:
sw 2014-06-04 09:55:38 +08:00
parent 66c9de94a8
commit 29ac5ff12a
2 changed files with 10 additions and 3 deletions

View File

@ -157,4 +157,9 @@ module CoursesHelper
end
people.include?(User.current)
end
#获取当前用户在指定作业下提交的作业的集合
def cur_user_homework_for_bid bid
cur_user_homework = HomeworkAttach.where("user_id = ? and bid_id = ?",User.current,params[:id])
cur_user_homework
end
end

View File

@ -13,17 +13,19 @@
<% end %>
<script type="text/javascript">
function j_submit () {
alert('start')
alert('start');
var submit_homework = function(){
$('#add_homework_form').clone().attr('action', '<%= url_for({:controller => "bids", :action => "add_homework"})+".js" %>').ajaxSubmit()
};
alert('stop')
alert('stop');
$.globalEval(submit_homework());
return false;
}
</script>
</div>
<% 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) && cur_user_homework_for_bid(@bid).count == 0 %>
<div class='icon icon-add'>
<!-- <%= link_to l(:label_commit_homework), new_submit_homework_path, :onclick => "$('#put-bid-form').slideToggle(); this.blur(); return false;" %> -->
<%= link_to l(:label_course_new_homework),new_homework_attach_path %>