Skip to content

Commit

Permalink
Release 2.5.1 (#642)
Browse files Browse the repository at this point in the history
* fix: Add block reported user task (#614)

* backport: remove sentry (#622)

* bump: Module Spam Detection to 4.1.2 (#630)

* bump: Fix geocofing on homepage interactive map (#635)

* feat: Add module emitter (#633)

* feat: Addition of the emitter module

* fix: Fix failing specs

* Fix/backport decidim awesome slowness on proposals index page (#631)

* add env variable

* add UUID and IP to logs

* add weighted voting configuration

* add secrets for weighted voting

* update test to fix CI

* continue fix test file

* fix CI

* fix CI

* clean spec

* clean and add test

* backport: Addition of sortable scopes using drag and drop  (#632)

* backport: Backport the Drag & Drop on Scopes on BackOffice

* fix: Fix locales that were not normalized or misplaced

* test: Add some specs about the check_boxes_tree_helper sort

* test: Add specs releated to the backport scopes management

* fix: Fix wrong locales

* fix: Add the weight sorting on select input of scopes

* fix: Add missing locale

* feat: Allow to choose notification settings when attachment added (#627)

* fix: Override Create attachment admin command

* fix: Force email notification on attachment event

* fix: Override attachment form

* feat: Allow admins to toggle notification sending

* refactor: Remove override and add extend

* lint: Fix rubocop offenses

---------

Co-authored-by: Lucie Grau <[email protected]>

* fix: Remove caching from the geocoding elements to avoid map not reloading when refreshing (#638)

* backport: Reorder scopes in meetings (#639)

* fix: Scopes can't be updated in BO (#640)

Co-authored-by: Lucie Grau <[email protected]>

* backport: Add layer of security and download p7zip-full lib on docker (#643)

* bump: Bump custom proposal states (#599)

* Feat: custom sort for processes (#596)

* feat: add custom sort for processesdepending on new variable

* feat: update locales files

* feat: update seeds

* test: add controller tests for assemblies and processes

* chore: update i18n config for unused keys

* docs: update overrides

* refactor: update env variable after review

* Fix form initiatives (#600)

* fix: XSS vulnerability with img on initiative form and model

* test: add tests for new validation

* docs: update overrides section

* fix: interference from added extends with migration

* style: update with rubocop

* fix: ActiveRecord::NoDatabaseError

* fix: trying to fix again interference

* fix: update initiative fomr extends and modify admin initiative controller

* refactor: update with rubocop

* fix: validation in initiative_form extends and update test

* docs: update overrides section in overloads.md

* fix: Update OVERLOADS.md

---------

Co-authored-by: Quentin Champenois <[email protected]>

* bump: Decidim-Awesome to last commit (#607)

* feat: Bump decidim-awesome to last commit

* fix: Fix migration that has been changed since first implementation

* fix: Add Referrer-Policy to strict (#613)

* fix: Flash message on proposal limit per user reached (#609)

* fix error message displaying when reaching proposition add limit

* add test

* add keys in ignore_missing keys

* fix: Add block reported user task (#614)

* feat: Add module decidim-cleaner (#597)

* feat: Add decidim-cleaner

* refactor: Comment env var by default

---------

Co-authored-by: Quentin Champenois <[email protected]>

* Install GuestMeetingRegistration module (#615)

* Install GuestMeetingRegistration module

* Update registration module

* feat: Add Sendethics possibility to the sms gateway (#605)

Co-authored-by: Lucie Grau <[email protected]>

* Bump: Phone authorization handler module (#623)

* backport: remove sentry (#622)

* backport: Use cdn (#624)

* backport: self hosted cdn

* backport: update js files content

* fix: Missing image in survey question (#621)

* fix: update condition to not empty input value if image is present

* test: add system test to check for input value

* test: update check for image

* test: update img check again

* test: last update check img

* test: update

* test: another update

* test: if img is present

* test: update other test to avoid ambiguous selector error

* test: update to see if image is presnet after save

* fix: override editor js in decidim_awesome

* test: update system test

* fix: Questions order in survey export (#618)

* chore: update after pull

* fix: order questions by position in serializer

* test: add test for question order

* refactor: update test

* style: remove empty line

* bump: Guest meeting registration module (#625)

* Bump: Guest meeting registration module

* refactor(Gemfile): Remove ref reference in Gemfile

---------

Co-authored-by: Quentin Champenois <[email protected]>

* feat: add decypted private body to extra fields (#608)

* feat: add new column to proposal extra fields

* feat: add callback to proposal extra field model

* test: add test for proposal extra field model

* feat: add rake task to update existing data

* test: add test for new rake task

* feat: add proposal extra field model extends to config

* chore: update rubocop rules

* refactor: update task and test

* create the job file

* update rake task

* lint code

* add tests file

* fix rspec

* clean double specs

* update spec

* update spec

* update syntax test with a context instade of only 'it'

* lint code by removing useless line in job spec file

* update spec

* add more context in spec file

* lint code

* update rake tasks test

---------

Co-authored-by: barbara oliveira <[email protected]>
Co-authored-by: Lucie Grau <[email protected]>
Co-authored-by: Quentin Champenois <[email protected]>

* feat: Clear minio s3 bucket (#612)

* feat(Docker): Add minio service

* feat(rake): Add new tasks to cleanup s3 bucket

* fix: Add S3 purge rake task

* fix: S3 Bucket endpoint for docker local

* fix(rake): Active storage clear orphans job

* fix(sidekiq): Add sidekiq configuration

* fix: Logger for active_storage.rake job

* fix: Prevent duplicated ActiveRecord Query

* fix: Prevent error on PP sort with end_date nil (#626)

* fix: update to handle processes without start_date or end_date

* fix: update sort in controllers

* test: update test with process without end date

* refactor: optimize queries in controllers and update tests

* refactor: update sort processes in controllers

---------

Co-authored-by: Lucie Grau <[email protected]>

* bump: Module Spam Detection to 4.1.2 (#630)

* feat: Author notification on proposal publication  (#620)

* add notification with eventmanager

* base to watch the CI and see files on github

* fix translation key & notififaction displaying

* add send_pubication_notification to right file

* start test rspec

* continuing rspec

* potential final test file

* fix: Merge proposal command and anonymous proposals

* fix: Change ProposalPublishedEvent to SimpleEvent

* fix: Proposal Published Event

* fix: Push FR locales

* test: Add specs for proposal_published_event

* update methode & file name

* adjust trad key

* adjust test file & update name of test file

* lint

* lint fr trad key

* lint

* update trad key order

* lint

* correct trad key link in method

* correst rspec

* fix rspec

* fix: Notification small title

* lint(rubocop): Fix offenses

* ci: Exclude BeEq Rubocop rule

* clean

* fix CI

* delete test file

* add ignore trad key in i118n-tasks.yml to fix CI

* update text syntaxe via trad key

* add '' in fr trad key

---------

Co-authored-by: Quentin Champenois <[email protected]>

* revert: "fix: Flash message on proposal limit per user reached (#609)" (#634)

This reverts commit 28003b5.

* bump: Fix geocofing on homepage interactive map (#635)

* feat: Add module emitter (#633)

* feat: Addition of the emitter module

* fix: Fix failing specs

* Fix/backport decidim awesome slowness on proposals index page (#631)

* add env variable

* add UUID and IP to logs

* add weighted voting configuration

* add secrets for weighted voting

* update test to fix CI

* continue fix test file

* fix CI

* fix CI

* clean spec

* clean and add test

* backport: Addition of sortable scopes using drag and drop  (#632)

* backport: Backport the Drag & Drop on Scopes on BackOffice

* fix: Fix locales that were not normalized or misplaced

* test: Add some specs about the check_boxes_tree_helper sort

* test: Add specs releated to the backport scopes management

* fix: Fix wrong locales

* fix: Add the weight sorting on select input of scopes

* fix: Add missing locale

* feat: Allow to choose notification settings when attachment added (#627)

* fix: Override Create attachment admin command

* fix: Force email notification on attachment event

* fix: Override attachment form

* feat: Allow admins to toggle notification sending

* refactor: Remove override and add extend

* lint: Fix rubocop offenses

---------

Co-authored-by: Lucie Grau <[email protected]>

* fix: Remove caching from the geocoding elements to avoid map not reloading when refreshing (#638)

* backport: Reorder scopes in meetings (#639)

* fix: Scopes can't be updated in BO (#640)

Co-authored-by: Lucie Grau <[email protected]>

* backport: Add layer of security and download p7zip-full lib on docker

---------

Co-authored-by: stephanierousset <[email protected]>
Co-authored-by: Quentin Champenois <[email protected]>
Co-authored-by: ’Barbara Oliveira <[email protected]>
Co-authored-by: Quentin Champenois <[email protected]>
Co-authored-by: Alexandru Emil Lupu <[email protected]>
Co-authored-by: Lucie Grau <[email protected]>
Co-authored-by: barbara oliveira <[email protected]>

---------

Co-authored-by: Quentin Champenois <[email protected]>
Co-authored-by: stephanierousset <[email protected]>
Co-authored-by: Guillaume MORET <[email protected]>
Co-authored-by: ’Barbara Oliveira <[email protected]>
Co-authored-by: Quentin Champenois <[email protected]>
Co-authored-by: Alexandru Emil Lupu <[email protected]>
Co-authored-by: barbara oliveira <[email protected]>
  • Loading branch information
8 people authored Dec 2, 2024
1 parent e48362d commit be5f07d
Show file tree
Hide file tree
Showing 46 changed files with 2,129 additions and 75 deletions.
4 changes: 3 additions & 1 deletion .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ DECIDIM_ADMIN_PASSWORD_STRONG="false"
## Generate values with: bin/rails decidim:pwa:generate_vapid_keys
# VAPID_PUBLIC_KEY
# VAPID_PRIVATE_KEY
RAILS_LOG_LEVEL=warn
# RAILS_LOG_LEVEL=warn

# DECIDIM_AWESOME_WEIGHTED_PROPOSAL_VOTING_ENABLED=disabled # or enabled

# Default notifications sending frequency : (daily, weekly, none, real_time)
# NOTIFICATIONS_SENDING_FREQUENCY=daily
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ENV RAILS_ENV=production \
WORKDIR /app

RUN apt-get update && \
apt-get -y install libpq-dev curl git libicu-dev build-essential && \
apt-get -y install libpq-dev curl git libicu-dev build-essential p7zip-full && \
curl https://deb.nodesource.com/setup_16.x | bash && \
apt-get install -y nodejs && \
npm install --global yarn && \
Expand Down Expand Up @@ -41,7 +41,7 @@ ENV RAILS_ENV=production \
RAILS_LOG_TO_STDOUT=true

RUN apt update && \
apt install -y postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 && \
apt install -y postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 p7zip-full && \
gem install bundler:2.4.9

WORKDIR /app
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.local
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ENV RAILS_ENV=production \
# Install common dependencies
RUN apt-get update -q && \
apt-get install -yq --no-install-recommends \
libpq-dev curl git libicu-dev build-essential openssl && \
libpq-dev curl git libicu-dev build-essential openssl p7zip-full && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand Down Expand Up @@ -66,7 +66,7 @@ WORKDIR /app
# Install runtime dependencies
RUN apt-get update -q && \
apt-get install -yq --no-install-recommends \
postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 && \
postgresql-client imagemagick libproj-dev proj-bin libjemalloc2 p7zip-full && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ gem "decidim-category_enhanced", "~> 0.0.1"
gem "decidim-cleaner"
gem "decidim-custom_proposal_states", git: "https://github.com/alecslupu-pfa/decidim-module-custom_proposal_states", branch: DECIDIM_BRANCH
gem "decidim-decidim_awesome", git: "https://github.com/decidim-ice/decidim-module-decidim_awesome", branch: DECIDIM_BRANCH
gem "decidim-emitter", git: "https://github.com/OpenSourcePolitics/decidim-module-emitter.git"
gem "decidim-extended_socio_demographic_authorization_handler", git: "https://github.com/OpenSourcePolitics/decidim-module-extended_socio_demographic_authorization_handler.git",
branch: DECIDIM_BRANCH
gem "decidim-extra_user_fields", git: "https://github.com/OpenSourcePolitics/decidim-module-extra_user_fields.git", branch: "temp/twilio-compatibility-0.27"
Expand Down
13 changes: 11 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ GIT
decidim-core (>= 0.27.0)
deface (~> 1.5)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-emitter.git
revision: 8633ea56b422eecfe7d8730c89f191387f860e55
specs:
decidim-emitter (0.1.0)
decidim-core (~> 0.27.0)
decidim-participatory_processes (~> 0.27.0)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-extended_socio_demographic_authorization_handler.git
revision: adec5e66cd07b5e5fdce5562453a7e8d6de88013
Expand Down Expand Up @@ -52,10 +60,10 @@ GIT

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-homepage_interactive_map.git
revision: dd685166fdf953a11bd6a9e0dac56feca3bd0708
revision: 1ff222533cb3e7c30c8112a56c09c217c0530dbc
branch: release/0.27-stable
specs:
decidim-homepage_interactive_map (2.0.0)
decidim-homepage_interactive_map (2.0.1)
decidim-admin (>= 0.25.0, < 0.28)
decidim-core (>= 0.25.0, < 0.28)
decidim-dev (>= 0.25.0, < 0.28)
Expand Down Expand Up @@ -1179,6 +1187,7 @@ DEPENDENCIES
decidim-custom_proposal_states!
decidim-decidim_awesome!
decidim-dev (~> 0.27.0)
decidim-emitter!
decidim-extended_socio_demographic_authorization_handler!
decidim-extra_user_fields!
decidim-friendly_signup!
Expand Down
37 changes: 37 additions & 0 deletions app/commands/admin/reorder_scopes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# frozen_string_literal: true

module Admin
class ReorderScopes < Decidim::Command
def initialize(organization, scope, ids)
@organization = organization
@scope = scope
@ids = ids
end

def call
return broadcast(:invalid) if @ids.blank?

reorder_scopes
broadcast(:ok)
end

def collection
@collection ||= Decidim::Scope.where(id: @ids, organization: @organization)
end

def reorder_scopes
transaction do
set_new_weights
end
end

def set_new_weights
@ids.each do |id|
current_scope = collection.find { |block| block.id == id.to_i }
next if current_scope.blank?

current_scope.update!(weight: @ids.index(id) + 1)
end
end
end
end
44 changes: 44 additions & 0 deletions app/forms/decidim/admin/attachment_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# frozen_string_literal: true

module Decidim
module Admin
# A form object used to create attachments in a participatory process.
#
class AttachmentForm < Form
include TranslatableAttributes

attribute :file
translatable_attribute :title, String
translatable_attribute :description, String
attribute :weight, Integer, default: 0
attribute :attachment_collection_id, Integer
attribute :send_notification_to_followers, Boolean, default: false

mimic :attachment

validates :file, presence: true, unless: :persisted?
validates :file, passthru: { to: Decidim::Attachment }
validates :title, :description, translatable_presence: true
validates :attachment_collection, presence: true, if: ->(form) { form.attachment_collection_id.present? }
validates :attachment_collection_id, inclusion: { in: :attachment_collection_ids }, allow_blank: true

delegate :attached_to, to: :context, prefix: false

alias organization current_organization

def attachment_collections
@attachment_collections ||= attached_to.attachment_collections
end

def attachment_collection
@attachment_collection ||= attachment_collections.find_by(id: attachment_collection_id)
end

private

def attachment_collection_ids
@attachment_collection_ids ||= attachment_collections.pluck(:id)
end
end
end
end
25 changes: 25 additions & 0 deletions app/forms/decidim/user_interest_scope_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

module Decidim
# The form object that handles the data behind updating a user's
# interests in their profile page.
class UserInterestScopeForm < Form
mimic :scope

attribute :name, JsonbAttributes
attribute :checked, Boolean
attribute :children, Array[UserInterestScopeForm]

def map_model(model_hash)
scope = model_hash[:scope]
user = model_hash[:user]

self.id = scope.id
self.name = scope.name
self.checked = user.interested_scopes_ids.include?(scope.id)
self.children = scope.children.sort_by(&:weight).map do |children_scope|
UserInterestScopeForm.from_model(scope: children_scope, user: user)
end
end
end
end
23 changes: 23 additions & 0 deletions app/forms/decidim/user_interests_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module Decidim
# The form object that handles the data behind updating a user's
# interests in their profile page.
class UserInterestsForm < Form
mimic :user

attribute :scopes, Array[UserInterestScopeForm]

def newsletter_notifications_at
return unless newsletter_notifications

Time.current
end

def map_model(user)
self.scopes = user.organization.scopes.top_level.sort_by(&:weight).map do |scope|
UserInterestScopeForm.from_model(scope: scope, user: user)
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# frozen_string_literal: true

module Decidim
module SimpleProposal
module ScopesHelperOverride
extend ActiveSupport::Concern
included do
def scopes_picker_field(form, name, root: false, options: { checkboxes_on_top: true })
options.merge!(selected: selected_scope(form)) if selected_scope(form)
form.select(name, simple_scope_options(root: root, options: options), include_blank: t("decidim.scopes.prompt"))
end

private

def selected_scope(form)
form.try(:scope_id) ||
form.try(:settings).try(:scope_id) ||
form.try(:object).try(:scope_id) ||
form.try(:object).try(:decidim_scope_id)
end

def simple_scope_options(root: false, options: {})
scopes_array = []
roots = root ? root.children : ancestors
roots.sort_by { |ancestor| ancestor.weight || 0 }.each do |ancestor|
children_after_parent(ancestor, scopes_array, "")
end
selected = options.has_key?(:selected) ? options[:selected] : params.dig(:filter, :decidim_scope_id)
options_for_select(scopes_array, selected)
end

def ancestors
@ancestors ||= current_organization.scopes.where(parent_id: nil)
end

def children_after_parent(ancestor, array, prefix)
array << ["#{prefix} #{translated_attribute(ancestor.name)}", ancestor.id]
ancestor.children.sort_by { |child| child.weight || 0 }.each do |child|
children_after_parent(child, array, "#{prefix}-")
end
end
end
end
end
end
2 changes: 2 additions & 0 deletions app/packs/entrypoints/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
// Activate Active Storage
// import * as ActiveStorage from "@rails/activestorage"
// ActiveStorage.start()

import "src/decidim/admin/reorder_scopes";
1 change: 1 addition & 0 deletions app/packs/entrypoints/decidim_custom_scopes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "stylesheets/decidim/scopes/scopes-custom.scss";
19 changes: 19 additions & 0 deletions app/packs/src/decidim/admin/reorder_scopes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
$(document).ready(() => {
let activeBlocks = Array.prototype.slice.call(document.querySelectorAll(".js-list-scopes li"));
const defaultOrder = activeBlocks.map(block => block.dataset.scopeId);

document.addEventListener("dragend", () => {
activeBlocks = Array.prototype.slice.call(document.querySelectorAll(".js-list-scopes li"));
let activeBlocksManifestName = activeBlocks.map(block => block.dataset.scopeId);
let sortUrl = document.querySelector(".js-list-scopes").dataset.sortUrl;

if (JSON.stringify(activeBlocksManifestName) === JSON.stringify(defaultOrder)) { return; }

$.ajax({
method: "PUT",
url: sortUrl,
contentType: "application/json",
data: JSON.stringify({ manifests: activeBlocksManifestName })
});
})
});
18 changes: 18 additions & 0 deletions app/packs/stylesheets/decidim/scopes/_scopes-custom.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.draggable-list .draggable-content {
cursor: move;
justify-content: space-between;
align-items: center;
font-weight: 600;
border: none !important;
background-color: transparent !important;
padding: 0.5rem 1rem;
}

.custom-text {
color: black;
}

.custom-list {
border: 1px solid lightgray !important;
margin: 0.4rem
}
8 changes: 6 additions & 2 deletions app/services/decidim/download_your_data_exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def export
save_user_data(tmpdir, user_data)
save_user_attachments(tmpdir, user_attachments)

SevenZipWrapper.compress_and_encrypt(filename: @path, password: @password, input_directory: tmpdir)
Decidim::SevenZipWrapper.compress_and_encrypt(filename: @path, password: @password, input_directory: tmpdir)
end

private
Expand Down Expand Up @@ -59,6 +59,9 @@ def save_user_data(tmpdir, user_data)
next if exporter_data.read == "\n"

file_name = File.join(tmpdir, "#{entity}-#{exporter_data.filename}")

dir_path = File.dirname(file_name)
FileUtils.mkdir_p(dir_path) unless Dir.exist?(dir_path)
File.write(file_name, exporter_data.read)
end
end
Expand All @@ -70,7 +73,8 @@ def save_user_attachments(tmpdir, user_attachments)

blobs = attachment.is_a?(ActiveStorage::Attached::One) ? [attachment.blob] : attachment.blobs
blobs.each do |blob|
Dir.mkdir(File.join(tmpdir, entity.parameterize))
dir_path = File.join(tmpdir, entity.parameterize)
Dir.mkdir(dir_path) unless Dir.exist?(dir_path)
file_name = File.join(tmpdir, entity.parameterize, blob.filename.to_s)
blob.open do |blob_file|
File.write(file_name, blob_file.read.force_encoding("UTF-8"))
Expand Down
33 changes: 33 additions & 0 deletions app/views/decidim/admin/attachments/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<div class="card">
<div class="card-divider">
<h2 class="card-title">
<%= title %>
</h2>
</div>

<div class="card-section">
<div class="row column">
<%= form.translated :text_field, :title, autofocus: true %>
</div>

<div class="row column">
<%= form.number_field :weight %>
</div>

<div class="row column">
<%= form.translated :text_field, :description %>
</div>

<div class="row column">
<%= form.select :attachment_collection_id, @form.attachment_collections.collect { |c| [translated_attribute(c.name), c.id] }, include_blank: true %>
</div>

<div class="row column">
<%= form.upload :file, required: true %>
</div>

<div class="row column">
<%= form.check_box :send_notification_to_followers, label: t(".send_notification_to_followers") %>
</div>
</div>
</div>
Loading

0 comments on commit be5f07d

Please sign in to comment.