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,96 @@
|
|
1
|
+
class StoriesController < ApplicationController
|
2
|
+
include Applicat::Mvc::Controller::Resource
|
3
|
+
include Wizard::Controller
|
4
|
+
|
5
|
+
wizard_steps :initialization, :setup_tasks, :activate
|
6
|
+
|
7
|
+
before_filter :build_resource, only: [:new, :create]
|
8
|
+
before_filter :resource, only: [:show, :edit, :update, :setup_tasks, :activate]
|
9
|
+
|
10
|
+
load_and_authorize_resource
|
11
|
+
|
12
|
+
respond_to :html, :js, :json
|
13
|
+
|
14
|
+
def index
|
15
|
+
parent = find_parent Story::PARENT_TYPES
|
16
|
+
@stories = parent ? parent.stories : Story.all
|
17
|
+
end
|
18
|
+
|
19
|
+
def show
|
20
|
+
@comments = @story.comments
|
21
|
+
end
|
22
|
+
|
23
|
+
def new
|
24
|
+
render_wizard
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
if @story.initialization
|
29
|
+
redirect_to edit_story_path(@story) and return
|
30
|
+
else
|
31
|
+
render_wizard
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def edit
|
36
|
+
#if @story.tasks.none?
|
37
|
+
#@story.tasks << @story.tasks.new
|
38
|
+
#@story.tasks.first.errors.clear
|
39
|
+
#end
|
40
|
+
|
41
|
+
render_wizard
|
42
|
+
end
|
43
|
+
|
44
|
+
def update
|
45
|
+
@story.attributes = params[:story]
|
46
|
+
|
47
|
+
success = params[:next_step] == '1' ? @story.send(step) : @story.save
|
48
|
+
|
49
|
+
if success
|
50
|
+
redirect_to(
|
51
|
+
edit_story_path(@story), notice: t('general.form.successfully_updated')
|
52
|
+
)
|
53
|
+
else
|
54
|
+
render_wizard
|
55
|
+
end
|
56
|
+
|
57
|
+
return
|
58
|
+
end
|
59
|
+
|
60
|
+
def destroy
|
61
|
+
@story = Story.find(params[:id])
|
62
|
+
@story.destroy
|
63
|
+
redirect_to @story.project, notice: t('general.form.destroyed')
|
64
|
+
end
|
65
|
+
|
66
|
+
def resource
|
67
|
+
@story = Story.find(params[:id]) unless @story || !params[:id].present?
|
68
|
+
@project = @story.project unless @project || !@story
|
69
|
+
@story
|
70
|
+
end
|
71
|
+
|
72
|
+
def resource=(value); @story = value; end
|
73
|
+
|
74
|
+
def parent
|
75
|
+
@project
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
def after_setup_tasks; render_wizard; end
|
81
|
+
def after_activate; render_wizard; end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def build_resource
|
86
|
+
@project = find_parent Story::PARENT_TYPES, action_name == 'create' ? :story : nil
|
87
|
+
@story = @project.story_class.new({ project_id: @project.id }.merge(params[:story] || {}))
|
88
|
+
end
|
89
|
+
|
90
|
+
def render_wizard
|
91
|
+
@presenter = Resources::General::Wizards::StoryPresenter.new(
|
92
|
+
self.view_context, resource: resource
|
93
|
+
)
|
94
|
+
render 'general/wizard'
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
class TasksController < ApplicationController
|
2
|
+
include Applicat::Mvc::Controller::Resource
|
3
|
+
include Wizard::Controller
|
4
|
+
|
5
|
+
wizard_steps :setup_tasks, :activate
|
6
|
+
|
7
|
+
before_filter :build_resource, only: [:new, :create]
|
8
|
+
before_filter :resource, only: [:show, :edit, :update, :setup_tasks, :activate]
|
9
|
+
|
10
|
+
load_and_authorize_resource
|
11
|
+
|
12
|
+
respond_to :html, :js, :json
|
13
|
+
|
14
|
+
def index
|
15
|
+
parent = find_parent Task::PARENT_TYPES
|
16
|
+
@tasks = parent ? parent.tasks : Task.all
|
17
|
+
end
|
18
|
+
|
19
|
+
def show
|
20
|
+
@comments = @task.comments
|
21
|
+
end
|
22
|
+
|
23
|
+
def new
|
24
|
+
render_wizard
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
if @task.initialization
|
29
|
+
redirect_to edit_task_path(@task) and return
|
30
|
+
else
|
31
|
+
render_wizard
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def edit
|
36
|
+
render_wizard
|
37
|
+
end
|
38
|
+
|
39
|
+
def update
|
40
|
+
@task.attributes = params[:task]
|
41
|
+
|
42
|
+
# shift the first empty task set after initialization on state :initialized
|
43
|
+
@task.tasks.shift if params[:next_step] == '1' && !@task.tasks.first.valid?
|
44
|
+
success = params[:next_step] == '1' ? @task.send(step) : @task.save
|
45
|
+
|
46
|
+
if success
|
47
|
+
redirect_to(
|
48
|
+
edit_task_path(@task), notice: t('general.form.successfully_updated')
|
49
|
+
)
|
50
|
+
else
|
51
|
+
render_wizard
|
52
|
+
end
|
53
|
+
|
54
|
+
return
|
55
|
+
end
|
56
|
+
|
57
|
+
def destroy
|
58
|
+
@task = Task.find(params[:id])
|
59
|
+
@task.destroy
|
60
|
+
redirect_to @task.story, notice: t('general.form.destroyed')
|
61
|
+
end
|
62
|
+
|
63
|
+
def resource
|
64
|
+
@task = Task.find(params[:id]) unless @task || !params[:id].present?
|
65
|
+
@story = @task.story unless @story || !@task
|
66
|
+
@task
|
67
|
+
end
|
68
|
+
|
69
|
+
def resource=(value); @task = value; end
|
70
|
+
|
71
|
+
def parent
|
72
|
+
@story
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def build_resource
|
78
|
+
@story = find_parent Task::PARENT_TYPES, action_name == 'create' ? :task : nil
|
79
|
+
@task = @story.tasks.new({ story_id: @story.id }.merge(params[:task] || {}))
|
80
|
+
end
|
81
|
+
|
82
|
+
def render_wizard
|
83
|
+
@presenter = Resources::General::Wizards::TaskPresenter.new(
|
84
|
+
self.view_context, resource: resource
|
85
|
+
)
|
86
|
+
render 'general/wizard'
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
class UsersController < ApplicationController
|
2
|
+
include Applicat::Mvc::Controller::Resource
|
3
|
+
|
4
|
+
before_filter :find_resource, only: [:show, :edit, :preferences, :update, :destroy]
|
5
|
+
|
6
|
+
respond_to :html, :js, :json
|
7
|
+
|
8
|
+
def index
|
9
|
+
parent = find_parent User::PARENT_TYPES
|
10
|
+
@users = parent ? parent.users : User.all
|
11
|
+
end
|
12
|
+
|
13
|
+
def languages
|
14
|
+
render json: User.languages(params[:q]).to_json and return
|
15
|
+
end
|
16
|
+
|
17
|
+
def show
|
18
|
+
end
|
19
|
+
|
20
|
+
def edit
|
21
|
+
@presenter = Resources::User::FormPresenter.new(self.view_context, resource: resource)
|
22
|
+
end
|
23
|
+
|
24
|
+
def preferences
|
25
|
+
if params[:user] && current_user.update_attributes(params[:user])
|
26
|
+
redirect_to preferences_user_path(current_user), notice: t('general.form.successfully_updated') and return
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
if current_user.update_attributes(params[:user])
|
32
|
+
redirect_to edit_user_path(current_user), notice: t('general.form.successfully_updated')
|
33
|
+
else
|
34
|
+
render :edit
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
current_user.destroy
|
40
|
+
redirect_to users_url, notice: t('general.form.destroyed')
|
41
|
+
end
|
42
|
+
|
43
|
+
def resource
|
44
|
+
@user
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def find_resource
|
50
|
+
@user = User.find(params[:id])
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class VacanciesController < ApplicationController
|
2
|
+
include Applicat::Mvc::Controller::Resource
|
3
|
+
|
4
|
+
load_and_authorize_resource
|
5
|
+
|
6
|
+
before_filter :find_project, only: [:index, :new, :edit]
|
7
|
+
|
8
|
+
respond_to :html, :js, :json
|
9
|
+
|
10
|
+
def index
|
11
|
+
@vacancies = @project ? @project.vacancies : Vacancy.all
|
12
|
+
end
|
13
|
+
|
14
|
+
def show
|
15
|
+
@vacancy = Vacancy.includes(:project, :candidatures, :comments).find(params[:id])
|
16
|
+
@comments = @vacancy.comments
|
17
|
+
end
|
18
|
+
|
19
|
+
def new
|
20
|
+
@vacancy = Vacancy.new
|
21
|
+
|
22
|
+
@vacancy.project = @project if @project
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
@vacancy = Vacancy.new(params[:vacancy])
|
27
|
+
|
28
|
+
if @vacancy.project.user_id == current_user.id
|
29
|
+
@vacancy.do_open
|
30
|
+
else
|
31
|
+
@vacancy.author_id = current_user.id
|
32
|
+
@vacancy.recommend
|
33
|
+
end
|
34
|
+
|
35
|
+
if @vacancy.save
|
36
|
+
redirect_to @vacancy, notice: t('general.form.successfully_created')
|
37
|
+
else
|
38
|
+
render :new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def edit
|
43
|
+
@vacancy = Vacancy.find(params[:id])
|
44
|
+
end
|
45
|
+
|
46
|
+
def update
|
47
|
+
@vacancy = Vacancy.find(params[:id])
|
48
|
+
|
49
|
+
if @vacancy.update_attributes(params[:vacancy])
|
50
|
+
redirect_to @vacancy, notice: t('general.form.successfully_updated')
|
51
|
+
else
|
52
|
+
render :edit
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def destroy
|
57
|
+
@vacancy = Vacancy.find(params[:id])
|
58
|
+
@vacancy.destroy
|
59
|
+
redirect_to vacancies_url, notice: t('general.form.destroyed')
|
60
|
+
end
|
61
|
+
|
62
|
+
def resource
|
63
|
+
@vacancy
|
64
|
+
end
|
65
|
+
|
66
|
+
transition_actions Vacancy::EVENTS
|
67
|
+
|
68
|
+
protected
|
69
|
+
|
70
|
+
def before_my_state
|
71
|
+
# e.g. set attributes of resource
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def find_project
|
77
|
+
@project = params[:project_id].present? ? Project.find(params[:project_id]) : nil
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
class Voluntary::ApplicationController < ActionController::Base
|
2
|
+
include Applicat::Mvc::Controller
|
3
|
+
|
4
|
+
protect_from_forgery
|
5
|
+
|
6
|
+
before_filter :set_twitter_sidenav_level
|
7
|
+
|
8
|
+
layout Proc.new { |controller| controller.request.xhr? ? 'facebox' : 'application' }
|
9
|
+
|
10
|
+
rescue_from CanCan::AccessDenied, with: :access_denied
|
11
|
+
rescue_from ActiveRecord::RecordNotFound, with: :not_found
|
12
|
+
rescue_from Mongoid::Errors::DocumentNotFound, with: :not_found
|
13
|
+
|
14
|
+
respond_to :html, :js, :json
|
15
|
+
|
16
|
+
def parent
|
17
|
+
@parent
|
18
|
+
end
|
19
|
+
|
20
|
+
helper_method :parent
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def current_ability
|
25
|
+
Ability.new(current_user, controller_namespace: current_namespace)
|
26
|
+
end
|
27
|
+
|
28
|
+
def after_sign_in_path_for(resource_or_scope)
|
29
|
+
if resource_or_scope.main_role.is_a? Role::ProjectOwner
|
30
|
+
workflow_project_owner_index_path
|
31
|
+
elsif resource_or_scope.main_role.is_a? Role::User
|
32
|
+
workflow_user_index_path
|
33
|
+
else
|
34
|
+
workflow_path
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_twitter_sidenav_level
|
39
|
+
@twitter_sidenav_level = 3
|
40
|
+
end
|
41
|
+
|
42
|
+
def find_parent(types, parent_key = nil)
|
43
|
+
parent_type, id = nil, nil
|
44
|
+
|
45
|
+
if parent_type = types.select{|p| params.keys.include?("#{p}_id") }.first
|
46
|
+
id = params["#{parent_type}_id"]
|
47
|
+
elsif parent_type = types.select{|p| params[parent_key] && params[parent_key].keys.include?("#{p}_id") }.first
|
48
|
+
id = params[parent_key]["#{parent_type}_id"]
|
49
|
+
end
|
50
|
+
|
51
|
+
return if parent_type.blank?
|
52
|
+
|
53
|
+
parent = parent_type.classify.constantize.find(id)
|
54
|
+
root_model_class_name = Voluntary::Helpers::Application.root_model_class_name_helper(parent)
|
55
|
+
eval("@#{root_model_class_name.tableize.singularize} = parent")
|
56
|
+
|
57
|
+
parent
|
58
|
+
end
|
59
|
+
|
60
|
+
def response_with_standard(format = nil, error = nil)
|
61
|
+
render status: error ? 500 : 200, json: { success: error ? false : true, error: error} and return true
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def current_namespace
|
67
|
+
controller_name_segments = params[:controller].split('/')
|
68
|
+
controller_name_segments.pop
|
69
|
+
controller_namespace = controller_name_segments.join('/').downcase
|
70
|
+
end
|
71
|
+
|
72
|
+
def access_denied
|
73
|
+
message = I18n.t('general.exceptions.access_denied')
|
74
|
+
|
75
|
+
if request.format.try('json?')
|
76
|
+
render status: 403, json: { error: message } and return
|
77
|
+
else
|
78
|
+
flash[:alert] = message
|
79
|
+
|
80
|
+
if request.env["HTTP_REFERER"]
|
81
|
+
redirect_to :back
|
82
|
+
else
|
83
|
+
redirect_to root_path
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def not_found(e)
|
89
|
+
logger.info "not found (#{e.inspect})"
|
90
|
+
redirect_to root_path, notice: t('general.exceptions.not_found')
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Workflow::CandidaturesController < ApplicationController
|
2
|
+
def new
|
3
|
+
state_action
|
4
|
+
end
|
5
|
+
|
6
|
+
def accepted
|
7
|
+
state_action
|
8
|
+
end
|
9
|
+
|
10
|
+
def denied
|
11
|
+
state_action
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def state_action
|
17
|
+
@candidatures = current_user.offeror_candidatures.where(state: action_name).includes(:vacancy, :user)
|
18
|
+
render 'candidatures/index'
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class Workflow::ProjectOwnerController < ApplicationController
|
2
|
+
def index
|
3
|
+
@stories = {}
|
4
|
+
@tasks = {}
|
5
|
+
@vacancies = {}
|
6
|
+
@candidatures = {}
|
7
|
+
|
8
|
+
{ vacancies: Vacancy::STATES, candidatures: Candidature::STATES }.each do |controller, states|
|
9
|
+
query = 'offeror_id = :user_id'
|
10
|
+
query += ' OR author_id = :user_id' if controller == :vacancies
|
11
|
+
query = "(#{query}) AND state = :state"
|
12
|
+
|
13
|
+
states.each do |state|
|
14
|
+
# eval("@#{controller}[state] = current_user.offeror_#{controller}.where(state: state).limit(5)")
|
15
|
+
collection = controller.to_s.classify.constantize.where(
|
16
|
+
query, user_id: current_user.id, state: state
|
17
|
+
).order('created_at DESC').limit(5)
|
18
|
+
eval("@#{controller}[state] = collection")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
{ stories: [:completed], tasks: [:under_supervision] }.each do |controller, states|
|
23
|
+
states.each do |state|
|
24
|
+
collection = controller.to_s.classify.constantize.where(
|
25
|
+
offeror_id: current_user.id, state: state
|
26
|
+
).limit(5)
|
27
|
+
eval("@#{controller}[state] = collection")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
@twitter_sidenav_level = 2
|
32
|
+
end
|
33
|
+
end
|