voluntary 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (295) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +48 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/javascripts/voluntary/application.js +6 -0
  5. data/app/assets/javascripts/voluntary/base.js.coffee +34 -0
  6. data/app/assets/javascripts/voluntary/bootstrap.js.coffee +4 -0
  7. data/app/assets/javascripts/voluntary/functions.js +24 -0
  8. data/app/assets/javascripts/voluntary/users.js.coffee +12 -0
  9. data/app/assets/stylesheets/voluntary/application.css +15 -0
  10. data/app/assets/stylesheets/voluntary/base.css.scss +40 -0
  11. data/app/assets/stylesheets/voluntary/bootstrap_and_overrides.css.less +67 -0
  12. data/app/controllers/areas_controller.rb +66 -0
  13. data/app/controllers/candidatures_controller.rb +79 -0
  14. data/app/controllers/comments_controller.rb +70 -0
  15. data/app/controllers/devise_extensions/registrations_controller.rb +37 -0
  16. data/app/controllers/home_controller.rb +7 -0
  17. data/app/controllers/organizations_controller.rb +67 -0
  18. data/app/controllers/pages_controller.rb +54 -0
  19. data/app/controllers/products_controller.rb +62 -0
  20. data/app/controllers/professions_controller.rb +66 -0
  21. data/app/controllers/projects_controller.rb +56 -0
  22. data/app/controllers/results_controller.rb +93 -0
  23. data/app/controllers/stories_controller.rb +96 -0
  24. data/app/controllers/tasks_controller.rb +88 -0
  25. data/app/controllers/users_controller.rb +52 -0
  26. data/app/controllers/vacancies_controller.rb +79 -0
  27. data/app/controllers/voluntary/application_controller.rb +92 -0
  28. data/app/controllers/workflow/candidatures_controller.rb +20 -0
  29. data/app/controllers/workflow/products_controller.rb +6 -0
  30. data/app/controllers/workflow/project_owner_controller.rb +33 -0
  31. data/app/controllers/workflow/stories_controller.rb +6 -0
  32. data/app/controllers/workflow/tasks_controller.rb +147 -0
  33. data/app/controllers/workflow/user_controller.rb +6 -0
  34. data/app/controllers/workflow/vacancies_controller.rb +17 -0
  35. data/app/controllers/workflow_controller.rb +7 -0
  36. data/app/helpers/application_helper.rb +65 -0
  37. data/app/helpers/collection_helper.rb +31 -0
  38. data/app/helpers/comments_helper.rb +11 -0
  39. data/app/helpers/form_helper.rb +39 -0
  40. data/app/helpers/language_helper.rb +15 -0
  41. data/app/helpers/layout_helper.rb +24 -0
  42. data/app/helpers/product_helper.rb +32 -0
  43. data/app/helpers/show_helper.rb +65 -0
  44. data/app/helpers/wizard_helper.rb +27 -0
  45. data/app/models/area.rb +19 -0
  46. data/app/models/area_user.rb +19 -0
  47. data/app/models/candidature.rb +35 -0
  48. data/app/models/comment.rb +16 -0
  49. data/app/models/history_tracker.rb +3 -0
  50. data/app/models/mongo_db_document.rb +11 -0
  51. data/app/models/organization.rb +19 -0
  52. data/app/models/page.rb +30 -0
  53. data/app/models/product.rb +99 -0
  54. data/app/models/product/new_product.rb +3 -0
  55. data/app/models/product/project_management.rb +29 -0
  56. data/app/models/profession.rb +13 -0
  57. data/app/models/project.rb +66 -0
  58. data/app/models/project_user.rb +13 -0
  59. data/app/models/result.rb +55 -0
  60. data/app/models/role.rb +8 -0
  61. data/app/models/role/admin.rb +2 -0
  62. data/app/models/role/master.rb +2 -0
  63. data/app/models/role/project_owner.rb +2 -0
  64. data/app/models/role/user.rb +2 -0
  65. data/app/models/state_machines/candidature.rb +42 -0
  66. data/app/models/state_machines/page.rb +18 -0
  67. data/app/models/state_machines/story.rb +51 -0
  68. data/app/models/state_machines/task.rb +46 -0
  69. data/app/models/state_machines/vacancy.rb +41 -0
  70. data/app/models/story.rb +82 -0
  71. data/app/models/task.rb +85 -0
  72. data/app/models/user.rb +95 -0
  73. data/app/models/user_role.rb +6 -0
  74. data/app/models/vacancy.rb +41 -0
  75. data/app/observers/candidature_observer.rb +29 -0
  76. data/app/observers/story_observer.rb +6 -0
  77. data/app/observers/task_observer.rb +34 -0
  78. data/app/presenters/layout/application_presenter.rb +3 -0
  79. data/app/presenters/layout_presenter.rb +9 -0
  80. data/app/presenters/presenter.rb +46 -0
  81. data/app/presenters/resource_presenter.rb +30 -0
  82. data/app/presenters/resources/general/wizard_presenter.rb +17 -0
  83. data/app/presenters/resources/general/wizards/story/steps/activate_presenter.rb +3 -0
  84. data/app/presenters/resources/general/wizards/story/steps/setup_tasks_presenter.rb +5 -0
  85. data/app/presenters/resources/general/wizards/story_presenter.rb +3 -0
  86. data/app/presenters/resources/user/form_presenter.rb +16 -0
  87. data/app/presenters/shared/collection/table_presenter.rb +33 -0
  88. data/app/views/areas/_form.html.erb +11 -0
  89. data/app/views/areas/edit.html.erb +3 -0
  90. data/app/views/areas/index.html.erb +5 -0
  91. data/app/views/areas/new.html.erb +3 -0
  92. data/app/views/areas/show.html.erb +6 -0
  93. data/app/views/candidatures/_form.html.erb +13 -0
  94. data/app/views/candidatures/edit.html.erb +3 -0
  95. data/app/views/candidatures/index.html.erb +11 -0
  96. data/app/views/candidatures/new.html.erb +3 -0
  97. data/app/views/candidatures/show.html.erb +18 -0
  98. data/app/views/comments/_form.html.erb +16 -0
  99. data/app/views/comments/_resource.html.erb +16 -0
  100. data/app/views/comments/edit.html.erb +3 -0
  101. data/app/views/comments/new.html.erb +3 -0
  102. data/app/views/devise/mailer/confirmation_instructions.html.erb +10 -0
  103. data/app/views/devise/registrations/new.html.erb +5 -0
  104. data/app/views/general/wizard.html.erb +16 -0
  105. data/app/views/kaminari/_first_page.html.erb +13 -0
  106. data/app/views/kaminari/_gap.html.erb +8 -0
  107. data/app/views/kaminari/_last_page.html.erb +13 -0
  108. data/app/views/kaminari/_next_page.html.erb +13 -0
  109. data/app/views/kaminari/_page.html.erb +12 -0
  110. data/app/views/kaminari/_paginator.html.erb +25 -0
  111. data/app/views/kaminari/_prev_page.html.erb +13 -0
  112. data/app/views/layouts/application.html.erb +48 -0
  113. data/app/views/layouts/shared/_flash_messages.html.erb +7 -0
  114. data/app/views/layouts/shared/_navigation.html.erb +7 -0
  115. data/app/views/organizations/_form.html.erb +11 -0
  116. data/app/views/organizations/edit.html.erb +3 -0
  117. data/app/views/organizations/index.html.erb +5 -0
  118. data/app/views/organizations/new.html.erb +3 -0
  119. data/app/views/organizations/show.html.erb +6 -0
  120. data/app/views/pages/_form.html.erb +12 -0
  121. data/app/views/pages/edit.html.erb +3 -0
  122. data/app/views/pages/index.html.erb +5 -0
  123. data/app/views/pages/new.html.erb +3 -0
  124. data/app/views/pages/show.html.erb +10 -0
  125. data/app/views/products/_form.html.erb +28 -0
  126. data/app/views/products/edit.html.erb +3 -0
  127. data/app/views/products/index.html.erb +5 -0
  128. data/app/views/products/mixins/_keywords.html.erb +4 -0
  129. data/app/views/products/new.html.erb +3 -0
  130. data/app/views/products/show.html.erb +11 -0
  131. data/app/views/products/types/text_creation/stories/_form.html.erb +19 -0
  132. data/app/views/products/types/text_creation/stories/_task_fields.html.erb +7 -0
  133. data/app/views/projects/_form.html.erb +16 -0
  134. data/app/views/projects/edit.html.erb +3 -0
  135. data/app/views/projects/index.html.erb +5 -0
  136. data/app/views/projects/new.html.erb +3 -0
  137. data/app/views/projects/show.html.erb +13 -0
  138. data/app/views/shared/_comments.html.erb +7 -0
  139. data/app/views/shared/collection/_list.html.erb +37 -0
  140. data/app/views/shared/collection/_table.html.erb +36 -0
  141. data/app/views/shared/form/_error_messages.html.erb +10 -0
  142. data/app/views/shared/resource/_actions.html.erb +26 -0
  143. data/app/views/shared/resource/_event_elements.html.erb +7 -0
  144. data/app/views/stories/_collection.html.erb +8 -0
  145. data/app/views/stories/_form.html.erb +19 -0
  146. data/app/views/stories/_task_fields.html.erb +11 -0
  147. data/app/views/stories/index.html.erb +1 -0
  148. data/app/views/stories/show.html.erb +13 -0
  149. data/app/views/stories/steps/_activate.html.erb +17 -0
  150. data/app/views/stories/steps/_setup_tasks.html.erb +35 -0
  151. data/app/views/stories/tasks.html.erb +0 -0
  152. data/app/views/tasks/_collection.html.erb +12 -0
  153. data/app/views/users/_form.html.erb +43 -0
  154. data/app/views/users/edit.html.erb +3 -0
  155. data/app/views/users/index.html.erb +6 -0
  156. data/app/views/users/new.html.erb +3 -0
  157. data/app/views/users/preferences.html.erb +11 -0
  158. data/app/views/users/show.html.erb +6 -0
  159. data/app/views/vacancies/_form.html.erb +15 -0
  160. data/app/views/vacancies/edit.html.erb +3 -0
  161. data/app/views/vacancies/index.html.erb +7 -0
  162. data/app/views/vacancies/new.html.erb +3 -0
  163. data/app/views/vacancies/show.html.erb +17 -0
  164. data/app/views/workflow/index.html.erb +0 -0
  165. data/app/views/workflow/products/show.html.erb +34 -0
  166. data/app/views/workflow/project_owner/_candidatures.html.erb +31 -0
  167. data/app/views/workflow/project_owner/_stories.html.erb +29 -0
  168. data/app/views/workflow/project_owner/_tasks.html.erb +34 -0
  169. data/app/views/workflow/project_owner/_vacancies.html.erb +27 -0
  170. data/app/views/workflow/project_owner/index.html.erb +24 -0
  171. data/app/views/workflow/tasks/_work_form.html.erb +8 -0
  172. data/app/views/workflow/tasks/_work_head.html.erb +15 -0
  173. data/app/views/workflow/tasks/edit.html.erb +3 -0
  174. data/app/views/workflow/tasks/index.html.erb +31 -0
  175. data/app/views/workflow/tasks/next.html.erb +0 -0
  176. data/app/views/workflow/tasks/steps/_complete.html.erb +11 -0
  177. data/app/views/workflow/tasks/steps/_review.html.erb +13 -0
  178. data/app/views/workflow/tasks/steps/_work.html.erb +17 -0
  179. data/app/views/workflow/user/_tasks.html.erb +30 -0
  180. data/app/views/workflow/user/index.html.erb +14 -0
  181. data/config/initializers/1_initialize_app_config.rb +5 -0
  182. data/config/initializers/devise.rb +193 -0
  183. data/config/initializers/locale_settings.rb +42 -0
  184. data/config/initializers/mongoid-history.rb +2 -0
  185. data/config/initializers/recaptcha.rb +7 -0
  186. data/config/initializers/simple_form.rb +178 -0
  187. data/config/initializers/simple_navigation.rb +2 -0
  188. data/config/locales/devise.en.yml +59 -0
  189. data/config/locales/en.yml +26 -0
  190. data/config/locales/general/en.yml +71 -0
  191. data/config/locales/resources/area/en.yml +12 -0
  192. data/config/locales/resources/candidature/en.yml +19 -0
  193. data/config/locales/resources/comment/en.yml +11 -0
  194. data/config/locales/resources/organization/en.yml +11 -0
  195. data/config/locales/resources/page/en.yml +11 -0
  196. data/config/locales/resources/product/en.yml +23 -0
  197. data/config/locales/resources/project/en.yml +9 -0
  198. data/config/locales/resources/result/en.yml +9 -0
  199. data/config/locales/resources/story/en.yml +34 -0
  200. data/config/locales/resources/task/en.yml +36 -0
  201. data/config/locales/resources/user/en.yml +14 -0
  202. data/config/locales/resources/vacancy/en.yml +29 -0
  203. data/config/locales/simple_form.en.yml +26 -0
  204. data/config/locales/workflow/en.yml +37 -0
  205. data/config/routes.rb +188 -0
  206. data/db/migrate/20120907144853_create_schema.rb +217 -0
  207. data/db/migrate/20120911093743_remove_timestamps_from_habtm_tables.rb +21 -0
  208. data/db/migrate/20120919161831_add_unique_index_for_one_user_candidature_per_vacancy.rb +9 -0
  209. data/db/migrate/20120922201955_create_mongo_db_documents.rb +13 -0
  210. data/db/migrate/20120923140109_add_product_to_project.rb +6 -0
  211. data/db/migrate/20121004061413_add_extra_user_attributes.rb +9 -0
  212. data/db/migrate/20121004132105_create_professions.rb +13 -0
  213. data/db/migrate/20121006162913_add_public_attribute_to_roles.rb +6 -0
  214. data/db/migrate/20121006170407_add_type_attribute_to_roles.rb +5 -0
  215. data/db/migrate/20121007071543_add_foreign_languages_to_user.rb +6 -0
  216. data/db/migrate/20121028073712_create_organizations.rb +13 -0
  217. data/db/seeds.rb +14 -0
  218. data/lib/applicat/mvc/controller.rb +171 -0
  219. data/lib/applicat/mvc/controller/error_handling.rb +40 -0
  220. data/lib/applicat/mvc/controller/resource.rb +19 -0
  221. data/lib/applicat/mvc/controller/transition_actions.rb +43 -0
  222. data/lib/applicat/mvc/model/resource/base.rb +56 -0
  223. data/lib/applicat/mvc/model/tokenable.rb +24 -0
  224. data/lib/applicat/mvc/model/tree.rb +82 -0
  225. data/lib/db_seed.rb +150 -0
  226. data/lib/environment_configuration.rb +54 -0
  227. data/lib/generators/voluntary/install/install_generator.rb +118 -0
  228. data/lib/generators/voluntary/install/templates/app/controllers/application_controller.rb +3 -0
  229. data/lib/generators/voluntary/install/templates/app/models/ability.rb +49 -0
  230. data/lib/generators/voluntary/install/templates/app/models/app_config.rb +32 -0
  231. data/lib/generators/voluntary/install/templates/app/views/layouts/application.html.erb +50 -0
  232. data/lib/generators/voluntary/install/templates/config/application.yml +147 -0
  233. data/lib/generators/voluntary/install/templates/config/cucumber.yml +8 -0
  234. data/lib/generators/voluntary/install/templates/config/database.example.yml +28 -0
  235. data/lib/generators/voluntary/install/templates/config/deploy.rb +59 -0
  236. data/lib/generators/voluntary/install/templates/config/email.example.yml +9 -0
  237. data/lib/generators/voluntary/install/templates/config/initializers/recaptcha_example +4 -0
  238. data/lib/generators/voluntary/install/templates/config/locale_settings.yml +121 -0
  239. data/lib/generators/voluntary/install/templates/config/main_navigation.rb +262 -0
  240. data/lib/generators/voluntary/install/templates/config/mongoid.yml +78 -0
  241. data/lib/generators/voluntary/install/templates/config/nginx.conf +27 -0
  242. data/lib/generators/voluntary/install/templates/config/unicorn.rb +9 -0
  243. data/lib/generators/voluntary/install/templates/config/unicorn_init.sh +84 -0
  244. data/lib/generators/voluntary/install/templates/db/seeds.rb +14 -0
  245. data/lib/generators/voluntary/install/templates/features/step_definitions/email_steps.rb +89 -0
  246. data/lib/generators/voluntary/install/templates/features/step_definitions/factory_steps.rb +120 -0
  247. data/lib/generators/voluntary/install/templates/features/step_definitions/javascript_steps.rb +15 -0
  248. data/lib/generators/voluntary/install/templates/features/step_definitions/navigation_steps.rb +3 -0
  249. data/lib/generators/voluntary/install/templates/features/step_definitions/resources_steps.rb +8 -0
  250. data/lib/generators/voluntary/install/templates/features/step_definitions/session_steps.rb +35 -0
  251. data/lib/generators/voluntary/install/templates/features/step_definitions/web_steps.rb +271 -0
  252. data/lib/generators/voluntary/install/templates/features/support/database_cleaner_patches.rb +24 -0
  253. data/lib/generators/voluntary/install/templates/features/support/env.rb +83 -0
  254. data/lib/generators/voluntary/install/templates/features/support/integration_sessions_controller.rb +32 -0
  255. data/lib/generators/voluntary/install/templates/features/support/integration_sessions_form.html.erb +1 -0
  256. data/lib/generators/voluntary/install/templates/features/support/paths.rb +98 -0
  257. data/lib/generators/voluntary/install/templates/features/support/selectors.rb +44 -0
  258. data/lib/generators/voluntary/install/templates/features/support/spork_env +72 -0
  259. data/lib/generators/voluntary/install/templates/features/support/user_cuke_helpers.rb +78 -0
  260. data/lib/generators/voluntary/install/templates/lib/volontariat_seed.rb +36 -0
  261. data/lib/generators/voluntary/install/templates/spec/spec_helper.rb +72 -0
  262. data/lib/generators/voluntary/install/templates/spec/support/deferred_garbage_collector.rb +45 -0
  263. data/lib/generators/voluntary/install/templates/spec/support/devise.rb +3 -0
  264. data/lib/generators/voluntary/install/templates/spec/support/mongo_database_cleaner.rb +19 -0
  265. data/lib/generators/voluntary/install/templates/vendor/assets/javascripts/jquery.tokeninput.js +915 -0
  266. data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-facebook.css +122 -0
  267. data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input-mac.css +204 -0
  268. data/lib/generators/voluntary/install/templates/vendor/assets/stylesheets/token-input.css +127 -0
  269. data/lib/i18n_interpolation_fallbacks.rb +21 -0
  270. data/lib/model/mongo_db/commentable.rb +17 -0
  271. data/lib/model/mongo_db/core_extensions.rb +10 -0
  272. data/lib/model/mongo_db/customizable.rb +23 -0
  273. data/lib/model/mongo_db/product/keywords.rb +31 -0
  274. data/lib/model/mongo_db/state_version_attributes.rb +15 -0
  275. data/lib/tasks/cucumber.rake +65 -0
  276. data/lib/tasks/voluntary_tasks.rake +4 -0
  277. data/lib/vendors/active_model/naming.rb +14 -0
  278. data/lib/vendors/simple_navigation/renderer/breadcrumbs_without_method_links.rb +30 -0
  279. data/lib/vendors/simple_navigation/renderer/twitter_sidenav.rb +34 -0
  280. data/lib/voluntary.rb +87 -0
  281. data/lib/voluntary/engine.rb +11 -0
  282. data/lib/voluntary/helpers/application.rb +69 -0
  283. data/lib/voluntary/helpers/collection.rb +35 -0
  284. data/lib/voluntary/helpers/comments.rb +15 -0
  285. data/lib/voluntary/helpers/form.rb +43 -0
  286. data/lib/voluntary/helpers/language.rb +19 -0
  287. data/lib/voluntary/helpers/layout.rb +28 -0
  288. data/lib/voluntary/helpers/product.rb +36 -0
  289. data/lib/voluntary/helpers/show.rb +69 -0
  290. data/lib/voluntary/helpers/wizard.rb +31 -0
  291. data/lib/voluntary/version.rb +3 -0
  292. data/lib/wizard.rb +58 -0
  293. data/lib/wizard/controller/concerns/paths.rb +31 -0
  294. data/lib/wizard/controller/concerns/steps.rb +142 -0
  295. metadata +1217 -0
@@ -0,0 +1,217 @@
1
+ class CreateSchema < ActiveRecord::Migration
2
+ def up
3
+ create_table :users do |t|
4
+ t.string :name
5
+ t.string :slug
6
+ t.string :rpx_identifier
7
+ t.string :password
8
+ t.text :text
9
+ t.text :serialized_private_key
10
+
11
+ # profile
12
+ t.string :language
13
+ t.string :first_name
14
+ t.string :last_name
15
+ t.string :salutation
16
+ t.string :marital_status
17
+ t.string :family_status
18
+ t.date :date_of_birth
19
+ t.string :place_of_birth
20
+ t.string :citizenship
21
+
22
+ # devise authentication data
23
+
24
+ ## Database authenticatable
25
+ t.string :email, :null => false, :default => ""
26
+ t.string :encrypted_password, :null => false, :default => ""
27
+
28
+ ## Recoverable
29
+ t.string :reset_password_token
30
+ t.datetime :reset_password_sent_at
31
+
32
+ ## Rememberable
33
+ t.datetime :remember_created_at
34
+
35
+ ## Trackable
36
+ t.integer :sign_in_count, :default => 0
37
+ t.datetime :current_sign_in_at
38
+ t.datetime :last_sign_in_at
39
+ t.string :current_sign_in_ip
40
+ t.string :last_sign_in_ip
41
+
42
+ ## Confirmable
43
+ t.string :confirmation_token
44
+ t.datetime :confirmed_at
45
+ t.datetime :confirmation_sent_at
46
+ t.string :unconfirmed_email # Only if using reconfirmable
47
+
48
+ ## Lockable
49
+ t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
50
+ t.string :unlock_token # Only if unlock strategy is :email or :both
51
+ t.datetime :locked_at
52
+
53
+ ## Token authenticatable
54
+ t.string :authentication_token
55
+
56
+ t.string :password_salt # Encryptable
57
+
58
+ t.string :state
59
+ t.timestamps
60
+ end
61
+
62
+ add_index :users, :slug, unique: true
63
+ add_index :users, :name, unique: true
64
+ add_index :users, :email, unique: true
65
+ add_index :users, :reset_password_token, unique: true
66
+
67
+ create_table :roles do |t|
68
+ t.string :name
69
+ t.string :state
70
+ t.timestamps
71
+ end
72
+
73
+ create_table :users_roles do |t|
74
+ t.integer :role_id
75
+ t.integer :user_id
76
+ t.string :state
77
+ t.timestamps
78
+ end
79
+
80
+ add_index :users_roles, [:user_id, :role_id], unique: true
81
+
82
+ create_table :projects do |t|
83
+ t.integer :user_id
84
+ t.string :name
85
+ t.string :slug
86
+ t.text :text
87
+ t.string :url
88
+ t.string :state
89
+ t.timestamps
90
+ end
91
+
92
+ add_index :projects, :slug, unique: true
93
+ add_index :projects, :user_id
94
+
95
+ create_table :vacancies do |t|
96
+ t.string :type # job, location, money
97
+ t.integer :project_id
98
+ t.integer :offeror_id
99
+ t.integer :author_id
100
+ t.integer :user_id
101
+ t.integer :project_user_id
102
+ t.string :name
103
+ t.string :slug
104
+ t.text :text
105
+ t.integer :limit, default: 1
106
+ t.string :state
107
+ t.timestamps
108
+ end
109
+
110
+ add_index :vacancies, :slug, unique: true
111
+ add_index :vacancies, [:project_id, :name], unique: true
112
+ add_index :vacancies, :project_id
113
+ add_index :vacancies, :offeror_id
114
+ add_index :vacancies, :user_id
115
+ add_index :vacancies, :project_user_id
116
+
117
+ create_table :candidatures do |t|
118
+ t.integer :vacancy_id
119
+ t.integer :offeror_id
120
+ t.integer :user_id
121
+ t.string :name
122
+ t.string :slug
123
+ t.text :text
124
+ t.string :state
125
+ t.timestamps
126
+ end
127
+
128
+ add_index :candidatures, :slug, unique: true
129
+ add_index :candidatures, [:vacancy_id, :name], unique: true
130
+ add_index :candidatures, :vacancy_id
131
+ add_index :candidatures, :user_id
132
+
133
+ # project stellen ausschreibung
134
+ # bewerbung (project, project stelle)
135
+
136
+ create_table :projects_users do |t|
137
+ t.integer :project_id
138
+ t.integer :vacancy_id
139
+ t.integer :role_id
140
+ t.integer :user_id
141
+ t.string :state
142
+ t.timestamps
143
+ end
144
+
145
+ add_index :projects_users, [:project_id, :user_id, :vacancy_id], unique: true
146
+ add_index :projects_users, :project_id
147
+ add_index :projects_users, :vacancy_id
148
+ add_index :projects_users, :role_id
149
+ add_index :projects_users, :user_id
150
+
151
+ create_table :areas do |t|
152
+ t.string :ancestry
153
+ t.integer :ancestry_depth, default: 0
154
+ t.integer :position
155
+ t.string :name
156
+ t.string :slug
157
+ t.integer :users_count, default: 0
158
+ t.timestamps
159
+ end
160
+
161
+ add_index :areas, :slug, unique: true
162
+ add_index :areas, :ancestry
163
+ add_index :areas, :name, unique: true
164
+
165
+ create_table :areas_users do |t|
166
+ t.integer :area_id
167
+ t.integer :user_id
168
+ t.timestamps
169
+ end
170
+
171
+ add_index :areas_users, [:area_id, :user_id], unique: true
172
+ add_index :areas_users, :area_id
173
+ add_index :areas_users, :user_id
174
+
175
+ create_table :areas_projects do |t|
176
+ t.integer :area_id
177
+ t.integer :project_id
178
+ t.timestamps
179
+ end
180
+
181
+ add_index :areas_projects, [:area_id, :project_id], unique: true
182
+ add_index :areas_projects, :area_id
183
+ add_index :areas_projects, :project_id
184
+
185
+ create_table :comments do |t|
186
+ t.string :commentable_type
187
+ t.integer :commentable_id
188
+ t.integer :user_id
189
+ t.string :ancestry
190
+ t.integer :ancestry_depth, default: 0
191
+ t.integer :position
192
+ t.string :name
193
+ t.text :text
194
+ t.string :state
195
+ t.timestamps
196
+ end
197
+
198
+ add_index :comments, [:commentable_id, :commentable_type]
199
+ add_index :comments, :ancestry
200
+
201
+ # 3rd party
202
+ create_table :friendly_id_slugs do |t|
203
+ t.string :slug, :null => false
204
+ t.integer :sluggable_id, :null => false
205
+ t.string :sluggable_type, :limit => 40
206
+ t.datetime :created_at
207
+ end
208
+
209
+ add_index :friendly_id_slugs, :sluggable_id
210
+ add_index :friendly_id_slugs, [:slug, :sluggable_type], :unique => true
211
+ add_index :friendly_id_slugs, :sluggable_type
212
+ end
213
+
214
+ def down
215
+ raise 'irreversable migration!'
216
+ end
217
+ end
@@ -0,0 +1,21 @@
1
+ class RemoveTimestampsFromHabtmTables < ActiveRecord::Migration
2
+ TABLES = [
3
+ :areas_projects, :areas_users, :projects_users, :users_roles
4
+ ]
5
+
6
+ def up
7
+ # Have to remove timestamps from cause of:
8
+ # PG::Error: ERROR: null value in column "created_at" violates not-null constraint
9
+ TABLES.each do |table|
10
+ remove_column table, :created_at
11
+ remove_column table, :updated_at
12
+ end
13
+ end
14
+
15
+ def down
16
+ TABLES.each do |table|
17
+ add_column table, :created_at, :datetime, null: false
18
+ add_column table, :updated_at, :datetime, null: false
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,9 @@
1
+ class AddUniqueIndexForOneUserCandidaturePerVacancy < ActiveRecord::Migration
2
+ def up
3
+ add_index :candidatures, [:user_id, :vacancy_id], unique: true
4
+ end
5
+
6
+ def down
7
+ remove_index :candidatures, [:user_id, :vacancy_id]
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateMongoDbDocuments < ActiveRecord::Migration
2
+ def change
3
+ create_table :mongo_db_documents do |t|
4
+ t.integer :mongo_db_object_id
5
+ t.string :klass_name
6
+ t.string :name
7
+ t.string :slug
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :mongo_db_documents, [:mongo_db_object_id, :klass_name], unique: true
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ class AddProductToProject < ActiveRecord::Migration
2
+ def change
3
+ add_column :projects, :product_id, :string
4
+ add_index :projects, :product_id
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ class AddExtraUserAttributes < ActiveRecord::Migration
2
+ def change
3
+ add_column :users, :country, :string
4
+ add_column :users, :foreign_language, :string
5
+ add_column :users, :interface_language, :string
6
+ add_column :users, :profession, :string
7
+ add_column :users, :employment_relationship, :string
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateProfessions < ActiveRecord::Migration
2
+ def change
3
+ create_table :professions do |t|
4
+ t.string :name
5
+ t.string :slug
6
+ t.timestamps
7
+ end
8
+
9
+ remove_column :users, :profession
10
+ add_column :users, :profession_id, :integer
11
+ add_index :users, :profession_id
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ class AddPublicAttributeToRoles < ActiveRecord::Migration
2
+ def change
3
+ add_column :roles, :public, :boolean, default: false
4
+ add_column :users, :main_role_id, :integer
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ class AddTypeAttributeToRoles < ActiveRecord::Migration
2
+ def change
3
+ add_column :roles, :type, :string
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddForeignLanguagesToUser < ActiveRecord::Migration
2
+ def change
3
+ remove_column :users, :foreign_language
4
+ add_column :users, :foreign_languages, :text
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ class CreateOrganizations < ActiveRecord::Migration
2
+ def change
3
+ create_table :organizations do |t|
4
+ t.string :name
5
+ t.string :slug
6
+ t.timestamps
7
+ end
8
+
9
+ add_index :organizations, :slug
10
+ add_column :projects, :organization_id, :integer
11
+ add_index :projects, :organization_id
12
+ end
13
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,14 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
7
+ # Mayor.create(name: 'Emanuel', city: cities.first)
8
+ delivery_method_was = ActionMailer::Base.delivery_method
9
+ ActionMailer::Base.delivery_method = :test
10
+
11
+ db_seed = VolontariatSeed.new
12
+ db_seed.create_fixtures
13
+
14
+ ActionMailer::Base.delivery_method = delivery_method_was
@@ -0,0 +1,171 @@
1
+ #module Applicat::Mvc::Controller
2
+ module Applicat
3
+ module Mvc
4
+ module Controller
5
+ def self.included(base)
6
+ base.class_eval do
7
+ include RailsInfo::Controller::ExceptionDiagnostics
8
+
9
+ include ErrorHandling
10
+ include TransitionActions
11
+
12
+ protect_from_forgery
13
+
14
+ layout proc { |controller| controller.request.xhr? || !controller.params[:is_ajax_request].nil? ? false : 'application' }
15
+
16
+ helper :all
17
+ helper_method :controller_action?, :resource_exists?, :layout_presenter
18
+
19
+ def controller_action?(input_controller, input_action)
20
+ if "#{input_controller}/#{input_action}" == "#{controller_name}/#{action_name}"
21
+ return true
22
+ else
23
+ return false
24
+ end
25
+ end
26
+
27
+ def resource_exists?(name)
28
+ if eval("@#{name}.nil?") || (eval("@#{name}.class.name") != name.classify && eval("@#{name}.class.superclass.name") != name.classify) || eval("@#{name}.id.nil?")
29
+ return false
30
+ else
31
+ return true
32
+ end
33
+ end
34
+
35
+ def help
36
+ helper = Helper.instance
37
+ helper.controller = self
38
+ return helper
39
+ end
40
+
41
+ def layout_presenter
42
+ layout_name = _layout
43
+
44
+ if layout_name.inspect.match('.')
45
+ # app/views/layouts/application.html.erb
46
+ layout_name = layout_name.inspect.gsub('"', '').split('/').last.split('.').first
47
+ end
48
+
49
+ @layout_presenter ||= "Layout::#{layout_name.classify}Presenter".constantize.new(
50
+ self.view_context, resource: self.respond_to?(:resource) ? resource : nil
51
+ )
52
+ end
53
+
54
+ protected
55
+
56
+ def eager_load_polymorphs(list, includes)
57
+ polymorphs = {}
58
+
59
+ logger.debug "eager_load_polymorphs for list length: #{list.length}"
60
+
61
+ list.each do |record|
62
+ includes.each do |include|
63
+ include = include.first if include.is_a?(Array)
64
+
65
+ polymorphs[eval("record.#{include}_type")] ||= []
66
+ polymorphs[eval("record.#{include}_type")] << eval("record.#{include}_id")
67
+ end
68
+ end
69
+
70
+ logger.debug "Load polymorphs: #{polymorphs.keys.join(', ')}"
71
+
72
+ polymorphs.each do |type,ids|
73
+ polymorphs[type] = type.constantize.find(ids)
74
+ end
75
+
76
+ list_index = 0
77
+
78
+ list.each do |record|
79
+ includes.each do |include|
80
+ polymorphs[eval("record.#{include}_type")].each do |polymorph|
81
+ next unless polymorph.id == eval("record.#{include}_id")
82
+
83
+ eval("list[list_index].#{include} = polymorph")
84
+
85
+ break
86
+ end
87
+ end
88
+
89
+ list_index += 1
90
+ end
91
+
92
+ # free memory
93
+ polymorphs.each do |type,ids|
94
+ polymorphs.delete(type)
95
+ end
96
+
97
+ return list
98
+ end
99
+
100
+ def model_name
101
+ self.class.name.gsub('Controller', '').classify
102
+ end
103
+
104
+ def set_i18n_locale_from_params
105
+ if params[:locale]
106
+ if I18n.available_locales.include?(params[:locale].to_sym)
107
+ I18n.locale = params[:locale]
108
+ else
109
+ flash.now[:notice] = "#{params[:locale]} translation not available"
110
+ logger.error flash.now[:notice]
111
+ end
112
+ end
113
+ end
114
+
115
+ def js_help
116
+ js_helper = JavaScriptHelper.instance
117
+ js_helper.controller = self
118
+ return js_helper
119
+ end
120
+
121
+ def store_location
122
+ session[:"user.return_to"] = request.fullpath
123
+ end
124
+
125
+ private
126
+
127
+ def exception_action(exception)
128
+ @exception_catched = true
129
+
130
+ if Rails.env == 'production'
131
+ notify_airbrake(exception)
132
+ logger.error "INTERNAL SERVER ERROR FOR REQUEST: " + exception.message
133
+ logger.error exception.backtrace.join("\n")
134
+ else
135
+ raise exception
136
+ end
137
+
138
+ if !request.env['REQUEST_URI'].match(/\/assets\//).nil?
139
+ render :text => '', :layout => false
140
+ elsif exception.is_a?(ActiveRecord::RecordNotFound)
141
+ render 'pages/exception_404', :layout => 'application'
142
+ else
143
+ render 'pages/exception_500', :layout => 'application'
144
+ end
145
+ end
146
+ end
147
+ end
148
+
149
+ class Helper
150
+ include Singleton
151
+ #include ActionView::Helpers::TextHelper
152
+ include ActionView::Helpers
153
+ include ActionView::Helpers::CaptureHelper
154
+ include ActionView::Helpers::UrlHelper
155
+
156
+ attr_accessor :controller
157
+
158
+ # Proxy Pattern use here cause of NoMethodError at help.link_to('destroy', send("#{@resource_class.name.downcase}_path", @resource_instance), :confirm => 'Are you sure?', :method => :delete) in presenters
159
+ # undefined method `protect_against_forgery?' for #<ApplicationController::Helper:0x804da10>
160
+ def method_missing(name, *args)
161
+ @controller.send(name, *args) unless @controller.nil?
162
+ end
163
+ end
164
+
165
+ class JavaScriptHelper
166
+ include Singleton
167
+ include ActionView::Helpers::JavaScriptHelper
168
+ end
169
+ end
170
+ end
171
+ end