Merge remote-tracking branch 'origin/dev_aliyun' into dev_aliyun

dev_aliyun
杨树明 5 years ago
commit 69b5afbcc9

@ -1746,22 +1746,26 @@ end
# 删除 # 删除
def delete_applied_departments def delete_applied_departments
applied_department = ApplyAddDepartment.find params[:depart_id] ActiveRecord::Base.transaction do
applied_message = AppliedMessage.where(:applied_id => applied_department.id, :applied_type => "ApplyAddDepartment") applied_department = ApplyAddDepartment.find params[:depart_id]
applied_message.update_all(:status => 3) applied_message = AppliedMessage.where(:applied_id => applied_department.id, :applied_type => "ApplyAddDepartment")
applied_department.update_attribute(:status, 3) applied_message.update_all(:status => 3)
# 未审批删除 applied_department.update_attribute(:status, 3)
if params[:tip] == "unapplied" # 未审批删除
# AppliedMessage.create(:user_id => applied_department.user_id, :status => 3, :viewed => 0, :applied_id => applied_department.id, :applied_type => "ApplyAddDepartment", :name => applied_department.name ) if params[:tip] == "unapplied"
Tiding.where(:user_id => 1, :trigger_user_id => applied_department.user_id, :container_id => applied_department.id, :container_type => 'ApplyAddDepartment', :status => 0, :tiding_type => "Apply").update_all(:status => 1) # AppliedMessage.create(:user_id => applied_department.user_id, :status => 3, :viewed => 0, :applied_id => applied_department.id, :applied_type => "ApplyAddDepartment", :name => applied_department.name )
Tiding.create(:user_id => applied_department.user_id, :trigger_user_id => 0, :container_id => applied_department.id, :container_type =>'ApplyAddDepartment', :belong_container_id => applied_department.department.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2, :extra => params[:reason]) Tiding.where(:user_id => 1, :trigger_user_id => applied_department.user_id, :container_id => applied_department.id, :container_type => 'ApplyAddDepartment', :status => 0, :tiding_type => "Apply").update_all(:status => 1)
# 删除学校的用户 Tiding.create(:user_id => applied_department.user_id, :trigger_user_id => 0, :container_id => applied_department.id, :container_type =>'ApplyAddDepartment', :belong_container_id => applied_department.department.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2, :extra => params[:reason])
users = UserExtensions.where("department_id = #{applied_department.department_id}") # 删除学校的用户
users.update_all(department_id: nil, profile_completed: false) user_exs = UserExtensions.where("department_id = #{applied_department.department_id}")
applied_department.department.destroy users = User.where(id: user_exs.pluck(:user_id))
# 已审批删除 user_exs.update_all(department_id: nil)
elsif params[:tip] == "applied" users.update_all(profile_completed: false)
applied_department.destroy applied_department.department.destroy
# 已审批删除
elsif params[:tip] == "applied"
applied_department.destroy
end
end end
respond_to do |format| respond_to do |format|
format.html{ redirect_to depart_managements_path } format.html{ redirect_to depart_managements_path }

@ -9,9 +9,9 @@ module EcMajorSchoolsHelper
subitem_ids = ec_year.ec_graduation_subitems.reorder(nil).pluck(:id) subitem_ids = ec_year.ec_graduation_subitems.reorder(nil).pluck(:id)
relations = EcGraduationRequirementCalculation.joins(ec_course_support: :ec_graduation_subitem_courses).where('ec_graduation_subitem_id in (?)', subitem_ids) relations = EcGraduationRequirementCalculation.joins(ec_course_support: :ec_graduation_subitem_courses).where('ec_graduation_subitem_courses.ec_graduation_subitem_id in (?)', subitem_ids)
reached_map = relations.where(status: true).group('ec_graduation_subitem_id').count reached_map = relations.where(status: true).group('ec_graduation_subitem_courses.ec_graduation_subitem_id').count
reached_map.keys.size reached_map.keys.size
end end

@ -11,7 +11,8 @@ class CompetitionTeam < ActiveRecord::Base
# attr_accessible :invite_code, :name, :team_type # attr_accessible :invite_code, :name, :team_type
def teacher def teacher
User.where(:id => self.teacher_id).first teacher_id = self.teachers.first&.user_id
User.where(id: teacher_id).first
end end
def group_members def group_members

@ -15,6 +15,7 @@ class CourseMember < ActiveRecord::Base
homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_type in (1, 3, 4)") homeworks = course.homework_commons.includes(:homework_detail_manual).where("homework_type in (1, 3, 4)")
if homeworks.count != 0 if homeworks.count != 0
homeworks.each do |hw| homeworks.each do |hw|
next if hw.student_works.where(user_id: user_id).any?
str += "," if str != "" str += "," if str != ""
str += "('#{hw.name}的作品提交',#{hw.id},#{user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" str += "('#{hw.name}的作品提交',#{hw.id},#{user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end end
@ -34,6 +35,7 @@ class CourseMember < ActiveRecord::Base
exercises = course.exercises exercises = course.exercises
if exercises.count != 0 if exercises.count != 0
exercises.each do |ex| exercises.each do |ex|
next if ex.exercise_users.where(user_id: user_id).any?
str += "," if str != "" str += "," if str != ""
str += "(#{ex.id},#{user_id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" str += "(#{ex.id},#{user_id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end end
@ -53,6 +55,7 @@ class CourseMember < ActiveRecord::Base
polls = course.polls polls = course.polls
if polls.count != 0 if polls.count != 0
polls.each do |poll| polls.each do |poll|
next if poll.poll_users.where(user_id: user_id).any?
str += "," if str != "" str += "," if str != ""
str += "(#{poll.id},#{user_id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" str += "(#{poll.id},#{user_id}, 0, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end end
@ -72,6 +75,7 @@ class CourseMember < ActiveRecord::Base
tasks = course.graduation_tasks tasks = course.graduation_tasks
if tasks.count != 0 if tasks.count != 0
tasks.each do |task| tasks.each do |task|
next if task.graduation_works.where(user_id: user_id).any?
str += "," if str != "" str += "," if str != ""
str += "(#{task.id}, #{user_id}, #{course.id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')" str += "(#{task.id}, #{user_id}, #{course.id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end end

@ -119,6 +119,10 @@ class Message < ActiveRecord::Base
message_detail.try(:content) message_detail.try(:content)
end end
def content
message_detail.try(:content)
end
# def content # def content
# self.try(:content) # self.try(:content)
# end # end

@ -5,16 +5,16 @@
<% if User.current.admin? || ((delete_allowed || User.current.id == file.author_id) && file.container_id == project.id && file.container_type == "Project") %> <% if User.current.admin? || ((delete_allowed || User.current.id == file.author_id) && file.container_id == project.id && file.container_type == "Project") %>
<i class="fa fa-align-justify color-grey-9"> <i class="fa fa-align-justify color-grey-9">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
<% if hidden_unproject_infos %> <%# if hidden_unproject_infos %>
<li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li> <!-- <li><%#= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li>-->
<% else %> <%# else %>
<li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li> <!-- <li><%#= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li>-->
<% end %> <%# end %>
<% if params[:tag_name].blank? %> <%# if params[:tag_name].blank? %>
<li><%= link_to '更新版本',attachments_versions_path(file, :project_id => project.id), :class => "postOptionLink", :remote => true %></li> <!-- <li><%#= link_to '更新版本',attachments_versions_path(file, :project_id => project.id), :class => "postOptionLink", :remote => true %></li>-->
<% else %> <%# else %>
<li><%= link_to '更新版本',attachments_versions_path(file, :tag_name => params[:tag_name].force_encoding("UTF-8"), :project_id => project.id, :other => params[:other]),:class => "postOptionLink",:remote=>true %></li> <!-- <li><%#= link_to '更新版本',attachments_versions_path(file, :tag_name => params[:tag_name].force_encoding("UTF-8"), :project_id => project.id, :other => params[:other]),:class => "postOptionLink",:remote=>true %></li>-->
<% end %> <%# end %>
<% if project.is_public? %> <% if project.is_public? %>
<li> <li>
@ -38,15 +38,15 @@
</i> </i>
<% end %> <% end %>
<% else %> <% else %>
<i class="fa fa-align-justify color-grey-9"> <!-- <i class="fa fa-align-justify color-grey-9">-->
<ul class="resourceSendO"> <!-- <ul class="resourceSendO">-->
<% if hidden_unproject_infos %> <%# if hidden_unproject_infos %>
<li><%= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li> <!-- <li><%#= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li>-->
<% else %> <%# else %>
<li><%= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li> <!-- <li><%#= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li>-->
<% end %> <%# end %>
</ul> <!-- </ul>-->
</i> <!-- </i>-->
<% end %> <% end %>
<% end %> <% end %>
</li> </li>

@ -0,0 +1,16 @@
class MigrateDeleteDepartment < ActiveRecord::Migration
def up
ApplyAddDepartment.where("status= 3 and created_at > '2019-07-25 00:00:00'").each do |apply|
if apply.department.present? && !apply.department.is_auth
user_exs = UserExtensions.where("department_id = #{apply.department_id}")
users = User.where(id: user_exs.pluck(:user_id))
user_exs.update_all(department_id: nil)
users.update_all(profile_completed: false)
apply.department.destroy
end
end
end
def down
end
end
Loading…
Cancel
Save