voluntary_classified_advertisement 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +3 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +29 -0
- data/app/models/asset.rb +9 -0
- data/app/models/product/classified_advertisement.rb +3 -0
- data/app/models/product/classified_advertisement/candidature.rb +20 -0
- data/app/models/product/classified_advertisement/story.rb +19 -0
- data/app/models/product/classified_advertisement/task.rb +142 -0
- data/app/models/product/classified_advertisement/vacancy.rb +106 -0
- data/app/views/products/types/classified_advertisement/stories/_task_fields.html.erb +33 -0
- data/app/views/products/types/classified_advertisement/stories/_vacancy_fields.html.erb +11 -0
- data/app/views/products/types/classified_advertisement/workflow/tasks/_candidature_fields.html.erb +32 -0
- data/app/views/products/types/classified_advertisement/workflow/tasks/_resource_fields.html.erb +7 -0
- data/app/views/products/types/classified_advertisement/workflow/tasks/_vacancy_fields.html.erb +27 -0
- data/app/views/products/types/classified_advertisement/workflow/tasks/_work_form.html.erb +16 -0
- data/app/views/products/types/classified_advertisement/workflow/tasks/_work_head.html.erb +15 -0
- data/config/locales/resources/story/en.yml +5 -0
- data/config/locales/resources/task/en.yml +10 -0
- data/config/locales/workflow/en.yml +7 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20130806131503_add_classified_advertisement_product.rb +11 -0
- data/db/migrate/20130809134227_add_task_id_to_vacancies.rb +5 -0
- data/db/migrate/20130830170731_create_assets.rb +9 -0
- data/lib/tasks/voluntary_classified_advertising_tasks.rake +4 -0
- data/lib/voluntary_classified_advertisement.rb +6 -0
- data/lib/voluntary_classified_advertisement/engine.rb +5 -0
- data/lib/voluntary_classified_advertisement/version.rb +3 -0
- metadata +175 -0
    
        data/CHANGELOG.md
    ADDED
    
    
    
        data/MIT-LICENSE
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright 2013 YOURNAME
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.rdoc
    ADDED
    
    
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            #!/usr/bin/env rake
         | 
| 2 | 
            +
            begin
         | 
| 3 | 
            +
              require 'bundler/setup'
         | 
| 4 | 
            +
            rescue LoadError
         | 
| 5 | 
            +
              puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
         | 
| 6 | 
            +
            end
         | 
| 7 | 
            +
            begin
         | 
| 8 | 
            +
              require 'rdoc/task'
         | 
| 9 | 
            +
            rescue LoadError
         | 
| 10 | 
            +
              require 'rdoc/rdoc'
         | 
| 11 | 
            +
              require 'rake/rdoctask'
         | 
| 12 | 
            +
              RDoc::Task = Rake::RDocTask
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            RDoc::Task.new(:rdoc) do |rdoc|
         | 
| 16 | 
            +
              rdoc.rdoc_dir = 'rdoc'
         | 
| 17 | 
            +
              rdoc.title    = 'VoluntaryClassifiedAdvertisement'
         | 
| 18 | 
            +
              rdoc.options << '--line-numbers'
         | 
| 19 | 
            +
              rdoc.rdoc_files.include('README.rdoc')
         | 
| 20 | 
            +
              rdoc.rdoc_files.include('lib/**/*.rb')
         | 
| 21 | 
            +
            end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            APP_RAKEFILE = File.expand_path("../dummy/Rakefile", __FILE__)
         | 
| 24 | 
            +
            load 'rails/tasks/engine.rake'
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
             | 
| 28 | 
            +
            Bundler::GemHelper.install_tasks
         | 
| 29 | 
            +
             | 
    
        data/app/models/asset.rb
    ADDED
    
    
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            class Product::ClassifiedAdvertisement::Candidature < ::Candidature
         | 
| 2 | 
            +
              accepts_nested_attributes_for :resource
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              attr_accessible :resource_attributes
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              def resource_attributes=(attributes)
         | 
| 7 | 
            +
                self.resource = if attributes[:id].present?
         | 
| 8 | 
            +
                  Asset.find(attributes[:id])
         | 
| 9 | 
            +
                else
         | 
| 10 | 
            +
                  Asset.new
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
                
         | 
| 13 | 
            +
                self.resource.attributes = attributes
         | 
| 14 | 
            +
                
         | 
| 15 | 
            +
                self.resource.save
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
                self.resource_type = 'Asset'
         | 
| 18 | 
            +
                self.resource_id = self.resource.id
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            class Product::ClassifiedAdvertisement::Story < Story
         | 
| 2 | 
            +
              has_many :tasks, dependent: :destroy, class_name: 'Product::ClassifiedAdvertisement::Task', inverse_of: :story
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              def tasks_attributes=(attributes)
         | 
| 5 | 
            +
                self.tasks ||= []
         | 
| 6 | 
            +
                
         | 
| 7 | 
            +
                attributes.each do |index, task_attributes|
         | 
| 8 | 
            +
                  destroy = task_attributes.delete :_destroy
         | 
| 9 | 
            +
                  
         | 
| 10 | 
            +
                  if task_attributes[:id].present? && destroy.to_i == 1
         | 
| 11 | 
            +
                    self.tasks.where(id: task_attributes[:id]).destroy_all
         | 
| 12 | 
            +
                  elsif task_attributes[:id].present?
         | 
| 13 | 
            +
                    tasks.find(task_attributes[:id]).update_attributes(task_attributes)
         | 
| 14 | 
            +
                  else
         | 
| 15 | 
            +
                    self.tasks.build(task_attributes)
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| @@ -0,0 +1,142 @@ | |
| 1 | 
            +
            class Product::ClassifiedAdvertisement::Task < ::Task
         | 
| 2 | 
            +
              belongs_to :story, class_name: 'Product::ClassifiedAdvertisement::Story', inverse_of: :task
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              attr_accessible :vacancies_attributes
         | 
| 5 | 
            +
              attr_writer :vacancies
         | 
| 6 | 
            +
              
         | 
| 7 | 
            +
              validates :text, presence: true
         | 
| 8 | 
            +
              
         | 
| 9 | 
            +
              validate :at_least_one_vacancy
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              after_save :save_dependencies
         | 
| 12 | 
            +
              after_destroy :destroy_non_mongodb_records
         | 
| 13 | 
            +
              
         | 
| 14 | 
            +
              state_machine :state, initial: :new do
         | 
| 15 | 
            +
                state :under_supervision do
         | 
| 16 | 
            +
                  validate :new_candidature_present?
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              
         | 
| 20 | 
            +
              def vacancies
         | 
| 21 | 
            +
                @vacancies ||= new_record? ? [vacancy_class.new(task: self)] : vacancy_class.where(task_id: id.to_s)
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
              
         | 
| 24 | 
            +
              def vacancies_attributes=(attributes = {})
         | 
| 25 | 
            +
                self.vacancies = [] if self.vacancies.length == 1 && self.vacancies.first.new_record?
         | 
| 26 | 
            +
                
         | 
| 27 | 
            +
                attributes.select{|k,v| (v[:name].present? && v[:text].present?) || v[:id].present? }.each do |index, vacancy_attributes|
         | 
| 28 | 
            +
                  destroy = vacancy_attributes.delete :_destroy
         | 
| 29 | 
            +
                  vacancy_attributes[:task] = self
         | 
| 30 | 
            +
                  vacancy = nil
         | 
| 31 | 
            +
                  
         | 
| 32 | 
            +
                  if vacancy_attributes[:id].present? && destroy.to_i == 1
         | 
| 33 | 
            +
                    begin; vacancy_class.destroy(vacancy_attributes[:id]); rescue ActiveRecord::RecordNotFound; end
         | 
| 34 | 
            +
                    @vacancies.select!{|v| v.id != vacancy_attributes[:id]}
         | 
| 35 | 
            +
                  elsif vacancy_attributes[:id].present?
         | 
| 36 | 
            +
                    begin; vacancy = vacancy_class.find(vacancy_attributes[:id]); rescue ActiveRecord::RecordNotFound; end
         | 
| 37 | 
            +
                    
         | 
| 38 | 
            +
                    vacancy_id = vacancy_attributes.delete(:id)
         | 
| 39 | 
            +
                    
         | 
| 40 | 
            +
                    vacancy.update_attributes(vacancy_attributes) if vacancy.present?
         | 
| 41 | 
            +
                    
         | 
| 42 | 
            +
                    vacancy_attributes[:id] = vacancy_id
         | 
| 43 | 
            +
                  else
         | 
| 44 | 
            +
                    vacancy = vacancy_class.new(vacancy_attributes)
         | 
| 45 | 
            +
                  end
         | 
| 46 | 
            +
                  
         | 
| 47 | 
            +
                  next unless vacancy.present?
         | 
| 48 | 
            +
                  
         | 
| 49 | 
            +
                  if vacancy_attributes[:id].present?
         | 
| 50 | 
            +
                    self.vacancies.each_with_index do |current_vacancy, vacancies_index|
         | 
| 51 | 
            +
                      if current_vacancy.id.to_s == vacancy_attributes[:id]
         | 
| 52 | 
            +
                        self.vacancies[vacancies_index] = vacancy
         | 
| 53 | 
            +
                      end
         | 
| 54 | 
            +
                    end
         | 
| 55 | 
            +
                  else
         | 
| 56 | 
            +
                    self.vacancies << vacancy
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
              
         | 
| 61 | 
            +
              def vacancies_attributes
         | 
| 62 | 
            +
                @vacancies_attributes ||= (vacancies.empty? ? [vacancy_class.new(task: self)] : vacancies).map{|v| v.attributes}
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
              
         | 
| 65 | 
            +
              def vacancy_class
         | 
| 66 | 
            +
                if product_id.present?
         | 
| 67 | 
            +
                  "#{product.class.name}::Vacancy".constantize rescue ::Product::ClassifiedAdvertisement::Vacancy
         | 
| 68 | 
            +
                else
         | 
| 69 | 
            +
                  ::Product::ClassifiedAdvertisement::Vacancy
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
              end
         | 
| 72 | 
            +
              
         | 
| 73 | 
            +
              def with_result?
         | 
| 74 | 
            +
                false
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
              
         | 
| 77 | 
            +
              def after_transition(transition)
         | 
| 78 | 
            +
                case transition.event
         | 
| 79 | 
            +
                when :follow_up
         | 
| 80 | 
            +
                  vacancies.each do |vacancy|
         | 
| 81 | 
            +
                    vacancy.candidatures.select{|c| c.state == 'new' || c.state == 'accepted'}.map(&:deny!)
         | 
| 82 | 
            +
                  end
         | 
| 83 | 
            +
                when :complete
         | 
| 84 | 
            +
                  vacancies.each do |vacancy|
         | 
| 85 | 
            +
                    vacancy.candidatures.select{|c| c.state == 'new'}.map(&:accept!)
         | 
| 86 | 
            +
                  end
         | 
| 87 | 
            +
                end
         | 
| 88 | 
            +
                
         | 
| 89 | 
            +
                super(transition)
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
              
         | 
| 92 | 
            +
              private
         | 
| 93 | 
            +
              
         | 
| 94 | 
            +
              def at_least_one_vacancy
         | 
| 95 | 
            +
                unless vacancies.select(&:valid?).any?
         | 
| 96 | 
            +
                  errors.add(:base, I18n.t('activerecord.errors.models.task.attributes.base.no_vacancies'))
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
              end
         | 
| 99 | 
            +
              
         | 
| 100 | 
            +
              def save_dependencies
         | 
| 101 | 
            +
                vacancies.select(&:new_record?).each do |vacancy|
         | 
| 102 | 
            +
                  vacancy.task = self
         | 
| 103 | 
            +
                  vacancy.do_open
         | 
| 104 | 
            +
                end
         | 
| 105 | 
            +
              end
         | 
| 106 | 
            +
              
         | 
| 107 | 
            +
              def new_candidature_present?
         | 
| 108 | 
            +
                vacancies.each do |vacancy|
         | 
| 109 | 
            +
                  new_candidatures = vacancy.candidatures.select{|c| c.state == 'new'}
         | 
| 110 | 
            +
                  
         | 
| 111 | 
            +
                  if new_candidatures.none?
         | 
| 112 | 
            +
                    errors.add(
         | 
| 113 | 
            +
                      :base, 
         | 
| 114 | 
            +
                      I18n.t(
         | 
| 115 | 
            +
                        'activerecord.errors.models.task.attributes.base.' + 
         | 
| 116 | 
            +
                        'only_one_new_candidature'
         | 
| 117 | 
            +
                      )
         | 
| 118 | 
            +
                    )
         | 
| 119 | 
            +
                  elsif new_candidatures.length == 1 && !new_candidatures.first.resource.valid?
         | 
| 120 | 
            +
                    errors.add(
         | 
| 121 | 
            +
                      :base, 
         | 
| 122 | 
            +
                      I18n.t(
         | 
| 123 | 
            +
                        'activerecord.errors.models.task.attributes.base.' + 
         | 
| 124 | 
            +
                        'candidature_resource_invalid'
         | 
| 125 | 
            +
                      )
         | 
| 126 | 
            +
                    )  
         | 
| 127 | 
            +
                  elsif new_candidatures.length != 1
         | 
| 128 | 
            +
                    errors.add(
         | 
| 129 | 
            +
                      :base, 
         | 
| 130 | 
            +
                      I18n.t(
         | 
| 131 | 
            +
                        'activerecord.errors.models.task.attributes.base.' + 
         | 
| 132 | 
            +
                        'only_one_new_candidature'
         | 
| 133 | 
            +
                      )
         | 
| 134 | 
            +
                    )
         | 
| 135 | 
            +
                  end
         | 
| 136 | 
            +
                end
         | 
| 137 | 
            +
              end
         | 
| 138 | 
            +
              
         | 
| 139 | 
            +
              def destroy_non_mongodb_records
         | 
| 140 | 
            +
                vacancies.destroy_all
         | 
| 141 | 
            +
              end
         | 
| 142 | 
            +
            end
         | 
| @@ -0,0 +1,106 @@ | |
| 1 | 
            +
            class Product::ClassifiedAdvertisement::Vacancy < ::Vacancy
         | 
| 2 | 
            +
              has_many :candidatures, dependent: :destroy, class_name: 'Product::ClassifiedAdvertisement::Candidature', inverse_of: :vacancy
         | 
| 3 | 
            +
              
         | 
| 4 | 
            +
              attr_accessible :task_id, :task
         | 
| 5 | 
            +
              
         | 
| 6 | 
            +
              after_initialize :set_defaults
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            =begin
         | 
| 9 | 
            +
              has_many :candidatures, -> do
         | 
| 10 | 
            +
                order(%Q{
         | 
| 11 | 
            +
                  CASE 
         | 
| 12 | 
            +
                    WHEN candidatures.state='new' THEN 1 
         | 
| 13 | 
            +
                    WHEN candidatures.state='accepted' THEN 2 
         | 
| 14 | 
            +
                    WHEN candidatures.state='denied' THEN 3 
         | 
| 15 | 
            +
                    ELSE 4 
         | 
| 16 | 
            +
                  END
         | 
| 17 | 
            +
                })
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            =end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              validates :task, presence: true
         | 
| 22 | 
            +
              
         | 
| 23 | 
            +
              def candidatures_attributes=(attributes)
         | 
| 24 | 
            +
                self.candidatures ||= []
         | 
| 25 | 
            +
                
         | 
| 26 | 
            +
                attributes.each do |index, candidature_attributes|
         | 
| 27 | 
            +
                  destroy = candidature_attributes.delete :_destroy
         | 
| 28 | 
            +
                  
         | 
| 29 | 
            +
                  if candidature_attributes[:id].present? && destroy.to_i == 1
         | 
| 30 | 
            +
                    begin; candidature_class.destroy(candidature_attributes[:id]); rescue ActiveRecord::RecordNotFound; end
         | 
| 31 | 
            +
                    @candidatures.select!{|v| v.id != candidature_attributes[:id]}
         | 
| 32 | 
            +
                    next
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                  
         | 
| 35 | 
            +
                  candidature_attributes[:vacancy] = self
         | 
| 36 | 
            +
                  candidature = nil
         | 
| 37 | 
            +
                  
         | 
| 38 | 
            +
                  if candidature_attributes[:id].present?
         | 
| 39 | 
            +
                    begin; candidature = candidature_class.find(candidature_attributes[:id]); rescue ActiveRecord::RecordNotFound; end
         | 
| 40 | 
            +
                    
         | 
| 41 | 
            +
                    candidature_attributes.delete(:id)
         | 
| 42 | 
            +
                    
         | 
| 43 | 
            +
                    candidature.attributes = candidature_attributes if candidature.present?
         | 
| 44 | 
            +
                  else
         | 
| 45 | 
            +
                    candidature = candidature_class.new(candidature_attributes)
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
                  
         | 
| 48 | 
            +
                  next unless candidature.present?
         | 
| 49 | 
            +
                  
         | 
| 50 | 
            +
                  if candidature_attributes[:id].present?
         | 
| 51 | 
            +
                    self.candidatures.each_with_index do |current_candidature, candidatures_index|
         | 
| 52 | 
            +
                      if current_candidature.id.to_s == candidature_attributes[:id]
         | 
| 53 | 
            +
                        self.candidatures[candidatures_index] = candidature
         | 
| 54 | 
            +
                      end
         | 
| 55 | 
            +
                    end
         | 
| 56 | 
            +
                  else
         | 
| 57 | 
            +
                    self.candidatures << candidature
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
              
         | 
| 62 | 
            +
              def task
         | 
| 63 | 
            +
                @task ||= task_class.where(id: task_id).first
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
              
         | 
| 66 | 
            +
              def task=(value)
         | 
| 67 | 
            +
                self.task_id = value.try(:id).try(:to_s)
         | 
| 68 | 
            +
                @task = value
         | 
| 69 | 
            +
              end
         | 
| 70 | 
            +
              
         | 
| 71 | 
            +
              def task_class
         | 
| 72 | 
            +
                if product.present?
         | 
| 73 | 
            +
                  "#{product.class.name}::Task".constantize rescue Task
         | 
| 74 | 
            +
                else
         | 
| 75 | 
            +
                  Task
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
              
         | 
| 79 | 
            +
              def candidature_class
         | 
| 80 | 
            +
                if product.present?
         | 
| 81 | 
            +
                  "#{product.class.name}::Candidature".constantize rescue Candidature
         | 
| 82 | 
            +
                else
         | 
| 83 | 
            +
                  Candidature
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
              end
         | 
| 86 | 
            +
              
         | 
| 87 | 
            +
              def product
         | 
| 88 | 
            +
                @product ||= project.product if project
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
              
         | 
| 91 | 
            +
              #def new_or_accepted_candidature
         | 
| 92 | 
            +
              #  candidatures.where(state: ['new', 'accepted']).first
         | 
| 93 | 
            +
              #end
         | 
| 94 | 
            +
              
         | 
| 95 | 
            +
              #def denied_candidatures
         | 
| 96 | 
            +
              #  candidatures.where(state: 'denied')
         | 
| 97 | 
            +
              #end
         | 
| 98 | 
            +
              
         | 
| 99 | 
            +
              protected
         | 
| 100 | 
            +
              
         | 
| 101 | 
            +
              def set_defaults
         | 
| 102 | 
            +
                self.project ||= task.try(:story).try(:project)
         | 
| 103 | 
            +
                
         | 
| 104 | 
            +
                super
         | 
| 105 | 
            +
              end
         | 
| 106 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            <fieldset>
         | 
| 2 | 
            +
              <%= f.input :name %>  
         | 
| 3 | 
            +
              <%= f.input :text, as: :text, input_html: {style: 'width: 500px; height:50px;'} %>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              <%= f.check_box :_destroy %>
         | 
| 6 | 
            +
              <%= f.label :_destroy, t('general.destroy') %>
         | 
| 7 | 
            +
              <div class="form-actions">
         | 
| 8 | 
            +
                <div class="control-group string required" style="display: block">
         | 
| 9 | 
            +
                  <div class="controls">
         | 
| 10 | 
            +
                        
         | 
| 11 | 
            +
                    <%= link_to_add_fields(
         | 
| 12 | 
            +
                      t('stories.steps.setup_tasks.add_vacancy'), f, :vacancies, target: 'setup_vacancies_input'
         | 
| 13 | 
            +
                    ) %>
         | 
| 14 | 
            +
                  </div>
         | 
| 15 | 
            +
                </div>
         | 
| 16 | 
            +
              </div>
         | 
| 17 | 
            +
              
         | 
| 18 | 
            +
              <fieldset>
         | 
| 19 | 
            +
                <legend><%= t('vacancies.index.title')%></legend>
         | 
| 20 | 
            +
                <div id="setup_vacancies_input" class="form-inputs">
         | 
| 21 | 
            +
                  <%= f.simple_fields_for :vacancies do |vacancy_form| %>
         | 
| 22 | 
            +
                    <% vacancy_form.object = f.object.vacancy_class.new(task: f.object) if vacancy_form.object.blank? %>
         | 
| 23 | 
            +
                    <%= render_product_specific_partial_if_available(
         | 
| 24 | 
            +
                      vacancy_form.object, 'stories/vacancy_fields', f: vacancy_form
         | 
| 25 | 
            +
                    ) %>
         | 
| 26 | 
            +
                  <% end %>
         | 
| 27 | 
            +
                </div>
         | 
| 28 | 
            +
              </fieldset>
         | 
| 29 | 
            +
              
         | 
| 30 | 
            +
              <%= link_to t('general.remove'), '#', class: 'remove_fields' %>
         | 
| 31 | 
            +
            </fieldset>
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            <hr/>
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            <fieldset>
         | 
| 2 | 
            +
              <%= f.input :name %>  
         | 
| 3 | 
            +
              <%= f.input :text, as: :text, input_html: {style: 'width: 500px; height:50px;'} %>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              <%= f.check_box :_destroy %>
         | 
| 6 | 
            +
              <%= f.label :_destroy, t('general.destroy') %>
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              <%= link_to t('general.remove'), '#', class: 'remove_fields' %>
         | 
| 9 | 
            +
            </fieldset>
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            <hr/>
         | 
    
        data/app/views/products/types/classified_advertisement/workflow/tasks/_candidature_fields.html.erb
    ADDED
    
    | @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            <%= render 'shared/form/error_messages', resource: f.object %>
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            <%= f.hidden_field :id %>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            <% f.object.resource ||= Asset.new %>
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            <% @candidature_states ||= {} %>
         | 
| 8 | 
            +
            <% @candidature_states[f.object.state] ||= 0 %>
         | 
| 9 | 
            +
            <% @candidature_states[f.object.state] += 1 %>
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            <% if @candidature_states[f.object.state] == 1 %>
         | 
| 12 | 
            +
              <p>
         | 
| 13 | 
            +
                <h5><%= I18n.t("general.#{f.object.state}") %></h5>
         | 
| 14 | 
            +
              </p>
         | 
| 15 | 
            +
            <% end%>
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            <% if f.object.state == 'new' %>
         | 
| 18 | 
            +
              <%= f.simple_fields_for :resource do |resource_form| %>
         | 
| 19 | 
            +
                <%= render_product_specific_partial_if_available(
         | 
| 20 | 
            +
                  resource_form.object, 'products/types/classified_advertisement/workflow/tasks/resource_fields', f: resource_form
         | 
| 21 | 
            +
                ) %>
         | 
| 22 | 
            +
              <% end %>
         | 
| 23 | 
            +
            <% else %>
         | 
| 24 | 
            +
              <hr/>
         | 
| 25 | 
            +
              <p>
         | 
| 26 | 
            +
                <strong><%= I18n.t('activerecord.attributes.general.name') %></strong> <%= f.object.resource.name %> <br/>
         | 
| 27 | 
            +
                <br/>
         | 
| 28 | 
            +
                <strong><%= I18n.t('activerecord.attributes.general.text') %></strong><br/>
         | 
| 29 | 
            +
                <br/>
         | 
| 30 | 
            +
                <%= f.object.resource.text %> 
         | 
| 31 | 
            +
              </p>
         | 
| 32 | 
            +
            <% end %>
         | 
    
        data/app/views/products/types/classified_advertisement/workflow/tasks/_vacancy_fields.html.erb
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            <tr class="<%= cycle('odd', 'even') %>">
         | 
| 2 | 
            +
              <td><%= f.object.name %></td>
         | 
| 3 | 
            +
              <td><%= f.object.text %></td>
         | 
| 4 | 
            +
            </tr>
         | 
| 5 | 
            +
            <tr>
         | 
| 6 | 
            +
              <td colspan="2" style="padding-left: 25px">
         | 
| 7 | 
            +
                <%= render 'shared/form/error_messages', resource: f.object %>
         | 
| 8 | 
            +
                
         | 
| 9 | 
            +
                <h5>Resource</h5>
         | 
| 10 | 
            +
                <%= f.hidden_field :id %>
         | 
| 11 | 
            +
                
         | 
| 12 | 
            +
                <% f.object.candidatures.build if f.object.candidatures.select{|c| ['new', 'accepted'].include?(c.state)}.none? %>
         | 
| 13 | 
            +
                
         | 
| 14 | 
            +
                <% 
         | 
| 15 | 
            +
                f.object.candidatures.sort! do |x,y|
         | 
| 16 | 
            +
                  Candidature::STATES.index(x.state.to_sym) <=> Candidature::STATES.index(y.state.to_sym) 
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
                %>
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                <%= f.simple_fields_for :candidatures do |candidature_form| %>
         | 
| 21 | 
            +
                  <% @debug = true %>
         | 
| 22 | 
            +
                  <%= render_product_specific_partial_if_available(
         | 
| 23 | 
            +
                    candidature_form.object, 'workflow/tasks/candidature_fields', f: candidature_form
         | 
| 24 | 
            +
                  ) %>
         | 
| 25 | 
            +
                <% end %>
         | 
| 26 | 
            +
              </td>
         | 
| 27 | 
            +
            </tr>
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            <%= render 'shared/form/error_messages', resource: resource %>
         | 
| 2 | 
            +
            <div class="form-inputs">
         | 
| 3 | 
            +
              <table class="table table-striped">
         | 
| 4 | 
            +
              	<thead>
         | 
| 5 | 
            +
                  <th>Name</th>
         | 
| 6 | 
            +
                  <th>Text</th>
         | 
| 7 | 
            +
                </thead>
         | 
| 8 | 
            +
                <tbody>
         | 
| 9 | 
            +
                  <%= f.simple_fields_for :vacancies do |vacancy_form| %>
         | 
| 10 | 
            +
                    <%= render_product_specific_partial_if_available(
         | 
| 11 | 
            +
                      vacancy_form.object, 'workflow/tasks/vacancy_fields', f: vacancy_form
         | 
| 12 | 
            +
                    ) %>
         | 
| 13 | 
            +
                  <% end %>
         | 
| 14 | 
            +
                </tbody>
         | 
| 15 | 
            +
              </table>
         | 
| 16 | 
            +
            </div>
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            <h3><%= resource.name %></h3>
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            <strong><%= t('activerecord.attributes.general.state') %>:</strong> <%= resource.state %>
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            <h4><%= t('tasks.show.story_text') %></h4>
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            <%= resource.story.text %>
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            <% if resource.text.present? %>
         | 
| 10 | 
            +
            <h4><%= t('tasks.show.text') %></h4>
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            <%= resource.text %>
         | 
| 13 | 
            +
            <% end %>
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            <h4><%= t('vacancies.index.title') %></h4>   
         | 
    
        data/config/routes.rb
    ADDED
    
    
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            class AddClassifiedAdvertisementProduct < ActiveRecord::Migration
         | 
| 2 | 
            +
              def up
         | 
| 3 | 
            +
                product = Product.new(name: 'Classified Advertisement', text: 'Classified Advertisement')
         | 
| 4 | 
            +
                product.user_id = User.where(name: 'Master').first.id
         | 
| 5 | 
            +
                product.save!
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
              
         | 
| 8 | 
            +
              def down
         | 
| 9 | 
            +
                Product.where(name: 'Classified Advertisement').first.destroy
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,175 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: voluntary_classified_advertisement
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Mathias Gawlista
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2013-10-30 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: voluntary
         | 
| 16 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - '='
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: 0.1.0
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                none: false
         | 
| 26 | 
            +
                requirements:
         | 
| 27 | 
            +
                - - '='
         | 
| 28 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 29 | 
            +
                    version: 0.1.0
         | 
| 30 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 31 | 
            +
              name: letter_opener
         | 
| 32 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            +
                none: false
         | 
| 34 | 
            +
                requirements:
         | 
| 35 | 
            +
                - - ! '>='
         | 
| 36 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            +
                    version: '0'
         | 
| 38 | 
            +
              type: :development
         | 
| 39 | 
            +
              prerelease: false
         | 
| 40 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            +
                none: false
         | 
| 42 | 
            +
                requirements:
         | 
| 43 | 
            +
                - - ! '>='
         | 
| 44 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            +
                    version: '0'
         | 
| 46 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 47 | 
            +
              name: oink
         | 
| 48 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            +
                none: false
         | 
| 50 | 
            +
                requirements:
         | 
| 51 | 
            +
                - - ! '>='
         | 
| 52 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 53 | 
            +
                    version: '0'
         | 
| 54 | 
            +
              type: :development
         | 
| 55 | 
            +
              prerelease: false
         | 
| 56 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            +
                none: false
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ! '>='
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: '0'
         | 
| 62 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 63 | 
            +
              name: awesome_print
         | 
| 64 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                none: false
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ! '>='
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '0'
         | 
| 70 | 
            +
              type: :development
         | 
| 71 | 
            +
              prerelease: false
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                none: false
         | 
| 74 | 
            +
                requirements:
         | 
| 75 | 
            +
                - - ! '>='
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            +
                    version: '0'
         | 
| 78 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            +
              name: rspec-rails
         | 
| 80 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 81 | 
            +
                none: false
         | 
| 82 | 
            +
                requirements:
         | 
| 83 | 
            +
                - - ~>
         | 
| 84 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 85 | 
            +
                    version: '2.0'
         | 
| 86 | 
            +
              type: :development
         | 
| 87 | 
            +
              prerelease: false
         | 
| 88 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 89 | 
            +
                none: false
         | 
| 90 | 
            +
                requirements:
         | 
| 91 | 
            +
                - - ~>
         | 
| 92 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 93 | 
            +
                    version: '2.0'
         | 
| 94 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 95 | 
            +
              name: database_cleaner
         | 
| 96 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 97 | 
            +
                none: false
         | 
| 98 | 
            +
                requirements:
         | 
| 99 | 
            +
                - - '='
         | 
| 100 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 101 | 
            +
                    version: 0.7.1
         | 
| 102 | 
            +
              type: :development
         | 
| 103 | 
            +
              prerelease: false
         | 
| 104 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 105 | 
            +
                none: false
         | 
| 106 | 
            +
                requirements:
         | 
| 107 | 
            +
                - - '='
         | 
| 108 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 109 | 
            +
                    version: 0.7.1
         | 
| 110 | 
            +
            description: Classified advertisement product for crowdsourcing engine voluntary.
         | 
| 111 | 
            +
            email:
         | 
| 112 | 
            +
            - gawlista@gmail.com
         | 
| 113 | 
            +
            executables: []
         | 
| 114 | 
            +
            extensions: []
         | 
| 115 | 
            +
            extra_rdoc_files: []
         | 
| 116 | 
            +
            files:
         | 
| 117 | 
            +
            - app/models/asset.rb
         | 
| 118 | 
            +
            - app/models/product/classified_advertisement/candidature.rb
         | 
| 119 | 
            +
            - app/models/product/classified_advertisement/story.rb
         | 
| 120 | 
            +
            - app/models/product/classified_advertisement/task.rb
         | 
| 121 | 
            +
            - app/models/product/classified_advertisement/vacancy.rb
         | 
| 122 | 
            +
            - app/models/product/classified_advertisement.rb
         | 
| 123 | 
            +
            - app/views/products/types/classified_advertisement/stories/_task_fields.html.erb
         | 
| 124 | 
            +
            - app/views/products/types/classified_advertisement/stories/_vacancy_fields.html.erb
         | 
| 125 | 
            +
            - app/views/products/types/classified_advertisement/workflow/tasks/_candidature_fields.html.erb
         | 
| 126 | 
            +
            - app/views/products/types/classified_advertisement/workflow/tasks/_resource_fields.html.erb
         | 
| 127 | 
            +
            - app/views/products/types/classified_advertisement/workflow/tasks/_vacancy_fields.html.erb
         | 
| 128 | 
            +
            - app/views/products/types/classified_advertisement/workflow/tasks/_work_form.html.erb
         | 
| 129 | 
            +
            - app/views/products/types/classified_advertisement/workflow/tasks/_work_head.html.erb
         | 
| 130 | 
            +
            - config/locales/resources/story/en.yml
         | 
| 131 | 
            +
            - config/locales/resources/task/en.yml
         | 
| 132 | 
            +
            - config/locales/workflow/en.yml
         | 
| 133 | 
            +
            - config/routes.rb
         | 
| 134 | 
            +
            - db/migrate/20130806131503_add_classified_advertisement_product.rb
         | 
| 135 | 
            +
            - db/migrate/20130809134227_add_task_id_to_vacancies.rb
         | 
| 136 | 
            +
            - db/migrate/20130830170731_create_assets.rb
         | 
| 137 | 
            +
            - lib/tasks/voluntary_classified_advertising_tasks.rake
         | 
| 138 | 
            +
            - lib/voluntary_classified_advertisement/engine.rb
         | 
| 139 | 
            +
            - lib/voluntary_classified_advertisement/version.rb
         | 
| 140 | 
            +
            - lib/voluntary_classified_advertisement.rb
         | 
| 141 | 
            +
            - CHANGELOG.md
         | 
| 142 | 
            +
            - MIT-LICENSE
         | 
| 143 | 
            +
            - Rakefile
         | 
| 144 | 
            +
            - README.rdoc
         | 
| 145 | 
            +
            homepage: http://github.com/volontariat/voluntary_classified_advertisement
         | 
| 146 | 
            +
            licenses: []
         | 
| 147 | 
            +
            post_install_message: 
         | 
| 148 | 
            +
            rdoc_options: []
         | 
| 149 | 
            +
            require_paths:
         | 
| 150 | 
            +
            - lib
         | 
| 151 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 152 | 
            +
              none: false
         | 
| 153 | 
            +
              requirements:
         | 
| 154 | 
            +
              - - ! '>='
         | 
| 155 | 
            +
                - !ruby/object:Gem::Version
         | 
| 156 | 
            +
                  version: '0'
         | 
| 157 | 
            +
                  segments:
         | 
| 158 | 
            +
                  - 0
         | 
| 159 | 
            +
                  hash: 205170909
         | 
| 160 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 161 | 
            +
              none: false
         | 
| 162 | 
            +
              requirements:
         | 
| 163 | 
            +
              - - ! '>='
         | 
| 164 | 
            +
                - !ruby/object:Gem::Version
         | 
| 165 | 
            +
                  version: '0'
         | 
| 166 | 
            +
                  segments:
         | 
| 167 | 
            +
                  - 0
         | 
| 168 | 
            +
                  hash: 205170909
         | 
| 169 | 
            +
            requirements: []
         | 
| 170 | 
            +
            rubyforge_project: 
         | 
| 171 | 
            +
            rubygems_version: 1.8.23
         | 
| 172 | 
            +
            signing_key: 
         | 
| 173 | 
            +
            specification_version: 3
         | 
| 174 | 
            +
            summary: Classified advertisement product for crowdsourcing engine voluntary.
         | 
| 175 | 
            +
            test_files: []
         |