<commit_before>ActiveAdmin.register LegalCase do
	menu :label => "Legal Cases"

	# scope :film_maker, joins(:roles).where('roles.name = ?', "Film Maker")
	
	controller do
		def new
			@legal_case = LegalCase.new
			@legal_case.build_court_decision
			@legal_case.build_court_decision_detail
			@legal_case.build_original_resource
			@legal_case.build_derivative_resource
		end
	end

	index do 
		column :id, :sortable => :id do |legal_case|
    		link_to legal_case.id, admin_legal_case_path(legal_case)	
  		end	
	    column :title do |legal_case|
    		link_to legal_case.title, admin_legal_case_path(legal_case)
    	end
    	column "Original" do |legal_case|
    		image_tag(legal_case.original_resource.source.url(:thumb), :height => '50')
  		end
  		column "Derivative" do |legal_case|
    		image_tag(legal_case.derivative_resource.source.url(:thumb), :height => '50')
  		end
  		column "Status" do |legal_case|
    		if legal_case.court_decision.get_result == true
    			status_tag "Fair Use" , :ok
    		elsif legal_case.court_decision.get_result == false
    			status_tag "Not Fair Use" , :error
    		else
    			status_tag "Undecided"  , :warning
    		end
  		end			
	    default_actions
  	end
  	filter :title
  	filter :facts
  	

	form do |f|
		f.inputs "Basic Details" do
	    	f.input :title
	    	f.input :facts
	    end

	    f.inputs "Original Resource", :for => :original_resource do |o|
	    	o.input :source, :hint => o.template.image_tag(o.object.source.url(:thumb)), :label => "Original Copy", :required => true 	
	    end
	     f.inputs "Derivative Resource", :for => :derivative_resource do |d|
	    	d.input :source, :hint => d.template.image_tag(d.object.source.url(:thumb)), :label => "Derivative Copy", :required => true 
	    end

	    f.inputs "Characters" do
	    	f.input :roles, :label => "Check corresponding roles", :as => :check_boxes, :collection => Role.all
	    end
	    
		f.inputs :name => "Court Decision", :for => :court_decision do |c|
	    	c.input :purpose_id, :as => :select, :collection => Hash[Question.all[0].answers.map{|a| [a.content,a.id]}]
	    	c.input :character_id, :as => :select, :collection => Hash[Question.all[1].answers.map{|a| [a.content,a.id]}]
	    	c.input :use_id, :as => :select, :collection => Hash[Question.all[2].answers.map{|a| [a.content,a.id]}]
	    	c.input :nature_id, :as => :select, :collection => Hash[Question.all[3].answers.map{|a| [a.content,a.id]}]
	    	c.input :amount_id, :as => :select, :collection => Hash[Question.all[4].answers.map{|a| [a.content,a.id]}]
	    	c.input :financial_id, :as => :select, :collection => Hash[Question.all[5].answers.map{|a| [a.content,a.id]}]
	    	c.input :result, :as => :select, :collection => { "Fair"=> true, "Not Fair" => false, "Undecided" => nil }
	    end	
	    
	    f.inputs :name => "Decision Details", :for => :court_decision_detail do |dd|
	    		dd.input :purpose
	    		dd.input :character
	    		dd.input :use
	    		dd.input :nature
	    		dd.input :amount
	    		dd.input :financial
	    end
	    f.buttons
	end

	show :title => :title do
  		panel "Basic Details" do
    		attributes_table_for legal_case do
    			row("Title") { legal_case.title }
				row("Facts") { legal_case.facts }
				row("Status") do
					if legal_case.court_decision.get_result == true
    					status_tag "Fair Use" , :ok
    				elsif legal_case.court_decision.get_result == false
    					status_tag "Not Fair Use" , :error
    				else
    					status_tag "Undecided"  , :warning
    				end
				end
			end
  		end
  		panel "Resources" do
  			attributes_table_for legal_case do
  				row("Original Resource") do
          			image_tag(legal_case.original_resource.source.url(:thumb))
        		end
        		row("Derivative Resource") do
          			image_tag(legal_case.derivative_resource.source.url(:thumb))
        		end
  			end	
  		end
  		panel "Characters" do
	    	table_for legal_case.roles do |t|
	      		t.column("Corresponding Roles to this Case ") { |role| link_to role.name, admin_role_path(role)  }
	    	end
 		end
  		panel "Court Decision Details" do<commit_msg>result rather than get_result<commit_after>ActiveAdmin.register LegalCase do
	menu :label => "Legal Cases"

	# scope :film_maker, joins(:roles).where('roles.name = ?', "Film Maker")
	
	controller do
		def new
			@legal_case = LegalCase.new
			@legal_case.build_court_decision
			@legal_case.build_court_decision_detail
			@legal_case.build_original_resource
			@legal_case.build_derivative_resource
		end
	end

	index do 
		column :id, :sortable => :id do |legal_case|
    		link_to legal_case.id, admin_legal_case_path(legal_case)	
  		end	
	    column :title do |legal_case|
    		link_to legal_case.title, admin_legal_case_path(legal_case)
    	end
    	column "Original" do |legal_case|
    		image_tag(legal_case.original_resource.source.url(:thumb), :height => '50')
  		end
  		column "Derivative" do |legal_case|
    		image_tag(legal_case.derivative_resource.source.url(:thumb), :height => '50')
  		end
  		column "Status" do |legal_case|
    		if legal_case.court_decision.result == true
    			status_tag "Fair Use" , :ok
    		elsif legal_case.court_decision.result == false
    			status_tag "Not Fair Use" , :error
    		else
    			status_tag "Undecided"  , :warning
    		end
  		end			
	    default_actions
  	end
  	filter :title
  	filter :facts
  	

	form do |f|
		f.inputs "Basic Details" do
	    	f.input :title
	    	f.input :facts
	    end

	    f.inputs "Original Resource", :for => :original_resource do |o|
	    	o.input :source, :hint => o.template.image_tag(o.object.source.url(:thumb)), :label => "Original Copy", :required => true 	
	    end
	     f.inputs "Derivative Resource", :for => :derivative_resource do |d|
	    	d.input :source, :hint => d.template.image_tag(d.object.source.url(:thumb)), :label => "Derivative Copy", :required => true 
	    end

	    f.inputs "Characters" do
	    	f.input :roles, :label => "Check corresponding roles", :as => :check_boxes, :collection => Role.all
	    end
	    
		f.inputs :name => "Court Decision", :for => :court_decision do |c|
	    	c.input :purpose_id, :as => :select, :collection => Hash[Question.all[0].answers.map{|a| [a.content,a.id]}]
	    	c.input :character_id, :as => :select, :collection => Hash[Question.all[1].answers.map{|a| [a.content,a.id]}]
	    	c.input :use_id, :as => :select, :collection => Hash[Question.all[2].answers.map{|a| [a.content,a.id]}]
	    	c.input :nature_id, :as => :select, :collection => Hash[Question.all[3].answers.map{|a| [a.content,a.id]}]
	    	c.input :amount_id, :as => :select, :collection => Hash[Question.all[4].answers.map{|a| [a.content,a.id]}]
	    	c.input :financial_id, :as => :select, :collection => Hash[Question.all[5].answers.map{|a| [a.content,a.id]}]
	    	c.input :result, :as => :select, :collection => { "Fair"=> true, "Not Fair" => false, "Undecided" => nil }
	    end	
	    
	    f.inputs :name => "Decision Details", :for => :court_decision_detail do |dd|
	    		dd.input :purpose
	    		dd.input :character
	    		dd.input :use
	    		dd.input :nature
	    		dd.input :amount
	    		dd.input :financial
	    end
	    f.buttons
	end

	show :title => :title do
  		panel "Basic Details" do
    		attributes_table_for legal_case do
    			row("Title") { legal_case.title }
				row("Facts") { legal_case.facts }
				row("Status") do
					if legal_case.court_decision.result == true
    					status_tag "Fair Use" , :ok
    				elsif legal_case.court_decision.result == false
    					status_tag "Not Fair Use" , :error
    				else
    					status_tag "Undecided"  , :warning
    				end
				end
			end
  		end
  		panel "Resources" do
  			attributes_table_for legal_case do
  				row("Original Resource") do
          			image_tag(legal_case.original_resource.source.url(:thumb))
        		end
        		row("Derivative Resource") do
          			image_tag(legal_case.derivative_resource.source.url(:thumb))
        		end
  			end	
  		end
  		panel "Characters" do
	    	table_for legal_case.roles do |t|
	      		t.column("Corresponding Roles to this Case ") { |role| link_to role.name, admin_role_path(role)  }
	    	end
 		end
  		panel "Court Decision Details" do
{'fraction_non_alphanumeric': 0.13080476537806954, 'fraction_numerical': 0.0024313153415998056, 'mean_word_length': 2.932600382409178, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 77, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4591576', 'n_tokens_mistral': 3228, 'n_tokens_neox': 2913, 'n_words': 638}