Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 2.5.0: Merge develop #629

Merged
merged 10 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
SECRET_KEY_BASE=
GEOCODER_LOOKUP_API_KEY=
SENTRY_DSN=
HELP_SCOUT_BEACON_ID_MAIN=
BACKUP_ENABLED=
BACKUP_S3SYNC_ENABLED=
Expand Down Expand Up @@ -48,8 +47,6 @@ AVAILABLE_LOCALES="fr,en"
# Force SSL - binary (default: 1)
# Can be disable for reverse proxy setup
FORCE_SSL=1
SENTRY_SIDEKIQ_SAMPLE_RATE=0.1
SENTRY_SAMPLE_RATE=0.5
FRIENDLY_SIGNUP_OVERRIDE_PASSWORDS=1
FRIENDLY_SIGNUP_INSTANT_VALIDATION=1
FRIENDLY_SIGNUP_HIDE_NICKNAME=1
Expand Down Expand Up @@ -93,6 +90,9 @@ RAILS_LOG_LEVEL=warn
# SMS_GATEWAY_PASSWORD=
## Set to replace the organization name
# SMS_GATEWAY_PLATFORM="hashimoto.local"
## In case you're using Sendethics service
SMS_GATEWAY_MB_API_KEY=
SMS_GATEWAY_MB_ACCOUNT_ID=

#Timeout for the unsubscribe link of the newsletter
# NEWSLETTERS_UNSUBSCRIBE_TIMEOUT=
Expand Down
1 change: 0 additions & 1 deletion .overloads
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ config/initializers/filter_parameter_logging.rb
config/initializers/inflections.rb
config/initializers/mime_types.rb
config/initializers/new_framework_defaults_5_2.rb
config/initializers/sentry.rb
config/initializers/social_share_button.rb
config/initializers/wrap_parameters.rb
config/locales/decidim-awesome/fr.yml
Expand Down
2 changes: 2 additions & 0 deletions .rubocop_rails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Rails/SkipsModelValidations:
Enabled: true
Exclude:
- db/migrate/*.rb
- lib/extends/models/decidim/decidim_awesome/proposal_extra_field_extends.rb
- spec/lib/tasks/decidim_app/set_decrypted_private_body_task_spec.rb

Rails/Validation:
Include:
Expand Down
5 changes: 1 addition & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ gem "decidim-spam_detection", git: "https://github.com/OpenSourcePolitics/decidi
gem "decidim-survey_multiple_answers", git: "https://github.com/OpenSourcePolitics/decidim-module-survey_multiple_answers"
gem "decidim-term_customizer", git: "https://github.com/OpenSourcePolitics/decidim-module-term_customizer.git", branch: "fix/email_with_precompile"

gem "decidim-guest_meeting_registration", git: "https://github.com/alecslupu-pfa/guest-meeting-registration.git", branch: DECIDIM_BRANCH, ref: "532de9e"
gem "decidim-guest_meeting_registration", git: "https://github.com/alecslupu-pfa/guest-meeting-registration.git", branch: DECIDIM_BRANCH
# Omniauth gems
gem "omniauth-france_connect", git: "https://github.com/OpenSourcePolitics/omniauth-france_connect"
gem "omniauth_openid_connect"
Expand Down Expand Up @@ -86,9 +86,6 @@ group :production do
gem "health_check", "~> 3.1"
gem "lograge"
gem "sendgrid-ruby"
gem "sentry-rails"
gem "sentry-ruby"
gem "sentry-sidekiq"
gem "sidekiq", "~> 6.0"
gem "sidekiq-scheduler", "~> 5.0"
end
20 changes: 4 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ GIT

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module_phone_authorization_handler
revision: a3e77fb29e9a19793b3ff8b5d2273d41fac0919b
revision: 885122479e7fb9d8294dcf4c4d4f2d34e978b3c6
branch: release/0.27-stable
specs:
decidim-phone_authorization_handler (1.0.0)
Expand Down Expand Up @@ -153,8 +153,7 @@ GIT

GIT
remote: https://github.com/alecslupu-pfa/guest-meeting-registration.git
revision: 532de9e87ecb8b2959c0013c6408d4c092abce87
ref: 532de9e
revision: 7b3af0d34d053cc430080e483cd6d1e48dcc0f32
branch: release/0.27-stable
specs:
decidim-guest_meeting_registration (0.27.7)
Expand All @@ -164,7 +163,7 @@ GIT

GIT
remote: https://github.com/decidim-ice/decidim-module-decidim_awesome
revision: 51bc593da8fb72d14c2e5b5df55dbb686be1fbbe
revision: b9aae42bc835485edec5887cb02062caaaf64ed1
branch: release/0.27-stable
specs:
decidim-decidim_awesome (0.10.3)
Expand Down Expand Up @@ -1036,14 +1035,6 @@ GEM
semantic_range (3.0.0)
sendgrid-ruby (6.7.0)
ruby_http_client (~> 3.4)
sentry-rails (5.16.1)
railties (>= 5.0)
sentry-ruby (~> 5.16.1)
sentry-ruby (5.16.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
sentry-sidekiq (5.16.1)
sentry-ruby (~> 5.16.1)
sidekiq (>= 3.0)
seven_zip_ruby (1.3.0)
sidekiq (6.5.12)
connection_pool (>= 2.2.5, < 3)
Expand Down Expand Up @@ -1223,9 +1214,6 @@ DEPENDENCIES
rack-attack (~> 6.6)
rubocop-faker
sendgrid-ruby
sentry-rails
sentry-ruby
sentry-sidekiq
sidekiq (~> 6.0)
sidekiq-scheduler (~> 5.0)
spring (~> 2.0)
Expand All @@ -1238,4 +1226,4 @@ RUBY VERSION
ruby 3.0.6p216

BUNDLED WITH
2.4.6
2.5.10
3 changes: 1 addition & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"heroku-redis:hobby-dev",
"memcachedcloud:30",
"newrelic:wayne",
"sendgrid:starter",
"sentry:f1"
"sendgrid:starter"
],
"scripts": {
"postdeploy":"rake db:schema:load db:migrate"
Expand Down
11 changes: 8 additions & 3 deletions app/controllers/decidim/assemblies/assemblies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ def assembly_participatory_processes
@assembly_participatory_processes ||= @current_participatory_space.linked_participatory_space_resources(:participatory_processes, "included_participatory_processes")
else
@assembly_participatory_processes = @current_participatory_space.linked_participatory_space_resources(:participatory_processes, "included_participatory_processes")
@active_processes ||= @assembly_participatory_processes.select(&:active?)
sorted_by_date = {
active: @assembly_participatory_processes.active_spaces.sort_by(&:end_date),
future: @assembly_participatory_processes.future_spaces.sort_by(&:start_date),
past: @assembly_participatory_processes.past_spaces.sort_by(&:end_date).reverse
active: @active_processes.reject { |process| process.end_date.nil? }.sort_by(&:end_date) + processes_without_end_date(@active_processes),
future: @assembly_participatory_processes.upcoming.sort_by(&:start_date),
past: @assembly_participatory_processes.past.sort_by(&:end_date).reverse
}
@assembly_participatory_processes = sorted_by_date
end
Expand All @@ -101,6 +102,10 @@ def assembly_participatory_processes
def current_assemblies_settings
@current_assemblies_settings ||= Decidim::AssembliesSetting.find_or_create_by(decidim_organization_id: current_organization.id)
end

def processes_without_end_date(processes)
processes.select { |process| process.end_date.nil? }
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def linked_assemblies
def custom_sort(date)
case date
when "active"
@participatory_processes.sort_by(&:end_date)
@participatory_processes.reject { |process| process.end_date.nil? }.sort_by(&:end_date) + processes_without_end_date(@participatory_processes)
when "past"
@participatory_processes.sort_by(&:end_date).reverse
when "upcoming"
Expand All @@ -149,11 +149,16 @@ def custom_sort(date)
end

def sort_all_processes
actives = @participatory_processes.select(&:active?).sort_by(&:end_date)
@actives_processes ||= @participatory_processes.select(&:active?)
actives = @actives_processes.reject { |process| process.end_date.nil? }.sort_by(&:end_date) + processes_without_end_date(@actives_processes)
pasts = @participatory_processes.select(&:past?).sort_by(&:end_date).reverse
upcomings = @participatory_processes.select(&:upcoming?).sort_by(&:start_date)
(actives + upcomings + pasts)
end

def processes_without_end_date(processes)
processes.select { |process| process.end_date.nil? }
end
end
end
end
39 changes: 39 additions & 0 deletions app/jobs/active_storage_clear_orphans_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

class ActiveStorageClearOrphansJob < ApplicationJob
include ActionView::Helpers::NumberHelper
queue_as :default

def perform(**args)
limit = args[:limit] || 10_000
Rails.logger.info "Looking for orphan blobs in S3... (limit: #{limit})"
objects = ActiveStorage::Blob.service.bucket.objects
Rails.logger.info "Total files: #{objects.size}"

current_iteration = 0
sum = 0
orphans_count = 0
objects.each do |obj|
break if current_iteration >= limit

current_iteration += 1
next if ActiveStorage::Blob.exists?(key: obj.key)

sum += delete_object(obj)
orphans_count += 1
end

Rails.logger.info "Size: #{number_to_human_size(sum)} in #{orphans_count} files"
Rails.logger.info "Configuration limit is #{limit} files"
Rails.logger.info "Terminated task... "
end

private

def delete_object(obj)
Rails.logger.info "Removing orphan: #{obj.key}"
size = obj.size
obj.delete
size
end
end
18 changes: 18 additions & 0 deletions app/jobs/private_body_decrypt_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

class PrivateBodyDecryptJob < ApplicationJob
queue_as :default

def perform
extra_fields = Decidim::DecidimAwesome::ProposalExtraField.where(decrypted_private_body: nil).where.not(private_body: nil)
return unless extra_fields.any?

Rails.logger.info "Extra fields to update: #{extra_fields.size}"
count = 0
extra_fields.find_each do |extra_field|
extra_field.update(decrypted_private_body: extra_field.private_body.to_s)
count += 1 if extra_field.decrypted_private_body_previous_change.present?
end
Rails.logger.info "Extra fields updated: #{count}"
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
require("formBuilder/dist/form-builder.min.js")
import "src/decidim/decidim_awesome/forms/rich_text_plugin"

window.CustomFieldsBuilders = window.CustomFieldsBuilders || [];

$(() => {
$(".awesome-edit-config .proposal_custom_fields_editor").each((_idx, el) => {
const key = $(el).closest(".proposal_custom_fields_container").data("key");
const configVar = $(el).closest(".proposal_custom_fields_container").data("var");
// DOCS: https://formbuilder.online/docs
window.CustomFieldsBuilders.push({
el: el,
key: key,
var: configVar,
config: {
i18n: {
locale: "fr-FR",
location: "https://decidim.storage.opensourcepolitics.eu/osp-cdn/form_builder/1.1.0"
},
formData: $(`input[name="config[${configVar}][${key}]"]`).val(),
disableFields: ["button", "file"],
disabledActionButtons: ["save", "data", "clear"],
disabledAttrs: [
"access",
"inline",
"className"
],
controlOrder: [
"text",
"textarea",
"number",
"date",
"checkbox-group",
"radio-group",
"select",
"autocomplete",
"header",
"paragraph"
],
disabledSubtypes: {
// default color as it generate hashtags in decidim (TODO: fix hashtag generator with this)
text: ["color"],
// disable default wysiwyg editors as they present problems
textarea: ["tinymce", "quill"]
}
},
instance: null
});
});

$(document).on("formBuilder.create", (_event, idx, list) => {
if (!list[idx]) {
return;
}

$(list[idx].el).formBuilder(list[idx].config).promise.then(function(res) {
list[idx].instance = res;
// Attach to DOM
list[idx].el.FormBuilder = res;
// remove spinner
$(list[idx].el).find(".loading-spinner").remove();
// for external use
$(document).trigger("formBuilder.created", [list[idx]]);
if (idx < list.length) {
$(document).trigger("formBuilder.create", [idx + 1, list]);
}
});
});

if (window.CustomFieldsBuilders.length) {
$(document).trigger("formBuilder.create", [0, window.CustomFieldsBuilders]);
}

$("form.awesome-edit-config").on("submit", () => {
window.CustomFieldsBuilders.forEach((builder) => {
$(`input[name="config[${builder.var}][${builder.key}]"]`).val(builder.instance.actions.getData("json"));
});
});
});
Loading
Loading