voluntary 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -0
  3. data/README.md +1 -1
  4. data/app/assets/javascripts/voluntary/lib/jquery-competitive_list.js +533 -0
  5. data/app/controllers/comments_controller.rb +1 -3
  6. data/app/controllers/concerns/voluntary/v1/base_controller.rb +1 -5
  7. data/app/controllers/home_controller.rb +0 -1
  8. data/app/controllers/workflow/project_owner_controller.rb +17 -15
  9. data/app/controllers/workflow/tasks_controller.rb +1 -1
  10. data/app/models/ability.rb +3 -7
  11. data/app/models/comment.rb +1 -1
  12. data/app/models/product/music_metadata_enrichment.rb +2 -0
  13. data/app/models/product.rb +0 -27
  14. data/app/models/project.rb +0 -1
  15. data/app/models/project_user.rb +2 -3
  16. data/app/models/user.rb +4 -3
  17. data/app/views/layouts/application.html.erb +0 -4
  18. data/app/views/layouts/shared/_flash_messages.html.erb +2 -2
  19. data/app/views/workflow/project_owner/index.html.erb +7 -7
  20. data/config/locales/en.yml +1 -2
  21. data/config/locales/general/en.yml +2 -8
  22. data/config/locales/workflow/en.yml +1 -5
  23. data/config/routes/workflow.rb +0 -25
  24. data/config/routes.rb +0 -35
  25. data/db/migrate/20131018143613_replace_user_by_polymorphic_resource_in_candidatures.rb +4 -4
  26. data/db/migrate/20150802141840_drop_recruiting_unless_recruiting_plugin_present.rb +59 -0
  27. data/lib/generators/voluntary/install/templates/features/support/paths.rb +0 -14
  28. data/lib/generators/voluntary/product_dummy/templates/config/main_navigation.rb +1 -260
  29. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/comment_steps.rb +1 -1
  30. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/custom_web_steps.rb +5 -0
  31. data/lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_controller.rb +1 -1
  32. data/lib/generators/voluntary/product_dummy/templates/features/support/paths.rb +0 -14
  33. data/lib/voluntary/navigation.rb +34 -74
  34. data/lib/voluntary/test/rspec_helpers/factories.rb +10 -17
  35. data/lib/voluntary/version.rb +1 -1
  36. data/lib/voluntary.rb +1 -2
  37. metadata +37 -44
  38. data/app/assets/javascripts/voluntary/lib/competitive_list.js +0 -484
  39. data/app/controllers/candidatures_controller.rb +0 -84
  40. data/app/controllers/vacancies_controller.rb +0 -88
  41. data/app/controllers/workflow/candidatures_controller.rb +0 -20
  42. data/app/controllers/workflow/vacancies_controller.rb +0 -17
  43. data/app/models/candidature.rb +0 -38
  44. data/app/models/state_machines/candidature.rb +0 -64
  45. data/app/models/state_machines/vacancy.rb +0 -49
  46. data/app/models/vacancy.rb +0 -43
  47. data/app/views/candidatures/_form.html.erb +0 -13
  48. data/app/views/candidatures/edit.html.erb +0 -3
  49. data/app/views/candidatures/index.html.erb +0 -11
  50. data/app/views/candidatures/new.html.erb +0 -3
  51. data/app/views/candidatures/show.html.erb +0 -18
  52. data/app/views/vacancies/_form.html.erb +0 -15
  53. data/app/views/vacancies/edit.html.erb +0 -3
  54. data/app/views/vacancies/index.html.erb +0 -7
  55. data/app/views/vacancies/new.html.erb +0 -3
  56. data/app/views/vacancies/show.html.erb +0 -15
  57. data/app/views/workflow/project_owner/_candidatures.html.erb +0 -32
  58. data/app/views/workflow/project_owner/_vacancies.html.erb +0 -27
  59. data/config/locales/resources/candidature/en.yml +0 -19
  60. data/config/locales/resources/vacancy/en.yml +0 -29
  61. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/candidature_steps.rb +0 -34
  62. data/lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb +0 -32
@@ -1,17 +0,0 @@
1
- class Workflow::VacanciesController < ApplicationController
2
- def open
3
- @vacancies = Vacancy.where(state: 'open')
4
- end
5
-
6
- def recommended
7
- @vacancies = Vacancy.where(state: 'recommended')
8
- end
9
-
10
- def denied
11
- @vacancies = Vacancy.where(state: 'denied')
12
- end
13
-
14
- def closed
15
- @vacancies = Vacancy.where(state: 'closed')
16
- end
17
- end
@@ -1,38 +0,0 @@
1
- class Candidature < ActiveRecord::Base
2
- include StateMachines::Candidature
3
-
4
- belongs_to :vacancy
5
- belongs_to :offeror, class_name: 'User'
6
- belongs_to :resource, polymorphic: true
7
-
8
- has_many :comments, as: :commentable, dependent: :destroy
9
-
10
- scope :accepted, -> { where(state: 'accepted') }
11
-
12
- validates :vacancy_id, presence: true
13
- validates :offeror_id, presence: true
14
- validates :resource_id, presence: true, uniqueness: { scope: [:resource_type, :vacancy_id] }
15
- #validates :name, presence: true, uniqueness: { scope: :vacancy_id }
16
-
17
- attr_accessible :vacancy, :vacancy_id, :name, :text
18
-
19
- extend FriendlyId
20
- friendly_id :name, use: :slugged
21
-
22
- before_validation :set_offeror
23
-
24
- # association shortcuts
25
- def project
26
- vacancy.project
27
- end
28
-
29
- def product
30
- project.product
31
- end
32
-
33
- private
34
-
35
- def set_offeror
36
- self.offeror_id = vacancy.project.user_id
37
- end
38
- end
@@ -1,64 +0,0 @@
1
- module StateMachines::Candidature
2
- def self.included(base)
3
- base.extend ClassMethods
4
-
5
- base.class_eval do
6
- attr_accessor :current_user
7
-
8
- const_set 'STATES', [:new, :accepted, :denied]
9
- const_set 'EVENTS', [:accept, :deny, :quit]
10
-
11
- after_initialize :set_initial_state
12
-
13
- state_machine :state, initial: :new do
14
- event :accept do
15
- transition [:new, :denied] => :accepted
16
- end
17
-
18
- state :accepted do
19
- validate :candidatures_limit_not_reached
20
- end
21
-
22
- event :deny do
23
- transition [:new, :accepted] => :denied
24
- end
25
-
26
- event :quit do
27
- transition :accepted => :denied
28
- end
29
-
30
- after_transition do |object, transition|
31
- case transition.to
32
- when 'accepted'
33
- ProjectUser.find_or_create_by_project_id_and_vacancy_id_and_user_id!(
34
- project_id: object.vacancy.project_id, vacancy_id: object.vacancy_id,
35
- user_id: object.resource_id
36
- )
37
-
38
- if object.vacancy.limit == object.vacancy.candidatures.accepted.count
39
- object.vacancy.close! unless object.vacancy.closed?
40
- end
41
- when 'denied'
42
- # if comming from :accepted then the vacancy offerer has to reopen the vacancy manually
43
- end
44
- end
45
- end
46
-
47
- private
48
-
49
- # state validations
50
- def candidatures_limit_not_reached
51
- if vacancy.limit == vacancy.candidatures.where(state: 'accepted').count
52
- errors[:state] << I18n.t('activerecord.errors.models.vacancy.attributes.limit.reached')
53
- end
54
- end
55
-
56
- def set_initial_state
57
- self.state ||= :new
58
- end
59
- end
60
- end
61
-
62
- module ClassMethods
63
- end
64
- end
@@ -1,49 +0,0 @@
1
- module StateMachines::Vacancy
2
- def self.included(base)
3
- base.extend ClassMethods
4
-
5
- base.class_eval do
6
- attr_accessor :current_user
7
-
8
- const_set 'STATES', [:open, :recommended, :denied, :closed]
9
- const_set 'EVENTS', [:accept_recommendation, :deny_recommendation, :close, :reopen]
10
-
11
- after_initialize :set_initial_state
12
-
13
- state_machine :state, initial: :new do
14
- event :recommend do
15
- transition :new => :recommended
16
- end
17
-
18
- event :accept_recommendation do
19
- transition :recommended => :open
20
- end
21
-
22
- event :deny_recommendation do
23
- transition :recommended => :denied
24
- end
25
-
26
- event :do_open do
27
- transition :new => :open
28
- end
29
-
30
- event :close do
31
- transition :open => :closed
32
- end
33
-
34
- event :reopen do
35
- transition [:denied, :closed] => :open
36
- end
37
- end
38
-
39
- private
40
-
41
- def set_initial_state
42
- self.state ||= :new
43
- end
44
- end
45
- end
46
-
47
- module ClassMethods
48
- end
49
- end
@@ -1,43 +0,0 @@
1
- class Vacancy < ActiveRecord::Base
2
- include StateMachines::Vacancy
3
-
4
- belongs_to :project
5
- belongs_to :offeror, class_name: 'User'
6
- belongs_to :author, class_name: 'User'
7
- belongs_to :resource, polymorphic: true
8
- belongs_to :project_user
9
-
10
- has_many :candidatures, dependent: :destroy
11
- has_many :comments, as: :commentable, dependent: :destroy
12
-
13
- accepts_nested_attributes_for :candidatures, allow_destroy: true, reject_if: ->(t) { t['name'].blank? }
14
- scope :open, -> { where(state: 'open') }
15
-
16
-
17
- validates :project_id, presence: true
18
- validates :offeror_id, presence: true
19
- validates :name, presence: true, uniqueness: { scope: :project_id }
20
- validates :text, presence: true
21
- validates :limit, presence: true
22
-
23
- attr_accessible :project_id, :name, :text, :limit, :candidatures_attributes
24
-
25
- extend FriendlyId
26
-
27
- friendly_id :name, use: :slugged
28
-
29
- before_validation :set_defaults
30
-
31
- def candidatures_left
32
- limit - candidatures.accepted.count
33
- end
34
-
35
- protected
36
-
37
- def set_defaults
38
- if project
39
- self.offeror_id = project.user_id
40
- self.author_id = project.user_id unless self.author_id.present?
41
- end
42
- end
43
- end
@@ -1,13 +0,0 @@
1
- <%= simple_form_for(@candidature) do |f| %>
2
- <%= render partial: 'shared/form/error_messages', locals: { resource: @candidature } %>
3
-
4
- <div class="form-inputs">
5
- <%= @candidature.vacancy ? f.hidden_field(:vacancy_id) : f.association(:vacancy) %>
6
- <%= f.input :name %>
7
- <%= f.input :text, input_html: {style: 'width: 500px; height:300px;'} %>
8
- </div>
9
-
10
- <div class="form-actions">
11
- <%= f.button :submit %>
12
- </div>
13
- <% end %>
@@ -1,3 +0,0 @@
1
- <h3><%= t('candidatures.edit.title') %></h3>
2
-
3
- <%= render 'form' %>
@@ -1,11 +0,0 @@
1
- <% columns = { 'name' => 'resource.name', 'resource_id' => ''} %>
2
- <% columns['vacancy_id'] = '' unless @vacancy %>
3
- <% columns['project_id'] = 'vacancy.project' unless @vacancy %>
4
-
5
- <%= form_tag update_multiple_candidatures_path, method: :post do %>
6
- <%= render partial: "shared/collection/#{@vacancy ? 'list' : 'table'}", locals: {
7
- type: 'candidatures', collection: @candidatures, columns: columns, content_column: 'text'
8
- } %>
9
- <% end %>
10
-
11
- <%= link_to t('candidatures.new.title'), new_vacancy_candidature_path(@vacancy) if @vacancy %>
@@ -1,3 +0,0 @@
1
- <h3><%= t('candidatures.new.title') %></h3>
2
-
3
- <%= render 'form' %>
@@ -1,18 +0,0 @@
1
- <h3>
2
- <a name="top">&nbsp;</a>
3
- <% if @candidature.name.present? %>
4
- <%= @candidature.name %>
5
- <% else %>
6
- No Name
7
- <% end %>
8
- </h3>
9
-
10
- <dl class="dl-horizontal">
11
- <%= show_associations :project, :vacancy, :resource %>
12
- <%= show_attribute :state %>
13
- <%= show_actions %>
14
- </dl>
15
-
16
- <%= markdown @candidature.text %>
17
-
18
- <%= render 'shared/comments', comment: @candidature.comments.new %>
@@ -1,15 +0,0 @@
1
- <%= simple_form_for(@vacancy, html: {class: 'form-horizontal'}) do |f| %>
2
- <%= render partial: 'shared/form/error_messages', locals: { resource: @vacancy } %>
3
-
4
- <div class="form-inputs">
5
- <%= @vacancy.project ? f.hidden_field(:project_id) : f.association(:project) %>
6
-
7
- <%= f.input :name %>
8
- <%= f.input :text, input_html: {style: 'width: 500px; height:300px;'} %>
9
- <%= f.input :limit %>
10
- </div>
11
-
12
- <div class="form-actions">
13
- <%= f.button :submit %>
14
- </div>
15
- <% end %>
@@ -1,3 +0,0 @@
1
- <h3><%= t('vacancies.edit.title') %></h3>
2
-
3
- <%= render 'form' %>
@@ -1,7 +0,0 @@
1
- <%= form_tag update_multiple_candidatures_path, method: :post do %>
2
- <%= render partial: "shared/collection/#{@project ? 'list' : 'table'}", locals: {
3
- type: 'vacancies', collection: @vacancies, columns: ['name', 'project_id'], content_column: 'text'
4
- } %>
5
- <% end %>
6
-
7
- <%= link_to t('vacancies.new.title'), new_project_vacancy_path(@project) if @project %>
@@ -1,3 +0,0 @@
1
- <h3><%= t('vacancies.new.title') %></h3>
2
-
3
- <%= render 'form' %>
@@ -1,15 +0,0 @@
1
- <h3>
2
- <a id="top" name="top"></a>
3
- <%= @vacancy.name %>
4
- </h3>
5
-
6
- <dl class="dl-horizontal">
7
- <%= show_associations :project %>
8
- <%= show_attribute :limit, value: "#{@vacancy.candidatures_left} / #{@vacancy.limit}" %>
9
- <%= show_attribute :state %>
10
- <%= show_actions %>
11
- </dl>
12
-
13
- <%= markdown @vacancy.text %>
14
-
15
- <%= render 'shared/comments', comment: @vacancy.comments.new %>
@@ -1,32 +0,0 @@
1
- <div class="tabs">
2
- <ul>
3
- <% Candidature::STATES.each do |state| %>
4
- <li>
5
- <a href="#<%= state %>_candidatures">
6
- <%= I18n.t("candidatures.show.states.#{state}") %>
7
- <% if @candidatures[state].length == 5 %>
8
- (<%= @candidatures[state].length %>+)
9
- <% elsif @candidatures[state].length > 0 %>
10
- (<%= @candidatures[state].length %>)
11
- <% end %>
12
- </a>
13
- </li>
14
- <% end %>
15
- </ul>
16
- <% Candidature::STATES.each do |state| %>
17
- <div id="<%= state %>_candidatures">
18
- <%= render partial: 'shared/collection/table', locals: {
19
- type: 'candidatures', collection: @candidatures[state],
20
- columns: {
21
- 'project_id' => 'vacancy.project', 'vacancy_id' => '', 'name' => 'user.name',
22
- 'resource_id' => ''
23
- },
24
- options: {show_title: false, append_new_link: false }
25
- } %>
26
-
27
- <% if @candidatures[state].length == 5 %>
28
- <p><%= link_to t('general.more'), eval("#{state}_workflow_candidatures_path") %></p>
29
- <% end %>
30
- </div>
31
- <% end %>
32
- </div>
@@ -1,27 +0,0 @@
1
- <div class="tabs">
2
- <ul>
3
- <% Vacancy::STATES.each do |state| %>
4
- <li>
5
- <a href="#<%= state %>_vacancies">
6
- <%= I18n.t("vacancies.show.states.#{state}") %>
7
- <% if @vacancies[state].length == 5 %>
8
- (<%= @vacancies[state].length %>+)
9
- <% elsif @vacancies[state].length > 0 %>
10
- (<%= @vacancies[state].length %>)
11
- <% end %>
12
- </a>
13
- </li>
14
- <% end %>
15
- </ul>
16
- <% Vacancy::STATES.each do |state| %>
17
- <div id="<%= state %>_vacancies">
18
- <%= render partial: 'shared/collection/table', locals: {
19
- type: 'vacancies', collection: @vacancies[state], columns: ['name', 'project_id'],
20
- options: {show_title: false, append_new_link: false }
21
- } %>
22
- <% if @vacancies[state].length == 5 %>
23
- <p><%= link_to t('general.more'), eval("#{state}_workflow_vacancies_path") if @vacancies[state].length > 0 %></p>
24
- <% end %>
25
- </div>
26
- <% end %>
27
- </div>
@@ -1,19 +0,0 @@
1
- en:
2
- candidatures:
3
- index:
4
- title: Candidatures
5
- empty_collection: No candidatures available.
6
- new:
7
- title: New Candidature
8
- edit:
9
- title: Edit Candidature
10
- show:
11
- states:
12
- new: New
13
- accepted: Accepted
14
- denied: Denied
15
- events:
16
- accept: Accept
17
- deny: Deny
18
- quit: Quit
19
-
@@ -1,29 +0,0 @@
1
- en:
2
- vacancies:
3
- index:
4
- title: Vacancies
5
- empty_collection: No vacancies available.
6
- new:
7
- title: New Vacancy
8
- edit:
9
- title: Edit Vacancy
10
- show:
11
- states:
12
- open: Open
13
- recommended: Recommended
14
- denied: Denied
15
- closed: Closed
16
- events:
17
- recommend: Recommend
18
- accept_recommendation: Accept recommendation
19
- deny_recommendation: Deny recommendation
20
- close: Close
21
- reopen: Reopen
22
-
23
- activerecord:
24
- errors:
25
- models:
26
- vacancy:
27
- attributes:
28
- limit:
29
- reached: Limit of candidatures already reached
@@ -1,34 +0,0 @@
1
- module CandidatureFactoryMethods
2
- def set_candidature_defaults(attributes)
3
- attributes[:user_id] ||= @me.id unless attributes[:user] || attributes[:user_id] || !@me
4
- attributes[:vacancy_id] ||= Vacancy.last.id unless attributes[:vacancy_id] || Vacancy.all.none?
5
- attributes[:offeror_id] ||= Vacancy.find(attributes[:vacancy_id]).project.user_id if attributes[:vacancy_id]
6
- end
7
-
8
- def new_candidature(name, state = nil)
9
- attributes = { name: name }
10
- attributes[:state] = state if state
11
-
12
- set_candidature_defaults(attributes)
13
-
14
- @candidature = Factory(:candidature, attributes)
15
-
16
- @candidature.reload
17
- end
18
- end
19
-
20
- World(CandidatureFactoryMethods)
21
-
22
- Given /^a candidature named "([^\"]*)"$/ do |name|
23
- new_candidature(name)
24
- end
25
-
26
- Given /^a candidature named "([^\"]*)" with state "([^\"]*)"$/ do |name,state|
27
- new_candidature(name, state)
28
- end
29
-
30
- Then /^I should see the following candidatures:$/ do |expected_table|
31
- rows = find('table').all('tr')
32
- table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
33
- expected_table.diff!(table)
34
- end
@@ -1,32 +0,0 @@
1
- module VacancyFactoryMethods
2
- def set_vacancy_defaults(attributes)
3
- attributes[:user_id] ||= @me.id unless attributes[:user_id] || !@me
4
- attributes[:project_id] ||= Project.last.id unless attributes[:project_id] || Project.all.none?
5
- end
6
-
7
- def new_vacancy(name, state = nil)
8
- attributes = { name: name }
9
- attributes[:state] = state if state
10
-
11
- set_vacancy_defaults(attributes)
12
-
13
- @vacancy = Factory(:vacancy, attributes)
14
- @vacancy.reload
15
- end
16
- end
17
-
18
- World(VacancyFactoryMethods)
19
-
20
- Given /^a vacancy named "([^\"]*)"$/ do |name|
21
- new_vacancy(name)
22
- end
23
-
24
- Given /^a vacancy named "([^\"]*)" with state "([^\"]*)"$/ do |name, state|
25
- new_vacancy(name, state)
26
- end
27
-
28
- Then /^I should see the following vacancies:$/ do |expected_table|
29
- rows = find('table').all('tr')
30
- table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
31
- expected_table.diff!(table)
32
- end