decidim-core 0.0.1.alpha9 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -25
  3. data/app/assets/config/decidim_core_manifest.js +1 -0
  4. data/app/assets/fonts/decidim/Source_Sans_Pro_400.eot +0 -0
  5. data/app/assets/fonts/decidim/Source_Sans_Pro_400.svg +345 -0
  6. data/app/assets/fonts/decidim/Source_Sans_Pro_400.ttf +0 -0
  7. data/app/assets/fonts/decidim/Source_Sans_Pro_400.woff +0 -0
  8. data/app/assets/fonts/decidim/Source_Sans_Pro_400.woff2 +0 -0
  9. data/app/assets/fonts/decidim/Source_Sans_Pro_600.eot +0 -0
  10. data/app/assets/fonts/decidim/Source_Sans_Pro_600.svg +339 -0
  11. data/app/assets/fonts/decidim/Source_Sans_Pro_600.ttf +0 -0
  12. data/app/assets/fonts/decidim/Source_Sans_Pro_600.woff +0 -0
  13. data/app/assets/fonts/decidim/Source_Sans_Pro_600.woff2 +0 -0
  14. data/app/assets/fonts/decidim/Source_Sans_Pro_900.eot +0 -0
  15. data/app/assets/fonts/decidim/Source_Sans_Pro_900.svg +342 -0
  16. data/app/assets/fonts/decidim/Source_Sans_Pro_900.ttf +0 -0
  17. data/app/assets/fonts/decidim/Source_Sans_Pro_900.woff +0 -0
  18. data/app/assets/fonts/decidim/Source_Sans_Pro_900.woff2 +0 -0
  19. data/app/assets/images/decidim/default-avatar.svg +14 -0
  20. data/app/assets/javascripts/decidim.js.es6 +5 -5
  21. data/app/assets/javascripts/decidim/editor.js.es6 +46 -0
  22. data/app/assets/stylesheets/decidim/_variables.scss +12 -13
  23. data/app/assets/stylesheets/decidim/application.sass +4 -1
  24. data/app/assets/stylesheets/decidim/editor.sass +4 -0
  25. data/app/assets/stylesheets/decidim/modules/_card-grid.scss +4 -1
  26. data/app/assets/stylesheets/decidim/modules/_cards.scss +5 -0
  27. data/app/assets/stylesheets/decidim/modules/_navbar.scss +1 -0
  28. data/app/assets/stylesheets/decidim/modules/_process-header.scss +24 -75
  29. data/app/assets/stylesheets/decidim/modules/_process-nav.scss +0 -1
  30. data/app/assets/stylesheets/decidim/modules/_process-phase.scss +80 -0
  31. data/app/assets/stylesheets/decidim/utils/_fontface.scss +39 -1
  32. data/app/assets/stylesheets/decidim/utils/_helpers.scss +25 -0
  33. data/app/assets/stylesheets/decidim/utils/_keyframes.scss +21 -0
  34. data/app/assets/stylesheets/decidim/utils/_mixins.scss +37 -0
  35. data/app/assets/stylesheets/decidim/utils/_settings.scss +11 -5
  36. data/app/commands/decidim/authorize_user.rb +2 -2
  37. data/app/constraints/decidim/current_feature.rb +48 -0
  38. data/app/controllers/concerns/decidim/form_factory.rb +80 -0
  39. data/app/controllers/concerns/decidim/locale_switcher.rb +17 -10
  40. data/app/controllers/concerns/decidim/needs_participatory_process.rb +33 -0
  41. data/app/controllers/decidim/application_controller.rb +1 -1
  42. data/app/controllers/decidim/devise/confirmations_controller.rb +1 -1
  43. data/app/controllers/decidim/devise/passwords_controller.rb +1 -1
  44. data/app/controllers/decidim/devise/registrations_controller.rb +1 -1
  45. data/app/controllers/decidim/devise/sessions_controller.rb +16 -2
  46. data/app/controllers/decidim/pages_controller.rb +14 -0
  47. data/app/controllers/decidim/participatory_processes_controller.rb +7 -0
  48. data/app/forms/decidim/form.rb +15 -0
  49. data/app/forms/translatable_presence_validator.rb +31 -0
  50. data/app/helpers/decidim/application_helper.rb +17 -2
  51. data/app/helpers/decidim/layout_helper.rb +8 -1
  52. data/app/helpers/decidim/localized_locales_helper.rb +43 -0
  53. data/app/helpers/decidim/participatory_process_helper.rb +16 -0
  54. data/app/helpers/decidim/translations_helper.rb +17 -0
  55. data/app/models/decidim/category.rb +35 -0
  56. data/app/models/decidim/component.rb +51 -0
  57. data/app/models/decidim/feature.rb +30 -0
  58. data/app/models/decidim/organization.rb +20 -1
  59. data/app/models/decidim/participatory_process.rb +43 -4
  60. data/app/models/decidim/participatory_process_attachment.rb +56 -0
  61. data/app/models/decidim/scope.rb +14 -0
  62. data/app/models/decidim/static_page.rb +56 -0
  63. data/app/models/decidim/user.rb +2 -0
  64. data/app/queries/decidim/organization_participatory_processes.rb +17 -0
  65. data/app/services/decidim/authorization_handler.rb +2 -2
  66. data/app/types/decidim/process_step_type.rb +24 -0
  67. data/app/types/decidim/process_type.rb +16 -0
  68. data/app/types/decidim/user_type.rb +14 -0
  69. data/app/uploaders/decidim/attachment_uploader.rb +70 -0
  70. data/app/uploaders/decidim/avatar_uploader.rb +14 -0
  71. data/app/uploaders/decidim/banner_image_uploader.rb +1 -1
  72. data/app/uploaders/decidim/hero_image_uploader.rb +1 -1
  73. data/app/uploaders/decidim/homepage_image_uploader.rb +11 -0
  74. data/app/uploaders/decidim/image_uploader.rb +46 -0
  75. data/app/uploaders/decidim/organization_logo_uploader.rb +9 -0
  76. data/app/views/decidim/devise/registrations/new.html.erb +1 -1
  77. data/app/views/decidim/participatory_processes/_documents.html.erb +26 -0
  78. data/app/views/decidim/participatory_processes/_photos.html.erb +16 -0
  79. data/app/views/decidim/participatory_processes/_promoted_process.html.erb +1 -1
  80. data/app/views/decidim/participatory_processes/show.html.erb +16 -11
  81. data/app/views/kaminari/decidim/_first_page.html.erb +11 -0
  82. data/app/views/kaminari/decidim/_gap.html.erb +8 -0
  83. data/app/views/kaminari/decidim/_last_page.html.erb +11 -0
  84. data/app/views/kaminari/decidim/_next_page.html.erb +11 -0
  85. data/app/views/kaminari/decidim/_page.html.erb +12 -0
  86. data/app/views/kaminari/decidim/_paginator.html.erb +25 -0
  87. data/app/views/kaminari/decidim/_prev_page.html.erb +11 -0
  88. data/app/views/layouts/decidim/_application.html.erb +17 -0
  89. data/app/views/layouts/decidim/_footer.html.erb +5 -3
  90. data/app/views/layouts/decidim/_header.html.erb +8 -21
  91. data/app/views/layouts/decidim/_language_chooser.html.erb +14 -0
  92. data/app/views/layouts/decidim/_logo.html.erb +17 -13
  93. data/app/views/layouts/decidim/_process_header.html.erb +34 -0
  94. data/app/views/layouts/decidim/_process_header_steps.html.erb +26 -0
  95. data/app/views/layouts/decidim/_user_menu.html.erb +2 -0
  96. data/app/views/layouts/decidim/application.html.erb +3 -0
  97. data/app/views/layouts/decidim/participatory_process.html.erb +15 -0
  98. data/app/views/pages/decidim_page.html.erb +12 -0
  99. data/app/views/pages/home.html.erb +106 -2
  100. data/config/i18n-tasks.yml +3 -1
  101. data/config/locales/ca.yml +40 -10
  102. data/config/locales/en.yml +39 -4
  103. data/config/locales/es.yml +44 -14
  104. data/config/routes.rb +14 -1
  105. data/db/migrate/20160919104837_create_decidim_organizations.rb +4 -0
  106. data/db/migrate/20161005153007_add_description_to_organizations.rb +1 -3
  107. data/db/migrate/20161010102356_translate_processes.rb +4 -4
  108. data/db/migrate/20161017085822_add_participatory_process_steps.rb +3 -3
  109. data/db/migrate/20161107152228_remove_not_null_on_step_position.rb +5 -0
  110. data/db/migrate/20161108093802_create_decidim_static_pages.rb +11 -0
  111. data/db/migrate/20161110092735_add_index_for_process_slug_organization.rb +8 -0
  112. data/db/migrate/20161110105712_create_decidim_features.rb +9 -0
  113. data/db/migrate/20161116115156_create_attachments.rb +18 -0
  114. data/db/migrate/20161123085134_add_categories.rb +10 -0
  115. data/db/migrate/20161130105257_create_decidim_scopes.rb +9 -0
  116. data/db/migrate/20161209134715_make_organization_description_optional.rb +5 -0
  117. data/db/migrate/20161213094244_add_avatar_to_users.rb +5 -0
  118. data/db/migrate/20161214152811_add_logo_to_organizations.rb +5 -0
  119. data/db/seeds.rb +36 -6
  120. data/db/seeds/Exampledocument.pdf +0 -0
  121. data/{app/assets/images/decidim/hero-home.jpg → db/seeds/homepage_image.jpg} +0 -0
  122. data/lib/decidim/core.rb +55 -2
  123. data/lib/decidim/core/engine.rb +16 -2
  124. data/lib/decidim/core/version.rb +11 -2
  125. data/lib/decidim/feature_manifest.rb +71 -0
  126. data/lib/decidim/features.rb +8 -0
  127. data/lib/decidim/features/base_controller.rb +32 -0
  128. data/lib/decidim/features/namer.rb +35 -0
  129. data/lib/decidim/form_builder.rb +140 -6
  130. data/lib/decidim/page_finder.rb +48 -0
  131. data/lib/decidim/query_extensions.rb +33 -0
  132. data/lib/decidim/translatable_attributes.rb +1 -24
  133. data/vendor/assets/javascripts/quill.min.js +14 -0
  134. data/vendor/assets/javascripts/quill.min.js.map +1 -0
  135. data/vendor/assets/stylesheets/quill.bubble.css +843 -0
  136. data/vendor/assets/stylesheets/quill.core.css +362 -0
  137. data/vendor/assets/stylesheets/quill.snow.css +881 -0
  138. metadata +164 -32
  139. data/LICENSE.txt +0 -619
  140. data/app/views/decidim/participatory_processes/_process_header_home.html.erb +0 -18
  141. data/app/views/pages/terms.ca.html.erb +0 -4
  142. data/app/views/pages/terms.en.html.erb +0 -4
  143. data/app/views/pages/terms.es.html.erb +0 -4
@@ -12,5 +12,22 @@ module Decidim
12
12
  def translated_attribute(attribute)
13
13
  attribute.try(:[], I18n.locale.to_s)
14
14
  end
15
+
16
+ # Public: Creates a translation for each available language in the list
17
+ # given a translation key.
18
+ #
19
+ # key - The key to translate.
20
+ # locales - A list of locales to scope the translations to. Picks up all the
21
+ # available locales by default.
22
+ #
23
+ # Returns a Hash with the locales as keys and the translations as values.
24
+ def multi_translation(key, locales = I18n.available_locales)
25
+ locales.each_with_object({}) do |locale, result|
26
+ I18n.with_locale(locale) do
27
+ result[locale.to_sym] = I18n.t(key)
28
+ end
29
+ end
30
+ end
31
+ module_function :multi_translation
15
32
  end
16
33
  end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # Categories serve as a taxonomy for components to use for while in the
4
+ # context of a participatory process.
5
+ class Category < ApplicationRecord
6
+ belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: Decidim::ParticipatoryProcess, inverse_of: :categories
7
+ has_many :subcategories, foreign_key: "parent_id", class_name: Decidim::Category, dependent: :destroy, inverse_of: :parent
8
+ belongs_to :parent, class_name: Decidim::Category, foreign_key: "parent_id", inverse_of: :subcategories
9
+
10
+ validate :forbid_deep_nesting
11
+ before_save :subcategories_have_same_process
12
+
13
+ # Scope to return only the first-class categories, that is, those that are
14
+ # not subcategories.
15
+ #
16
+ # Returns an ActiveRecord::Relation.
17
+ def self.first_class
18
+ where(parent_id: nil)
19
+ end
20
+
21
+ private
22
+
23
+ def forbid_deep_nesting
24
+ return unless parent
25
+ return unless parent.parent.present?
26
+
27
+ errors.add(:parent_id, :nesting_too_deep)
28
+ end
29
+
30
+ def subcategories_have_same_process
31
+ return unless parent
32
+ self.participatory_process = parent.participatory_process
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # A Component represents the association between a participatory process and a
4
+ # Component Engine. It configures how that component should behave, its name,
5
+ # and other relevant fields.
6
+ class Component < ApplicationRecord
7
+ belongs_to :feature, foreign_key: "decidim_feature_id"
8
+
9
+ belongs_to :step,
10
+ foreign_key: "decidim_participatory_process_step_id",
11
+ class_name: "Decidim::ParticipatoryProcessStep"
12
+
13
+ has_one :participatory_process, through: :feature
14
+
15
+ validates :feature, :step, :manifest, presence: true
16
+
17
+ validate :manifest_belongs_to_feature
18
+ validate :participatory_process_is_valid
19
+
20
+ # Public: Finds the manifest this particular component is associated to.
21
+ #
22
+ # Returns a ComponentManifest.
23
+ def manifest
24
+ Decidim.find_component_manifest(manifest_name)
25
+ end
26
+
27
+ # Public: Assigns a manifest to this component.
28
+ #
29
+ # manifest - The ComponentManifest for this Component.
30
+ #
31
+ # Returns nothing.
32
+ def manifest=(manifest)
33
+ self.manifest_name = manifest.name
34
+ end
35
+
36
+ private
37
+
38
+ def manifest_belongs_to_feature
39
+ return if feature&.manifest&.component_manifests&.include?(manifest)
40
+
41
+ errors.add(:manifest, I18n.t("errors.messages.invalid_manifest"))
42
+ end
43
+
44
+ def participatory_process_is_valid
45
+ return if !step&.participatory_process || !feature&.participatory_process
46
+ return if feature.participatory_process == step.participatory_process
47
+
48
+ errors.add(:manifest, I18n.t("errors.messages.invalid_participatory_process"))
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # A Feature represents a self-contained group of functionalities usually
4
+ # defined via a FeatureManifest and its Components. It's meant to be able to
5
+ # provide a single feature that spans over several steps, each one with its component.
6
+ class Feature < ApplicationRecord
7
+ belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id"
8
+ has_one :organization, through: :participatory_process
9
+ has_many :categories, through: :participatory_process
10
+ has_many :scopes, through: :organization
11
+
12
+ validates :participatory_process, presence: true
13
+
14
+ # Public: Finds the manifest this feature is associated to.
15
+ #
16
+ # Returns a FeatureManifest.
17
+ def manifest
18
+ Decidim.find_feature_manifest(manifest_name)
19
+ end
20
+
21
+ # Public: Assigns a manifest to this feature.
22
+ #
23
+ # manifest - The FeatureManifest for this Feature.
24
+ #
25
+ # Returns nothing.
26
+ def manifest=(manifest)
27
+ self.manifest_name = manifest.name
28
+ end
29
+ end
30
+ end
@@ -4,7 +4,26 @@ module Decidim
4
4
  # installation we can find many organizations and each of them can start
5
5
  # their own participatory processes.
6
6
  class Organization < ApplicationRecord
7
- has_many :participatory_processes, foreign_key: "decidim_organization_id", class_name: Decidim::ParticipatoryProcess
7
+ has_many :participatory_processes, foreign_key: "decidim_organization_id", class_name: Decidim::ParticipatoryProcess, inverse_of: :organization
8
+ has_many :static_pages, foreign_key: "decidim_organization_id", class_name: Decidim::StaticPage, inverse_of: :organization
9
+ has_many :scopes, foreign_key: "decidim_organization_id", class_name: Decidim::Scope, inverse_of: :organization
10
+
8
11
  validates :name, :host, uniqueness: true
12
+
13
+ mount_uploader :homepage_image, Decidim::HomepageImageUploader
14
+ mount_uploader :logo, Decidim::OrganizationLogoUploader
15
+
16
+ def homepage_big_url
17
+ homepage_image.big.url
18
+ end
19
+
20
+ # Fetches the admins of the given organization.
21
+ #
22
+ # Returns an ActiveRecord::Relation.
23
+ def admins
24
+ @admins ||= Decidim::User
25
+ .where(organization: self)
26
+ .where("roles @> ?", "{admin}")
27
+ end
9
28
  end
10
29
  end
@@ -6,14 +6,39 @@ module Decidim
6
6
  # steps that get enabled or disabled depending on which step is currently
7
7
  # active.
8
8
  class ParticipatoryProcess < ApplicationRecord
9
- belongs_to :organization, foreign_key: "decidim_organization_id", class_name: Decidim::Organization
10
- has_many :steps, -> { order(position: :asc) }, foreign_key: "decidim_participatory_process_id", class_name: Decidim::ParticipatoryProcessStep
11
- has_one :active_step, -> { where(active: true) }, foreign_key: "decidim_participatory_process_id", class_name: Decidim::ParticipatoryProcessStep
9
+ belongs_to :organization,
10
+ foreign_key: "decidim_organization_id",
11
+ class_name: Decidim::Organization,
12
+ inverse_of: :participatory_processes
13
+ has_many :steps,
14
+ -> { order(position: :asc) },
15
+ foreign_key: "decidim_participatory_process_id",
16
+ class_name: Decidim::ParticipatoryProcessStep,
17
+ dependent: :destroy,
18
+ inverse_of: :participatory_process
19
+ has_one :active_step,
20
+ -> { where(active: true) },
21
+ foreign_key: "decidim_participatory_process_id",
22
+ class_name: Decidim::ParticipatoryProcessStep,
23
+ dependent: :destroy,
24
+ inverse_of: :participatory_process
25
+ has_many :attachments,
26
+ foreign_key: "decidim_participatory_process_id",
27
+ class_name: Decidim::ParticipatoryProcessAttachment,
28
+ dependent: :destroy,
29
+ inverse_of: :participatory_process
30
+ has_many :categories,
31
+ foreign_key: "decidim_participatory_process_id",
32
+ class_name: Decidim::Category,
33
+ dependent: :destroy,
34
+ inverse_of: :participatory_process
35
+
36
+ has_many :features, foreign_key: "decidim_participatory_process_id"
12
37
 
13
38
  attr_readonly :active_step
14
39
 
15
40
  validates :slug, presence: true
16
- validates :slug, uniqueness: true
41
+ validates :slug, uniqueness: { scope: :organization }
17
42
 
18
43
  mount_uploader :hero_image, Decidim::HeroImageUploader
19
44
  mount_uploader :banner_image, Decidim::BannerImageUploader
@@ -38,5 +63,19 @@ module Decidim
38
63
  def published?
39
64
  published_at.present?
40
65
  end
66
+
67
+ # All the attachments that are photos for this porcess.
68
+ #
69
+ # Returns an Array<Attachment>
70
+ def photos
71
+ @photos ||= attachments.select(&:photo?)
72
+ end
73
+
74
+ # All the attachments that are documents for this porcess.
75
+ #
76
+ # Returns an Array<Attachment>
77
+ def documents
78
+ @documents ||= attachments.select(&:document?)
79
+ end
41
80
  end
42
81
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # Attachment can be any type of document or images related to a partcipatory
4
+ # process.
5
+ class ParticipatoryProcessAttachment < ApplicationRecord
6
+ belongs_to :participatory_process, foreign_key: "decidim_participatory_process_id", class_name: Decidim::ParticipatoryProcess, inverse_of: :attachments
7
+
8
+ validates :file, :participatory_process, :content_type, presence: true
9
+ validates :file, file_size: { less_than_or_equal_to: 10.megabytes }
10
+ mount_uploader :file, Decidim::AttachmentUploader
11
+
12
+ # Whether this attachment is a photo or not.
13
+ #
14
+ # Returns Boolean.
15
+ def photo?
16
+ @photo ||= content_type.start_with? "image"
17
+ end
18
+
19
+ # Whether this attachment is a document or not.
20
+ #
21
+ # Returns Boolean.
22
+ def document?
23
+ !photo?
24
+ end
25
+
26
+ # Which kind of file this is.
27
+ #
28
+ # Returns String.
29
+ def file_type
30
+ file.file.extension
31
+ end
32
+
33
+ # The URL to download the file.
34
+ #
35
+ # Returns String.
36
+ def url
37
+ file.url
38
+ end
39
+
40
+ # The URL to download the thumbnail of the file. Only works with images.
41
+ #
42
+ # Returns String.
43
+ def thumbnail_url
44
+ return unless photo?
45
+ file.thumbnail.url
46
+ end
47
+
48
+ # The URL to download the a big version of the file. Only works with images.
49
+ #
50
+ # Returns String.
51
+ def big_url
52
+ return unless photo?
53
+ file.big.url
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # Scopes are used in some entities through Decidim to help users know which is
4
+ # the scope of a participatory process.
5
+ # (i.e. does it affect the whole city or just a district?)
6
+ class Scope < ApplicationRecord
7
+ belongs_to :organization,
8
+ foreign_key: "decidim_organization_id",
9
+ class_name: Decidim::Organization,
10
+ inverse_of: :scopes
11
+
12
+ validates :name, presence: true, uniqueness: { scope: :organization }
13
+ end
14
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # A page is used to add static content to the website, it can be useful so
4
+ # organization can add their own terms and conditions, privacy policy or
5
+ # other pages they might need from an admin panel.
6
+ #
7
+ # Pages with a default slug cannot be destroyed and its slug cannot be
8
+ # modified.
9
+ class StaticPage < ApplicationRecord
10
+ belongs_to :organization, foreign_key: "decidim_organization_id", class_name: Decidim::Organization, inverse_of: :static_pages
11
+
12
+ validates :slug, :organization, presence: true
13
+ validates :slug, uniqueness: { scope: :organization }
14
+
15
+ # These pages will be created by default when registering an organization
16
+ # and cannot be deleted.
17
+ DEFAULT_PAGES = %w(faq terms-and-conditions accessibility).freeze
18
+
19
+ before_destroy :can_be_destroyed?
20
+ before_update :can_update_slug?
21
+
22
+ # Whether this is slug of a default page or not.
23
+ #
24
+ # slug - The String with the value of the slug.
25
+ #
26
+ # Returns Boolean.
27
+ def self.default?(slug)
28
+ DEFAULT_PAGES.include?(slug)
29
+ end
30
+
31
+ # Whether this is page is a default one or not.
32
+ #
33
+ # Returns Boolean.
34
+ def default?
35
+ self.class.default?(slug)
36
+ end
37
+
38
+ # Customize to_param so when we want to create a link to a page we use the
39
+ # slug instead of the id.
40
+ #
41
+ # Returns a String.
42
+ def to_param
43
+ slug
44
+ end
45
+
46
+ private
47
+
48
+ def can_be_destroyed?
49
+ throw(:abort) if default?
50
+ end
51
+
52
+ def can_update_slug?
53
+ throw(:abort) if slug_changed? && self.class.default?(slug_was)
54
+ end
55
+ end
56
+ end
@@ -16,6 +16,8 @@ module Decidim
16
16
  validates :locale, inclusion: { in: I18n.available_locales.map(&:to_s) }, allow_blank: true
17
17
  validates :tos_agreement, acceptance: true, allow_nil: false, on: :create
18
18
  validate :all_roles_are_valid
19
+ validates :avatar, file_size: { less_than_or_equal_to: 5.megabytes }
20
+ mount_uploader :avatar, Decidim::AvatarUploader
19
21
 
20
22
  # Public: Allows customizing the invitation instruction email content when
21
23
  # inviting a user.
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # This query class returns the visible Participatory Processes given an
4
+ # Organization.
5
+ class OrganizationParticipatoryProcesses < Rectify::Query
6
+ def initialize(organization)
7
+ @organization = organization
8
+ end
9
+
10
+ def query
11
+ raise MandatoryOrganization unless @organization
12
+ ParticipatoryProcess.where(organization: @organization).published
13
+ end
14
+
15
+ class MandatoryOrganization < StandardError; end
16
+ end
17
+ end
@@ -7,7 +7,7 @@ module Decidim
7
7
  # authorization will be created for the user.
8
8
  #
9
9
  # It also sets two default attributes, `user` and `handler_name`.
10
- class AuthorizationHandler < Rectify::Form
10
+ class AuthorizationHandler < Form
11
11
  # The user that is trying to authorize, it's initialized with the
12
12
  # `current_user` from the controller.
13
13
  attribute :user, Decidim::User
@@ -86,7 +86,7 @@ module Decidim
86
86
 
87
87
  return unless Decidim.authorization_handlers.include?(handler_klass)
88
88
 
89
- handler_klass.new(params || {})
89
+ handler_klass.from_params(params || {})
90
90
  rescue NameError
91
91
  nil
92
92
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # This type represents a step on a participatory process.
4
+ ProcessStepType = GraphQL::ObjectType.define do
5
+ name "ProcessStep"
6
+ description "A participatory process step"
7
+
8
+ field :id, !types.ID, "The unique ID of this step."
9
+
10
+ field :process do
11
+ type ProcessType
12
+ description "The participatory process in which this step belongs to."
13
+ property :participatory_process
14
+ end
15
+
16
+ field :title, Api::TranslatedFieldType, "The title of this step"
17
+
18
+ field :shortDescription do
19
+ type Api::TranslatedFieldType
20
+ description "A short description of the step."
21
+ property :short_description
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ # This type represents a ParticipatoryProcess.
4
+ ProcessType = GraphQL::ObjectType.define do
5
+ name "Process"
6
+ description "A participatory process"
7
+
8
+ field :id, !types.ID, "The Process' unique ID"
9
+
10
+ field :title, Api::TranslatedFieldType, "The title of this process."
11
+
12
+ connection :steps, ProcessStepType.connection_type do
13
+ description "All the steps of this process."
14
+ end
15
+ end
16
+ end