角色的修改

This commit is contained in:
cxt 2016-07-29 16:27:02 +08:00
parent a1a2b3dd33
commit a1553c7a8f
3 changed files with 2 additions and 28 deletions

View File

@ -158,7 +158,7 @@ class MembersController < ApplicationController
role_ids = attrs.delete(:role_ids)
#role = Role.find(params[:membership][:role_ids])
# 这里的判断只能通过角色名,可以弄成常量
if role_ids && !role_ids.include?("9") && role_ids.include?("10")
if role_ids && role_ids.include?("10")
StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id)
end
@ -257,7 +257,7 @@ class MembersController < ApplicationController
attrs = params[:membership].dup
role_ids = attrs.delete(:role_ids)
if role_ids && !role_ids.include?("9") && role_ids.include?("10")
if role_ids && role_ids.include?("10")
StudentsForCourse.create(:student_id => @member.user_id, :course_id =>@course.id)
else
joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id)

View File

@ -52,7 +52,6 @@
<script>
$(function() {
$("#add_member_checkbox_7").on('click', function(){
$("#add_member_checkbox_10").attr("checked",$("#add_member_checkbox_7").is(":checked"));
if($("#add_member_checkbox_7").is(":checked")) {
$("#add_member_checkbox_9").attr('disabled', 'disabled');
} else {
@ -60,23 +59,11 @@
}
});
$("#add_member_checkbox_9").on('click', function(){
$("#add_member_checkbox_10").attr("checked",$("#add_member_checkbox_9").is(":checked"));
if($("#add_member_checkbox_9").is(":checked")) {
$("#add_member_checkbox_7").attr('disabled', 'disabled');
} else {
$("#add_member_checkbox_7").removeAttr('disabled');
}
});
$("#add_member_checkbox_10").on('click', function(){
if($("#add_member_checkbox_10").is(":checked")) {
$("#add_member_checkbox_7").removeAttr('disabled');
$("#add_member_checkbox_9").removeAttr('disabled');
} else {
$("#add_member_checkbox_7").removeAttr('disabled');
$("#add_member_checkbox_9").removeAttr('disabled');
$("#add_member_checkbox_7").attr("checked",false);
$("#add_member_checkbox_9").attr("checked",false);
}
});
});
</script>

View File

@ -39,7 +39,6 @@
<script>
$(function() {
$("#edit_member_role_<%=member.id %>_7").on('click', function(){
$("#edit_member_role_<%=member.id %>_10").attr("checked",$("#edit_member_role_<%=member.id %>_7").is(":checked"));
if($("#edit_member_role_<%=member.id %>_7").is(":checked")) {
$("#edit_member_role_<%=member.id %>_9").attr("checked",false);
$("#edit_member_role_<%=member.id %>_9").attr('disabled', 'disabled');
@ -48,7 +47,6 @@
}
});
$("#edit_member_role_<%=member.id %>_9").on('click', function(){
$("#edit_member_role_<%=member.id %>_10").attr("checked",$("#edit_member_role_<%=member.id %>_9").is(":checked"));
if($("#edit_member_role_<%=member.id %>_9").is(":checked")) {
$("#edit_member_role_<%=member.id %>_7").attr('disabled', 'disabled');
$("#edit_member_role_<%=member.id %>_7").attr("checked",false);
@ -56,17 +54,6 @@
$("#edit_member_role_<%=member.id %>_7").removeAttr('disabled');
}
});
$("#edit_member_role_<%=member.id %>_10").on('click', function(){
if($("#edit_member_role_<%=member.id %>_10").is(":checked")) {
$("#edit_member_role_<%=member.id %>_7").removeAttr('disabled');
$("#edit_member_role_<%=member.id %>_9").removeAttr('disabled');
} else {
$("#edit_member_role_<%=member.id %>_7").removeAttr('disabled');
$("#edit_member_role_<%=member.id %>_9").removeAttr('disabled');
$("#edit_member_role_<%=member.id %>_7").attr("checked",false);
$("#edit_member_role_<%=member.id %>_9").attr("checked",false);
}
});
});
</script>
<% end%>