DEPRECATION NOTE: The description
field in the categories admin forms has been removed (this applies to any participatory space using categories). For now it's still available in the database, so you can extract it with the following command in the Rails console:
Decidim::Category.pluck(:id, :name, :description)
In the next version (v0.28.0) it will be fully removed from the database.
PR #8725 Modifies the default generator to create a new Decidim app (command decidim my-decidim
).
Once generated, the default initializers allows to setup most of the optional configuration values (such as geolocation, languages, etc) for Decidim entirely via ENV variables.
Documentation is also updated so be sure to check the options in the Environment Variables doc.
Note that this change does not affect existing installations as only the config/initializers/decidim.rb
and config/secrets.yml
files are involved.
However you can migrate to the new structure easily by creating a new Decidim app and copying or adapting those files to your own project.
decidim-core, decidim-budgets: Reminders for pending orders in budgets #8621. To generate reminders:
bundle exec rake decidim:reminders:all
Or add cronjob:
4 0 * * * cd /home/user/decidim_application && RAILS_ENV=production bundle exec rake decidim:reminders:all
PR #8012 Participatory space to comments, to fix the statistics. Use
rake decidim_comments:update_participatory_process_in_comments
to migrate existing comments to the new structure.
PR #8631 Replaces graphql-docs npm package with gem. In this PR we have also added 3 configurable parameters:
# defines the schema max_per_page to configure GraphQL pagination
Decidim::Api.schema_max_per_page = 50
# defines the schema max_complexity to configure GraphQL query complexity
Decidim::Api.schema_max_complexity = 5000
# defines the schema max_depth to configure GraphQL query max_depth
Decidim::Api.schema_max_depth = 15
The static documentation will be rendered into : app/views/static/api/docs
which is being refreshed automatically when you will run rake decidim:upgrade
.
You can manually regenerate the docs by running: rake decidim_api:generate_docs
PR #8658 Added the ability to search for a user by nickname, to update the existing search, Run in a rails console or create a migration with:
Decidim::User.find_each(&:try_update_index_for_search_resource)
Please be aware that it could take a while if your database has a lot of Users.
As per #8669, your Decidim::Form
s will no longer use Rectify::Form
or Virtus.model
attributes because Virtus
is discontinued and Decidim is loosening the dependency on the virtus
gem. Instead, the attributes implementation is now based on ActiveModel::Attributes
with an integration layer within Decidim that aims to provide as much backwards compatibility as possible with the Virtus.model
attributes that were previously used.
For most cases, no changes in the code should be needed but there are specific differences with the implementation which may require changes in the 3rd party code as well. Both Rectify::Form
and Virtus
will be still available in the core (through the rectify
gem) but you should migrate away from them as soon as possible as they may be removed in future versions of Decidim.
There are specific things that you need to change regarding your Form or Virtus.model
classes when migrating to Decidim::AttributeObject
:
- Change all instances of
YourForm < Rectify::Form
toYourForm < Decidim::Form
. It should be very rare to find any classes in your code that inherit directly fromRectify::Form
but in case you have used that, replace those references withDecidim::Form
. - Change all instances of
include Virtus.model
toinclude Decidim::AttributeObject::Model
. - For all file objects that may be of type
String
orActionDispatch::Http::UploadedFile
, remove theString
type casting from these attributes as otherwise the uploaded file objects would be converted to strings. In other words, change allattribute :uploaded_image, String
definitions within the forms toattribute :uploaded_image
which allows them to be of any type. - Change all
attribute :attr_name, Hash
toattribute :attr_name, Hash[Symbol => ExpectedType]
whereExpectedType
is the type you are expecting the hash values to be. The new layer will default the hash key types toSymbol
and hash value types toObject
(= any type). The Virtus Hash attribute did not force any default types for these. It should be preferred to use the actual expected type for the values instead ofObject
(= any type) to make your code more robust and less buggy. - Change all
attribute :attr_name, Array
toattribute :attr_name, Array[ExpectedType]
whereExpectedType
is the type you are expecting the array values to be. It should be preferred to use the actual expected type for the values instead ofObject
(= any type) to make your code more robust and less buggy. - The original form attribute values are no longer available through the
@attr_name
instance variables within the Form orVirtus.model
classes. Instead, change all these references to@attributes["attr_name"].value
in case you want to fetch the original value of the attribute without using its accessor method. Another way is to provide an alias for the original attribute method before overriding it. If you have not overridden the original attribute accessor, simply remove the@
character in front of the attribute name to fetch the attribute value using the original accessor method. - When calling the
attributes
method of the model/form classes, use strings to refer to the attribute names, not symbols as you might have done withVirtus
orRectify::Form
. Change allmodel.attributes[:attr_name]
method calls tomodel.attributes["attr_name"]
. - When calling
model.attributes.slice(...)
, you also need to use strings to refer to the attribute keys. Change all instances ofmodel.attributes.slice(:attr1, :attr2)
tomodel.attributes.slice("attr1", "attr2")
- If you had overridden any of the
Rectify::Form
methods within your form classes, remove those overrides. For example, you might have overridden theform_attributes_valid?
method which no longer does anything. Instead, define a custom validation in order to add extra validations to your forms. - Very rarely, when defining a an attribute of type
Rails::Engine
, you need to changeattribute :attr_name, Rails::Engine
toattribute :attr_name, Rails::Engine, {}
. This is because we want to preserve the method signature againstActiveModel::Attributes
for theattribute
class method intead of the legacyVirtus.model
. There is a limitation in the Ruby language that if the method has default values for the previous arguments and defines keyword arguments, the last argument will always receive arespond_to?(:to_hash)
call to it which doesn't work forRails::Engine
(you can try it out in the Rails console by callingRails::Engine.respond_to?(:to_hash)
). - Test all your form and command classes thoroughly to notice any differences between the two implementations. The new layer is a bit more "robust" with some of the type castings, so some things may break during the migration in case you have relied on some of the oversights within
Virtus
.
PR #8645 we now only allow PNG images at Favicon so we can provide higher quality versions to mobile devices.
- decidim-core: The
Decidim::ActivitySearch
class has been rewritten asDecidim::PublicActivities
which is now aRectify::Query
class instead ofSearchlight::Search
class due to the removal of Searchlight at #8748. - decidim-core: The
Decidim::ResourceSearch
class now inherits fromRansack::Search
instead ofSearchlight::Search
as of #8748. The newResourceSearch
class provides extra search functionality for contextual searches that require context information in addition to the search parameters, such as current user or current component. It has barely anything to do with theResourceSearch
class in the previous versions which contained much more logic. Please review all your search classes that were inheriting from this class. You should migrate your search filtering to Ransack. - decidim-debates, decidim-initiatives, decidim-meetings: The resource search classes
Decidim::Debates::DebateSearch
,Decidim::Intitatives::InitiativeSearch
andDecidim::Meetings::MeetingSearch
are rewritten for the Ransack searches due to Searchlight removal at #8748. The role of these classes is now to pass contextual information to the searches, such as the current user. All other search filtering should happen directly through Ransack. - decidim-meetings: The
visible_meetings_for
scope for theMeeting
model has been renamed tovisible_for
in #8748 for consistency. - decidim-core: The
official_origin
,participants_origin
,user_group_origin
andmeeting_origin
scopes for theDecidim::Authorable
andDecidim::Coauthorable
concerns have been changed towith_official_origin
,with_participants_origin
,with_user_group_origin
andwith_meeting_origin
respectively in #8748 for consistency. See the Searchlight removal change notes for reasoning.
The searchlight
gem has been removed in favor of Ransack as of #8748 in order to standardize all searches within Decidim around a single way of performing searches. Ransack was selected as the preferred search backend because it is better maintained and has a larger community of developers around it compared to Searchlight.
Ransack provides a search API that produces the search queries semi-automatically against the available database columns and ActiveRecord scopes made available for the Ransack searches while Searchlight used to require to write all the search logic manually in the search classes. Due to the inner workings of the Ransack gem and for consistency reasons, the following changes have been made for the search filtering:
- For search scopes that are doing more than matching against a specific column in the database or require special programming logic during the searches, there is a new scope convention introduced with the
with_*
andwith_any_*
scope names. Thewith_*
convention should be used when providing a search scope that searches against one key, such aswith_category(1)
and thewith_any_*
convention should be used when providing a search scope that searches against one or multiple keys, such aswith_any_category(1, 2, 3)
.- An example of such scope is
with_any_category
provided by theHasCategory
concern which searches against the provided category IDs or any sub-category of those category IDs. You can find all the introduced (or changed) scopes by searching forscope :with_
within the Decidim codebase. - With Searchlight, these search parameters were provided e.g. as
category_id
which was then used to perform the explained search query manually in the ResourceSearch class which is now used for a different purpose. As the search now happens through Ransack and the ActiveRecord scopes, these parameters have been renamed to better explain what they do. With Ransack, matching e.g. against thecategory_id_eq
key would mean that the search is done against this specific column in the record's database table and only searching for the provided search input (and not e.g. the parent categories in the category case).
- An example of such scope is
- The origin scopes provided by
Decidim::Authorable
andDecidim::Coauthorable
have been renamed with thewith_
prefix as explained above. - All the filtering key changes have been reflected to the participant filtering views (
_filters.html.erb
in most modules) as well as the controller methodsdefault_filter_params
where applicable. - The
default_filter_params
method within the participant-facing controllers now defines all the parameters that are allowed in the search queries and only these parameters are passed to the Ransack search. This limitation is made in order to protect the participant views from providing more searching options through the URL parameters than they are supposed to provide. In the past, theSearchlight::Search
classes took care of utilizing only the allowed parameters but Ransacker does not have any middle-layer that would do the same, which is why the limitation is done at the controller side. - The
search_collection
method now defines the base collection used for the searches within the filtering controllers. In previous versions, there used to be a method that defined asearch_klass
method that defined theSearchlight::Search
class to be used as the basis for the search. Now, thesearch_collection
defines the base collection instead against which the Ransack search is run.
3rd party developers that have developed their own modules or customizations for the core controllers or filtering views, should revisit their customizations and make sure they reflect these changes made for the controllers or filtering views. It is suggested to remove the customizations related to the filtering views/controllers and re-do from scratch what needs to be customized in order to ensure full compatibility with the changed filtering APIs. In case you had created your own Searchlight::Search
(or ResourceSearch
) classes, you should scrap those and start over using Ransack.
More information on using Ransack can be found from the Ransack documentation. You can find examples for filtering in the core filtering views and controllers.
- decidim-core: The
searchlight
gem has been removed in favor of Ransach as of #8748. Please review the Changed notes regarding the required changes. Please review all your search classes that were inheriting fromSearchlight::Search
. You should migrate your search filtering to Ransack. - decidim-core: The
search_params
anddefault_search_params
methods within the participant-facing controllers are now removed in favor of usingfilter_params
anddefault_filter_params
as of #8748. The duplicate methods were redundant after the Ransack migration which is why they were removed. In case you had overridden these methods in your controllers, they no longer do anything. In case you were calling these methods before, you will now receive aNoMethodError
because they are removed. Please usefilter_params
anddefault_filter_params
instead. - decidim-accountability, decidim-assemblies, decidim-budgets, decidim-consultations, decidim-core, decidim-elections, decidim-initiatives, decidim-participatory_processes, decidim-proposals, decidim-sortitions: The search service classes inheriting from
Searchlight::Search
that are no longer necessary due to the Ransack migration have been removed in all modules as of #8748. This includesDecidim::Accountability::ResultSearch
,Decidim::Assemblies::AssemblySearch
,Decidim::Budgets::ProjectSearch
,Decidim::Consultations::ConsultationSearch
,Decidim::HomeActivitySearch
,Decidim::ParticipatorySpaceSearch
,Decidim::Elections::ElectionsSearch
,Decidim::Votings::VotingSearch
,Decidim::Meetings::Directory::MeetingSearch
,Decidim::ParticipatoryProcesses::ParticipatoryProcessesSearch
,Decidim::Proposals::CollaborativeDraftSearch
,Decidim::Proposals::ProposalSearch
andDecidim::Sortitions::SortitionSearch
.
Please check release/0.26-stable for previous changes.