<commit_before>require 'jira_lib/jira_interface.rb'

class ProjectsController < ApplicationController
	skip_before_filter :login_required, :only => [:index, :show]

  before_filter :get_project, :only => [:show, :edit, :update, :destroy]
  before_filter :get_terms_and_conditions_text, :only => [:new, :create]
  
  deny :show, :edit, :update, :destroy, :exec => :project_unapproved_and_user_not_site_admin?, :redirect_to => :projects
  deny :show, :edit, :update, :destroy, :exec => :project_private_and_user_not_member?, :redirect_to => :projects
  
#  allow :new, :create, :user => :is_registered_user?, :redirect_to => '/forge'
  allow :index, :new, :create, :user => :is_company_employee?, :redirect_to => '/forge'
  
  allow :edit, :update, :user => :is_project_administrator_for?, :redirect_to => :project
  allow :destroy, :user => :is_site_admin?, :redirect_to => :project

  def index
    @tags = Project.tag_counts
    @levels = (1 .. 5).map { |i| "level-#{i}" }
    
    if params[:show_search_form]
      @advanced_search = false
      search_params = { "order_by" => "name", "order_as" => "ASC" }
      search_params.merge!(params[:search]) if params[:search]
      search_params.delete("conditions")
      
      if current_user.is_site_admin?
        @search = Project.new_search(search_params)
      else
        @search = Project.approved.public.new_search(search_params)
      end

      if params[:search]
        @search.conditions.any = true
        
        if params[:advanced_search]
          @advanced_search = true
          @search.conditions.name_kw_using_or = params[:search][:conditions][:name_kw_using_or]
          @search.conditions.shortname_kw_using_or = params[:search][:conditions][:shortname_kw_using_or]
          @search.conditions.description_kw_using_or = params[:search][:conditions][:description_kw_using_or]
          @search.conditions.tags.name_kw_using_or = params[:search][:conditions][:tags][:name_kw_using_or]<commit_msg>added logic to deny project functions access to non employees<commit_after>require 'jira_lib/jira_interface.rb'

class ProjectsController < ApplicationController
	skip_before_filter :login_required, :only => [:index, :show]

  before_filter :get_project, :only => [:show, :edit, :update, :destroy]
  before_filter :get_terms_and_conditions_text, :only => [:new, :create]
  
  deny :show, :edit, :update, :destroy, :exec => :project_unapproved_and_user_not_site_admin?, :redirect_to => :projects
  deny :show, :edit, :update, :destroy, :exec => :project_private_and_user_not_member?, :redirect_to => :projects
  
#  allow :new, :create, :user => :is_registered_user?, :redirect_to => '/forge'
  allow :index, :new, :create, :user => :is_company_employee?, :redirect_to => :homepage
  
  allow :edit, :update, :user => :is_project_administrator_for?, :redirect_to => :project
  allow :destroy, :user => :is_site_admin?, :redirect_to => :project

  def index
    @tags = Project.tag_counts
    @levels = (1 .. 5).map { |i| "level-#{i}" }
    
    if params[:show_search_form]
      @advanced_search = false
      search_params = { "order_by" => "name", "order_as" => "ASC" }
      search_params.merge!(params[:search]) if params[:search]
      search_params.delete("conditions")
      
      if current_user.is_site_admin?
        @search = Project.new_search(search_params)
      else
        @search = Project.approved.public.new_search(search_params)
      end

      if params[:search]
        @search.conditions.any = true
        
        if params[:advanced_search]
          @advanced_search = true
          @search.conditions.name_kw_using_or = params[:search][:conditions][:name_kw_using_or]
          @search.conditions.shortname_kw_using_or = params[:search][:conditions][:shortname_kw_using_or]
          @search.conditions.description_kw_using_or = params[:search][:conditions][:description_kw_using_or]
          @search.conditions.tags.name_kw_using_or = params[:search][:conditions][:tags][:name_kw_using_or]
{'fraction_non_alphanumeric': 0.13810357768326245, 'fraction_numerical': 0.0010007505629221916, 'mean_word_length': 4.337783711615487, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '7043493', 'n_tokens_mistral': 1304, 'n_tokens_neox': 1278, 'n_words': 236}