voluntary 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +48 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/voluntary/application.js +6 -0
- data/app/assets/javascripts/voluntary/base.js.coffee +34 -0
- data/app/assets/javascripts/voluntary/bootstrap.js.coffee +4 -0
- data/app/assets/javascripts/voluntary/functions.js +24 -0
- data/app/assets/javascripts/voluntary/users.js.coffee +12 -0
- data/app/assets/stylesheets/voluntary/application.css +15 -0
- data/app/assets/stylesheets/voluntary/base.css.scss +40 -0
- data/app/assets/stylesheets/voluntary/bootstrap_and_overrides.css.less +67 -0
- data/app/controllers/areas_controller.rb +66 -0
- data/app/controllers/candidatures_controller.rb +79 -0
- data/app/controllers/comments_controller.rb +70 -0
- data/app/controllers/devise_extensions/registrations_controller.rb +37 -0
- data/app/controllers/home_controller.rb +7 -0
- data/app/controllers/organizations_controller.rb +67 -0
- data/app/controllers/pages_controller.rb +54 -0
- data/app/controllers/products_controller.rb +62 -0
- data/app/controllers/professions_controller.rb +66 -0
- data/app/controllers/projects_controller.rb +56 -0
- data/app/controllers/results_controller.rb +93 -0
- data/app/controllers/stories_controller.rb +96 -0
- data/app/controllers/tasks_controller.rb +88 -0
- data/app/controllers/users_controller.rb +52 -0
- data/app/controllers/vacancies_controller.rb +79 -0
- data/app/controllers/voluntary/application_controller.rb +92 -0
- data/app/controllers/workflow/candidatures_controller.rb +20 -0
- data/app/controllers/workflow/products_controller.rb +6 -0
- data/app/controllers/workflow/project_owner_controller.rb +33 -0
- data/app/controllers/workflow/stories_controller.rb +6 -0
- data/app/controllers/workflow/tasks_controller.rb +147 -0
- data/app/controllers/workflow/user_controller.rb +6 -0
- data/app/controllers/workflow/vacancies_controller.rb +17 -0
- data/app/controllers/workflow_controller.rb +7 -0
- data/app/helpers/application_helper.rb +65 -0
- data/app/helpers/collection_helper.rb +31 -0
- data/app/helpers/comments_helper.rb +11 -0
- data/app/helpers/form_helper.rb +39 -0
- data/app/helpers/language_helper.rb +15 -0
- data/app/helpers/layout_helper.rb +24 -0
- data/app/helpers/product_helper.rb +32 -0
- data/app/helpers/show_helper.rb +65 -0
- data/app/helpers/wizard_helper.rb +27 -0
- data/app/models/area.rb +19 -0
- data/app/models/area_user.rb +19 -0
- data/app/models/candidature.rb +35 -0
- data/app/models/comment.rb +16 -0
- data/app/models/history_tracker.rb +3 -0
- data/app/models/mongo_db_document.rb +11 -0
- data/app/models/organization.rb +19 -0
- data/app/models/page.rb +30 -0
- data/app/models/product.rb +99 -0
- data/app/models/product/new_product.rb +3 -0
- data/app/models/product/project_management.rb +29 -0
- data/app/models/profession.rb +13 -0
- data/app/models/project.rb +66 -0
- data/app/models/project_user.rb +13 -0
- data/app/models/result.rb +55 -0
- data/app/models/role.rb +8 -0
- data/app/models/role/admin.rb +2 -0
- data/app/models/role/master.rb +2 -0
- data/app/models/role/project_owner.rb +2 -0
- data/app/models/role/user.rb +2 -0
- data/app/models/state_machines/candidature.rb +42 -0
- data/app/models/state_machines/page.rb +18 -0
- data/app/models/state_machines/story.rb +51 -0
- data/app/models/state_machines/task.rb +46 -0
- data/app/models/state_machines/vacancy.rb +41 -0
- data/app/models/story.rb +82 -0
- data/app/models/task.rb +85 -0
- data/app/models/user.rb +95 -0
- data/app/models/user_role.rb +6 -0
- data/app/models/vacancy.rb +41 -0
- data/app/observers/candidature_observer.rb +29 -0
- data/app/observers/story_observer.rb +6 -0
- data/app/observers/task_observer.rb +34 -0
- data/app/presenters/layout/application_presenter.rb +3 -0
- data/app/presenters/layout_presenter.rb +9 -0
- data/app/presenters/presenter.rb +46 -0
- data/app/presenters/resource_presenter.rb +30 -0
- data/app/presenters/resources/general/wizard_presenter.rb +17 -0
- data/app/presenters/resources/general/wizards/story/steps/activate_presenter.rb +3 -0
- data/app/presenters/resources/general/wizards/story/steps/setup_tasks_presenter.rb +5 -0
- data/app/presenters/resources/general/wizards/story_presenter.rb +3 -0
- data/app/presenters/resources/user/form_presenter.rb +16 -0
- data/app/presenters/shared/collection/table_presenter.rb +33 -0
- data/app/views/areas/_form.html.erb +11 -0
- data/app/views/areas/edit.html.erb +3 -0
- data/app/views/areas/index.html.erb +5 -0
- data/app/views/areas/new.html.erb +3 -0
- data/app/views/areas/show.html.erb +6 -0
- data/app/views/candidatures/_form.html.erb +13 -0
- data/app/views/candidatures/edit.html.erb +3 -0
- data/app/views/candidatures/index.html.erb +11 -0
- data/app/views/candidatures/new.html.erb +3 -0
- data/app/views/candidatures/show.html.erb +18 -0
- data/app/views/comments/_form.html.erb +16 -0
- data/app/views/comments/_resource.html.erb +16 -0
- data/app/views/comments/edit.html.erb +3 -0
- data/app/views/comments/new.html.erb +3 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +10 -0
- data/app/views/devise/registrations/new.html.erb +5 -0
- data/app/views/general/wizard.html.erb +16 -0
- data/app/views/kaminari/_first_page.html.erb +13 -0
- data/app/views/kaminari/_gap.html.erb +8 -0
- data/app/views/kaminari/_last_page.html.erb +13 -0
- data/app/views/kaminari/_next_page.html.erb +13 -0
- data/app/views/kaminari/_page.html.erb +12 -0
- data/app/views/kaminari/_paginator.html.erb +25 -0
- data/app/views/kaminari/_prev_page.html.erb +13 -0
- data/app/views/layouts/application.html.erb +48 -0
- data/app/views/layouts/shared/_flash_messages.html.erb +7 -0
- data/app/views/layouts/shared/_navigation.html.erb +7 -0
- data/app/views/organizations/_form.html.erb +11 -0
- data/app/views/organizations/edit.html.erb +3 -0
- data/app/views/organizations/index.html.erb +5 -0
- data/app/views/organizations/new.html.erb +3 -0
- data/app/views/organizations/show.html.erb +6 -0
- data/app/views/pages/_form.html.erb +12 -0
- data/app/views/pages/edit.html.erb +3 -0
- data/app/views/pages/index.html.erb +5 -0
- data/app/views/pages/new.html.erb +3 -0
- data/app/views/pages/show.html.erb +10 -0
- data/app/views/products/_form.html.erb +28 -0
- data/app/views/products/edit.html.erb +3 -0
- data/app/views/products/index.html.erb +5 -0
- data/app/views/products/mixins/_keywords.html.erb +4 -0
- data/app/views/products/new.html.erb +3 -0
- data/app/views/products/show.html.erb +11 -0
- data/app/views/products/types/text_creation/stories/_form.html.erb +19 -0
- data/app/views/products/types/text_creation/stories/_task_fields.html.erb +7 -0
- data/app/views/projects/_form.html.erb +16 -0
- data/app/views/projects/edit.html.erb +3 -0
- data/app/views/projects/index.html.erb +5 -0
- data/app/views/projects/new.html.erb +3 -0
- data/app/views/projects/show.html.erb +13 -0
- data/app/views/shared/_comments.html.erb +7 -0
- data/app/views/shared/collection/_list.html.erb +37 -0
- data/app/views/shared/collection/_table.html.erb +36 -0
- data/app/views/shared/form/_error_messages.html.erb +10 -0
- data/app/views/shared/resource/_actions.html.erb +26 -0
- data/app/views/shared/resource/_event_elements.html.erb +7 -0
- data/app/views/stories/_collection.html.erb +8 -0
- data/app/views/stories/_form.html.erb +19 -0
- data/app/views/stories/_task_fields.html.erb +11 -0
- data/app/views/stories/index.html.erb +1 -0
- data/app/views/stories/show.html.erb +13 -0
- data/app/views/stories/steps/_activate.html.erb +17 -0
- data/app/views/stories/steps/_setup_tasks.html.erb +35 -0
- data/app/views/stories/tasks.html.erb +0 -0
- data/app/views/tasks/_collection.html.erb +12 -0
- data/app/views/users/_form.html.erb +43 -0
- data/app/views/users/edit.html.erb +3 -0
- data/app/views/users/index.html.erb +6 -0
- data/app/views/users/new.html.erb +3 -0
- data/app/views/users/preferences.html.erb +11 -0
- data/app/views/users/show.html.erb +6 -0
- data/app/views/vacancies/_form.html.erb +15 -0
- data/app/views/vacancies/edit.html.erb +3 -0
- data/app/views/vacancies/index.html.erb +7 -0
- data/app/views/vacancies/new.html.erb +3 -0
- data/app/views/vacancies/show.html.erb +17 -0
- data/app/views/workflow/index.html.erb +0 -0
- data/app/views/workflow/products/show.html.erb +34 -0
- data/app/views/workflow/project_owner/_candidatures.html.erb +31 -0
- data/app/views/workflow/project_owner/_stories.html.erb +29 -0
- data/app/views/workflow/project_owner/_tasks.html.erb +34 -0
- data/app/views/workflow/project_owner/_vacancies.html.erb +27 -0
- data/app/views/workflow/project_owner/index.html.erb +24 -0
- data/app/views/workflow/tasks/_work_form.html.erb +8 -0
- data/app/views/workflow/tasks/_work_head.html.erb +15 -0
- data/app/views/workflow/tasks/edit.html.erb +3 -0
- data/app/views/workflow/tasks/index.html.erb +31 -0
- data/app/views/workflow/tasks/next.html.erb +0 -0
- data/app/views/workflow/tasks/steps/_complete.html.erb +11 -0
- data/app/views/workflow/tasks/steps/_review.html.erb +13 -0
- data/app/views/workflow/tasks/steps/_work.html.erb +17 -0
- data/app/views/workflow/user/_tasks.html.erb +30 -0
- data/app/views/workflow/user/index.html.erb +14 -0
- data/config/initializers/1_initialize_app_config.rb +5 -0
- data/config/initializers/devise.rb +193 -0
- data/config/initializers/locale_settings.rb +42 -0
- data/config/initializers/mongoid-history.rb +2 -0
- data/config/initializers/recaptcha.rb +7 -0
- data/config/initializers/simple_form.rb +178 -0
- data/config/initializers/simple_navigation.rb +2 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/en.yml +26 -0
- data/config/locales/general/en.yml +71 -0
- data/config/locales/resources/area/en.yml +12 -0
- data/config/locales/resources/candidature/en.yml +19 -0
- data/config/locales/resources/comment/en.yml +11 -0
- data/config/locales/resources/organization/en.yml +11 -0
- data/config/locales/resources/page/en.yml +11 -0
- data/config/locales/resources/product/en.yml +23 -0
- data/config/locales/resources/project/en.yml +9 -0
- data/config/locales/resources/result/en.yml +9 -0
- data/config/locales/resources/story/en.yml +34 -0
- data/config/locales/resources/task/en.yml +36 -0
- data/config/locales/resources/user/en.yml +14 -0
- data/config/locales/resources/vacancy/en.yml +29 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/workflow/en.yml +37 -0
- data/config/routes.rb +188 -0
- data/db/migrate/20120907144853_create_schema.rb +217 -0
- data/db/migrate/20120911093743_remove_timestamps_from_habtm_tables.rb +21 -0
- data/db/migrate/20120919161831_add_unique_index_for_one_user_candidature_per_vacancy.rb +9 -0
- data/db/migrate/20120922201955_create_mongo_db_documents.rb +13 -0
- data/db/migrate/20120923140109_add_product_to_project.rb +6 -0
- data/db/migrate/20121004061413_add_extra_user_attributes.rb +9 -0
- data/db/migrate/20121004132105_create_professions.rb +13 -0
- data/db/migrate/20121006162913_add_public_attribute_to_roles.rb +6 -0
- data/db/migrate/20121006170407_add_type_attribute_to_roles.rb +5 -0
- data/db/migrate/20121007071543_add_foreign_languages_to_user.rb +6 -0
- data/db/migrate/20121028073712_create_organizations.rb +13 -0
- data/db/seeds.rb +14 -0
- data/lib/applicat/mvc/controller.rb +171 -0
- data/lib/applicat/mvc/controller/error_handling.rb +40 -0
- data/lib/applicat/mvc/controller/resource.rb +19 -0
- data/lib/applicat/mvc/controller/transition_actions.rb +43 -0
- data/lib/applicat/mvc/model/resource/base.rb +56 -0
- data/lib/applicat/mvc/model/tokenable.rb +24 -0
- data/lib/applicat/mvc/model/tree.rb +82 -0
- data/lib/db_seed.rb +150 -0
- data/lib/environment_configuration.rb +54 -0
- data/lib/generators/voluntary/install/install_generator.rb +118 -0
- data/lib/generators/voluntary/install/templates/app/controllers/application_controller.rb +3 -0
- data/lib/generators/voluntary/install/templates/app/models/ability.rb +49 -0
- data/lib/generators/voluntary/install/templates/app/models/app_config.rb +32 -0
- data/lib/generators/voluntary/install/templates/app/views/layouts/application.html.erb +50 -0
- data/lib/generators/voluntary/install/templates/config/application.yml +147 -0
- data/lib/generators/voluntary/install/templates/config/cucumber.yml +8 -0
- data/lib/generators/voluntary/install/templates/config/database.example.yml +28 -0
- data/lib/generators/voluntary/install/templates/config/deploy.rb +59 -0
- data/lib/generators/voluntary/install/templates/config/email.example.yml +9 -0
- data/lib/generators/voluntary/install/templates/config/initializers/recaptcha_example +4 -0
- data/lib/generators/voluntary/install/templates/config/locale_settings.yml +121 -0
- data/lib/generators/voluntary/install/templates/config/main_navigation.rb +262 -0
- data/lib/generators/voluntary/install/templates/config/mongoid.yml +78 -0
- data/lib/generators/voluntary/install/templates/config/nginx.conf +27 -0
- data/lib/generators/voluntary/install/templates/config/unicorn.rb +9 -0
- data/lib/generators/voluntary/install/templates/config/unicorn_init.sh +84 -0
- data/lib/generators/voluntary/install/templates/db/seeds.rb +14 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/email_steps.rb +89 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/factory_steps.rb +120 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/javascript_steps.rb +15 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/navigation_steps.rb +3 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/resources_steps.rb +8 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/session_steps.rb +35 -0
- data/lib/generators/voluntary/install/templates/features/step_definitions/web_steps.rb +271 -0
- data/lib/generators/voluntary/install/templates/features/support/database_cleaner_patches.rb +24 -0
- data/lib/generators/voluntary/install/templates/features/support/env.rb +83 -0
- data/lib/generators/voluntary/install/templates/features/support/integration_sessions_controller.rb +32 -0
- data/lib/generators/voluntary/install/templates/features/support/integration_sessions_form.html.erb +1 -0
- data/lib/generators/voluntary/install/templates/features/support/paths.rb +98 -0
- data/lib/generators/voluntary/install/templates/features/support/selectors.rb +44 -0
- data/lib/generators/voluntary/install/templates/features/support/spork_env +72 -0
- data/lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb +78 -0
- data/lib/generators/voluntary/install/templates/lib/volontariat_seed.rb +36 -0
- data/lib/generators/voluntary/install/templates/spec/spec_helper.rb +72 -0
- data/lib/generators/voluntary/install/templates/spec/support/deferred_garbage_collector.rb +45 -0
- data/lib/generators/voluntary/install/templates/spec/support/devise.rb +3 -0
- data/lib/generators/voluntary/install/templates/spec/support/mongo_database_cleaner.rb +19 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/javascripts/jquery.tokeninput.js +915 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-facebook.css +122 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-mac.css +204 -0
- data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input.css +127 -0
- data/lib/i18n_interpolation_fallbacks.rb +21 -0
- data/lib/model/mongo_db/commentable.rb +17 -0
- data/lib/model/mongo_db/core_extensions.rb +10 -0
- data/lib/model/mongo_db/customizable.rb +23 -0
- data/lib/model/mongo_db/product/keywords.rb +31 -0
- data/lib/model/mongo_db/state_version_attributes.rb +15 -0
- data/lib/tasks/cucumber.rake +65 -0
- data/lib/tasks/voluntary_tasks.rake +4 -0
- data/lib/vendors/active_model/naming.rb +14 -0
- data/lib/vendors/simple_navigation/renderer/breadcrumbs_without_method_links.rb +30 -0
- data/lib/vendors/simple_navigation/renderer/twitter_sidenav.rb +34 -0
- data/lib/voluntary.rb +87 -0
- data/lib/voluntary/engine.rb +11 -0
- data/lib/voluntary/helpers/application.rb +69 -0
- data/lib/voluntary/helpers/collection.rb +35 -0
- data/lib/voluntary/helpers/comments.rb +15 -0
- data/lib/voluntary/helpers/form.rb +43 -0
- data/lib/voluntary/helpers/language.rb +19 -0
- data/lib/voluntary/helpers/layout.rb +28 -0
- data/lib/voluntary/helpers/product.rb +36 -0
- data/lib/voluntary/helpers/show.rb +69 -0
- data/lib/voluntary/helpers/wizard.rb +31 -0
- data/lib/voluntary/version.rb +3 -0
- data/lib/wizard.rb +58 -0
- data/lib/wizard/controller/concerns/paths.rb +31 -0
- data/lib/wizard/controller/concerns/steps.rb +142 -0
- metadata +1217 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
module WizardHelper
|
2
|
+
def section_header(wizard_step)
|
3
|
+
wizard_step_index = wizard_steps.index(wizard_step) + 1
|
4
|
+
|
5
|
+
content = ["#{wizard_step_index} / #{wizard_steps.length}"]
|
6
|
+
content << t("stories.steps.#{wizard_step}.title")
|
7
|
+
content << (future_step?(wizard_step) ? t('general.not_available') : '')
|
8
|
+
|
9
|
+
content.join(' ')
|
10
|
+
end
|
11
|
+
|
12
|
+
def step_pane(wizard_step)
|
13
|
+
return if future_step?(wizard_step)
|
14
|
+
|
15
|
+
partial_path = wizard_step == :initialization ? 'form' : "steps/#{wizard_step}"
|
16
|
+
|
17
|
+
if @presenter.respond_to?(wizard_step)
|
18
|
+
@step_presenter = @presenter.send(wizard_step)
|
19
|
+
else
|
20
|
+
@step_presenter = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
render_product_specific_partial_if_available(
|
24
|
+
resource, "#{controller_name}/#{partial_path}"
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
data/app/models/area.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
class Area < ActiveRecord::Base
|
2
|
+
include Applicat::Mvc::Model::Resource::Base
|
3
|
+
include Applicat::Mvc::Model::Tree
|
4
|
+
include Applicat::Mvc::Model::Tokenable
|
5
|
+
|
6
|
+
has_and_belongs_to_many :users
|
7
|
+
has_and_belongs_to_many :projects
|
8
|
+
|
9
|
+
validates :name, presence: true, uniqueness: true
|
10
|
+
|
11
|
+
attr_accessible :name
|
12
|
+
|
13
|
+
extend FriendlyId
|
14
|
+
|
15
|
+
friendly_id :name, :use => :slugged
|
16
|
+
|
17
|
+
def products
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class AreaUser < ActiveRecord::Base
|
2
|
+
self.table_name = 'areas_users'
|
3
|
+
|
4
|
+
belongs_to :area
|
5
|
+
belongs_to :user
|
6
|
+
|
7
|
+
after_create :increment_area_users_count
|
8
|
+
after_destroy :decrement_area_users_count
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def increment_area_users_count
|
13
|
+
area.users_count.increment!
|
14
|
+
end
|
15
|
+
|
16
|
+
def decrement_area_users_count
|
17
|
+
area.users_count.decrement!
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class Candidature < ActiveRecord::Base
|
2
|
+
include StateMachines::Candidature
|
3
|
+
|
4
|
+
belongs_to :vacancy
|
5
|
+
belongs_to :offeror, class_name: 'User'
|
6
|
+
belongs_to :user
|
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 :user_id, presence: true, uniqueness: { scope: :vacancy_id }
|
15
|
+
#validates :name, presence: true, uniqueness: { scope: :vacancy_id }
|
16
|
+
validates :text, presence: true
|
17
|
+
|
18
|
+
attr_accessible :vacancy_id, :name, :text
|
19
|
+
|
20
|
+
#extend FriendlyId
|
21
|
+
#friendly_id :name, use: :slugged
|
22
|
+
|
23
|
+
before_validation :set_offeror
|
24
|
+
|
25
|
+
# association shortcuts
|
26
|
+
def project
|
27
|
+
vacancy.project
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def set_offeror
|
33
|
+
self.offeror_id = vacancy.project.user_id
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Comment < ActiveRecord::Base
|
2
|
+
has_ancestry
|
3
|
+
|
4
|
+
belongs_to :commentable, polymorphic: true
|
5
|
+
belongs_to :user
|
6
|
+
|
7
|
+
validates :commentable_type, presence: true
|
8
|
+
validates :commentable_id, presence: true
|
9
|
+
validates :user_id, presence: true
|
10
|
+
validates :name, presence: true
|
11
|
+
validates :text, presence: true
|
12
|
+
|
13
|
+
attr_accessible :commentable_type, :commentable_id, :parent_id, :name, :text
|
14
|
+
|
15
|
+
COMMENTABLE_TYPES = ['project', 'vacancy', 'candidature']
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class MongoDbDocument < ActiveRecord::Base
|
2
|
+
has_many :comments, as: :commentable, dependent: :destroy
|
3
|
+
|
4
|
+
validates :mongo_db_object_id, presence: true, uniqueness: { scope: :klass_name }
|
5
|
+
validates :klass_name, presence: true
|
6
|
+
validates :name, presence: true
|
7
|
+
|
8
|
+
def mongo_db_object
|
9
|
+
klass_name.constantize.find(mongo_db_object_id)
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Organization < ActiveRecord::Base
|
2
|
+
include Applicat::Mvc::Model::Resource::Base
|
3
|
+
#include Applicat::Mvc::Model::Tree
|
4
|
+
include Applicat::Mvc::Model::Tokenable
|
5
|
+
|
6
|
+
belongs_to :user
|
7
|
+
|
8
|
+
has_many :projects
|
9
|
+
|
10
|
+
validates :name, presence: true, uniqueness: true
|
11
|
+
|
12
|
+
attr_accessible :name
|
13
|
+
|
14
|
+
extend FriendlyId
|
15
|
+
|
16
|
+
friendly_id :name, :use => :slugged
|
17
|
+
|
18
|
+
PARENT_TYPES = ['user']
|
19
|
+
end
|
data/app/models/page.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
class Page
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
include Mongoid::History::Trackable
|
5
|
+
include Mongoid::Slug
|
6
|
+
|
7
|
+
include StateMachines::Page
|
8
|
+
|
9
|
+
field :user_id, type: Integer
|
10
|
+
field :name, type: String
|
11
|
+
field :text, type: String
|
12
|
+
field :state, type: String
|
13
|
+
|
14
|
+
index({ name: 1 }, { unique: true })
|
15
|
+
|
16
|
+
attr_accessible :name, :text
|
17
|
+
|
18
|
+
scope :active, where(state: 'active')
|
19
|
+
|
20
|
+
validates :user_id, presence: true
|
21
|
+
validates :name, presence: true, uniqueness: true
|
22
|
+
validates :text, presence: true
|
23
|
+
|
24
|
+
track_history on: [:user_id, :name, :text, :state]
|
25
|
+
slug :name
|
26
|
+
|
27
|
+
# belongs_to (SQL)
|
28
|
+
def user; user_id ? User.find(user_id) : nil; end
|
29
|
+
def user=(value); self.user_id = value.id; end
|
30
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
class Product
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
|
5
|
+
field :_id, type: String, default: -> { name.to_s.parameterize }
|
6
|
+
field :user_id, type: Integer
|
7
|
+
field :name, type: String, localize: true
|
8
|
+
field :text, type: String, localize: true
|
9
|
+
field :area_ids, type: Array, default: []
|
10
|
+
field :state, type: String
|
11
|
+
|
12
|
+
attr_accessible :name, :text, :area_ids
|
13
|
+
|
14
|
+
validates :user_id, presence: true
|
15
|
+
validates :name, presence: true, uniqueness: true
|
16
|
+
validates :area_ids, presence: true
|
17
|
+
|
18
|
+
validate :english_name_available?
|
19
|
+
validate :existing_model_file?
|
20
|
+
|
21
|
+
index({ name: 1 }, { unique: true })
|
22
|
+
|
23
|
+
before_validation :set_type
|
24
|
+
|
25
|
+
# active record compatibility
|
26
|
+
# just belongs_to reflections for cucumber's factory steps
|
27
|
+
def self.reflections
|
28
|
+
struct = OpenStruct.new(values: [])
|
29
|
+
|
30
|
+
# sql belongs_to relations
|
31
|
+
struct.values << OpenStruct.new(name: 'user', options: {})
|
32
|
+
|
33
|
+
::Product.relations.each do |relation_name, relation|
|
34
|
+
# select only belongs_to relations
|
35
|
+
next unless relation_name == relation_name.singularize
|
36
|
+
|
37
|
+
# automatically include mongo db's belongs_to relations
|
38
|
+
struct.values << OpenStruct.new(name: relation_name, options: {})
|
39
|
+
end
|
40
|
+
|
41
|
+
struct
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.stories(id, user, page)
|
45
|
+
collection = if id == 'no-name'
|
46
|
+
Story.exists(_type: false)
|
47
|
+
else
|
48
|
+
product = Product.find(id)
|
49
|
+
|
50
|
+
begin
|
51
|
+
product.story_class.for_user(user)
|
52
|
+
rescue NotImplementedError
|
53
|
+
product.story_class
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
collection.where(:users_without_tasks_ids.ne => user.id)#.page(page).per(1)
|
58
|
+
end
|
59
|
+
|
60
|
+
# belongs_to (SQL)
|
61
|
+
def user; User.find(offeror_id); end
|
62
|
+
def user=(value); self.user_id = value.id; end
|
63
|
+
|
64
|
+
# has_many (SQL)
|
65
|
+
def areas; Area.where(id: area_ids); end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def english_name_available?
|
70
|
+
unless attributes['name']['en'].present?
|
71
|
+
errors[:name] << I18n.t(
|
72
|
+
'activerecord.errors.models.product.attributes.name.missing_english_name'
|
73
|
+
)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def existing_model_file?
|
78
|
+
unless (get_type.constantize rescue false)
|
79
|
+
errors[:name] << I18n.t(
|
80
|
+
'activerecord.errors.models.product.attributes.name.missing_model_file'
|
81
|
+
)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_type
|
86
|
+
if name == 'Product'
|
87
|
+
'Product'
|
88
|
+
else
|
89
|
+
[
|
90
|
+
'Product', name.gsub(' - ', '_').gsub('-', '_').gsub(' ', '_').classify
|
91
|
+
].join('::')
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def set_type
|
96
|
+
# TODO: check with a better internet connection a better regex on rubular.com
|
97
|
+
self._type = get_type
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Product::ProjectManagement
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
has_many :stories, dependent: :nullify
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def stories(id, user, page)
|
10
|
+
collection = if id == 'no-name'
|
11
|
+
Story.exists(_type: false)
|
12
|
+
else
|
13
|
+
product = Product.find(id)
|
14
|
+
|
15
|
+
begin
|
16
|
+
product.story_class.for_user(user)
|
17
|
+
rescue NotImplementedError
|
18
|
+
product.story_class
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
collection.where(:users_without_tasks_ids.ne => user.id)#.page(page).per(1)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def projects; Project.where(product_id: id); end
|
27
|
+
|
28
|
+
def story_class; "#{self.class.name}::Story".constantize rescue Story; end
|
29
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Profession < ActiveRecord::Base
|
2
|
+
include Applicat::Mvc::Model::Resource::Base
|
3
|
+
|
4
|
+
has_many :users
|
5
|
+
|
6
|
+
validates :name, presence: true, uniqueness: true
|
7
|
+
|
8
|
+
attr_accessible :name
|
9
|
+
|
10
|
+
extend FriendlyId
|
11
|
+
|
12
|
+
friendly_id :name, :use => :slugged
|
13
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class Project < ActiveRecord::Base
|
2
|
+
belongs_to :user
|
3
|
+
belongs_to :organization
|
4
|
+
|
5
|
+
has_many :project_users, dependent: :destroy
|
6
|
+
has_many :vacancies, dependent: :destroy
|
7
|
+
has_many :roles, through: :project_users
|
8
|
+
has_many :comments, as: :commentable, dependent: :destroy
|
9
|
+
|
10
|
+
has_and_belongs_to_many :users
|
11
|
+
has_and_belongs_to_many :areas
|
12
|
+
|
13
|
+
accepts_nested_attributes_for :areas, allow_destroy: true
|
14
|
+
|
15
|
+
validates :user_id, presence: true
|
16
|
+
validates :name, presence: true, uniqueness: true
|
17
|
+
validates :text, presence: true
|
18
|
+
validates :area_ids, presence: true
|
19
|
+
|
20
|
+
attr_accessible :organization_id, :product_id, :name, :text, :url, :area_ids
|
21
|
+
|
22
|
+
extend FriendlyId
|
23
|
+
|
24
|
+
before_validation :include_areas_of_product
|
25
|
+
after_create :create_project_user
|
26
|
+
after_destroy :destroy_non_active_records
|
27
|
+
|
28
|
+
friendly_id :name, use: :slugged
|
29
|
+
|
30
|
+
PARENT_TYPES = ['area', 'product', 'user']
|
31
|
+
|
32
|
+
# belongs_to (Mongo DB)
|
33
|
+
def product
|
34
|
+
product_id.blank? ? nil : Product.find(product_id)
|
35
|
+
end
|
36
|
+
|
37
|
+
# has_many (Mongo DB)
|
38
|
+
def story_class
|
39
|
+
if product_id.present?
|
40
|
+
"#{product.class.name}::Story".constantize rescue Story
|
41
|
+
else
|
42
|
+
Story
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def stories; story_class.where(project_id: id); end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def include_areas_of_product
|
51
|
+
self.area_ids ||= []
|
52
|
+
|
53
|
+
if product
|
54
|
+
self.area_ids += product.areas.map(&:id)
|
55
|
+
self.area_ids.uniq!
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_project_user
|
60
|
+
ProjectUser.create(project_id: id, user_id: user_id)
|
61
|
+
end
|
62
|
+
|
63
|
+
def destroy_non_active_records
|
64
|
+
stories.all.map(&:destroy)
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class ProjectUser < ActiveRecord::Base#
|
2
|
+
self.table_name = 'projects_users'
|
3
|
+
|
4
|
+
belongs_to :project
|
5
|
+
belongs_to :vacancy
|
6
|
+
belongs_to :user
|
7
|
+
belongs_to :role
|
8
|
+
|
9
|
+
validates :project_id, presence: true
|
10
|
+
validates :user_id, presence: true, uniqueness: { scope: [:project_id, :vacancy_id] }
|
11
|
+
|
12
|
+
attr_accessible :project_id, :vacancy_id, :user_id, :role_id
|
13
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class Result
|
2
|
+
include Mongoid::Document
|
3
|
+
include Mongoid::Timestamps
|
4
|
+
#include Mongoid::History::Trackable
|
5
|
+
|
6
|
+
include Model::MongoDb::Customizable
|
7
|
+
include Model::MongoDb::Commentable
|
8
|
+
|
9
|
+
#embedded_in :task
|
10
|
+
belongs_to :task
|
11
|
+
|
12
|
+
# cached associations
|
13
|
+
belongs_to :story
|
14
|
+
|
15
|
+
field :offeror_id, type: Integer
|
16
|
+
field :user_id, type: Integer
|
17
|
+
field :name, type: String
|
18
|
+
field :text, type: String
|
19
|
+
field :state, type: String
|
20
|
+
|
21
|
+
attr_accessible :task_id, :name, :text
|
22
|
+
|
23
|
+
validates :task_id, presence: true
|
24
|
+
validates :story_id, presence: true
|
25
|
+
validates :offeror_id, presence: true
|
26
|
+
validates :text, presence: true
|
27
|
+
|
28
|
+
after_initialize :cache_associations
|
29
|
+
before_validation :cache_associations
|
30
|
+
after_create :set_tasks_result_association
|
31
|
+
after_destroy :unset_tasks_result_association
|
32
|
+
|
33
|
+
#track_history on: [:name, :text, :state], scope: :task
|
34
|
+
|
35
|
+
# belongs_to (SQL)
|
36
|
+
def offeror; offeror_id ? User.find(offeror_id) : nil; end
|
37
|
+
def offeror=(value); self.offeror_id = value.id; end
|
38
|
+
|
39
|
+
def user; user_id ? User.find(user_id) : nil; end
|
40
|
+
def user=(value); self.user_id = value.id; end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def cache_associations
|
45
|
+
self.story_id = task.story_id if task_id.present? && (task rescue nil)
|
46
|
+
self.offeror_id = task.offeror_id if task_id.present? && (task rescue nil)
|
47
|
+
end
|
48
|
+
|
49
|
+
def cache_product_association
|
50
|
+
self.product_id = task.product_id if task_id.present? && (task rescue nil)
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_tasks_result_association; task.update_attribute(:result_id, id); end
|
54
|
+
def unset_tasks_result_association; task.update_attribute(:result_id, nil); end
|
55
|
+
end
|