Sha256: fcc758d03245a8f59261370f626b4eec098cabe4afe66fe79db99c917ebe7fd9

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

class Workflow::ProjectOwnerController < ApplicationController
  def index
    @stories = {}
    @tasks = {}
    @vacancies = {}
    @candidatures = {}
    
    { vacancies: Vacancy::STATES, candidatures: Candidature::STATES }.each do |controller, states|
      query = 'offeror_id = :user_id'
      query += ' OR author_id = :user_id' if controller == :vacancies
      query = "(#{query}) AND state = :state"
      
      states.each do |state|
        # eval("@#{controller}[state] = current_user.offeror_#{controller}.where(state: state).limit(5)")
        collection = controller.to_s.classify.constantize.where(
          query, user_id: current_user.id, state: state
        ).order('created_at DESC').limit(5)
        eval("@#{controller}[state] = collection")
      end
    end
    
    { stories: [:completed, :active], tasks: [:under_supervision] }.each do |controller, states|
      states.each do |state|
        collection = controller.to_s.classify.constantize.where(
          offeror_id: current_user.id, state: state
        ).limit(5)
        eval("@#{controller}[state] = collection")
      end
    end
    
    @twitter_sidenav_level = 2
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
voluntary-0.3.0 app/controllers/workflow/project_owner_controller.rb
voluntary-0.2.4 app/controllers/workflow/project_owner_controller.rb
voluntary-0.2.3 app/controllers/workflow/project_owner_controller.rb
voluntary-0.2.2 app/controllers/workflow/project_owner_controller.rb
voluntary-0.2.1 app/controllers/workflow/project_owner_controller.rb
voluntary-0.2.0 app/controllers/workflow/project_owner_controller.rb
voluntary-0.1.0 app/controllers/workflow/project_owner_controller.rb
voluntary-0.1.0.rc4 app/controllers/workflow/project_owner_controller.rb
voluntary-0.1.0.rc3 app/controllers/workflow/project_owner_controller.rb
voluntary-0.1.0.rc2 app/controllers/workflow/project_owner_controller.rb
voluntary-0.1.0.rc1 app/controllers/workflow/project_owner_controller.rb