decidim-assemblies 0.9.3 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/app/commands/decidim/assemblies/admin/create_assembly.rb +18 -6
  3. data/app/commands/decidim/assemblies/admin/create_assembly_admin.rb +29 -10
  4. data/app/commands/decidim/assemblies/admin/destroy_assembly_admin.rb +53 -0
  5. data/app/commands/decidim/assemblies/admin/publish_assembly.rb +8 -3
  6. data/app/commands/decidim/assemblies/admin/unpublish_assembly.rb +9 -4
  7. data/app/commands/decidim/assemblies/admin/update_assembly.rb +11 -1
  8. data/app/commands/decidim/assemblies/admin/update_assembly_admin.rb +11 -1
  9. data/app/controllers/decidim/assemblies/admin/assembly_attachment_collections_controller.rb +26 -0
  10. data/app/controllers/decidim/assemblies/admin/assembly_publications_controller.rb +2 -2
  11. data/app/controllers/decidim/assemblies/admin/assembly_user_roles_controller.rb +6 -4
  12. data/app/controllers/decidim/assemblies/assemblies_controller.rb +1 -0
  13. data/app/forms/decidim/assemblies/admin/assembly_copy_form.rb +1 -1
  14. data/app/forms/decidim/assemblies/admin/assembly_form.rb +7 -1
  15. data/app/models/decidim/assemblies/abilities/admin/assembly_admin_ability.rb +4 -0
  16. data/app/models/decidim/assemblies/abilities/admin/assembly_role_ability.rb +2 -2
  17. data/app/models/decidim/assemblies/abilities/assembly_role_ability.rb +2 -2
  18. data/app/models/decidim/assembly.rb +11 -3
  19. data/app/models/decidim/assembly_user_role.rb +8 -0
  20. data/app/presenters/decidim/assemblies/admin_log/assembly_presenter.rb +61 -0
  21. data/app/presenters/decidim/assemblies/admin_log/assembly_user_role_presenter.rb +53 -0
  22. data/app/presenters/decidim/assemblies/admin_log/value_types/role_presenter.rb +22 -0
  23. data/app/views/decidim/assemblies/admin/assemblies/_form.html.erb +4 -0
  24. data/app/views/decidim/assemblies/assemblies/show.html.erb +9 -0
  25. data/app/views/layouts/decidim/admin/assembly.html.erb +15 -3
  26. data/config/locales/ca.yml +22 -2
  27. data/config/locales/en.yml +20 -0
  28. data/config/locales/es.yml +20 -0
  29. data/config/locales/eu.yml +20 -0
  30. data/config/locales/fi.yml +20 -0
  31. data/config/locales/fr.yml +32 -12
  32. data/config/locales/gl.yml +20 -0
  33. data/config/locales/it.yml +20 -0
  34. data/config/locales/nl.yml +20 -0
  35. data/config/locales/pl.yml +20 -5
  36. data/config/locales/pt-BR.yml +20 -0
  37. data/config/locales/pt.yml +20 -0
  38. data/config/locales/sv.yml +20 -0
  39. data/config/locales/uk.yml +28 -4
  40. data/db/migrate/20180125104426_add_reference_to_assemblies.rb +7 -0
  41. data/db/migrate/20180216091553_add_area_to_assemblies.rb +7 -0
  42. data/lib/decidim/assemblies/admin_engine.rb +1 -0
  43. data/lib/decidim/assemblies/participatory_space.rb +14 -0
  44. data/lib/decidim/assemblies/version.rb +1 -1
  45. metadata +16 -9
@@ -6,17 +6,21 @@ module Decidim
6
6
  # several features (proposals, debates...) that can be enabled or disabled.
7
7
  class Assembly < ApplicationRecord
8
8
  include Decidim::HasAttachments
9
+ include Decidim::HasAttachmentCollections
9
10
  include Decidim::Participable
10
11
  include Decidim::Publicable
11
12
  include Decidim::Scopable
12
13
  include Decidim::Followable
14
+ include Decidim::HasReference
15
+ include Decidim::Traceable
16
+ include Decidim::Loggable
13
17
 
14
18
  belongs_to :organization,
15
19
  foreign_key: "decidim_organization_id",
16
20
  class_name: "Decidim::Organization"
17
- belongs_to :scope,
18
- foreign_key: "decidim_scope_id",
19
- class_name: "Decidim::Scope",
21
+ belongs_to :area,
22
+ foreign_key: "decidim_area_id",
23
+ class_name: "Decidim::Area",
20
24
  optional: true
21
25
  has_many :categories,
22
26
  foreign_key: "decidim_participatory_space_id",
@@ -39,6 +43,10 @@ module Decidim
39
43
  where(promoted: true)
40
44
  end
41
45
 
46
+ def self.log_presenter_class_for(_log)
47
+ Decidim::Assemblies::AdminLog::AssemblyPresenter
48
+ end
49
+
42
50
  def hashtag
43
51
  attributes["hashtag"].to_s.delete("#")
44
52
  end
@@ -4,13 +4,21 @@ module Decidim
4
4
  # Defines a relation between a user and an assembly, and what kind of relation
5
5
  # does the user have.
6
6
  class AssemblyUserRole < ApplicationRecord
7
+ include Traceable
8
+ include Loggable
9
+
7
10
  belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User", optional: true
8
11
  belongs_to :assembly, foreign_key: "decidim_assembly_id", class_name: "Decidim::Assembly", optional: true
12
+ alias participatory_space assembly
9
13
 
10
14
  ROLES = %w(admin collaborator moderator).freeze
11
15
  validates :role, inclusion: { in: ROLES }, uniqueness: { scope: [:user, :assembly] }
12
16
  validate :user_and_assembly_same_organization
13
17
 
18
+ def self.log_presenter_class_for(_log)
19
+ Decidim::Assemblies::AdminLog::AssemblyUserRolePresenter
20
+ end
21
+
14
22
  private
15
23
 
16
24
  # Private: check if the process and the user have the same organization
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module AdminLog
6
+ # This class holds the logic to present a `Decidim::Assembly`
7
+ # for the `AdminLog` log.
8
+ #
9
+ # Usage should be automatic and you shouldn't need to call this class
10
+ # directly, but here's an example:
11
+ #
12
+ # action_log = Decidim::ActionLog.last
13
+ # view_helpers # => this comes from the views
14
+ # AssemblyPresenter.new(action_log, view_helpers).present
15
+ class AssemblyPresenter < Decidim::Log::BasePresenter
16
+ private
17
+
18
+ def diff_fields_mapping
19
+ {
20
+ description: :i18n,
21
+ hashtag: :string,
22
+ decidim_area_id: :area,
23
+ decidim_scope_id: :scope,
24
+ developer_group: :i18n,
25
+ local_area: :i18n,
26
+ meta_scope: :i18n,
27
+ participatory_scope: :i18n,
28
+ participatory_structure: :i18n,
29
+ promoted: :boolean,
30
+ published_at: :date,
31
+ reference: :string,
32
+ scopes_enabled: :boolean,
33
+ short_description: :i18n,
34
+ show_statistics: :boolean,
35
+ slug: :default,
36
+ subtitle: :i18n,
37
+ target: :i18n,
38
+ title: :i18n
39
+ }
40
+ end
41
+
42
+ def i18n_labels_scope
43
+ "activemodel.attributes.assembly"
44
+ end
45
+
46
+ def action_string
47
+ case action
48
+ when "create", "publish", "unpublish", "update"
49
+ "decidim.admin_log.assembly.#{action}"
50
+ else
51
+ super
52
+ end
53
+ end
54
+
55
+ def has_diff?
56
+ action == "unpublish" || super
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module AdminLog
6
+ # This class holds the logic to present a `Decidim::AssemblyUserRole`
7
+ # for the `AdminLog` log.
8
+ #
9
+ # Usage should be automatic and you shouldn't need to call this class
10
+ # directly, but here's an example:
11
+ #
12
+ # action_log = Decidim::ActionLog.last
13
+ # view_helpers # => this comes from the views
14
+ # AssemblyUserRolePresenter.new(action_log, view_helpers).present
15
+ class AssemblyUserRolePresenter < Decidim::Log::BasePresenter
16
+ private
17
+
18
+ def diff_fields_mapping
19
+ {
20
+ role: "Decidim::Assemblies::AdminLog::ValueTypes::RolePresenter"
21
+ }
22
+ end
23
+
24
+ def i18n_labels_scope
25
+ "activemodel.attributes.assembly_user_role"
26
+ end
27
+
28
+ def action_string
29
+ case action
30
+ when "create", "delete", "update"
31
+ "decidim.admin_log.assembly_user_role.#{action}"
32
+ else
33
+ super
34
+ end
35
+ end
36
+
37
+ def changeset
38
+ return super unless action.to_s == "delete"
39
+
40
+ Decidim::Log::DiffChangesetCalculator.new(
41
+ { role: [action_log.version.object["role"], ""] },
42
+ diff_fields_mapping,
43
+ i18n_labels_scope
44
+ ).changeset
45
+ end
46
+
47
+ def has_diff?
48
+ action == "delete" || super
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Assemblies
5
+ module AdminLog
6
+ module ValueTypes
7
+ # This class presents the given value as a user role. Check
8
+ # the `DefaultPresenter` for more info on how value
9
+ # presenters work.
10
+ class RolePresenter < Decidim::Log::ValueTypes::DefaultPresenter
11
+ # Public: Presents the value as a user role.
12
+ #
13
+ # Returns an HTML-safe String.
14
+ def present
15
+ return if value.blank?
16
+ h.t(value, scope: "decidim.admin.models.assembly_user_role.roles", default: value)
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -75,6 +75,10 @@
75
75
  <%= scopes_picker_field form, :scope_id, root: nil %>
76
76
  </div>
77
77
 
78
+ <div class="row column">
79
+ <%= form.select :area_id, option_groups_from_collection_for_select(current_organization.area_types, :areas, :translated_name, :id, :translated_name, current_assembly.try(:decidim_area_id)), include_blank: t(".select_an_area") %>
80
+ </div>
81
+
78
82
  <div class="row column">
79
83
  <%= form.translated :text_field, :participatory_scope %>
80
84
  </div>
@@ -65,7 +65,16 @@
65
65
  <%= translated_attribute(current_participatory_space.participatory_structure) %>
66
66
  </div>
67
67
  <% end %>
68
+
69
+ <% if translated_attribute(current_participatory_space.try(:area).try(:name)).present? %>
70
+ <div class="definition-data__item area">
71
+ <span class="definition-data__title"><%= t("assemblies.show.area", scope: "decidim") %></span>
72
+ <%= translated_attribute(current_participatory_space.area.area_type.name) %> - <%= translated_attribute(current_participatory_space.area.name) %>
73
+ </div>
74
+ <% end %>
75
+
68
76
  </div>
77
+ <%= resource_reference(current_participatory_space) %>
69
78
  <%= render partial: "decidim/shared/share_modal" %>
70
79
  <%= embed_modal_for assembly_assembly_widget_url(current_participatory_space, format: :js) %>
71
80
  </div>
@@ -30,9 +30,21 @@
30
30
  <%= aria_selected_link_to t("categories", scope: "decidim.admin.menu.assemblies_submenu"), decidim_admin_assemblies.categories_path(current_participatory_space) %>
31
31
  </li>
32
32
  <% end %>
33
- <% if can? :read, Decidim::Attachment %>
34
- <li <% if is_active_link?(decidim_admin_assemblies.assembly_attachments_path(current_participatory_space)) %> class="is-active" <% end %>>
35
- <%= aria_selected_link_to t("attachments", scope: "decidim.admin.menu.assemblies_submenu"), decidim_admin_assemblies.assembly_attachments_path(current_participatory_space) %>
33
+ <% if can?(:read, Decidim::AttachmentCollection) || can?(:read, Decidim::Attachment) %>
34
+ <li>
35
+ <span class="secondary-nav__subtitle"><%= t("attachments", scope: "decidim.admin.menu.assemblies_submenu") %></span>
36
+ <ul>
37
+ <% if can? :read, Decidim::AttachmentCollection %>
38
+ <li <% if is_active_link?(decidim_admin_assemblies.assembly_attachment_collections_path(current_participatory_space)) %> class="is-active" <% end %>>
39
+ <%= aria_selected_link_to t("attachment_collections", scope: "decidim.admin.menu.assemblies_submenu"), decidim_admin_assemblies.assembly_attachment_collections_path(current_participatory_space) %>
40
+ </li>
41
+ <% end %>
42
+ <% if can? :read, Decidim::Attachment %>
43
+ <li <% if is_active_link?(decidim_admin_assemblies.assembly_attachments_path(current_participatory_space)) %> class="is-active" <% end %>>
44
+ <%= aria_selected_link_to t("attachment_files", scope: "decidim.admin.menu.assemblies_submenu"), decidim_admin_assemblies.assembly_attachments_path(current_participatory_space) %>
45
+ </li>
46
+ <% end %>
47
+ </ul>
36
48
  </li>
37
49
  <% end %>
38
50
  <% if can? :read, Decidim::AssemblyUserRole %>
@@ -2,9 +2,12 @@ ca:
2
2
  activemodel:
3
3
  attributes:
4
4
  assembly:
5
+ area_id: Àrea
5
6
  banner_image: Imatge de bàner
6
7
  copy_categories: Copiar categories
7
8
  copy_features: Copiar funcionalitats
9
+ decidim_area_id: Àrea
10
+ decidim_scope_id: Abast
8
11
  description: Descripció
9
12
  developer_group: Grup promotor
10
13
  domain: Àrees municipals
@@ -15,13 +18,15 @@ ca:
15
18
  participatory_scope: Àmbit participatiu
16
19
  participatory_structure: Estructura participativa
17
20
  promoted: Destacat
21
+ published_at: Publicat el
18
22
  scope_id: Àmbit
19
23
  scopes_enabled: Àmbit habilitat
20
24
  short_description: Descripció breu
25
+ show_statistics: Mostra estadístiques
21
26
  slug: Nom curt d'URL
22
27
  subtitle: Subtítol
23
28
  target: A qui va dirigit?
24
- title: Grup de processos participatius
29
+ title: Títol
25
30
  decidim:
26
31
  admin:
27
32
  assemblies:
@@ -80,6 +85,8 @@ ca:
80
85
  assemblies: Assemblees
81
86
  assemblies_submenu:
82
87
  assembly_admins: Usuaris de l'assemblea
88
+ attachment_collections: Col·leccions
89
+ attachment_files: Fitxers
83
90
  attachments: Adjunts
84
91
  categories: Categories
85
92
  features: Funcionalitats
@@ -91,7 +98,7 @@ ca:
91
98
  created_at: Data de creació
92
99
  promoted: Destacat
93
100
  published: Publicat
94
- title: Grup de processos participatius
101
+ title: Títol
95
102
  name: Assemblea
96
103
  assembly_user_role:
97
104
  fields:
@@ -105,10 +112,21 @@ ca:
105
112
  moderator: Moderador
106
113
  titles:
107
114
  assemblies: Assemblees
115
+ admin_log:
116
+ assembly:
117
+ create: "%{user_name} ha creat l'assemblea %{resource_name}"
118
+ publish: "%{user_name} ha publicat l'assemblea %{resource_name}"
119
+ unpublish: "%{user_name} ha despublicat l'assemblea %{resource_name}"
120
+ update: "%{user_name} ha actualitzat l'assemblea %{resource_name}"
121
+ assembly_user_role:
122
+ create: "%{user_name} ha convidat %{resource_name} a l'assemblea %{space_name}"
123
+ delete: "%{user_name} ha eliminat l'usuari %{resource_name} de l'assemblea %{space_name}"
124
+ update: "%{user_name} ha canviat el rol de %{resource_name} a l'assemblea %{space_name}"
108
125
  assemblies:
109
126
  admin:
110
127
  assemblies:
111
128
  form:
129
+ select_an_area: Selecciona una àrea
112
130
  slug_help: 'Els noms curts d''URL s''utilitzen per generar les URL que apunten a aquesta assemblea. Només accepta lletres, números i guions, i ha de començar amb una lletra. Exemple: %{url}'
113
131
  assembly_copies:
114
132
  form:
@@ -121,6 +139,7 @@ ca:
121
139
  active_assemblies: Assemblees actives
122
140
  see_all_assemblies: Veure totes les assemblees
123
141
  show:
142
+ area: Àrea
124
143
  developer_group: Grup promotor
125
144
  local_area: Àrea municipal
126
145
  participatory_scope: Àmbit participatiu
@@ -131,6 +150,7 @@ ca:
131
150
  answers_count: Respostes
132
151
  assemblies_count: Assemblees
133
152
  comments_count: Comentaris
153
+ endorsements_count: Adhesions
134
154
  headline: Activitat
135
155
  meetings_count: Trobades presencials
136
156
  orders_count: Vots
@@ -3,9 +3,12 @@ en:
3
3
  activemodel:
4
4
  attributes:
5
5
  assembly:
6
+ area_id: Area
6
7
  banner_image: Banner image
7
8
  copy_categories: Copy categories
8
9
  copy_features: Copy features
10
+ decidim_area_id: Area
11
+ decidim_scope_id: Scope
9
12
  description: Description
10
13
  developer_group: Developer group
11
14
  domain: Domain
@@ -16,9 +19,11 @@ en:
16
19
  participatory_scope: Participatory scope
17
20
  participatory_structure: Participatory structure
18
21
  promoted: Promoted
22
+ published_at: Published at
19
23
  scope_id: Scope
20
24
  scopes_enabled: Scopes enabled
21
25
  short_description: Short description
26
+ show_statistics: Show statistics
22
27
  slug: URL slug
23
28
  subtitle: Subtitle
24
29
  target: Target
@@ -81,6 +86,8 @@ en:
81
86
  assemblies: Assemblies
82
87
  assemblies_submenu:
83
88
  assembly_admins: Assembly users
89
+ attachment_collections: Collections
90
+ attachment_files: Files
84
91
  attachments: Attachments
85
92
  categories: Categories
86
93
  features: Features
@@ -106,10 +113,21 @@ en:
106
113
  moderator: Moderator
107
114
  titles:
108
115
  assemblies: Assemblies
116
+ admin_log:
117
+ assembly:
118
+ create: "%{user_name} created the %{resource_name} assembly"
119
+ publish: "%{user_name} published the %{resource_name} assembly"
120
+ unpublish: "%{user_name} unpublished the %{resource_name} assembly"
121
+ update: "%{user_name} updated the %{resource_name} assembly"
122
+ assembly_user_role:
123
+ create: "%{user_name} invited %{resource_name} to the %{space_name} assembly"
124
+ delete: "%{user_name} removed the user %{resource_name} from the %{space_name} assembly"
125
+ update: "%{user_name} changed the role of %{resource_name} in the %{space_name} assembly"
109
126
  assemblies:
110
127
  admin:
111
128
  assemblies:
112
129
  form:
130
+ select_an_area: Select an Area
113
131
  slug_help: 'URL slugs are used to generate the URLs that point to this assembly. Only accepts letters, numbers and dashes, and must start with a letter. Example: %{url}'
114
132
  assembly_copies:
115
133
  form:
@@ -122,6 +140,7 @@ en:
122
140
  active_assemblies: Active assemblies
123
141
  see_all_assemblies: See all assemblies
124
142
  show:
143
+ area: Area
125
144
  developer_group: Developer group
126
145
  local_area: Local area
127
146
  participatory_scope: Participatory scope
@@ -132,6 +151,7 @@ en:
132
151
  answers_count: Answers
133
152
  assemblies_count: Assemblies
134
153
  comments_count: Comments
154
+ endorsements_count: Endorsements
135
155
  headline: Activity
136
156
  meetings_count: Meetings
137
157
  orders_count: Votes
@@ -2,9 +2,12 @@ es:
2
2
  activemodel:
3
3
  attributes:
4
4
  assembly:
5
+ area_id: Área
5
6
  banner_image: Imagen de banner
6
7
  copy_categories: Copiar categorías
7
8
  copy_features: Copiar funcionalidades
9
+ decidim_area_id: Área
10
+ decidim_scope_id: Ámbito
8
11
  description: Descripción
9
12
  developer_group: Grupo promotor
10
13
  domain: Dominio
@@ -15,9 +18,11 @@ es:
15
18
  participatory_scope: Ámbito participativo
16
19
  participatory_structure: Estructura participativa
17
20
  promoted: Destacado
21
+ published_at: Publicado
18
22
  scope_id: Ámbito
19
23
  scopes_enabled: Ámbitos habilitados
20
24
  short_description: Descripción breve
25
+ show_statistics: Mostrar estadísticas
21
26
  slug: Texto corto de URL
22
27
  subtitle: Subtítulo
23
28
  target: '¿A quién va dirigido?'
@@ -80,6 +85,8 @@ es:
80
85
  assemblies: Asambleas
81
86
  assemblies_submenu:
82
87
  assembly_admins: Usuarios de la asamblea
88
+ attachment_collections: Colecciones
89
+ attachment_files: Archivos
83
90
  attachments: Archivos adjuntos
84
91
  categories: Categorías
85
92
  features: Funcionalidades
@@ -105,10 +112,21 @@ es:
105
112
  moderator: Moderador
106
113
  titles:
107
114
  assemblies: Asambleas
115
+ admin_log:
116
+ assembly:
117
+ create: "%{user_name} creó la asamblea %{resource_name}"
118
+ publish: "%{user_name} publicó la asamblea %{resource_name}"
119
+ unpublish: "%{user_name} despublicó la asamblea %{resource_name}"
120
+ update: "%{user_name} actualizó la asamblea %{resource_name}"
121
+ assembly_user_role:
122
+ create: "%{user_name} invitó %{resource_name} a la asamblea %{space_name}"
123
+ delete: "%{user_name} eliminó al usuario %{resource_name} de la asamblea %{space_name}"
124
+ update: "%{user_name} cambió el rol de %{resource_name} en la asamblea %{space_name}"
108
125
  assemblies:
109
126
  admin:
110
127
  assemblies:
111
128
  form:
129
+ select_an_area: Seleccione un Área
112
130
  slug_help: 'Los textos cortos de URL se utilizan para generar las URL que apuntan a esta asamblea. Sólo acepta letras, números y guiones, y debe comenzar con una letra. Ejemplo: %{url}'
113
131
  assembly_copies:
114
132
  form:
@@ -121,6 +139,7 @@ es:
121
139
  active_assemblies: Asambleas activas
122
140
  see_all_assemblies: Ver todas las asambleas
123
141
  show:
142
+ area: Área
124
143
  developer_group: Grupo promotor
125
144
  local_area: Áreas municipales
126
145
  participatory_scope: Ámbito participativo
@@ -131,6 +150,7 @@ es:
131
150
  answers_count: Respuestas
132
151
  assemblies_count: Asambleas
133
152
  comments_count: Comentarios
153
+ endorsements_count: Respaldos
134
154
  headline: Actividad
135
155
  meetings_count: Encuentros
136
156
  orders_count: Votos