Skip to content

Commit

Permalink
Merge branch 'release/0.28-stable' of github.com:AjuntamentdeBarcelon…
Browse files Browse the repository at this point in the history
…a/decidim into release/0.28-stable-bcn
  • Loading branch information
fblupi committed Nov 14, 2024
2 parents 4bfc73b + c12ffd2 commit f3b1252
Show file tree
Hide file tree
Showing 80 changed files with 932 additions and 132 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/test_app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ jobs:
name: Install Chrome version ${{inputs.chrome_version}}
with:
chromedriver-version: ${{inputs.chrome_version}}
- run: |
sudo apt install wkhtmltopdf
- uses: actions/cache@v3
id: app-cache
with:
Expand Down
1 change: 1 addition & 0 deletions .spelling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ exclude_paths:
- config/locales/((?!en).)*\.yml
- decidim-dev/lib/decidim/dev/assets/participatory_text.md
- decidim-core/lib/decidim/db/common-passwords.txt
- decidim-core/spec/lib/attributes/time_with_timezone_spec.rb
- decidim-initiatives/spec/types/initiative_type_spec.rb
- decidim-proposals/app/packs/documents/decidim/proposals/participatory_texts/participatory_text.md

Expand Down
4 changes: 0 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ PATH
decidim-core (= 0.28.4)
decidim-meetings (= 0.28.4)
wicked_pdf (~> 2.7)
wkhtmltopdf-binary (~> 0.12)
decidim-core (0.28.4)
active_link_to (~> 1.0)
acts_as_list (~> 1.0)
Expand Down Expand Up @@ -149,7 +148,6 @@ PATH
decidim-forms (0.28.4)
decidim-core (= 0.28.4)
wicked_pdf (~> 2.1)
wkhtmltopdf-binary (~> 0.12)
decidim-generators (0.28.4)
decidim-core (= 0.28.4)
decidim-initiatives (0.28.4)
Expand All @@ -159,7 +157,6 @@ PATH
decidim-verifications (= 0.28.4)
hexapdf (~> 0.32.0)
wicked_pdf (~> 2.1)
wkhtmltopdf-binary (~> 0.12)
decidim-meetings (0.28.4)
decidim-core (= 0.28.4)
decidim-forms (= 0.28.4)
Expand Down Expand Up @@ -804,7 +801,6 @@ GEM
activesupport
wisper (2.0.1)
wisper-rspec (1.1.0)
wkhtmltopdf-binary (0.12.6.6)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.12)
Expand Down
13 changes: 13 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ gem "decidim-dev", "0.28.0.rc1"

```console
sudo apt install p7zip # or the alternative installation process for your operating system. See "2.1. 7zip dependency introduction"
sudo apt install wkhtmltopdf # or the alternative installation process for your operating system. See "2.5. wkhtmltopdf binary change"
bundle remove spring spring-watcher-listen
bundle update decidim
bin/rails decidim:upgrade
Expand Down Expand Up @@ -80,6 +81,18 @@ bin/rails decidim_proposals:upgrade:set_categories

You can read more about this change on PR [#13395](https://github.com/decidim/decidim/pull/13395).

### 2.5. wkhtmltopdf binary change

For improving the support with latest versions of Ubuntu, and keeping a low size in Heroku/Docker images, we removed the `wkhtmltopdf-binary` gem dependency. This means that your package manager should have the `wkhtmltopdf` binary installed.

In the case of Ubuntu/Debian, this is done with the following command:

```bash
sudo apt install wkhtmltopdf
```

You can read more about this change on PR [#13616](https://github.com/decidim/decidim/pull/13616).

## 3. One time actions

### 3.1. Verifications documents configurations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ResultForm < Decidim::Form
include TranslationsHelper

translatable_attribute :title, String
translatable_attribute :description, String
translatable_attribute :description, Decidim::Attributes::RichText

attribute :decidim_scope_id, Integer
attribute :decidim_category_id, Integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TimelineEntryForm < Decidim::Form
attribute :decidim_accountability_result_id, Integer
attribute :entry_date, Decidim::Attributes::LocalizedDate
translatable_attribute :title, String
translatable_attribute :description, String
translatable_attribute :description, Decidim::Attributes::RichText

validates :entry_date, presence: true
validates :title, translatable_presence: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ def select_recipients_to_deliver
end

def recipients_count
data = params.permit(data: {}).to_h[:data]
data = params.permit(newsletter: {}).to_h[:newsletter]

@form = form(SelectiveNewsletterForm).from_params(data)
render plain: recipients_count_query
end
Expand Down
2 changes: 1 addition & 1 deletion decidim-admin/app/forms/decidim/admin/help_section_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class HelpSectionForm < Decidim::Form
include TranslationsHelper

attribute :id, String
translatable_attribute :content, String
translatable_attribute :content, Decidim::Attributes::RichText

def name
multi_translation("activerecord.models.#{manifest.model_class_name.underscore}.other")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ class OrganizationAppearanceForm < Form
attribute :alert_color, String

translatable_attribute :cta_button_text, String
translatable_attribute :description, String
translatable_attribute :description, Decidim::Attributes::RichText
translatable_attribute :highlighted_content_banner_title, String
translatable_attribute :highlighted_content_banner_short_description, String
translatable_attribute :highlighted_content_banner_short_description, Decidim::Attributes::RichText
translatable_attribute :highlighted_content_banner_action_title, String
translatable_attribute :highlighted_content_banner_action_subtitle, String
translatable_attribute :omnipresent_banner_title, String
Expand Down
4 changes: 2 additions & 2 deletions decidim-admin/app/forms/decidim/admin/organization_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class OrganizationForm < Form
attribute :customize_welcome_notification, Boolean

translatable_attribute :welcome_notification_subject, String
translatable_attribute :welcome_notification_body, String
translatable_attribute :welcome_notification_body, Decidim::Attributes::RichText

translatable_attribute :admin_terms_of_service_body, String
translatable_attribute :admin_terms_of_service_body, Decidim::Attributes::RichText

validates :welcome_notification_subject, :welcome_notification_body, translatable_presence: true, if: proc { |form| form.customize_welcome_notification }

Expand Down
2 changes: 1 addition & 1 deletion decidim-admin/app/forms/decidim/admin/static_page_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StaticPageForm < Form
attribute :slug, String
validates :title, translatable_presence: true
translatable_attribute :title, String
translatable_attribute :content, String
translatable_attribute :content, Decidim::Attributes::RichText
attribute :changed_notably, Boolean
attribute :show_in_footer, Boolean
attribute :allow_public_access, Boolean
Expand Down
27 changes: 18 additions & 9 deletions decidim-admin/app/packs/src/decidim/admin/newsletters.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ $(() => {
$participatorySpacesForSelect.hide();
}

$(".form .spaces-block-tag").each(function(_i, blockTag) {
$(".form .spaces-block-tag").each(function (_i, blockTag) {
const selectTag = $(blockTag).find(".chosen-select")
selectTag.change(function() {
selectTag.change(function () {
let optionSelected = selectTag.find("option:selected").val()
if (optionSelected === "all") {
selectTag.find("option").not(":first").prop("selected", true);
Expand All @@ -67,16 +67,25 @@ $(() => {
});
})

$form.on("change", function() {
let $data = $form.serializeJSON().newsletter;
let $url = $form.data("recipients-count-newsletter-path");
$form.on("change", function(event) {
let formData = new FormData(event.target.closest("form"));
let url = $form.data("recipients-count-newsletter-path");
const $modal = $("#recipients_count_spinner");
$modal.removeClass("hide");
$.get($url, {data: $data}, function(recipientsCount) {
$("#recipients_count").text(recipientsCount);
}).always(function() {

const xhr = new XMLHttpRequest();
xhr.open("POST", url, true);
xhr.onload = function() {
if (xhr.status === 200) {
$("#recipients_count").text(xhr.responseText);
}
$modal.addClass("hide");
});
};
xhr.onerror = function() {
$modal.addClass("hide");
};
// Send the form data
xhr.send(formData);
})
}
});
2 changes: 1 addition & 1 deletion decidim-admin/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

resources :newsletters, except: [:new, :create] do
member do
get :recipients_count
post :recipients_count
post :send_to_user
get :preview
get :select_recipients_to_deliver
Expand Down
33 changes: 33 additions & 0 deletions decidim-admin/spec/system/admin_manages_newsletters_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,24 @@ def select_all
expect(page).to have_content("5 / 5")
end
end

context "when the followers count varies" do
let!(:followers) do
deliverable_users.first(3).each do |follower|
create(:follow, followable: component.participatory_space, user: follower)
end
end

it "has a working user counter" do
visit decidim_admin.select_recipients_to_deliver_newsletter_path(newsletter)
expect(page).to have_content("This newsletter will be send to 5 users.")
uncheck("Send to all users")
uncheck("Send to participants")
check("Send to followers")
select_all
expect(page).to have_content("This newsletter will be send to 3 users.")
end
end
end

context "when participants are selected" do
Expand All @@ -264,6 +282,21 @@ def select_all
end
end

it "has a working user counter" do
visit decidim_admin.select_recipients_to_deliver_newsletter_path(newsletter)
expect(page).to have_content("This newsletter will be send to 5 users.")
uncheck("Send to all users")
uncheck("Send to followers")
check("Send to participants")

plural_name = assembly.model_name.route_key
within ".#{plural_name}-block" do
select translated(assembly.title), from: "newsletter_participatory_space_types_#{plural_name}__ids"
end

expect(page).to have_content("This newsletter will be send to 0 users.")
end

it "sends to participants", :slow do
visit decidim_admin.select_recipients_to_deliver_newsletter_path(newsletter)
perform_enqueued_jobs do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ class AssemblyForm < Form

mimic :assembly

translatable_attribute :composition, String
translatable_attribute :closing_date_reason, String
translatable_attribute :composition, Decidim::Attributes::RichText
translatable_attribute :closing_date_reason, Decidim::Attributes::RichText
translatable_attribute :created_by_other, String
translatable_attribute :description, String
translatable_attribute :description, Decidim::Attributes::RichText
translatable_attribute :developer_group, String
translatable_attribute :internal_organisation, String
translatable_attribute :internal_organisation, Decidim::Attributes::RichText
translatable_attribute :local_area, String
translatable_attribute :meta_scope, String
translatable_attribute :participatory_scope, String
translatable_attribute :participatory_structure, String
translatable_attribute :purpose_of_action, String
translatable_attribute :short_description, String
translatable_attribute :special_features, String
translatable_attribute :purpose_of_action, Decidim::Attributes::RichText
translatable_attribute :short_description, Decidim::Attributes::RichText
translatable_attribute :special_features, Decidim::Attributes::RichText
translatable_attribute :subtitle, String
translatable_attribute :target, String
translatable_attribute :title, String
translatable_attribute :announcement, String
translatable_attribute :announcement, Decidim::Attributes::RichText

attribute :created_by, String
attribute :facebook_handler, String
Expand Down
7 changes: 6 additions & 1 deletion decidim-assemblies/app/models/decidim/assembly.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ def self.log_presenter_class_for(_log)
Decidim::Assemblies::AdminLog::AssemblyPresenter
end

# This is a overwrite for Decidim::ParticipatorySpaceResourceable.visible?
def visible?
published? && (!private_space? || (private_space? && is_transparent?))
end

def hashtag
attributes["hashtag"].to_s.delete("#")
end
Expand Down Expand Up @@ -149,7 +154,7 @@ def closed?
end

def user_roles(role_name = nil)
roles = Decidim::AssemblyUserRole.where(assembly: self_and_ancestors)
roles = Decidim::AssemblyUserRole.order_by_name.where(assembly: self_and_ancestors)
return roles if role_name.blank?

roles.where(role: role_name)
Expand Down
12 changes: 12 additions & 0 deletions decidim-assemblies/spec/models/decidim/assembly_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ module Decidim
end
end

describe ".visible?" do
let!(:private_assembly) { create(:assembly, :private, :opaque) }
let!(:private_transparent_assembly) { create(:assembly, :private, :transparent) }
let!(:public_assembly) { create(:assembly, :public) }

it "returns the right visibility" do
expect(private_assembly).not_to be_visible
expect(private_transparent_assembly).to be_visible
expect(public_assembly).to be_visible
end
end

describe "scopes" do
describe "public_spaces" do
let!(:private_assembly) { create(:assembly, :private, :opaque) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module Decidim
subtitle: Decidim::Faker::Localized.name,
short_description: Decidim::Faker::Localized.sentence,
description: description1,
users: [author]
users: [author],
is_transparent: false
)
end
let(:participatory_space) { assembly }
Expand All @@ -42,6 +43,23 @@ module Decidim
}
}
end

context "when participatory_spaces ARE private but transparent" do
it "does NOT indexes a SearchableResource after ParticipatorySpace update" do
participatory_space.update(published_at: Time.current, private_space: true)
organization.available_locales.each do |locale|
searchables = Decidim::SearchableResource.where(resource_type: participatory_space.class.name, resource_id: participatory_space.id, locale:)
expect(searchables.size).to eq(0)
end

participatory_space.update(published_at: Time.current, private_space: true, is_transparent: true)
organization.available_locales.each do |locale|
searchables = Decidim::SearchableResource.where(resource_type: participatory_space.class.name, resource_id: participatory_space.id, locale:)
expect(searchables.size).to eq(1)
expect(searchables.first.content_a).to eq(I18n.transliterate(translated(participatory_space.title, locale:)))
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion decidim-blogs/app/forms/decidim/blogs/admin/post_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PostForm < Decidim::Form
include TranslatableAttributes

translatable_attribute :title, String
translatable_attribute :body, String
translatable_attribute :body, Decidim::Attributes::RichText

attribute :decidim_author_id, Integer
attribute :published_at, Decidim::Attributes::TimeWithZone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def proposals
end

def all_proposals
Decidim::Proposals::Proposal.where(component: origin_component).accepted
Decidim::Proposals::Proposal.where(component: origin_component)
.accepted.published.not_hidden.not_withdrawn.accepted.order(:published_at)
end

def origin_component
Expand All @@ -87,9 +88,13 @@ def proposal_already_copied?(original_proposal)
# because otherwise duplicates could be created until the component is
# published.
original_proposal.linked_resources(:projects, "included_proposals", component_published: false).any? do |project|
project.budget == form.budget
component_budgets.exists?(project.decidim_budgets_budget_id)
end
end

def component_budgets
@component_budgets ||= Decidim::Budgets::Budget.where(component: form.budget.component)
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class BudgetForm < Decidim::Form

translatable_attribute :title, String
attribute :weight, Integer, default: 0
translatable_attribute :description, String
translatable_attribute :description, Decidim::Attributes::RichText
attribute :total_budget, Integer, default: 0
attribute :decidim_scope_id, Integer

Expand Down
Loading

0 comments on commit f3b1252

Please sign in to comment.