decidim-core 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/config/decidim_core_manifest.js +1 -0
  3. data/app/assets/javascripts/decidim/notifications.js.es6 +33 -0
  4. data/app/assets/stylesheets/decidim/extras/_meeting-registrations.scss +11 -0
  5. data/app/assets/stylesheets/decidim/modules/_extra.scss +4 -0
  6. data/app/assets/stylesheets/decidim/modules/_process-nav.scss +14 -0
  7. data/app/commands/decidim/create_follow.rb +40 -0
  8. data/app/commands/decidim/create_omniauth_registration.rb +0 -2
  9. data/app/commands/decidim/create_registration.rb +1 -3
  10. data/app/commands/decidim/create_report.rb +7 -7
  11. data/app/commands/decidim/delete_follow.rb +37 -0
  12. data/app/commands/decidim/invite_user.rb +1 -3
  13. data/app/commands/decidim/update_notifications_settings.rb +1 -2
  14. data/app/constraints/decidim/current_feature.rb +3 -4
  15. data/app/controllers/concerns/decidim/settings.rb +1 -1
  16. data/app/controllers/decidim/features/base_controller.rb +5 -6
  17. data/app/controllers/decidim/follows_controller.rb +45 -0
  18. data/app/controllers/decidim/notifications_controller.rb +39 -0
  19. data/app/controllers/decidim/pages_controller.rb +2 -2
  20. data/app/controllers/decidim/scopes_controller.rb +2 -0
  21. data/app/controllers/decidim/widgets_controller.rb +3 -3
  22. data/app/forms/decidim/follow_form.rb +20 -0
  23. data/app/forms/decidim/invite_user_form.rb +1 -1
  24. data/app/forms/decidim/notifications_settings_form.rb +2 -4
  25. data/app/helpers/decidim/action_authorization_helper.rb +2 -1
  26. data/app/helpers/decidim/decidim_form_helper.rb +4 -0
  27. data/app/helpers/decidim/feature_path_helper.rb +2 -13
  28. data/app/helpers/decidim/icon_helper.rb +26 -8
  29. data/app/helpers/decidim/paginate_helper.rb +1 -1
  30. data/app/helpers/decidim/scopes_helper.rb +1 -1
  31. data/app/jobs/decidim/email_notification_generator_job.rb +12 -0
  32. data/app/jobs/decidim/export_job.rb +1 -3
  33. data/app/jobs/decidim/notification_generator_for_recipient_job.rb +14 -0
  34. data/app/jobs/decidim/notification_generator_job.rb +12 -0
  35. data/app/mailers/decidim/export_mailer.rb +6 -7
  36. data/app/mailers/decidim/notification_mailer.rb +20 -0
  37. data/app/mailers/decidim/reported_mailer.rb +3 -3
  38. data/app/models/decidim/abilities/admin_ability.rb +0 -1
  39. data/app/models/decidim/abilities/base_ability.rb +8 -0
  40. data/app/models/decidim/abilities/everyone_ability.rb +0 -2
  41. data/app/models/decidim/abilities/participatory_process_admin_ability.rb +1 -1
  42. data/app/models/decidim/abilities/participatory_process_collaborator_ability.rb +1 -1
  43. data/app/models/decidim/category.rb +4 -4
  44. data/app/models/decidim/feature.rb +29 -4
  45. data/app/models/decidim/follow.rb +10 -0
  46. data/app/models/decidim/moderation.rb +1 -1
  47. data/app/models/decidim/notification.rb +12 -0
  48. data/app/models/decidim/scope.rb +8 -8
  49. data/app/models/decidim/user.rb +11 -1
  50. data/app/presenters/decidim/home_stats_presenter.rb +1 -1
  51. data/app/presenters/decidim/resource_locator_presenter.rb +3 -18
  52. data/app/queries/decidim/participatory_processes_with_user_role.rb +1 -1
  53. data/app/services/decidim/email_notification_generator.rb +63 -0
  54. data/app/services/decidim/events_manager.rb +41 -0
  55. data/app/services/decidim/notification_generator.rb +51 -0
  56. data/app/services/decidim/notification_generator_for_recipient.rb +50 -0
  57. data/app/uploaders/decidim/attachment_uploader.rb +1 -1
  58. data/app/views/decidim/authorizations/first_login.html.erb +2 -2
  59. data/app/views/decidim/follows/update_button.js.erb +3 -0
  60. data/app/views/decidim/notification_mailer/event_received.html.erb +9 -0
  61. data/app/views/decidim/notifications/_notification.html.erb +18 -0
  62. data/app/views/decidim/notifications/index.html.erb +32 -0
  63. data/app/views/decidim/notifications_settings/show.html.erb +3 -10
  64. data/app/views/decidim/shared/_follow_button.html.erb +19 -0
  65. data/app/views/layouts/decidim/_head.html.erb +1 -0
  66. data/app/views/layouts/decidim/_head_extra.html.erb +7 -0
  67. data/app/views/layouts/decidim/_user_menu.html.erb +1 -0
  68. data/app/views/layouts/decidim/_wrapper.html.erb +3 -0
  69. data/app/views/layouts/decidim/widget.html.erb +3 -3
  70. data/app/views/pages/home/_hero.html.erb +1 -1
  71. data/app/views/pages/home/_highlighted_processes.html.erb +3 -3
  72. data/config/locales/ca.yml +29 -74
  73. data/config/locales/en.yml +23 -71
  74. data/config/locales/es.yml +31 -78
  75. data/config/locales/eu.yml +61 -65
  76. data/config/locales/fi.yml +91 -51
  77. data/config/locales/fr.yml +40 -83
  78. data/config/locales/it.yml +129 -54
  79. data/config/locales/nl.yml +90 -51
  80. data/config/locales/pl.yml +319 -10
  81. data/config/locales/uk.yml +400 -0
  82. data/config/routes.rb +8 -14
  83. data/db/migrate/20170720120231_make_moderations_polymorphic.rb +29 -0
  84. data/db/migrate/20170726145242_make_categories_polymorphic.rb +27 -0
  85. data/db/migrate/20170807123535_create_decidim_follows.rb +20 -0
  86. data/db/migrate/20170808071019_create_decidim_notifications.rb +13 -0
  87. data/db/migrate/20170906091718_add_extra_to_notifications.rb +7 -0
  88. data/db/migrate/20170912082054_add_emails_on_notifications_flag_to_user.rb +7 -0
  89. data/db/migrate/20170913092351_add_header_snippets_to_organizations.rb +7 -0
  90. data/db/migrate/20170914075721_remove_followable_index_from_follows.rb +7 -0
  91. data/db/migrate/20170914092116_remove_comment_and_replies_notifications_from_users.rb +8 -0
  92. data/db/seeds.rb +2 -108
  93. data/lib/decidim/core.rb +46 -8
  94. data/lib/decidim/core/engine.rb +20 -6
  95. data/lib/decidim/core/test.rb +3 -0
  96. data/lib/decidim/core/test/factories.rb +37 -75
  97. data/lib/decidim/core/test/shared_examples/comments_examples.rb +0 -26
  98. data/lib/decidim/core/test/shared_examples/follows_examples.rb +37 -0
  99. data/lib/decidim/core/test/shared_examples/manage_moderations_examples.rb +1 -1
  100. data/lib/decidim/core/test/shared_examples/process_announcements_examples.rb +1 -1
  101. data/lib/decidim/core/test/shared_examples/reportable.rb +4 -4
  102. data/lib/decidim/core/test/shared_examples/reports_examples.rb +1 -1
  103. data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +41 -0
  104. data/lib/decidim/core/test/shared_examples/user_localised_email_examples.rb +25 -0
  105. data/lib/decidim/core/version.rb +1 -1
  106. data/lib/decidim/engine_router.rb +54 -0
  107. data/lib/decidim/events.rb +9 -0
  108. data/lib/decidim/events/base_event.rb +70 -0
  109. data/lib/decidim/events/email_event.rb +39 -0
  110. data/lib/decidim/events/notification_event.rb +32 -0
  111. data/lib/decidim/exporters.rb +7 -0
  112. data/lib/decidim/exporters/export_data.rb +14 -0
  113. data/lib/decidim/feature_manifest.rb +2 -2
  114. data/lib/decidim/features/namer.rb +1 -1
  115. data/lib/decidim/followable.rb +13 -0
  116. data/lib/decidim/form_builder.rb +1 -1
  117. data/lib/decidim/has_feature.rb +1 -1
  118. data/lib/decidim/has_settings.rb +19 -15
  119. data/lib/decidim/manifest_registry.rb +1 -3
  120. data/lib/decidim/participable.rb +80 -0
  121. data/lib/decidim/participatory_space_manifest.rb +40 -0
  122. data/lib/decidim/query_extensions.rb +1 -1
  123. data/lib/decidim/resource_manifest.rb +1 -1
  124. data/lib/decidim/settings_manifest.rb +0 -4
  125. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.uk.js +14 -0
  126. data/vendor/assets/javascripts/morphdom.js +14 -5
  127. metadata +70 -79
  128. data/app/assets/images/decidim/process.svg +0 -10
  129. data/app/constraints/decidim/current_participatory_process.rb +0 -35
  130. data/app/controllers/concerns/decidim/needs_participatory_process.rb +0 -46
  131. data/app/controllers/decidim/participatory_process_groups_controller.rb +0 -26
  132. data/app/controllers/decidim/participatory_process_steps_controller.rb +0 -18
  133. data/app/controllers/decidim/participatory_process_widgets_controller.rb +0 -19
  134. data/app/controllers/decidim/participatory_processes_controller.rb +0 -49
  135. data/app/helpers/decidim/participatory_process_helper.rb +0 -17
  136. data/app/helpers/decidim/participatory_process_steps_helper.rb +0 -18
  137. data/app/models/decidim/participatory_process.rb +0 -61
  138. data/app/models/decidim/participatory_process_group.rb +0 -15
  139. data/app/models/decidim/participatory_process_step.rb +0 -39
  140. data/app/presenters/decidim/participatory_process_stats_presenter.rb +0 -50
  141. data/app/queries/decidim/highlighted_participatory_processes.rb +0 -10
  142. data/app/queries/decidim/organization_participatory_process_groups.rb +0 -14
  143. data/app/queries/decidim/organization_participatory_processes.rb +0 -14
  144. data/app/queries/decidim/organization_prioritized_participatory_processes.rb +0 -18
  145. data/app/queries/decidim/organization_published_participatory_processes.rb +0 -17
  146. data/app/queries/decidim/prioritized_participatory_processes.rb +0 -11
  147. data/app/queries/decidim/promoted_participatory_processes.rb +0 -10
  148. data/app/queries/decidim/published_participatory_processes.rb +0 -10
  149. data/app/views/decidim/participatory_process_groups/_participatory_process_group.html.erb +0 -22
  150. data/app/views/decidim/participatory_process_groups/show.html.erb +0 -11
  151. data/app/views/decidim/participatory_process_steps/_participatory_process_step.html.erb +0 -16
  152. data/app/views/decidim/participatory_process_steps/_timeline.html.erb +0 -7
  153. data/app/views/decidim/participatory_process_steps/index.html.erb +0 -14
  154. data/app/views/decidim/participatory_process_widgets/show.html.erb +0 -17
  155. data/app/views/decidim/participatory_processes/_no_processes_yet.html.erb +0 -3
  156. data/app/views/decidim/participatory_processes/_order_by_processes.html.erb +0 -3
  157. data/app/views/decidim/participatory_processes/_participatory_process.html.erb +0 -28
  158. data/app/views/decidim/participatory_processes/_promoted_process.html.erb +0 -32
  159. data/app/views/decidim/participatory_processes/_statistics.html.erb +0 -10
  160. data/app/views/decidim/participatory_processes/index.html.erb +0 -17
  161. data/app/views/decidim/participatory_processes/show.html.erb +0 -85
  162. data/app/views/layouts/decidim/_process_header.html.erb +0 -65
  163. data/app/views/layouts/decidim/_process_header_steps.html.erb +0 -27
  164. data/app/views/layouts/decidim/participatory_process.html.erb +0 -30
  165. data/config/i18n-tasks.yml +0 -138
  166. data/db/migrate/20161005130108_add_participatory_processes.rb +0 -19
  167. data/db/migrate/20161010102356_translate_processes.rb +0 -17
  168. data/db/migrate/20161011125616_add_hero_image_to_processes.rb +0 -7
  169. data/db/migrate/20161011141033_add_banner_image_to_processes.rb +0 -7
  170. data/db/migrate/20161013134732_add_promoted_flag_to_processes.rb +0 -7
  171. data/db/migrate/20161017085822_add_participatory_process_steps.rb +0 -18
  172. data/db/migrate/20161019072016_add_active_flag_to_step.rb +0 -13
  173. data/db/migrate/20161020080756_add_position_to_steps.rb +0 -9
  174. data/db/migrate/20161025125300_add_published_at_to_processes.rb +0 -7
  175. data/db/migrate/20161107152228_remove_not_null_on_step_position.rb +0 -7
  176. data/db/migrate/20161110092735_add_index_for_process_slug_organization.rb +0 -10
  177. data/db/migrate/20161116115156_create_attachments.rb +0 -18
  178. data/db/migrate/20170116135237_loosen_step_requirements.rb +0 -8
  179. data/db/migrate/20170123134023_make_attachments_polymorphic.rb +0 -20
  180. data/db/migrate/20170125135937_rename_attachable_to_attached_to.rb +0 -13
  181. data/db/migrate/20170126151123_add_extra_info_to_processes.rb +0 -10
  182. data/db/migrate/20170206083118_rename_extra_info_on_processes.rb +0 -14
  183. data/db/migrate/20170220110740_remove_steps_short_description.rb +0 -23
  184. data/db/migrate/20170221094835_add_scopes_to_processes.rb +0 -8
  185. data/db/migrate/20170228142440_add_participatory_process_groups.rb +0 -17
  186. data/db/migrate/20170404132616_change_steps_end_and_start_date_to_date.rb +0 -8
  187. data/db/migrate/20170725085104_add_show_statistics_to_participatory_processes.rb +0 -7
  188. data/db/migrate/20170804125402_attachment_description_nullable.rb +0 -7
  189. data/db/migrate/20170808080905_add_announcement_to_participatory_processes.rb +0 -7
  190. data/db/migrate/20170809084005_add_scopes_enabled_to_participatory_processes.rb +0 -7
  191. data/db/seeds/Exampledocument.pdf +0 -0
  192. data/db/seeds/city.jpeg +0 -0
  193. data/db/seeds/city2.jpeg +0 -0
  194. data/lib/decidim/notifiable.rb +0 -22
@@ -0,0 +1,39 @@
1
+ # frozen-string_literal: true
2
+
3
+ module Decidim
4
+ module Events
5
+ # This module is used to be included in event classes (those inheriting from
6
+ # `Decidim::Events::BaseEvent`) that need to send emails with the notification.
7
+ #
8
+ # This modules adds the needed logic to deliver emails to a given user.
9
+ #
10
+ # Example:
11
+ #
12
+ # class MyEvent < Decidim::Events::BaseEvent
13
+ # include Decidim::Events::EmailEvent
14
+ # end
15
+ module EmailEvent
16
+ extend ActiveSupport::Concern
17
+
18
+ included do
19
+ types << :email
20
+
21
+ def email_subject
22
+ I18n.t("decidim.events.email_event.email_subject", resource_title: resource_title)
23
+ end
24
+
25
+ def email_greeting
26
+ I18n.t("decidim.events.email_event.email_greeting", user_name: user.name)
27
+ end
28
+
29
+ def email_intro
30
+ I18n.t("decidim.events.email_event.email_intro", resource_title: resource_title)
31
+ end
32
+
33
+ def email_outro
34
+ I18n.t("decidim.events.email_event.email_outro", resource_title: resource_title)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Events
5
+ # This module is used to be included in event classes (those inheriting from
6
+ # `Decidim::Events::BaseEvent`) that need to create system notifications, which
7
+ # will be later listed to the user in their Notifications Dashboard.
8
+ #
9
+ # This modules adds the needed logic to display these notifications.
10
+ #
11
+ # Example:
12
+ #
13
+ # class MyEvent < Decidim::Events::BaseEvent
14
+ # include Decidim::Events::NotificationEvent
15
+ # end
16
+ module NotificationEvent
17
+ extend ActiveSupport::Concern
18
+
19
+ included do
20
+ types << :notification
21
+
22
+ def notification_title
23
+ I18n.t(
24
+ "decidim.events.notification_event.notification_title",
25
+ resource_title: resource_title,
26
+ resource_path: resource_path
27
+ ).html_safe
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -7,5 +7,12 @@ module Decidim
7
7
  autoload :CSV, "decidim/exporters/csv"
8
8
  autoload :ExportData, "decidim/exporters/export_data"
9
9
  autoload :Serializer, "decidim/exporters/serializer"
10
+
11
+ # Get the exporter class constant from the format as a string.
12
+ #
13
+ # format - The exporter format as a string. i.e "csv"
14
+ def self.find_exporter(format)
15
+ const_get(format.upcase)
16
+ end
10
17
  end
11
18
  end
@@ -18,6 +18,20 @@ module Decidim
18
18
  def read
19
19
  @data
20
20
  end
21
+
22
+ # Generates a filename based on the export creation date.
23
+ #
24
+ # prefix - A string value for the filename prefix. (default: 'export')
25
+ # options - An optional hash of options
26
+ # * extension - Whether the filename should include the extension or not.
27
+ #
28
+ # Returns a String with the filename of the export.
29
+ def filename(prefix = "export", options = {})
30
+ options[:extension] = !options[:extension].nil? ? options[:extension] : true
31
+ result = "#{prefix}-#{I18n.localize(Date.today, format: :default)}-#{Time.now.seconds_since_midnight.to_i}"
32
+ result += ".#{extension}" if options[:extension]
33
+ result
34
+ end
21
35
  end
22
36
  end
23
37
  end
@@ -92,8 +92,8 @@ module Decidim
92
92
  # Public: Creates the seeds for this features in order to populate the database.
93
93
  #
94
94
  # Returns nothing.
95
- def seed!(process)
96
- @seeds&.call(process)
95
+ def seed!(participatory_space)
96
+ @seeds&.call(participatory_space)
97
97
  end
98
98
 
99
99
  # Public: Adds configurable attributes for this feature, scoped to a name. It
@@ -11,7 +11,7 @@ module Decidim
11
11
  # Examples:
12
12
  #
13
13
  # Decidim::Feature.create!(
14
- # participatory_process: process,
14
+ # participatory_space: process,
15
15
  # name: Decidim::Feature::Namer.new(organization.available_locales, :my_feature_name).i18n_name
16
16
  # manifest_name: :my_feature_name
17
17
  # )
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ # This concern contains the logic related to followable resources.
5
+ module Followable
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ has_many :follows, as: :followable, foreign_key: "decidim_followable_id", foreign_type: "decidim_followable_type", class_name: "Decidim::Follow"
10
+ has_many :followers, through: :follows, source: :user
11
+ end
12
+ end
13
+ end
@@ -243,7 +243,7 @@ module Decidim
243
243
  template += content_tag :div, class: "field" do
244
244
  safe_join([
245
245
  @template.check_box(@object_name, "remove_#{attribute}"),
246
- label("remove_#{attribute}", label_for("remove_#{attribute}"))
246
+ label("remove_#{attribute}", I18n.t("remove_this_file", scope: "decidim.forms"))
247
247
  ])
248
248
  end
249
249
  end
@@ -10,7 +10,7 @@ module Decidim
10
10
 
11
11
  included do
12
12
  belongs_to :feature, foreign_key: "decidim_feature_id", class_name: "Decidim::Feature"
13
- has_one :organization, through: :feature
13
+ delegate :organization, to: :feature, allow_nil: true
14
14
  end
15
15
 
16
16
  class_methods do
@@ -15,7 +15,15 @@ module Decidim
15
15
  end
16
16
 
17
17
  def settings=(data)
18
- self[:settings]["global"] = serialize_settings(settings_schema(:global), data)
18
+ self[:settings]["global"] = settings_schema(:global).new(data)
19
+ end
20
+
21
+ def current_settings
22
+ if participatory_space.allows_steps?
23
+ active_step_settings
24
+ else
25
+ default_step_settings
26
+ end
19
27
  end
20
28
 
21
29
  def default_step_settings
@@ -23,38 +31,34 @@ module Decidim
23
31
  end
24
32
 
25
33
  def default_step_settings=(data)
26
- self[:settings]["default_step"] = serialize_settings(settings_schema(:step), data)
34
+ self[:settings]["default_step"] = settings_schema(:step).new(data)
27
35
  end
28
36
 
29
37
  def step_settings
30
- participatory_process.steps.each_with_object({}) do |step, result|
38
+ return {} unless participatory_space.allows_steps?
39
+
40
+ participatory_space.steps.each_with_object({}) do |step, result|
31
41
  result[step.id.to_s] = settings_schema(:step).new(self[:settings].dig("steps", step.id.to_s))
32
42
  end
33
43
  end
34
44
 
35
45
  def step_settings=(data)
36
46
  self[:settings]["steps"] = data.each_with_object({}) do |(key, value), result|
37
- result[key.to_s] = serialize_settings(settings_schema(:step), value)
47
+ result[key.to_s] = settings_schema(:step).new(value)
38
48
  end
39
49
  end
40
50
 
51
+ private
52
+
41
53
  def active_step_settings
42
- active_step = participatory_process.active_step
54
+ return unless participatory_space.allows_steps?
55
+
56
+ active_step = participatory_space.active_step
43
57
  return default_step_settings unless active_step
44
58
 
45
59
  step_settings.fetch(active_step.id.to_s)
46
60
  end
47
61
 
48
- private
49
-
50
- def serialize_settings(schema, value)
51
- if value.respond_to?(:attributes)
52
- value.attributes
53
- else
54
- schema.new(value)
55
- end
56
- end
57
-
58
62
  def settings_schema(name)
59
63
  manifest.settings(name.to_sym).schema
60
64
  end
@@ -37,9 +37,7 @@ module Decidim
37
37
  private
38
38
 
39
39
  def manifest_class
40
- case @entity
41
- when :features then FeatureManifest
42
- end
40
+ "Decidim::#{@entity.to_s.classify}Manifest".constantize
43
41
  end
44
42
  end
45
43
  end
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ #
5
+ # Utilities for models that can act as participatory spaces
6
+ #
7
+ module Participable
8
+ extend ActiveSupport::Concern
9
+
10
+ # rubocop:disable Metrics/BlockLength
11
+ included do
12
+ def demodulized_name
13
+ self.class.name.demodulize
14
+ end
15
+
16
+ def foreign_key
17
+ demodulized_name.foreign_key
18
+ end
19
+
20
+ def module_name
21
+ "Decidim::#{demodulized_name.pluralize}"
22
+ end
23
+
24
+ def admin_module_name
25
+ "#{module_name}::Admin"
26
+ end
27
+
28
+ def underscored_name
29
+ demodulized_name.underscore
30
+ end
31
+
32
+ def mounted_engine
33
+ "decidim_#{underscored_name.pluralize}"
34
+ end
35
+
36
+ def mounted_admin_engine
37
+ "decidim_admin_#{underscored_name.pluralize}"
38
+ end
39
+
40
+ def mounted_params
41
+ { host: organization.host, foreign_key.to_sym => id }
42
+ end
43
+
44
+ def extension_module
45
+ "#{module_name}::#{demodulized_name}Context".constantize
46
+ end
47
+
48
+ def admin_extension_module
49
+ "#{admin_module_name}::#{demodulized_name}Context".constantize
50
+ end
51
+
52
+ def admins_query
53
+ "#{admin_module_name}::AdminUsers".constantize
54
+ end
55
+
56
+ def admins
57
+ admins_query.for(self)
58
+ end
59
+
60
+ def allows_steps?
61
+ respond_to?(:steps)
62
+ end
63
+
64
+ def has_steps?
65
+ allows_steps? && steps.any?
66
+ end
67
+
68
+ def manifest
69
+ self.class.participatory_space_manifest
70
+ end
71
+ end
72
+ # rubocop:enable Metrics/BlockLength
73
+
74
+ class_methods do
75
+ def participatory_space_manifest
76
+ Decidim.find_participatory_space_manifest(name.demodulize.underscore.pluralize)
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/settings_manifest"
4
+
5
+ module Decidim
6
+ # This class handles all the logic associated to configuring a participatory
7
+ # space, the highest level object of Decidim.
8
+ #
9
+ # It's normally not used directly but through the API exposed through
10
+ # `Decidim.register_participatory_space`.
11
+ class ParticipatorySpaceManifest
12
+ include ActiveModel::Model
13
+ include Virtus.model
14
+
15
+ attribute :admin_engine, Rails::Engine
16
+ attribute :engine, Rails::Engine
17
+
18
+ attribute :name, Symbol
19
+
20
+ # A String with the feature's icon. The icon must be stored in the
21
+ # engine's assets path.
22
+ attribute :icon, String
23
+
24
+ validates :name, presence: true
25
+
26
+ # Public: A block that gets called when seeding for this feature takes place.
27
+ #
28
+ # Returns nothing.
29
+ def seeds(&block)
30
+ @seeds = block
31
+ end
32
+
33
+ # Public: Creates the seeds for this features in order to populate the database.
34
+ #
35
+ # Returns nothing.
36
+ def seed!
37
+ @seeds&.call
38
+ end
39
+ end
40
+ end
@@ -16,7 +16,7 @@ module Decidim
16
16
  description "Lists all processes."
17
17
 
18
18
  resolve lambda { |_obj, _args, ctx|
19
- OrganizationPublishedParticipatoryProcesses.new(ctx[:current_organization])
19
+ ParticipatoryProcesses::OrganizationPublishedParticipatoryProcesses.new(ctx[:current_organization])
20
20
  }
21
21
  end
22
22
 
@@ -43,7 +43,7 @@ module Decidim
43
43
  #
44
44
  # Returns an ActiveRecord::Relation.
45
45
  def resource_scope(feature)
46
- feature_ids = Decidim::Feature.where(participatory_process: feature.participatory_process, manifest_name: feature_manifest.name).pluck(:id)
46
+ feature_ids = Decidim::Feature.where(participatory_space: feature.participatory_space, manifest_name: feature_manifest.name).pluck(:id)
47
47
  return model_class.none if feature_ids.empty?
48
48
 
49
49
  model_class.where(feature: feature_ids)
@@ -52,10 +52,6 @@ module Decidim
52
52
  self.class.manifest
53
53
  end
54
54
 
55
- def ==(other)
56
- other.attributes == attributes
57
- end
58
-
59
55
  manifest.attributes.each do |name, attribute|
60
56
  if attribute.translated?
61
57
  translatable_attribute name, attribute.type_class, default: attribute.default_value
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Ukrainian translation for foundation-datepicker
3
+ * Dmytro Ivakhnenko <aavuso@gmail.com>
4
+ */
5
+ ;(function($){
6
+ $.fn.fdatepicker.dates['uk'] = {
7
+ days: ["Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота", "Неділя"],
8
+ daysShort: ["Нед", "Пон", "Вівт", "Сер", "Четв", "П'ятн", "Суб", "Нед"],
9
+ daysMin: ["Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Нд"],
10
+ months: ["Січень", "Лютий", "Березень", "Квітень", "Травень", "Червень", "Липень", "Серпень", "Вересень", "Жовтень", "Листопад", "Грудень"],
11
+ monthsShort: ["Січ", "Лют", "Бер", "Кві", "Тра", "Чер", "Лип", "Серп", "Вер", "Жовт", "Лист", "Гру"],
12
+ today: "Сьогодні"
13
+ };
14
+ }(jQuery));
@@ -208,14 +208,17 @@ var specialElHandlers = {
208
208
  fromEl.value = newValue;
209
209
  }
210
210
 
211
- if (fromEl.firstChild) {
211
+ var firstChild = fromEl.firstChild;
212
+ if (firstChild) {
212
213
  // Needed for IE. Apparently IE sets the placeholder as the
213
214
  // node value and vise versa. This ignores an empty update.
214
- if (newValue === '' && fromEl.firstChild.nodeValue === fromEl.placeholder) {
215
+ var oldValue = firstChild.nodeValue;
216
+
217
+ if (oldValue == newValue || (!newValue && oldValue == fromEl.placeholder)) {
215
218
  return;
216
219
  }
217
220
 
218
- fromEl.firstChild.nodeValue = newValue;
221
+ firstChild.nodeValue = newValue;
219
222
  }
220
223
  },
221
224
  SELECT: function(fromEl, toEl) {
@@ -526,7 +529,10 @@ function morphdomFactory(morphAttrs) {
526
529
  isCompatible = true;
527
530
  // Simply update nodeValue on the original node to
528
531
  // change the text value
529
- curFromNodeChild.nodeValue = curToNodeChild.nodeValue;
532
+ if (curFromNodeChild.nodeValue !== curToNodeChild.nodeValue) {
533
+ curFromNodeChild.nodeValue = curToNodeChild.nodeValue;
534
+ }
535
+
530
536
  }
531
537
  }
532
538
 
@@ -625,7 +631,10 @@ function morphdomFactory(morphAttrs) {
625
631
  }
626
632
  } else if (morphedNodeType === TEXT_NODE || morphedNodeType === COMMENT_NODE) { // Text or comment node
627
633
  if (toNodeType === morphedNodeType) {
628
- morphedNode.nodeValue = toNode.nodeValue;
634
+ if (morphedNode.nodeValue !== toNode.nodeValue) {
635
+ morphedNode.nodeValue = toNode.nodeValue;
636
+ }
637
+
629
638
  return morphedNode;
630
639
  } else {
631
640
  // Text node to something else