50 lines
2.7 KiB
Ruby
50 lines
2.7 KiB
Ruby
class ShieldActivitiesController < ApplicationController
|
|
def create
|
|
if params[:org_id]
|
|
if params[:project_id]
|
|
ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
|
|
elsif params[:course_id]
|
|
ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Course', :shield_id => params[:course_id].to_i)
|
|
end
|
|
elsif params[:user_id]
|
|
if params[:project_id]
|
|
ShieldActivity.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
|
|
elsif params[:course_id]
|
|
ShieldActivity.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Course', :shield_id => params[:course_id].to_i)
|
|
elsif params[:contest_id]
|
|
ShieldActivity.create(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Contest', :shield_id => params[:contest_id].to_i)
|
|
end
|
|
end
|
|
end
|
|
|
|
def show_acts
|
|
if params[:org_id]
|
|
if params[:project_id]
|
|
ShieldActivity.where("container_type='Organization' and container_id=#{params[:org_id].to_i} and shield_type='Project' and shield_id=#{params[:project_id]}").each do |act|
|
|
act.destroy
|
|
end
|
|
# ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
|
|
elsif params[:course_id]
|
|
ShieldActivity.where("container_type='Organization' and container_id=#{params[:org_id].to_i} and shield_type='Course' and shield_id=#{params[:course_id]}").each do |act|
|
|
act.destroy
|
|
end
|
|
end
|
|
elsif params[:user_id]
|
|
if params[:project_id]
|
|
ShieldActivity.where("container_type='User' and container_id=#{params[:user_id].to_i} and shield_type='Project' and shield_id=#{params[:project_id]}").each do |act|
|
|
act.destroy
|
|
end
|
|
# ShieldActivity.create(:container_type => 'Organization', :container_id => params[:org_id].to_i, :shield_type => 'Project', :shield_id => params[:project_id].to_i)
|
|
elsif params[:course_id]
|
|
ShieldActivity.where("container_type='User' and container_id=#{params[:user_id].to_i} and shield_type='Course' and shield_id=#{params[:course_id]}").each do |act|
|
|
act.destroy
|
|
end
|
|
elsif params[:contest_id]
|
|
ShieldActivity.where(:container_type => 'User', :container_id => params[:user_id].to_i, :shield_type => 'Contest', :shield_id => params[:contest_id].to_i).each do |act|
|
|
act.destroy
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|