分班权限的签到调整

PCqiandao
cxt 5 years ago
parent ba2e65b086
commit 35b8a229bd

@ -9,8 +9,10 @@ class Weapps::AttendancesController < ApplicationController
def create
ActiveRecord::Base.transaction do
attendance = @course.course_attendances.create!(create_params.merge(user_id: current_user.id))
unless params[:group_ids].blank? || @course.course_groups.where(id: params[:group_ids]).count == @course.course_groups.count
group_ids = @course.charge_group_ids(current_user) & params[:group_ids].map(&:to_i)
group_ids = params[:group_ids] || []
group_ids = group_ids.blank? ? @course.charge_group_ids(current_user) : @course.charge_group_ids(current_user) & params[:group_ids].map(&:to_i)
unless group_ids.blank? || @course.course_groups.where(id: group_ids).count == @course.course_groups.count
# group_ids = @course.charge_group_ids(current_user) & params[:group_ids].map(&:to_i)
group_ids.each do |group_id|
@course.course_attendance_groups.create!(course_group_id: group_id, course_attendance: attendance)
end

Loading…
Cancel
Save