voluntary 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/voluntary/application.js +1 -1
- data/app/assets/javascripts/voluntary/base.js.coffee +30 -1
- data/app/assets/stylesheets/voluntary/application.css +1 -0
- data/app/assets/stylesheets/voluntary/base.css.sass +1 -1
- data/app/controllers/areas_controller.rb +6 -5
- data/app/controllers/candidatures_controller.rb +15 -10
- data/app/controllers/concerns/voluntary/v1/base_controller.rb +95 -0
- data/app/controllers/devise_extensions/registrations_controller.rb +2 -2
- data/app/controllers/organizations_controller.rb +7 -6
- data/app/controllers/professions_controller.rb +6 -5
- data/app/controllers/projects_controller.rb +11 -6
- data/app/controllers/users_controller.rb +2 -2
- data/app/controllers/vacancies_controller.rb +14 -5
- data/app/controllers/voluntary/api/v1/api_controller.rb +9 -0
- data/app/controllers/voluntary/application_controller.rb +2 -66
- data/app/controllers/workflow/candidatures_controller.rb +1 -1
- data/app/controllers/workflow/products_controller.rb +7 -7
- data/app/controllers/workflow/stories_controller.rb +1 -1
- data/app/controllers/workflow/tasks_controller.rb +2 -2
- data/app/controllers/workflow/user/product/areas_controller.rb +2 -2
- data/app/controllers/workflow/user/projects_controller.rb +10 -2
- data/app/helpers/voluntary/application_helper.rb +79 -0
- data/app/helpers/voluntary/collection_helper.rb +45 -0
- data/app/helpers/voluntary/comments_helper.rb +13 -0
- data/app/helpers/voluntary/form_helper.rb +46 -0
- data/app/helpers/voluntary/language_helper.rb +17 -0
- data/app/helpers/voluntary/layout_helper.rb +42 -0
- data/app/helpers/voluntary/product_helper.rb +36 -0
- data/app/helpers/voluntary/show_helper.rb +67 -0
- data/app/helpers/voluntary/wizard_helper.rb +29 -0
- data/app/models/ability.rb +20 -4
- data/app/models/candidature.rb +10 -7
- data/app/models/column.rb +1 -0
- data/app/models/concerns/user/extensions.rb +5 -0
- data/app/models/concerns/user/listable.rb +10 -0
- data/app/models/list.rb +30 -0
- data/app/models/list_item.rb +22 -0
- data/app/models/organization.rb +1 -0
- data/app/models/page.rb +2 -1
- data/app/models/product.rb +3 -2
- data/app/models/project.rb +2 -2
- data/app/models/result.rb +1 -0
- data/app/models/role.rb +1 -1
- data/app/models/state_machines/candidature.rb +17 -1
- data/app/models/state_machines/story.rb +15 -2
- data/app/models/state_machines/task.rb +33 -0
- data/app/models/story.rb +3 -2
- data/app/models/task.rb +44 -6
- data/app/models/thing.rb +3 -0
- data/app/models/user.rb +15 -4
- data/app/models/vacancy.rb +7 -5
- data/app/presenters/resources/general/wizards/story/steps/setup_tasks_presenter.rb +1 -1
- data/app/presenters/shared/collection/table_presenter.rb +1 -1
- data/app/views/candidatures/index.html.erb +1 -1
- data/app/views/candidatures/show.html.erb +1 -1
- data/app/views/columns/_collection.html.erb +0 -0
- data/app/views/comments/_resource.html.erb +1 -1
- data/app/views/layouts/application.html.erb +12 -0
- data/app/views/layouts/shared/_navigation.html.erb +3 -3
- data/app/views/organizations/show.html.erb +0 -1
- data/app/views/products/index.html.erb +53 -4
- data/app/views/projects/_form.html.erb +1 -0
- data/app/views/projects/show.html.erb +2 -1
- data/app/views/shared/collection/_list.html.erb +1 -1
- data/app/views/shared/resource/_actions.html.erb +2 -2
- data/app/views/stories/_column_fields.html.erb +0 -0
- data/app/views/stories/_form.html.erb +1 -1
- data/app/views/stories/steps/_activate.html.erb +1 -1
- data/app/views/workflow/products/show.html.erb +1 -1
- data/app/views/workflow/project_owner/_candidatures.html.erb +2 -1
- data/app/views/workflow/tasks/_work_head.html.erb +1 -1
- data/app/views/workflow/tasks/steps/_complete.html.erb +6 -2
- data/app/views/workflow/tasks/steps/_review.html.erb +6 -2
- data/app/views/workflow/tasks/steps/_work.html.erb +4 -2
- data/app/views/workflow/user/product/areas/show.html.erb +0 -0
- data/app/views/workflow/user/projects/show.html.erb +0 -0
- data/config/initializers/devise.rb +2 -5
- data/config/initializers/filter_parameters_logging.rb +1 -0
- data/config/initializers/friendly_id.rb +88 -0
- data/config/initializers/wrap_parameters.rb +15 -0
- data/config/locales/general/en.yml +15 -9
- data/config/locales/resources/story/en.yml +1 -0
- data/config/routes.rb +9 -0
- data/config/routes/workflow.rb +15 -15
- data/db/migrate/20120907144853_create_schema.rb +1 -1
- data/db/migrate/20120922201955_create_mongo_db_documents.rb +1 -1
- data/db/migrate/20121004132105_create_professions.rb +1 -1
- data/db/migrate/20121006162913_add_public_attribute_to_roles.rb +20 -1
- data/db/migrate/20130817090734_create_lists.rb +33 -0
- data/db/migrate/20131018143613_replace_user_by_polymorphic_resource_in_candidatures.rb +46 -0
- data/db/migrate/20140307113214_add_user_id_to_organizations.rb +5 -0
- data/lib/api_constraints.rb +10 -0
- data/lib/applicat/mvc/model/tree.rb +1 -1
- data/lib/concerns/model/base_list_item.rb +30 -0
- data/lib/concerns/model/base_thing.rb +50 -0
- data/lib/db_seed.rb +15 -4
- data/lib/generators/voluntary/install/install_generator.rb +17 -16
- data/lib/generators/voluntary/install/templates/app/views/layouts/application.html.erb +17 -1
- data/lib/generators/voluntary/install/templates/config/main_navigation.rb +1 -260
- data/lib/generators/voluntary/install/templates/features/support/integration_sessions_controller.rb +1 -2
- data/lib/generators/voluntary/install/templates/spec/factories.rb +19 -0
- data/lib/generators/voluntary/install/templates/spec/support/mongo_database_cleaner.rb +14 -4
- data/lib/generators/voluntary/product_dummy/product_dummy_generator.rb +23 -17
- data/lib/generators/voluntary/product_dummy/templates/config/database.example.yml +1 -1
- data/lib/generators/voluntary/product_dummy/templates/dummy/spec/factories.rb +19 -0
- data/lib/generators/voluntary/product_dummy/templates/dummy/spec/spec_helper.rb +75 -0
- data/lib/generators/voluntary/product_dummy/templates/features/support/integration_sessions_controller.rb +1 -2
- data/lib/generators/voluntary/product_dummy/templates/spec/factories.rb +19 -0
- data/lib/voluntary.rb +10 -22
- data/lib/voluntary/engine.rb +27 -3
- data/lib/voluntary/navigation.rb +358 -0
- data/lib/voluntary/test/rspec_helpers/factories.rb +123 -0
- data/lib/voluntary/version.rb +1 -1
- data/vendor_extensions/active_model/naming.rb +1 -1
- metadata +526 -308
- data/app/helpers/application_helper.rb +0 -65
- data/app/helpers/collection_helper.rb +0 -35
- data/app/helpers/comments_helper.rb +0 -11
- data/app/helpers/form_helper.rb +0 -43
- data/app/helpers/language_helper.rb +0 -15
- data/app/helpers/layout_helper.rb +0 -39
- data/app/helpers/product_helper.rb +0 -34
- data/app/helpers/show_helper.rb +0 -65
- data/app/helpers/wizard_helper.rb +0 -27
- data/app/observers/candidature_observer.rb +0 -29
- data/app/observers/story_observer.rb +0 -6
- data/app/observers/task_observer.rb +0 -34
- data/lib/voluntary/helpers/application.rb +0 -69
- data/lib/voluntary/helpers/collection.rb +0 -35
- data/lib/voluntary/helpers/comments.rb +0 -15
- data/lib/voluntary/helpers/form.rb +0 -43
- data/lib/voluntary/helpers/language.rb +0 -19
- data/lib/voluntary/helpers/layout.rb +0 -28
- data/lib/voluntary/helpers/product.rb +0 -36
- data/lib/voluntary/helpers/show.rb +0 -69
- data/lib/voluntary/helpers/wizard.rb +0 -31
@@ -1,65 +0,0 @@
|
|
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
|
@@ -1,35 +0,0 @@
|
|
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
|
-
begin
|
17
|
-
link_to value, eval("#{root_model_class_name(resource).tableize.singularize}_path(resource)")
|
18
|
-
rescue
|
19
|
-
link_to value, eval("#{root_model_class_name(resource).constantize.table_name.singularize}_path(resource)")
|
20
|
-
end
|
21
|
-
elsif column.match('_id')
|
22
|
-
association = nil
|
23
|
-
|
24
|
-
begin
|
25
|
-
association = resource.send(column.gsub('_id', ''))
|
26
|
-
rescue
|
27
|
-
association = eval("resource.#{alternative_value}") if alternative_value.present?
|
28
|
-
end
|
29
|
-
|
30
|
-
association ? link_to(association.name, association) : value
|
31
|
-
else
|
32
|
-
resource.send(column)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,11 +0,0 @@
|
|
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
|
data/app/helpers/form_helper.rb
DELETED
@@ -1,43 +0,0 @@
|
|
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, namespace = nil)
|
37
|
-
if namespace
|
38
|
-
f.input "#{field}_name", input_html: { data: {autocomplete: eval("autocomplete_#{namespace}_#{field.to_s.tableize}_path")} }
|
39
|
-
else
|
40
|
-
f.input "#{field}_name", input_html: { data: {autocomplete: eval("autocomplete_#{field.to_s.tableize}_path")} }
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,15 +0,0 @@
|
|
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
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module LayoutHelper
|
2
|
-
def breadcrumbs
|
3
|
-
result = render_navigation context: :main, renderer: :breadcrumbs_without_method_links, join_with: ' > '
|
4
|
-
result = result && result.scan('<a').length > 1 ? result : ''
|
5
|
-
|
6
|
-
if respond_to?(:resource) && resource.respond_to?(:ancestors)
|
7
|
-
breadcrumbs_with_ancestors(result)
|
8
|
-
else
|
9
|
-
result
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def breadcrumbs_with_ancestors(links)
|
14
|
-
links = links.split(' > ')
|
15
|
-
current_resource_link = links.pop
|
16
|
-
links += resource.ancestors.map {|ancestor| link_to ancestor.name, ancestor }
|
17
|
-
links << current_resource_link
|
18
|
-
raw links.join(' > ')
|
19
|
-
end
|
20
|
-
|
21
|
-
def sidenav(links_count = 2)
|
22
|
-
links_count ||= 2
|
23
|
-
result = render_navigation context: :main, renderer: :twitter_sidenav, level: @twitter_sidenav_level
|
24
|
-
result && result.scan('<a').length >= links_count ? result : ''
|
25
|
-
end
|
26
|
-
|
27
|
-
def footer_navigation
|
28
|
-
links = []
|
29
|
-
|
30
|
-
['privacy-policy', 'terms-of-use', 'about-us'].each do |page_name|
|
31
|
-
text = t("pages.#{page_name.gsub('-', '_')}.title")
|
32
|
-
path = "#{controller_name}/#{params[:id]}"
|
33
|
-
active = path == "#{controller_name}/#{page_name}"
|
34
|
-
links << (active ? text : link_to(text, page_path(page_name)))
|
35
|
-
end
|
36
|
-
|
37
|
-
raw links.join(' | ')
|
38
|
-
end
|
39
|
-
end
|
@@ -1,34 +0,0 @@
|
|
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
|
-
path = [path, file_name].join('/')
|
22
|
-
|
23
|
-
begin
|
24
|
-
return render(path, options)
|
25
|
-
rescue ActionView::MissingTemplate
|
26
|
-
path = nil
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
path = [partial_path, file_name].join('/') if path.blank?
|
31
|
-
|
32
|
-
render path, options
|
33
|
-
end
|
34
|
-
end
|
data/app/helpers/show_helper.rb
DELETED
@@ -1,65 +0,0 @@
|
|
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
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module WizardHelper
|
2
|
-
def section_header(wizard_step)
|
3
|
-
wizard_step_index = wizard_steps.index(wizard_step) + 1
|
4
|
-
|
5
|
-
content = ["#{wizard_step_index} / #{wizard_steps.length}"]
|
6
|
-
content << t("stories.steps.#{wizard_step}.title")
|
7
|
-
content << (future_step?(wizard_step) ? t('general.not_available') : '')
|
8
|
-
|
9
|
-
content.join(' ')
|
10
|
-
end
|
11
|
-
|
12
|
-
def step_pane(wizard_step)
|
13
|
-
return if future_step?(wizard_step)
|
14
|
-
|
15
|
-
partial_path = wizard_step == :initialization ? 'form' : "steps/#{wizard_step}"
|
16
|
-
|
17
|
-
if @presenter.respond_to?(wizard_step)
|
18
|
-
@step_presenter = @presenter.send(wizard_step)
|
19
|
-
else
|
20
|
-
@step_presenter = nil
|
21
|
-
end
|
22
|
-
|
23
|
-
render_product_specific_partial_if_available(
|
24
|
-
resource, "#{controller_name}/#{partial_path}"
|
25
|
-
)
|
26
|
-
end
|
27
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class CandidatureObserver < ActiveRecord::Observer
|
2
|
-
def after_create(candidature)
|
3
|
-
end
|
4
|
-
|
5
|
-
def before_transition(object, transition)
|
6
|
-
#object.event = transition.event.to_s
|
7
|
-
#object.from_state = transition.from
|
8
|
-
end
|
9
|
-
|
10
|
-
def after_transition(object, transition)
|
11
|
-
#object.initiator_user = object.initiator_user
|
12
|
-
#object.trigger = object.trigger
|
13
|
-
#object.trigger_object = object.trigger_object
|
14
|
-
|
15
|
-
case transition.to
|
16
|
-
when 'accepted'
|
17
|
-
ProjectUser.find_or_create_by_project_id_and_vacancy_id_and_user_id!(
|
18
|
-
project_id: object.vacancy.project_id, vacancy_id: object.vacancy_id,
|
19
|
-
user_id: object.user_id
|
20
|
-
)
|
21
|
-
|
22
|
-
if object.vacancy.limit == object.vacancy.candidatures.accepted.count
|
23
|
-
object.vacancy.close! unless object.vacancy.closed?
|
24
|
-
end
|
25
|
-
when 'denied'
|
26
|
-
# if comming from :accepted then the vacancy offerer has to reopen the vacancy manually
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
class TaskObserver < ActiveRecord::Observer
|
2
|
-
def before_transition(object, transition)
|
3
|
-
object.event = transition.event.to_s
|
4
|
-
object.state_before = transition.from
|
5
|
-
|
6
|
-
case transition.event
|
7
|
-
when :assign
|
8
|
-
object.author_id = object.user_id
|
9
|
-
when :cancel
|
10
|
-
object.unassigned_user_ids ||= []
|
11
|
-
object.unassigned_user_ids << object.user_id
|
12
|
-
object.user_id = nil
|
13
|
-
object.author_id = nil
|
14
|
-
object.result.text = nil if object.result
|
15
|
-
when :review
|
16
|
-
object.user_id = object.offeror_id
|
17
|
-
when :follow_up
|
18
|
-
object.user_id = object.author_id
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def after_transition(object, transition)
|
23
|
-
case transition.event
|
24
|
-
when :follow_up
|
25
|
-
if object.story.completed?
|
26
|
-
object.story.activate
|
27
|
-
end
|
28
|
-
when :complete
|
29
|
-
if object.story.tasks.complete.count == object.story.tasks.count
|
30
|
-
object.story.complete
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
module Voluntary
|
2
|
-
module Helpers
|
3
|
-
module Application
|
4
|
-
include AutoHtml
|
5
|
-
|
6
|
-
def self.root_model_class_name_helper(resource)
|
7
|
-
if resource.class.superclass.name == 'ActiveRecord::Base'
|
8
|
-
resource.class.name
|
9
|
-
elsif resource.class.superclass.name == 'Object'
|
10
|
-
# classes like mongo db models without a specific superclass
|
11
|
-
resource.class.name
|
12
|
-
else
|
13
|
-
resource.class.superclass.name
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def markdown(text)
|
18
|
-
text = Redcarpet::Markdown.new(Redcarpet::Render::XHTML.new(filter_html: true)).render(text)
|
19
|
-
|
20
|
-
auto_html(text) do
|
21
|
-
youtube(width: 515, height: 300)
|
22
|
-
dailymotion(width: 515, height: 300)
|
23
|
-
vimeo(width: 515, height: 300)
|
24
|
-
google_video(width: 515, height: 300)
|
25
|
-
image
|
26
|
-
|
27
|
-
redcarpet(
|
28
|
-
renderer: Redcarpet::Render::XHTML.new(
|
29
|
-
no_images: true, no_styles: true, hard_wrap: true, with_toc_data: true
|
30
|
-
),
|
31
|
-
markdown_options: { no_intra_emphasis: true, autolink: true, fenced_code_blocks: true }
|
32
|
-
)
|
33
|
-
link :target => "_blank", :rel => "nofollow"
|
34
|
-
end.gsub(/(>https?:\/\/[^\<\\]+)/) do |match|
|
35
|
-
truncate(match)
|
36
|
-
end.html_safe
|
37
|
-
end
|
38
|
-
|
39
|
-
def root_model_class_name(resource)
|
40
|
-
::Voluntary::Helpers::Application.root_model_class_name_helper(resource)
|
41
|
-
end
|
42
|
-
|
43
|
-
def directory_for_resource(resource)
|
44
|
-
resource.class.name.split('::').last.underscore
|
45
|
-
end
|
46
|
-
|
47
|
-
def link_list(collection)
|
48
|
-
raw collection.map{|a| link_to a.name, a}.join(', ')
|
49
|
-
end
|
50
|
-
|
51
|
-
def general_attribute?(attribute)
|
52
|
-
begin
|
53
|
-
t("activerecord.attributes.general.#{attribute}", raise: true)
|
54
|
-
true
|
55
|
-
rescue
|
56
|
-
false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def attribute_translation(attribute, current_resource = nil)
|
61
|
-
current_resource = current_resource || resource
|
62
|
-
|
63
|
-
t("activerecord.attributes.#{root_model_class_name(current_resource).underscore}.#{attribute}",
|
64
|
-
default: t("activerecord.attributes.general.#{attribute}")
|
65
|
-
)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|