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
applied_department = ApplyAddDepartment.find params[:depart_id]
applied_message = AppliedMessage.where(:applied_id => applied_department.id, :applied_type => "ApplyAddDepartment")
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 )
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)
applied_department.department.destroy
# 已审批删除
elsif params[:tip] == "applied"
applied_department.destroy
ActiveRecord::Base.transaction do
applied_department = ApplyAddDepartment.find params[:depart_id]
applied_message = AppliedMessage.where(:applied_id => applied_department.id, :applied_type => "ApplyAddDepartment")
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 )
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])
# 删除学校的用户
user_exs = UserExtensions.where("department_id = #{applied_department.department_id}")
users = User.where(id: user_exs.pluck(:user_id))
user_exs.update_all(department_id: nil)
users.update_all(profile_completed: false)
applied_department.department.destroy
# 已审批删除
elsif params[:tip] == "applied"
applied_department.destroy
end
end
respond_to do |format|
format.html{ redirect_to depart_managements_path }

@ -9,9 +9,9 @@ module EcMajorSchoolsHelper
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
end

@ -11,7 +11,8 @@ class CompetitionTeam < ActiveRecord::Base
# attr_accessible :invite_code, :name, :team_type
def teacher
User.where(:id => self.teacher_id).first
teacher_id = self.teachers.first&.user_id
User.where(id: teacher_id).first
end
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)")
if homeworks.count != 0
homeworks.each do |hw|
next if hw.student_works.where(user_id: user_id).any?
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')}')"
end
@ -34,6 +35,7 @@ class CourseMember < ActiveRecord::Base
exercises = course.exercises
if exercises.count != 0
exercises.each do |ex|
next if ex.exercise_users.where(user_id: user_id).any?
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')}')"
end
@ -53,6 +55,7 @@ class CourseMember < ActiveRecord::Base
polls = course.polls
if polls.count != 0
polls.each do |poll|
next if poll.poll_users.where(user_id: user_id).any?
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')}')"
end
@ -72,6 +75,7 @@ class CourseMember < ActiveRecord::Base
tasks = course.graduation_tasks
if tasks.count != 0
tasks.each do |task|
next if task.graduation_works.where(user_id: user_id).any?
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')}')"
end

@ -119,6 +119,10 @@ class Message < ActiveRecord::Base
message_detail.try(:content)
end
def content
message_detail.try(:content)
end
# def content
# self.try(:content)
# 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") %>
<i class="fa fa-align-justify color-grey-9">
<ul class="homepagePostSettiongText">
<% 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>
<% 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>
<% end %>
<% if params[:tag_name].blank? %>
<li><%= link_to '更新版本',attachments_versions_path(file, :project_id => project.id), :class => "postOptionLink", :remote => true %></li>
<% 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>
<% end %>
<%# 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>-->
<%# 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>-->
<%# end %>
<%# if params[:tag_name].blank? %>
<!-- <li><%#= link_to '更新版本',attachments_versions_path(file, :project_id => project.id), :class => "postOptionLink", :remote => true %></li>-->
<%# 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>-->
<%# end %>
<% if project.is_public? %>
<li>
@ -38,15 +38,15 @@
</i>
<% end %>
<% else %>
<i class="fa fa-align-justify color-grey-9">
<ul class="resourceSendO">
<% 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>
<% else %>
<li><%= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li>
<% end %>
</ul>
</i>
<!-- <i class="fa fa-align-justify color-grey-9">-->
<!-- <ul class="resourceSendO">-->
<%# 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>-->
<%# else %>
<!-- <li><%#= link_to("发&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send_hidden('#{file.id}','#{User.current.id}','file')") %></li>-->
<%# end %>
<!-- </ul>-->
<!-- </i>-->
<% end %>
<% end %>
</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