voluntary 0.3.0 → 0.4.0

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.
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
@@ -19,7 +19,7 @@ class Ability
19
19
  alias_action :read, :assign_actions, to: :supervisor
20
20
 
21
21
  can :read, [
22
- Area, Organization, Profession, Product, Project, Vacancy, Candidature, Story, Task, Result, Comment
22
+ Area, Organization, Profession, Product, Project, Story, Task, Result, Comment
23
23
  ]
24
24
  can [:read, :check_name, :check_url, :check_email, :check_email_unblocked], User
25
25
  can :show, Page
@@ -27,21 +27,17 @@ class Ability
27
27
  if user.present?
28
28
  can :destroy, User, id: user.id
29
29
 
30
- can [:new, :create], [Area, Profession, Project, Vacancy, Candidature, Comment, Like]
30
+ can [:new, :create], [Area, Profession, Project, Comment, Like]
31
31
  can :assign, Task
32
32
  can [:update, :cancel, :review], [Task, Like], user_id: user.id
33
33
 
34
34
  {
35
35
  user_id: [Product, Organization, Project, Comment, ProjectUser, Result],
36
- offeror_id: [Vacancy, Story, Task]
36
+ offeror_id: [Story, Task]
37
37
  }.each do |attribute, classes|
38
38
  can :restful_actions, classes, attribute => user.id
39
39
  end
40
40
 
41
- can :restful_actions, Candidature, resource_type: 'User', resource_id: user.id
42
-
43
- can Candidature::EVENTS, Candidature, offeror_id: user.id
44
- can Vacancy::EVENTS, Vacancy, offeror_id: user.id
45
41
  can Story::EVENTS, Story, offeror_id: user.id
46
42
  can Task::EVENTS + [:update], Task, offeror_id: user.id
47
43
 
@@ -12,5 +12,5 @@ class Comment < ActiveRecord::Base
12
12
 
13
13
  attr_accessible :commentable_type, :commentable_id, :parent_id, :name, :text
14
14
 
15
- COMMENTABLE_TYPES = ['project', 'vacancy', 'candidature']
15
+ COMMENTABLE_TYPES = ['project']
16
16
  end
@@ -0,0 +1,2 @@
1
+ class Product::MusicMetadataEnrichment < ::Product
2
+ end
@@ -16,12 +16,9 @@ class Product
16
16
  validates :name, presence: true, uniqueness: true
17
17
 
18
18
  validate :english_name_available?
19
- validate :existing_model_file?
20
19
 
21
20
  index({ name: 1 }, { unique: true })
22
21
 
23
- before_validation :set_klass_name
24
-
25
22
  # active record compatibility
26
23
  # just belongs_to reflections for cucumber's factory steps
27
24
  def self.reflections
@@ -77,28 +74,4 @@ class Product
77
74
  )
78
75
  end
79
76
  end
80
-
81
- def existing_model_file?
82
- unless (get_klass_name.constantize rescue false)
83
- errors[:name] << I18n.t(
84
- 'activerecord.errors.models.product.attributes.name.missing_model_file'
85
- )
86
- end
87
- end
88
-
89
- def get_klass_name
90
- if klass_name.present?
91
- klass_name
92
- elsif name == 'Product'
93
- 'Product'
94
- else
95
- [
96
- 'Product', name.gsub(' - ', '_').gsub('-', '_').gsub(' ', '_').classify
97
- ].join('::')
98
- end
99
- end
100
-
101
- def set_klass_name
102
- self._type = get_klass_name
103
- end
104
77
  end
@@ -3,7 +3,6 @@ class Project < ActiveRecord::Base
3
3
  belongs_to :organization
4
4
 
5
5
  has_many :project_users, dependent: :destroy
6
- has_many :vacancies, dependent: :destroy
7
6
  has_many :roles, through: :project_users
8
7
  has_many :comments, as: :commentable, dependent: :destroy
9
8
 
@@ -2,12 +2,11 @@ class ProjectUser < ActiveRecord::Base#
2
2
  self.table_name = 'projects_users'
3
3
 
4
4
  belongs_to :project
5
- belongs_to :vacancy
6
5
  belongs_to :user
7
6
  belongs_to :role
8
7
 
9
8
  validates :project_id, presence: true
10
- validates :user_id, presence: true, uniqueness: { scope: [:project_id, :vacancy_id] }
9
+ validates :user_id, presence: true, uniqueness: { scope: [:project_id] }
11
10
 
12
- attr_accessible :project_id, :vacancy_id, :user_id, :role_id
11
+ attr_accessible :project_id, :user_id, :role_id
13
12
  end
data/app/models/user.rb CHANGED
@@ -13,9 +13,6 @@ class User < ActiveRecord::Base
13
13
  has_and_belongs_to_many :projects
14
14
 
15
15
  has_many :organizations, dependent: :destroy
16
- has_many :offeror_vacancies, source: :offeror, class_name: 'Vacancy'
17
- has_many :offeror_candidatures, source: :offeror, class_name: 'Candidature'
18
- has_many :candidatures, as: :resource
19
16
 
20
17
  accepts_nested_attributes_for :areas, allow_destroy: true
21
18
 
@@ -49,6 +46,10 @@ class User < ActiveRecord::Base
49
46
 
50
47
  PARENT_TYPES = ['area', 'project']
51
48
 
49
+ def self.by_slug_or_id(id)
50
+ id.to_i.to_s == id.to_s ? find(id) : friendly.find(id)
51
+ end
52
+
52
53
  def self.languages(query = nil)
53
54
  options = []
54
55
 
@@ -11,10 +11,6 @@
11
11
  <body>
12
12
  <div id="bootstrap_modal" class="modal hide fade"></div>
13
13
 
14
- <% if voluntary_application_repository_path.present? %>
15
- <a href="https://github.com/<%= voluntary_application_repository_path %>"><img style="position: absolute; top: 41px; right: 0; border: 0; z-index: 100;" src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"></a>
16
- <% end %>
17
-
18
14
  <section id="dialog">
19
15
  <img alt="Ajax-loader-small" class="hide " id="dialog_body_spinner" src="<%=image_path('voluntary/spinner.gif')%>"/>
20
16
  <div id="dialog_body"/>
@@ -1,7 +1,7 @@
1
1
  <div class="flash">
2
2
  <% flash.each do |type, message| -%>
3
- <div class="message <%= type == :notice ? 'alert-info' : type %>">
4
- <p><%= message %></p>
3
+ <div class="alert message <%= (type.to_sym == :notice ? 'alert-info' : 'alert-error') %>">
4
+ <%= message %><br/>
5
5
  </div>
6
6
  <% end -%>
7
7
  </div>
@@ -4,8 +4,9 @@
4
4
  <ul>
5
5
  <li><a href="#stories"><%= I18n.t('stories.index.title') %></a></li>
6
6
  <li><a href="#tasks"><%= I18n.t('workflow.project_owner.index.tasks') %></a></li>
7
- <li><a href="#candidatures"><%= I18n.t('candidatures.index.title') %></a></li>
8
- <li><a href="#vacancies"><%= I18n.t('vacancies.index.title') %></a></li>
7
+ <% Workflow::ProjectOwnerController.extra_tabs.each do |tab| %>
8
+ <li><a href="#<%= tab %>"><%= I18n.t("#{tab}.index.title") %></a></li>
9
+ <% end %>
9
10
  </ul>
10
11
  <div id="stories">
11
12
  <%= render 'stories' %>
@@ -13,12 +14,11 @@
13
14
  <div id="tasks">
14
15
  <%= render 'tasks' %>
15
16
  </div>
16
- <div id="candidatures">
17
- <%= render 'candidatures' %>
18
- </div>
19
- <div id="vacancies">
20
- <%= render 'vacancies' %>
17
+ <% Workflow::ProjectOwnerController.extra_tabs.each do |tab| %>
18
+ <div id="<%= tab %>">
19
+ <%= render "workflow/project_owner/#{tab}" %>
21
20
  </div>
21
+ <% end %>
22
22
  </div>
23
23
  </div>
24
24
  </div>
@@ -16,8 +16,7 @@ en:
16
16
  home:
17
17
  index:
18
18
  last_projects: Last projects
19
- last_vacancies: Last vacancies
20
-
19
+
21
20
  authentication:
22
21
  title: Authentication
23
22
  sign_in: Sign in
@@ -55,8 +55,7 @@ en:
55
55
  parent: Parent
56
56
  project_id: Project
57
57
  state: State
58
- user_id: User
59
- vacancy_id: Vacancy
58
+ user_id: User
60
59
  roles: Roles
61
60
  position: Position
62
61
  date: Date
@@ -65,7 +64,6 @@ en:
65
64
  activerecord:
66
65
  models:
67
66
  area: Area
68
- candidature: Candidature
69
67
  comment: Comment
70
68
  product: Product
71
69
  organization: Organization
@@ -74,14 +72,10 @@ en:
74
72
  story: Story
75
73
  task: Task
76
74
  user: User
77
- vacancy: Vacancy
78
75
 
79
76
  attributes:
80
77
  comment:
81
78
  name: Subject
82
- vacancy:
83
- name: Name
84
- limit: Limit
85
79
  user:
86
80
  area_tokens: Areas
87
81
  country: Country
@@ -89,7 +83,7 @@ en:
89
83
  foreign_language: Foreign language
90
84
  interface_language: Interface language
91
85
  language: Mother tongue
92
- profession: Beruf
86
+ profession: Profession
93
87
 
94
88
  errors:
95
89
  models:
@@ -34,8 +34,4 @@ en:
34
34
  tasks:
35
35
  next:
36
36
  title: Next Task
37
- unavailable: No further task available.
38
-
39
- controllers:
40
- vacancies:
41
- candidatures:
37
+ unavailable: No further task available.
@@ -25,29 +25,4 @@ namespace 'workflow' do
25
25
  get 'tasks/:id/complete' => 'tasks#complete', as: :complete_task
26
26
  end
27
27
  end
28
-
29
- resources :vacancies, controller: 'vacancies', only: :index do
30
- collection do
31
- get '/' => 'vacancies#open', as: :open
32
-
33
- get :autocomplete
34
-
35
- get :open
36
- get :recommended
37
- get :denied
38
- get :closed
39
- end
40
- end
41
-
42
- resources :candidatures, controller: 'candidatures', only: :index do
43
- collection do
44
- get '/' => 'candidatures#new', as: :new
45
-
46
- get :autocomplete
47
-
48
- get :new
49
- get :accepted
50
- get :denied
51
- end
52
- end
53
28
  end
data/config/routes.rb CHANGED
@@ -49,7 +49,6 @@ Rails.application.routes.draw do
49
49
 
50
50
  resources :projects do
51
51
  resources :users, only: :index
52
- resources :vacancies, only: [:index, :new]
53
52
  resources :stories, only: [:index, :new]
54
53
  resources :comments, only: [:index, :new]
55
54
 
@@ -58,39 +57,6 @@ Rails.application.routes.draw do
58
57
  get :autocomplete
59
58
  end
60
59
  end
61
-
62
- resources :vacancies do
63
- resources :candidatures, only: [:index, :new]
64
- resources :comments, only: [:index, :new]
65
-
66
- collection do
67
- put :update_multiple
68
- get :autocomplete
69
- end
70
-
71
- member do
72
- put :recommend
73
- put :accept_recommendation
74
- put :deny_recommendation
75
- put :close
76
- put :reopen
77
- end
78
- end
79
-
80
- resources :candidatures do
81
- resources :comments, only: [:index, :new]
82
-
83
- collection do
84
- put :update_multiple
85
- get :autocomplete
86
- end
87
-
88
- member do
89
- get :accept
90
- get :deny
91
- get :quit
92
- end
93
- end
94
60
 
95
61
  resources :stories, only: [:create, :show, :edit, :update, :destroy] do
96
62
  resources :tasks, only: [:index, :new]
@@ -134,7 +100,6 @@ Rails.application.routes.draw do
134
100
 
135
101
  resources :users do
136
102
  resources :projects, only: [:index, :new]
137
- resources :candidatures, only: :index
138
103
 
139
104
  collection do
140
105
  put :update_multiple
@@ -3,16 +3,16 @@ class ReplaceUserByPolymorphicResourceInCandidatures < ActiveRecord::Migration
3
3
  add_column :vacancies, :resource_type, :string
4
4
  add_column :vacancies, :resource_id, :integer
5
5
 
6
- Vacancy.update_all(resource_type: "User")
7
- Vacancy.update_all('resource_id = user_id')
6
+ Vacancy.where('user_id IS NOT NULL').update_all(resource_type: "User")
7
+ Vacancy.where('user_id IS NOT NULL').update_all('resource_id = user_id')
8
8
 
9
9
  remove_column :vacancies, :user_id
10
10
 
11
11
  add_column :candidatures, :resource_type, :string
12
12
  add_column :candidatures, :resource_id, :integer
13
13
 
14
- Candidature.update_all(resource_type: "User")
15
- Candidature.update_all('resource_id = user_id')
14
+ Candidature.where('user_id IS NOT NULL').update_all(resource_type: "User")
15
+ Candidature.where('user_id IS NOT NULL').update_all('resource_id = user_id')
16
16
 
17
17
  remove_column :candidatures, :user_id
18
18
 
@@ -0,0 +1,59 @@
1
+ class DropRecruitingUnlessRecruitingPluginPresent < ActiveRecord::Migration
2
+ def up
3
+ unless (Product::Recruiting rescue nil)
4
+ drop_table :vacancies
5
+ drop_table :candidatures
6
+ remove_index name: 'index_projects_users_on_project_id_and_user_id_and_vacancy_id'
7
+ drop_column :projects_users, :vacancy_id
8
+ add_index 'projects_users', ['project_id', 'user_id'], name: 'index_projects_users_on_project_id_and_user_id', unique: true, using: :btree
9
+ end
10
+ end
11
+
12
+ def down
13
+ unless (Product::Recruiting rescue nil)
14
+ create_table 'vacancies', force: true do |t|
15
+ t.string 'type'
16
+ t.integer 'project_id'
17
+ t.integer 'offeror_id'
18
+ t.integer 'author_id'
19
+ t.integer 'project_user_id'
20
+ t.string 'name'
21
+ t.string 'slug'
22
+ t.text 'text'
23
+ t.integer 'limit', default: 1
24
+ t.string 'state'
25
+ t.datetime 'created_at', null: false
26
+ t.datetime 'updated_at', null: false
27
+ t.string 'resource_type'
28
+ t.integer 'resource_id'
29
+ end
30
+
31
+ add_index 'vacancies', ['offeror_id'], name: 'index_vacancies_on_offeror_id', using: :btree
32
+ add_index 'vacancies', ['project_id', 'name'], name: 'index_vacancies_on_project_id_and_name', unique: true, using: :btree
33
+ add_index 'vacancies', ['project_id'], name: 'index_vacancies_on_project_id', using: :btree
34
+ add_index 'vacancies', ['project_user_id'], name: 'index_vacancies_on_project_user_id', using: :btree
35
+ add_index 'vacancies', ['slug'], name: 'index_vacancies_on_slug', unique: true, using: :btree
36
+
37
+ create_table 'candidatures', force: true do |t|
38
+ t.integer 'vacancy_id'
39
+ t.integer 'offeror_id'
40
+ t.string 'name'
41
+ t.string 'slug'
42
+ t.text 'text'
43
+ t.string 'state'
44
+ t.datetime 'created_at', null: false
45
+ t.datetime 'updated_at', null: false
46
+ t.string 'resource_type'
47
+ t.integer 'resource_id'
48
+ end
49
+
50
+ add_index 'candidatures', ['resource_id', 'resource_type', 'vacancy_id'], name: 'index_candidatures_on_resource_and_vacancy', unique: true, using: :btree
51
+ add_index 'candidatures', ['slug'], name: 'index_candidatures_on_slug', unique: true, using: :btree
52
+ add_index 'candidatures', ['vacancy_id', 'name'], name: 'index_candidatures_on_vacancy_id_and_name', unique: true, using: :btree
53
+ add_index 'candidatures', ['vacancy_id'], name: 'index_candidatures_on_vacancy_id', using: :btree
54
+
55
+ add_column 'projects_users', 'vacancy_id', :integer
56
+ add_index 'projects_users', ['project_id', 'user_id', 'vacancy_id'], name: 'index_projects_users_on_project_id_and_user_id_and_vacancy_id', unique: true, using: :btree
57
+ end
58
+ end
59
+ end
@@ -43,20 +43,6 @@ module NavigationHelpers
43
43
 
44
44
  when /the edit project page/
45
45
  edit_project_path(@project)
46
-
47
- # vacancies
48
- when /the vacancy page/
49
- vacancy_path(@vacancy)
50
-
51
- when /the edit vacancy page/
52
- edit_vacancy_path(@vacancy)
53
-
54
- # candidatures
55
- when /the candidature page/
56
- candidature_path(@candidature)
57
-
58
- when /the edit candidature page/
59
- edit_candidature_path(@candidature)
60
46
 
61
47
  # stories
62
48
  when /the new project story page/