decidim 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97d410258149c9479d08c4c0a5cab0576f8e575b8b2b99b87a0b2ec079aeaa46
4
- data.tar.gz: de5dac8b18a31f81fc81102de483e43d8ae844e709715e41366f2eb662c15231
3
+ metadata.gz: 17d019f66b126b4f7b1d5c7616dce95b19d070912f1459a95337c92f9292acf8
4
+ data.tar.gz: ca71c26ce698370573fdb38e79f24763c808f5735807af11f41966ed845bf12d
5
5
  SHA512:
6
- metadata.gz: 8dc887b951003179d5ac662ebf96979877792f763c7afe8d3c4fd3d07b47e18d95974428db7fb1f33964d97dd2e9b7934cbdc7fbf5180ef88a8cf75b5eb43891
7
- data.tar.gz: e2381ca71618c8db78e5f1675fd3e8da69b1da0ed1cfb01601075e4f2fb671def840c562dfda3caba9fc642d982e5a49a51365e1e8aad05b2b835a1ff4446ed8
6
+ metadata.gz: 5a4b1113e208137c2f7819a6e2f987451e4a8d22a7fd2ab4465adc3e5f2e49c56e14bbc69b8800856059beba5a8d94023fa037c02811fb52ed3f7da6cbe55357
7
+ data.tar.gz: e5b69c27b69d6a8b28b2d2a9d6e0c7e3594b4cc7b4ada2d0d3f6f9cde762b4f06356d57b22c0dfe9910b029c339a292dc81236f8e114038717599481cc9aaaa1
data/README.md CHANGED
@@ -100,60 +100,11 @@ Also, if you want to verify yourself against the default authorization handler u
100
100
 
101
101
  ## Modules
102
102
 
103
- ### Official (stable)
104
-
105
- | Module | Description |
106
- | --------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
107
- | [API](https://github.com/decidim/decidim/tree/master/decidim-api) | Exposes a GraphQL API to programatically interact with the Decidim platform via HTTP. |
108
- | [Accountability](https://github.com/decidim/decidim/tree/master/decidim-accountability) | Adds an accountability section to any participatory space so users can follow along the state of the accepted proposals. |
109
- | [Admin](https://github.com/decidim/decidim/tree/master/decidim-admin) | Adds an administration dashboard so users can manage their organization and all other entities. |
110
- | [Assemblies](https://github.com/decidim/decidim/tree/master/decidim-assemblies) | Permanent participatory spaces. |
111
- | [Blogs](https://github.com/decidim/decidim/tree/master/decidim-blogs) | This component makes possible to add posts ordered by publication time to spaces. |
112
- | [Budgets](https://github.com/decidim/decidim/tree/master/decidim-budgets) | Adds a participatory budgets system to any participatory space. |
113
- | [Comments](https://github.com/decidim/decidim/tree/master/decidim-comments) | The Comments module adds the ability to include comments to any resource which can be commentable by users. |
114
- | [Conferences](https://github.com/decidim/decidim/tree/master/decidim-conferences) | This module will be a configurator and generator of Conference pages, understood as a collection of Meetings, with program, inscriptions and categories |
115
- | [Consultations](https://github.com/decidim/decidim/tree/master/decidim-consultations) | This module creates a new space for decidim to host consultations: debates around critical questions and a proxy for eVoting |
116
- | [Core](https://github.com/decidim/decidim/tree/master/decidim-core) | The basics of Decidim: users, organizations, etc. This is the only required engine to run Decidim, all the others are optional. |
117
- | [Debates](https://github.com/decidim/decidim/tree/master/decidim-debates) | The Debates module adds debate to any participatory process. It adds a CRUD engine to the admin and public view scoped inside the participatory process. |
118
- | [Dev](https://github.com/decidim/decidim/tree/master/decidim-dev) | Aids the local development of Decidim's components. |
119
- | [Generators](https://github.com/decidim/decidim/tree/master/decidim-generators) | It helps you with generating decidim applications & new components. It provides the `decidim` executable. |
120
- | [Initiatives](https://github.com/decidim/decidim/tree/master/decidim-initiatives) | Initiatives is the place on Decidim's where citizens can promote a civic initiative. Unlike participatory processes that must be created by an administrator, Civic initiatives can be created by any user of the platform. |
121
- | [Meetings](https://github.com/decidim/decidim/tree/master/decidim-meetings) | The Meeting module adds meeting to any participatory space. It adds a CRUD engine to the admin and public view scoped inside the participatory space. |
122
- | [Pages](https://github.com/decidim/decidim/tree/master/decidim-pages) | The Pages module adds static page capabilities to any participatory space. It basically provides an interface to include arbitrary HTML content to any step. |
123
- | [Participatory Processes](https://github.com/decidim/decidim/tree/master/decidim-participatory_processes) | The main concept of a Decidim installation: participatory processes. |
124
- | [Proposals](https://github.com/decidim/decidim/tree/master/decidim-proposals) | The Proposals module adds one of the main components of Decidim: allows users to contribute to a participatory space by creating proposals. |
125
- | [Sortitions](https://github.com/decidim/decidim/tree/master/decidim-sortitions) | This component makes possible to select randomly a number of proposals among a set of proposals (or a category of proposals within a set) maximizing guarantees of randomness and avoiding manipulation of results by the administrator. |
126
- | [Surveys](https://github.com/decidim/decidim/tree/master/decidim-surveys) | Adds the ability for admins to create arbitrary surveys. |
127
- | [System](https://github.com/decidim/decidim/tree/master/decidim-system) | Multitenant Admin to manage multiple organizations in a single installation. |
128
- | [Verifications](https://github.com/decidim/decidim/tree/master/decidim-verifications) | Offers several methods for allowing participants to get authorization to perform certain privileged actions. This module implements several of those methods and also offers a way for installation to implement their custom verification methods. |
129
-
130
- ### Community
131
-
132
103
  If you need to have some features that we don't have yet, we recommend that you make a module. This is a Ruby on Rails engine with some APIs specific to Decidim (for registering with the menus, integration with spaces like Participatory Processes or Assemblies, with /admin or /api, etc).
133
104
 
134
105
  As a base you can use these modules, although check first that the version is compatible with your current Decidim version. Also you should know that until v1.0.0 We're under development and these internal APIs can change. We recommend that you extensively test your module.
135
106
 
136
- | Module | Version | Description |
137
- | -----------------------------------------------------------------------------------------------------------------------| -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
138
- | [Age Action Authorization](https://github.com/diputacioBCN/decidim-diba/tree/master/decidim-age_action_authorization) | 0.9.3 | A Decidim based action authorization to check user's age inside actions. |
139
- | [Antivirus](https://github.com/mainio/decidim-module-antivirus) | 0.15.x-0.17.x | Virus scanning validation for uploaded attachments based on ClamAV. |
140
- | [Calendar](https://github.com/alabs/decidim-module-calendar) | 0.13.1, 0.16.1-0.18.x | Adds a calendar, gantt graph and ICAL download for all the Meetings, Participatory Processes, Debates, Consultations and external events in the scope of a multitenant organization. |
141
- | [Crowdfunding](https://github.com/podemos-infoparticipa2/tree/master/decidim-module-crowdfundings) | 0.14.1 | This rails engine implements a Decidim component that allows to the administrators to configure crowfunding campaigns for a participatory space. |
142
- | [DataViz](https://github.com/AjuntamentdeBarcelona/decidim-barcelona/tree/master/decidim-dataviz) | 0.13.1 | The Dataviz module adds the PAM data visualizations to any participatory process but it is intended to be used just for the PAM participatory process. |
143
- | [Gravity Forms](https://github.com/podemos-info/participa2/tree/master/decidim-module-gravity_forms) | 0.14.1 | A gravity forms component for Decidim. |
144
- | [LDAP](https://github.com/diputacioBCN/decidim-diba/tree/master/decidim-ldap) | 0.9.3 | User authentication via LDAP |
145
- | [News](https://github.com/castilla-lamancha/participa-castillalamancha/tree/master/decidim-news) | 0.14.1 | This will add an admin dashboard to manage news posts and front-end views for posts. |
146
- | [Members](https://github.com/ElectricThings/decidim-members) | 0.13.1 | Members list and search plugin for Decidim |
147
- | [MPASSid](https://github.com/mainio/decidim-module-mpassid) | 0.18.x | User authentication and automatic authorization through the [MPASSid national identification](https://mpass.fi/english/) service for comprehensive school and secondary education students in Finland. |
148
- | [Personal Number](https://github.com/PierreMesure/decidim-module-personal_number) | 0.11.0.pre | This module allows users to register with a personal number and to log in with it. |
149
- | [Plans](https://github.com/mainio/decidim-module-plans) | 0.15.x-0.17.x | Collaborative planning phase for the participatory budgeting projects based on the proposals submitted by people. People can participate on creating the actual plans and collaborate on them before the budgeting voting starts. |
150
- | [Pol.is](https://github.com/OpenSourcePolitics/decidim-polis) | 0.7.1 | Pol.is integration on Decidim |
151
- | [Questions](https://github.com/OpenSourcePolitics/decidim-questions) | 0.12.2 | Questions / Views / Inputs based on decidim-proposals. |
152
- | [Riksdagen](https://github.com/DinRiksdag/decidim-module-riksdagen) | 0.11.0.pre | A Decidim module to integrate some of the open data produced by the Swedish parliament |
153
- | [Suomi.fi](https://github.com/mainio/decidim-module-suomifi) | 0.18.x | User authentication and automatic strong authorization through the [Suomi.fi e-Identification](https://www.suomi.fi/instructions-and-support/information-on-eidentification) service in Finland. |
154
- | [Term Customizer](https://github.com/mainio/decidim-module-term_customizer) | 0.16.x-0.17.x | Module that allows customizing the translatable terms in the system. The admins can also limit where these customizations apply, e.g. in the whole organization, a specific participatory space or a specific component. |
155
- | [User Export](https://github.com/OpenSourcePolitics/decidim-user-export) | 0.8.3 | Allow user export |
156
- | [Votings](https://github.com/podemos-info/participa2/tree/master/decidim-module-votings) | 0.14.1 | An administrator can add one or more votings to a participatory process or assambly |
107
+ See [Modules page on Decidim.org](https://decidim.org/modules).
157
108
 
158
109
  ### Authorizations Strategies
159
110
 
@@ -4,8 +4,7 @@ Regarging authorship of Decidim resources/entities, there are three concerns
4
4
  involved directly:
5
5
 
6
6
  - `Decidim::ActsAsAuthor`: which defines how an author should behave.
7
- - `Decidim::Authorable` and `Decidim::Coauthorable`: which define the behaviour
8
- around who authored a resource.
7
+ - `Decidim::Authorable` and `Decidim::Coauthorable`: which define the behaviour around who authored a resource.
9
8
 
10
9
  But the presenters for the classes including `ActsAsAuthor` should also behave
11
10
  in a certain maneer. This has been resolved using the duck typing strategy
@@ -58,3 +58,43 @@ end
58
58
  ```
59
59
 
60
60
  Every model in a component doesn't have to (and should not) know about its parent participatory space, but instead should be scoped to the components.
61
+
62
+ ## Settings
63
+
64
+ Components can define settings that modify its behavior. This settings can be defined to be set for the whole life of the component (global settings), or to be set for each different step of the participatory space (step settings).
65
+
66
+ Each attribute defined can be described through properties:
67
+
68
+ * they should have a `type`: `boolean`, `integer`, `string` (short texts), `text` (long texts) or `enum`.
69
+ * they can be `required` or not
70
+ * they can have a `default` value
71
+ * `text` and `string` attributes can be `translated`, which will allow admin users to enter values for every language.
72
+ * `text` attributes can use an `editor` to edit them as HTML code
73
+ * `enum` attributes should have a `choices` attributes that list all the possible values. This could be a lambda function.
74
+ * they can be `readonly` in some cases, throught a lambda function that received the current component within the `context`.
75
+
76
+ ```ruby
77
+ # :my_component is the unique name of the component that will be globally registered.
78
+ Decidim.register_component(:my_component) do |component|
79
+ ...
80
+
81
+ component.settings(:global) do |settings|
82
+ settings.attribute :a_boolean_setting, type: :boolean, default: true
83
+ settings.attribute :an_enum_setting, type: :enum, default: "all", choices: %w(all one none)
84
+ end
85
+
86
+ component.settings(:step) do |settings|
87
+ settings.attribute :a_text_setting, type: :text, default: false, required: true, translated: true, editor: true
88
+ settings.attribute :a_lambda_enum_setting, type: :enum, default: "all", choices: -> { SomeClass.enum_options }
89
+ settings.attribute :a_readonly_setting, type: :string, readonly: ->(context) { SomeClass.readonly?(context[:component]) }
90
+ end
91
+
92
+ ...
93
+ end
94
+ ```
95
+
96
+ Each setting should have one or more translation texts related for the admin zone:
97
+
98
+ * `decidim.components.[component_name].settings.[global|step].[attribute_name]`: Admin label for the setting.
99
+ * `decidim.components.[component_name].settings.[global|step].[attribute_name]_help`: Additional text with help for the setting use.
100
+ * `decidim.components.[component_name].settings.[global|step].[attribute_name]_readonly`: Additional text for the setting when it is readonly.
@@ -44,9 +44,11 @@ end
44
44
 
45
45
  ## Managing content blocks
46
46
 
47
- Currently content blocks are only used in the homepage. You can manage them in the admin area, under Settings -> Homepage. you need to be an organization admin in order to enter this section.
47
+ Content blocks registered under the `:homepage` scope can be seen in the admin area, under Settings -> Homepage. You need to be an organization admin in order to enter this section.
48
48
 
49
- You'll see all the registered content blocks, those active and those inactive. You can reorder blocks and (un)publish them.
49
+ You'll see all the registered content blocks for the `:homepage` scope, those active and those inactive. You can reorder blocks and (un)publish them.
50
+
51
+ Another use for content blocks, for example, can be seen at the newsletter templates system.
50
52
 
51
53
  ## Rendering content blocks
52
54
 
@@ -57,4 +59,4 @@ You can check the code we use in the homepage to render them, or use something l
57
59
  <% next unless content_block.manifest %>
58
60
  <%= cell content_block.manifest.cell %>
59
61
  <% end %>
60
- ```
62
+ ```
@@ -4,7 +4,7 @@ Simple HTML `select`s are not usable enough for the big collections of data Deci
4
4
 
5
5
  Current Decidim's selector is inspired on [this](https://medium.com/@mibosc/responsive-design-why-and-how-we-ditched-the-good-old-select-element-bc190d62eff5) article.
6
6
 
7
- Data Picker is a selector thought to be reusable in many contexts and kinds of data. The idea behind it is a reusable widget that opens a popup where the user will perform a given selection and, on finish, this selection is returned to the source widget in the main page. The popup is accompained by a semitransparent layer behind it to blur the background and keep the user concentrated in the current action, the selection.
7
+ Data Picker is a selector thought to be reusable in many contexts and kinds of data. The idea behind it is a reusable widget that opens a popup where the user will perform a given selection and then return to the main page. The popup is accompained by a semitransparent layer behind it to blur the background and keep the user concentrated in the current action, the selection.
8
8
 
9
9
  ## Artifacts
10
10
 
@@ -43,13 +43,41 @@ It is a good way to implement the widget to think that it is a component that ta
43
43
 
44
44
  ### Selector popup content
45
45
 
46
- Anchors in the selector can have the following attributes:
47
- data-close: this anchor will be ignored
48
- href: the url to be used for choosing
49
- picker-choose: when 'undefined' will load the given href url. Otherwise a choose action in the component is invoked with params: `url: href, value: picker-value, text: picker-text`.
50
- picker-value: the selected value
51
- picker-text (optional): The text to be shown in the picker button.
46
+ **Anchors** in the selector can have the following attributes:
52
47
 
53
- ### Returning the selection to the widget
48
+ - data-close: this anchor will be ignored and will close the picker
49
+ - href: the url to be used for choosing
50
+ - picker-choose: when not present the picker will navigate as a regular anchor. Otherwise a choose action in the component is invoked with params: `url: href, value: picker-value, text: picker-text`.
51
+ - picker-value: the selected value
52
+ - picker-text (optional): The text to be shown in the picker button.
54
53
 
55
- To return the selection to the widget in the main page use javascript to set the data-picker-value in the #proposal-picker-choose button.
54
+ This is an example of a link used to choose an element:
55
+
56
+ ```html
57
+ <a class="button" href="[picker path browsing this element]" data-picker-text="[text]" data-picker-value="[value]" data-picker-choose>[text]</a>
58
+ ```
59
+
60
+ **Checkboxes** also can be used in the selector, to allow to select several values at once. In this case, the `href` attribute is replaced with `data-picker-url` and the `data-picker-value` attribute is replaced with the `value` built-in attribute.
61
+
62
+ This is an example of a checkbox that allow to choose an element without closing the picker:
63
+
64
+ ```html
65
+ <label><input type="checkbox" data-picker-url="[picker path browsing this element]" data-picker-text="[text]" value="[value]" data-picker-choose>[text]</label>
66
+ ```
67
+
68
+ ## Examples of use of the DataPicker
69
+
70
+ - Scopes picker: Allows to browse the tree of scopes and select one or several scopes.
71
+ - [FormBuilder scopes picker field](../../decidim-core/lib/decidim/form_builder.rb): Basic method to render a scope picker for a form.
72
+ - [FilterFormBuilder scopes picker field](../../decidim-core/lib/decidim/filter_form_builder.rb): Basic method to render a scope picker for a filter form.
73
+ - [Scopes pickers helpers](../../decidim-core/app/helpers/decidim/scopes_helper.rb): Helpers to simplify the call to basic methods.
74
+ - [Global scopes picker controller](../../decidim-core/app/controllers/decidim/scopes_controller.rb): Controller used to browse the scopes on a picker in any part of the application.
75
+ - [Proposals' frontend form using a scopes picker](../../decidim-proposals/app/views/decidim/proposals/proposals/_edit_form_fields.html.erb): Use of a scope picker helper on a frontend page.
76
+ - [Proposals' admin form using a scopes picker](../../decidim-proposals/app/views/decidim/proposals/admin/proposals/_form.html.erb): Use of a scope picker helper on an admin page.
77
+ - [Meetings' multiple scopes picker for filtering](../../decidim-meetings/app/views/decidim/meetings/meetings/_filters.html.erb): Use of a multiple scopes picker on a filter form.
78
+ - Proposals picker: Allows to search and select multiple proposals to be referenced from other components.
79
+ - [Proposals pickers helper](../../decidim-proposals/app/helpers/decidim/proposals/admin/proposals_picker_helper.rb): Helper to render a DataPicker for proposals selection.
80
+ - [Proposals picker concern for admin pages](../../decidim-proposals/app/controllers/concerns/decidim/proposals/admin/picker.rb): You will need to add this concern to your controller, add a route for `proposals_picker` endpoint and create a view for it to show the proposals picker in your component context.
81
+ - [Proposals picker cell](../../decidim-proposals/app/cells/decidim/proposals/proposals_picker_cell.rb): You can use this cell to reuse the logic in your picker view.
82
+ - [Accountability's admin controller with a proposals picker](../../decidim-accountability/app/controllers/decidim/accountability/admin/results_controller.rb): It only needs to add the concern (and the endpoint to the routes).
83
+ - [Accountability's admin view with a proposals picker](../../decidim-accountability/app/views/decidim/accountability/admin/results/proposals_picker.html.erb): It only needs to render the cell.
@@ -1,6 +1,7 @@
1
1
  # Embeddable
2
2
 
3
3
  `Decidim` allows you to share a information box related to some spaces as:
4
+
4
5
  - **Assemblies**
5
6
  - **Conferences**
6
7
  - **Initiatives**
@@ -8,7 +9,7 @@
8
9
 
9
10
  or even `Meetings` component in an easy way with the `embeddable` option that offers the platform.
10
11
 
11
- ## How to ##
12
+ ## How to
12
13
 
13
14
  All that you have to do, is to enter into whathever space/component you want to share info to, and look for down right part of the page to find embeddable share option.
14
15
 
@@ -0,0 +1,113 @@
1
+ # Endorsable
2
+
3
+ ## Things can be endorsable
4
+
5
+ `Endorsable` is a feature to allow participants to promote (reivindicate, etc.) resources in the platform to their followers.
6
+
7
+ When endorsing an element the endorsements counter for this element is increased and a notification to all the followers of the participant is sent.
8
+
9
+ Participants can endorse with their own identity or with the identify of the `user_groups` they belong to. Each endorsing identity on its own will increment the endorsements counter by one.
10
+
11
+ ## Data model
12
+
13
+ A `decidim_endorsements` table registers each endorsement that each identity gives to each element. This is, one endorsable has many endorsements, and each endorsement belongs to one endorsable.
14
+ For performance, an endorsable has a counter cache of endorsements.
15
+
16
+ ```ascii
17
+ +----------------------+
18
+ | Decidim::Endorsable |
19
+ | ((Proposal,...)) | +-------------+
20
+ +----------------------+ 0..N +--------------------+ +--+Decidim::User|
21
+ |-has_many endorsements|-------+Decidim::Endorsement| | +-------------+
22
+ |#counter cahce column | +--------------------+ |
23
+ |-endorsements_counter | |-author: may be a |<--+
24
+ +----------------------+ | user or a | |
25
+ | user_group | | +------------------+
26
+ +--------------------+ +--+Decidim::UserGroup|
27
+ +------------------+
28
+ ```
29
+
30
+ Thus, each endorsable must have the endorsements counter cache column.
31
+ This is an example migration to add the endorsements counter cache column to a resource:
32
+
33
+ ```ruby
34
+ class AddEndorsementsCounterCacheToProposals < ActiveRecord::Migration[5.2]
35
+ def change
36
+ add_column :decidim_proposals_proposals, :endorsements_count, :integer, null: false, default: 0
37
+ end
38
+ end
39
+
40
+ ```
41
+
42
+ ## Administration Panel
43
+
44
+ It is a good practice to give the opportunity to the admin to switch Endorsements on and off.
45
+
46
+ There are two switches that are normally defined in the manifest of the element in the following way:
47
+
48
+ ```ruby
49
+ settings.attribute :endorsements_enabled, type: :boolean, default: true
50
+ settings.attribute :endorsements_blocked, type: :boolean
51
+ ```
52
+
53
+ - `endorsements_enabled`: when enabled endorsement functionality appears in the public views, when disabled, this functionality is hidden.
54
+ - `endorsements_blocked`: when blocked, the counter of endorsements is visible but no more endorsements can be added or withdrawn, the button is hidden.
55
+
56
+ ## Permissions
57
+
58
+ In some cases, it may be interesting to require the user to be verified in order to be able to endorse. To do so, add the endorse action to the component manifest:
59
+
60
+ ```ruby
61
+ component.actions = %w(endorse vote create withdraw amend)
62
+ ```
63
+
64
+ Given that some settings have been defined in the Administration Panel, for the user to have permissions to endorse endorsements should be enabled and not blocked.
65
+
66
+ ## Public view
67
+
68
+ ### The "Endorse" buttons cell
69
+
70
+ It normally appears in the resource detail view (show). At the action card, in right-side of the view.
71
+ It allows users to endorse with any of their identities, the personal one, and/or their user_groups', if any.
72
+ It also shows the current number of endorsements for this resource.
73
+
74
+ To render this button, `decidim-core` offers the `decidim/endorsement_buttons` cell. It is strongly recommended to use this cell to make new resources endorsable.
75
+
76
+ ```ruby
77
+ cell("decidim/endorsement_buttons", resource)
78
+ ```
79
+
80
+ This cell, renders the endorsements counter and the endorsement button by default. But it has the possibility to be invoked to render elements sepparately.
81
+
82
+ ```ruby
83
+ # By default the `show` method is invoked as usual
84
+ # Renders `render_endorsements_count` and `render_endorsements_button` in a block.
85
+ cell("decidim/endorsement_buttons", resource)
86
+ # It is recommended to use the `endorsement_buttons_cell` helper method
87
+ endorsement_buttons_cell(resource)
88
+
89
+ # Renders the "Endorse" button
90
+ # It takes into account:
91
+ # - if endorsements are enabled
92
+ # - if users are logged in
93
+ # - if users can endorse with many identities (of their user_groups)
94
+ # - if users require verification
95
+ endorsement_buttons_cell(resource).render_endorsements_button
96
+
97
+ # Renders the counter of endorsements that appears in card.
98
+ endorsement_buttons_cell(resource).render_endorsements_count
99
+
100
+ # Renders a button to perform the endorse action, but only with the personal identity of the user. It does not take into account if the user belongs to any user group.
101
+ endorsement_buttons_cell(resource).render_user_identity_endorse_button
102
+ ```
103
+
104
+ ### The list of endorsers
105
+
106
+ The `Decidim::EndorsersListCell` renders the list of endorsers of a resource. It is usually rendered in the show of the resource, just upside the comments.
107
+
108
+ ```ruby
109
+ # to render the list of endorsers, the cell requires the endorsable resource, and the current user
110
+ cell "decidim/endorsers_list", resource
111
+ # or using the helper
112
+ endorsers_list_cell(resource)
113
+ ```
@@ -5,14 +5,15 @@ At the request of some instances, we have analyzed the issues related to metrics
5
5
  ## Problems
6
6
 
7
7
  We have identified two main problems:
8
+
8
9
  - Metrics generation crashing, which cause `MetricJob`s to run again and again.
9
10
  - Peaks in generated metrics, sudden changes from day to day when displaying metrics.
10
11
 
11
- **Metrics generation crashing**
12
+ ### Metrics generation crashing
12
13
 
13
14
  We have identified only one culprit here: "orphans" records, meaning records whose related component or participatory space cannot be found in the database. This is because in a previous decidim release `PartipatorySpaces` could be deleted but they were not deleted properly. So any application that has deleted a participatory space in the past, will probably have unrelated records that will make some metrics calculation crash.
14
15
 
15
- **Peaks in generated metrics**
16
+ ### Peaks in generated metrics
16
17
 
17
18
  If somehow the metrics jobs fail to execute for a period of time, big differences can appear in metrics. So first make sure that you have metrics for every day, if not [generate them](https://github.com/decidim/decidim/blob/master/docs/advanced/metrics.md).
18
19
 
@@ -24,10 +25,12 @@ Finally, if you see that the differences in some days are multiples of a previou
24
25
 
25
26
  We cannot offer a definitive solution for duplicate metrics, other than to delete old duplicate metrics and generate them again. If this problem persists, however, consider using Delayed Job.
26
27
  For a given metric type (`rake decidim:metrics:list`) that has duplicates:
28
+
27
29
  - Option 1: Remove individually each metric record per day.
28
30
  - Option 2: Delete all metric records and recalculate them. [CHANGELOG](https://github.com/decidim/decidim/blob/0.18-stable/CHANGELOG.md#participants-metrics) of decidim version 0.18 has an example for "participants".
29
31
 
30
32
  For orphan records, you can do the following:
33
+
31
34
  - Back up the database.
32
35
  - Delete orphan records fromt the console (code is below).
33
36
  - Delete "comments" metrics and recalculate them following the [aforementioned example](https://github.com/decidim/decidim/blob/0.18-stable/CHANGELOG.md#participants-metrics).
@@ -62,12 +65,14 @@ For orphan records, you can do the following:
62
65
  ```
63
66
 
64
67
  ### Delete orphan records
68
+
65
69
  "proposals", "meetings", "accountability", "debates", "pages", "budgets", "surveys"
66
70
 
67
71
  #### Proposals
72
+
68
73
  Delete proposals whose component does not have a participatory space and delete components of a proposal type that do not have a participatory space
69
74
 
70
- ```
75
+ ```ruby
71
76
  Decidim::Component.where(manifest_name: "proposals").find_each(batch_size: 100) { |c|
72
77
  if c.participatory_space.blank?
73
78
  Decidim::Proposals::Proposal.where(component: c).destroy_all
@@ -77,7 +82,8 @@ Decidim::Component.where(manifest_name: "proposals").find_each(batch_size: 100)
77
82
  ```
78
83
 
79
84
  Delete proposals that do not have a component
80
- ```
85
+
86
+ ```ruby
81
87
  Decidim::Proposals::Proposal.find_each(batch_size: 100) { |proposal|
82
88
  proposal.delete if proposal.component.blank?
83
89
  }
@@ -87,7 +93,7 @@ Decidim::Proposals::Proposal.find_each(batch_size: 100) { |proposal|
87
93
 
88
94
  Delete meetings whose component has no participatory space and delete components of meeting type that do not have a participatory space
89
95
 
90
- ```
96
+ ```ruby
91
97
  Decidim::Component.where(manifest_name: "meetings").find_each(batch_size: 100) { |c|
92
98
  if c.participatory_space.blank?
93
99
  Decidim::Meetings::Meeting.where(component: c).destroy_all
@@ -97,16 +103,18 @@ Decidim::Component.where(manifest_name: "meetings").find_each(batch_size: 100) {
97
103
  ```
98
104
 
99
105
  Delete meetings that do not have a component
100
- ```
106
+
107
+ ```ruby
101
108
  Decidim::Meetings::Meeting.find_each(batch_size: 100) { |meeting|
102
109
  meeting.delete if meeting.component.blank?
103
110
  }
104
111
  ````
105
112
 
106
113
  #### Debates
114
+
107
115
  Delete debates that its component has no participatory space and the debate components that do not have a participatory space
108
116
 
109
- ```
117
+ ```ruby
110
118
  Decidim::Component.where(manifest_name: "debates").find_each(batch_size: 100) { |c|
111
119
  if c.participatory_space.blank?
112
120
  Decidim::Debates::Debate.where(component: c).destroy_all
@@ -116,7 +124,8 @@ Decidim::Component.where(manifest_name: "debates").find_each(batch_size: 100) {
116
124
  ```
117
125
 
118
126
  Destroy debates that do not have a component
119
- ```
127
+
128
+ ```ruby
120
129
  Decidim::Debates::Debate.find_each(batch_size: 100) { |debate|
121
130
  debate.delete if debate.component.blank?
122
131
  }
@@ -125,7 +134,8 @@ Decidim::Debates::Debate.find_each(batch_size: 100) { |debate|
125
134
  #### Posts
126
135
 
127
136
  Destroy posts whose component has no participatory space and blog components that do not have a participatory space
128
- ```
137
+
138
+ ```ruby
129
139
  Decidim::Component.where(manifest_name: "blogs").find_each(batch_size: 100) { |c|
130
140
  if c.participatory_space.blank?
131
141
  Decidim::Blogs::Post.where(component: c).destroy_all
@@ -135,7 +145,8 @@ Decidim::Component.where(manifest_name: "blogs").find_each(batch_size: 100) { |c
135
145
  ```
136
146
 
137
147
  Destroy posts that do not have a component
138
- ```
148
+
149
+ ```ruby
139
150
  Decidim::Blogs::Post.find_each(batch_size: 100) { |post|
140
151
  post.delete if post.component.blank?
141
152
  }
@@ -145,7 +156,7 @@ Decidim::Blogs::Post.find_each(batch_size: 100) { |post|
145
156
 
146
157
  Destroy results whose component has no participatory space and components of accountability type that do not have a participatory space
147
158
 
148
- ```
159
+ ```ruby
149
160
  Decidim::Component.where(manifest_name: "accountability").find_each(batch_size: 100) { |c|
150
161
  if c.participatory_space.blank?
151
162
  Decidim::Accountability::Result.where(component: c).destroy_all
@@ -156,7 +167,7 @@ Decidim::Component.where(manifest_name: "accountability").find_each(batch_size:
156
167
 
157
168
  Destroy results that do not have a component
158
169
 
159
- ```
170
+ ```ruby
160
171
  Decidim::Accountability::Result.find_each(batch_size: 100) { |result|
161
172
  result.delete if result.component.blank?
162
173
  }
@@ -165,7 +176,8 @@ Decidim::Accountability::Result.find_each(batch_size: 100) { |result|
165
176
  #### Pages
166
177
 
167
178
  Destroy page components that do not have a participatory space
168
- ```
179
+
180
+ ```ruby
169
181
  Decidim::Component.where(manifest_name: "pages").find_each(batch_size: 100) { |c|
170
182
  if c.participatory_space.blank?
171
183
  c.destroy
@@ -177,7 +189,7 @@ Decidim::Component.where(manifest_name: "pages").find_each(batch_size: 100) { |c
177
189
 
178
190
  Destroy projects whose component has no participatory space and budget components that do not have a participatory space
179
191
 
180
- ```
192
+ ```ruby
181
193
  Decidim::Component.where(manifest_name: "budgets").find_each(batch_size: 100) { |c|
182
194
  if c.participatory_space.blank?
183
195
  Decidim::Budgets::Project.where(component: c).destroy_all
@@ -187,7 +199,8 @@ Decidim::Component.where(manifest_name: "budgets").find_each(batch_size: 100) {
187
199
  ```
188
200
 
189
201
  Destroy results that do not have a component
190
- ```
202
+
203
+ ```ruby
191
204
  Decidim::Budgets::Project.find_each(batch_size: 100) { |project|
192
205
  project.delete if project.component.blank?
193
206
  }
@@ -195,7 +208,7 @@ Decidim::Budgets::Project.find_each(batch_size: 100) { |project|
195
208
 
196
209
  #### Surveys
197
210
 
198
- ```
211
+ ```ruby
199
212
  Decidim::Component.where(manifest_name: "surveys").find_each(batch_size: 100) { |c|
200
213
  if c.participatory_space.blank?
201
214
  Decidim::Surveys::Survey.where(component: c).destroy_all
@@ -205,18 +218,18 @@ Decidim::Component.where(manifest_name: "surveys").find_each(batch_size: 100) {
205
218
  ```
206
219
 
207
220
  Destroy surveys that do not have a component
208
- ```
221
+
222
+ ```ruby
209
223
  Decidim::Surveys::Survey.find_each(batch_size: 100) { |survey|
210
224
  survey.delete if survey.component.blank?
211
225
  }
212
226
  ```
213
227
 
214
-
215
228
  #### Comments
216
229
 
217
230
  Destroy comments whose commentable root is a proposal that does not have a participatory space.
218
231
 
219
- ```
232
+ ```ruby
220
233
  proposal_ids = Decidim::Comments::Comment.where(decidim_root_commentable_type: "Decidim::Proposals::Proposal").pluck(:decidim_root_commentable_id)
221
234
 
222
235
  proposal_ids_without_space = Decidim::Proposals::Proposal.where(id: proposal_ids).find_all{|p| p.participatory_space.blank? }.pluck(:id)