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,147 @@
|
|
1
|
+
class Workflow::TasksController < ApplicationController
|
2
|
+
include Wizard::Controller
|
3
|
+
|
4
|
+
wizard_steps :work, :review
|
5
|
+
wizard_step_per_state work: [:assigned], review: [:under_supervision]
|
6
|
+
|
7
|
+
before_filter :build_result, only: [:edit, :cancel, :skip, :update]
|
8
|
+
load_and_authorize_resource except: [:next]
|
9
|
+
|
10
|
+
helper_method :resource
|
11
|
+
|
12
|
+
def current_step_is_next_step_after_event
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def index
|
17
|
+
@story = Story.find(params[:story_id])
|
18
|
+
@tasks = @story.tasks
|
19
|
+
|
20
|
+
# increase level when there are more sub items for tasks_workflow_user_index_path(@task))
|
21
|
+
@twitter_sidenav_level = 4
|
22
|
+
end
|
23
|
+
|
24
|
+
def next
|
25
|
+
story = Story.find(params[:story_id])
|
26
|
+
task = story.next_task_for_user(current_user)
|
27
|
+
product_id = story.product_id.blank? ? 'no-name' : story.product_id
|
28
|
+
|
29
|
+
if task.is_a?(String)
|
30
|
+
redirect_to(
|
31
|
+
product_workflow_user_index_path(product_id), notice: task
|
32
|
+
) and return
|
33
|
+
elsif task
|
34
|
+
redirect_to edit_task_workflow_user_index_path(task) and return
|
35
|
+
else
|
36
|
+
redirect_to(
|
37
|
+
product_workflow_user_index_path(product_id),
|
38
|
+
notice: I18n.t('workflow.user.tasks.next.unavailable')
|
39
|
+
) and return
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def edit
|
44
|
+
@story = @task.story
|
45
|
+
end
|
46
|
+
|
47
|
+
def cancel
|
48
|
+
if @task.cancel
|
49
|
+
notice = I18n.t(
|
50
|
+
"general.notifications.event_successful",
|
51
|
+
event: I18n.t("tasks.general.events.cancel")
|
52
|
+
)
|
53
|
+
redirect_to(
|
54
|
+
tasks_workflow_user_index_path(@task.story), notice: notice
|
55
|
+
) and return
|
56
|
+
else
|
57
|
+
render 'edit' and return
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def skip
|
62
|
+
if @task.cancel
|
63
|
+
redirect_to(
|
64
|
+
next_task_workflow_user_index_path(@task.story)
|
65
|
+
) and return
|
66
|
+
else
|
67
|
+
render 'edit' and return
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def update
|
72
|
+
if params[:event] && params[:event].keys.select{|k| ['cancel', 'skip'].include?(k)}.any?
|
73
|
+
send(params[:event].keys.first)
|
74
|
+
return
|
75
|
+
end
|
76
|
+
|
77
|
+
@task.attributes = params[:task]
|
78
|
+
method = params[:event] ? params[:event].keys.first : 'save'
|
79
|
+
success = false
|
80
|
+
|
81
|
+
if @result.valid?
|
82
|
+
success = if params[:next_step] == '1' || (params[:event] && params[:event][:next])
|
83
|
+
@task.send(step)
|
84
|
+
elsif (method == 'save' && can?(:update, @task)) || can?(method.to_sym, @task)
|
85
|
+
@task.send(method)
|
86
|
+
else
|
87
|
+
false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
render 'edit' and return unless success
|
92
|
+
|
93
|
+
@result.save
|
94
|
+
|
95
|
+
if params[:event] && params[:event][:next]
|
96
|
+
redirect_to(
|
97
|
+
next_task_workflow_user_index_path(@task.story),
|
98
|
+
notice: I18n.t('general.form.successfully_updated')
|
99
|
+
) and return
|
100
|
+
end
|
101
|
+
|
102
|
+
notice = if method == 'save'
|
103
|
+
I18n.t('general.form.successfully_updated')
|
104
|
+
else
|
105
|
+
I18n.t(
|
106
|
+
"general.notifications.event_successful",
|
107
|
+
event: I18n.t("tasks.general.events.#{method}")
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
if can? :edit, @task
|
112
|
+
redirect_to(
|
113
|
+
edit_task_workflow_user_index_path(@task), notice: notice
|
114
|
+
)
|
115
|
+
else
|
116
|
+
redirect_to(
|
117
|
+
tasks_workflow_user_index_path(@task.story), notice: notice
|
118
|
+
)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def resource
|
123
|
+
@task ||= Task.find(params[:id])
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def build_result
|
129
|
+
result_params = params[:task] ? params[:task].delete(:result_attributes) : nil
|
130
|
+
result_params = result_params || {}
|
131
|
+
|
132
|
+
unless resource.result_id.present?
|
133
|
+
@result = resource.result_class.new(result_params.merge(task_id: resource.id))
|
134
|
+
@result.errors.clear
|
135
|
+
return
|
136
|
+
end
|
137
|
+
|
138
|
+
if resource.result
|
139
|
+
@result = resource.result
|
140
|
+
elsif resource.result_id
|
141
|
+
# WORKAROUND: do we still need this case?
|
142
|
+
@result = resource.result_class.find(resource.result_id)
|
143
|
+
end
|
144
|
+
|
145
|
+
result_params.each {|param,value| @result.send("#{param}=", value) }
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,17 @@
|
|
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
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module ApplicationHelper
|
2
|
+
include AutoHtml
|
3
|
+
|
4
|
+
def self.root_model_class_name_helper(resource)
|
5
|
+
if resource.class.superclass.name == 'ActiveRecord::Base'
|
6
|
+
resource.class.name
|
7
|
+
elsif resource.class.superclass.name == 'Object'
|
8
|
+
# classes like mongo db models without a specific superclass
|
9
|
+
resource.class.name
|
10
|
+
else
|
11
|
+
resource.class.superclass.name
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def markdown(text)
|
16
|
+
text = Redcarpet::Markdown.new(Redcarpet::Render::XHTML.new(filter_html: true)).render(text)
|
17
|
+
|
18
|
+
auto_html(text) do
|
19
|
+
youtube(width: 515, height: 300)
|
20
|
+
dailymotion(width: 515, height: 300)
|
21
|
+
vimeo(width: 515, height: 300)
|
22
|
+
google_video(width: 515, height: 300)
|
23
|
+
image
|
24
|
+
|
25
|
+
redcarpet(
|
26
|
+
renderer: Redcarpet::Render::XHTML.new(
|
27
|
+
no_images: true, no_styles: true, hard_wrap: true, with_toc_data: true
|
28
|
+
),
|
29
|
+
markdown_options: { no_intra_emphasis: true, autolink: true, fenced_code_blocks: true }
|
30
|
+
)
|
31
|
+
link :target => "_blank", :rel => "nofollow"
|
32
|
+
end.gsub(/(>https?:\/\/[^\<\\]+)/) do |match|
|
33
|
+
truncate(match)
|
34
|
+
end.html_safe
|
35
|
+
end
|
36
|
+
|
37
|
+
def root_model_class_name(resource)
|
38
|
+
::ApplicationHelper.root_model_class_name_helper(resource)
|
39
|
+
end
|
40
|
+
|
41
|
+
def directory_for_resource(resource)
|
42
|
+
resource.class.name.split('::').last.underscore
|
43
|
+
end
|
44
|
+
|
45
|
+
def link_list(collection)
|
46
|
+
raw collection.map{|a| link_to a.name, a}.join(', ')
|
47
|
+
end
|
48
|
+
|
49
|
+
def general_attribute?(attribute)
|
50
|
+
begin
|
51
|
+
t("activerecord.attributes.general.#{attribute}", raise: true)
|
52
|
+
true
|
53
|
+
rescue
|
54
|
+
false
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def attribute_translation(attribute, current_resource = nil)
|
59
|
+
current_resource = current_resource || resource
|
60
|
+
|
61
|
+
t("activerecord.attributes.#{root_model_class_name(current_resource).underscore}.#{attribute}",
|
62
|
+
default: t("activerecord.attributes.general.#{attribute}")
|
63
|
+
)
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module CollectionHelper
|
2
|
+
def table_cell column, resource, alternative_value = nil
|
3
|
+
value = '-'
|
4
|
+
|
5
|
+
if column == 'name'
|
6
|
+
value = resource.send(column)
|
7
|
+
|
8
|
+
if alternative_value.is_a?(Proc)
|
9
|
+
return alternative_value.call(resource)
|
10
|
+
elsif value.blank? && alternative_value.present?
|
11
|
+
value = eval("resource.#{alternative_value}")
|
12
|
+
elsif value.blank?
|
13
|
+
value = '-'
|
14
|
+
end
|
15
|
+
|
16
|
+
link_to value, eval("#{root_model_class_name(resource).tableize.singularize}_path(resource)")
|
17
|
+
elsif column.match('_id')
|
18
|
+
association = nil
|
19
|
+
|
20
|
+
begin
|
21
|
+
association = resource.send(column.gsub('_id', ''))
|
22
|
+
rescue
|
23
|
+
association = eval("resource.#{alternative_value}") if alternative_value.present?
|
24
|
+
end
|
25
|
+
|
26
|
+
association ? link_to(association.name, association) : value
|
27
|
+
else
|
28
|
+
resource.send(column)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module CommentsHelper
|
2
|
+
def nested_comments(comments)
|
3
|
+
comments.map do |comment, sub_comments|
|
4
|
+
next if comment.id.blank?
|
5
|
+
|
6
|
+
content = render(partial: 'comments/resource', locals: { resource: comment })
|
7
|
+
content += content_tag(:div, nested_comments(sub_comments), class: 'nested_comments')
|
8
|
+
content
|
9
|
+
end.join.html_safe
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module FormHelper
|
2
|
+
def link_to_add_fields(name, f, association, options = {})
|
3
|
+
attributes = {
|
4
|
+
"#{root_model_class_name(f.object).tableize.singularize}_id".to_sym => f.object.id
|
5
|
+
}
|
6
|
+
|
7
|
+
new_object = if f.object.respond_to? "#{association.to_s.singularize}_class"
|
8
|
+
f.object.tasks.new(attributes)
|
9
|
+
else
|
10
|
+
f.object.send(association).new(attributes)
|
11
|
+
end
|
12
|
+
|
13
|
+
id = new_object.object_id
|
14
|
+
|
15
|
+
fields = f.fields_for(association, new_object, child_index: id) do |builder|
|
16
|
+
render_product_specific_partial_if_available(
|
17
|
+
new_object, "#{controller_name}/#{association.to_s.singularize}_fields",
|
18
|
+
f: builder
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
data = {id: id, fields: fields.gsub("\n", '')}
|
23
|
+
data[:target] = options[:target] if options.has_key?(:target)
|
24
|
+
|
25
|
+
link_to(name, '#', class: 'add_fields', data: data)
|
26
|
+
end
|
27
|
+
|
28
|
+
def remove_fields(f)
|
29
|
+
if f.object.try(:new_record?)
|
30
|
+
link_to t('general.remove'), '#', class: 'remove_fields'
|
31
|
+
else
|
32
|
+
f.check_box(:_destroy) + f.label(:_destroy, t('general.destroy'))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def autocomplete_input(f, field)
|
37
|
+
f.input "#{field}_name", input_html: { data: {autocomplete: eval("autocomplete_#{field.to_s.tableize}_path")} }
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LanguageHelper
|
2
|
+
def available_language_options
|
3
|
+
options = []
|
4
|
+
|
5
|
+
AVAILABLE_LANGUAGES.each do |locale, language|
|
6
|
+
options << [language, locale]
|
7
|
+
end
|
8
|
+
|
9
|
+
options.sort_by { |o| o[0] }
|
10
|
+
end
|
11
|
+
|
12
|
+
def all_language_options
|
13
|
+
User.languages.sort_by { |o| o[0] }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module LayoutHelper
|
2
|
+
def breadcrumbs
|
3
|
+
result = render_navigation context: :main, renderer: :breadcrumbs_without_method_links, join_with: ' > '
|
4
|
+
result && result.split('<a').length > 2 ? result : ''
|
5
|
+
end
|
6
|
+
|
7
|
+
def sidenav
|
8
|
+
result = render_navigation context: :main, renderer: :twitter_sidenav, level: @twitter_sidenav_level
|
9
|
+
result && result.split('<a').length > 2 ? result : ''
|
10
|
+
end
|
11
|
+
|
12
|
+
def footer_navigation
|
13
|
+
links = []
|
14
|
+
|
15
|
+
['privacy-policy', 'terms-of-use', 'about-us'].each do |page_name|
|
16
|
+
text = t("pages.#{page_name.gsub('-', '_')}.title")
|
17
|
+
path = "#{controller_name}/#{params[:id]}"
|
18
|
+
active = path == "#{controller_name}/#{page_name}"
|
19
|
+
links << (active ? text : link_to(text, page_path(page_name)))
|
20
|
+
end
|
21
|
+
|
22
|
+
raw links.join(' | ')
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module ProductHelper
|
2
|
+
def render_product_specific_presenter_if_available(resource, partial_path, method, options = {})
|
3
|
+
if @presenter.respond_to?(method)
|
4
|
+
@step_presenter = @presenter.send(method)
|
5
|
+
else
|
6
|
+
@step_presenter = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
render_product_specific_partial_if_available(resource, "#{partial_path}/#{method}", options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def render_product_specific_partial_if_available(resource, partial_path, options = {})
|
13
|
+
path = nil
|
14
|
+
partial_path = partial_path.split('/')
|
15
|
+
file_name = partial_path.pop
|
16
|
+
partial_path = partial_path.join('/')
|
17
|
+
|
18
|
+
if resource && resource.respond_to?(:product) && resource.product
|
19
|
+
path = "products/types/#{directory_for_resource(resource.product)}/#{partial_path}"
|
20
|
+
|
21
|
+
if File.exist?("#{Rails.root.to_s}/app/views/#{path}/_#{file_name}.html.erb")
|
22
|
+
path = [path, file_name].join('/')
|
23
|
+
else
|
24
|
+
path = nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
path = [partial_path, file_name].join('/') if path.blank?
|
29
|
+
|
30
|
+
render path, options
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module ShowHelper
|
2
|
+
def show_attributes(*attributes)
|
3
|
+
result = ''
|
4
|
+
|
5
|
+
attributes.each {|attribute| result += show_attribute attribute}
|
6
|
+
|
7
|
+
raw result
|
8
|
+
end
|
9
|
+
|
10
|
+
def show_attribute(attribute, options = {})
|
11
|
+
title = options[:title] || attribute_translation(attribute)
|
12
|
+
value = options[:value] || resource.send(attribute)
|
13
|
+
|
14
|
+
value.blank? ? '' : content_tag(:dt, title) + content_tag(:dd, value)
|
15
|
+
end
|
16
|
+
|
17
|
+
def show_associations(*associations)
|
18
|
+
result = ''
|
19
|
+
|
20
|
+
associations.each {|association| result += show_association association}
|
21
|
+
|
22
|
+
raw result
|
23
|
+
end
|
24
|
+
|
25
|
+
def show_association(association)
|
26
|
+
if association.to_s == association.to_s.pluralize
|
27
|
+
return show_attribute(
|
28
|
+
association,
|
29
|
+
title: t("#{association}.index.title"),
|
30
|
+
value: raw(resource.send(association).map{|a| link_to a.name, a}.join(', '))
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
title = if general_attribute?(:parent)
|
35
|
+
t("activerecord.attributes.general.#{association}")
|
36
|
+
else
|
37
|
+
if resource.send(association)
|
38
|
+
t("activerecord.models.#{root_model_class_name(resource.send(association)).underscore}")
|
39
|
+
else
|
40
|
+
t("activerecord.models.#{association}")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
if resource.send(association)
|
45
|
+
show_attribute(
|
46
|
+
association,
|
47
|
+
title: title,
|
48
|
+
value: link_to(resource.send(association).try(:name), resource.send(association))
|
49
|
+
)
|
50
|
+
else
|
51
|
+
''
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def show_actions
|
56
|
+
result = content_tag :dt, raw(' ')
|
57
|
+
result += content_tag :dd, render(
|
58
|
+
partial: 'shared/resource/actions', locals: {
|
59
|
+
type: root_model_class_name(resource).tableize, resource: resource
|
60
|
+
}
|
61
|
+
)
|
62
|
+
|
63
|
+
raw result
|
64
|
+
end
|
65
|
+
end
|