Skip to content

Commit

Permalink
feat: Backport language selector and allow to modify notification sen…
Browse files Browse the repository at this point in the history
…ding frequency (#505)

* feat: Backport Extra User Fields account specs

* fix: Extra Signup Fields form account

* fix: Friendly Signup initializer

* fix: Add account specs

* feat: Disable locale selector in my account

* fix: Create registration spec

* ci: Add CA ES locales in CI

* fix: Add translations keys

* fix: Deprecated spe

* feat: Allow to modify default notification sending frequency
  • Loading branch information
Quentinchampenois authored Mar 8, 2024
1 parent 7bc1f00 commit b67b452
Show file tree
Hide file tree
Showing 12 changed files with 541 additions and 20 deletions.
3 changes: 3 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@ DECIDIM_ADMIN_PASSWORD_STRONG="false"
# VAPID_PUBLIC_KEY
# VAPID_PRIVATE_KEY
RAILS_LOG_LEVEL=warn

# Default notifications sending frequency : (daily, weekly, none, real_time)
# NOTIFICATIONS_SENDING_FREQUENCY=daily
4 changes: 2 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ env:
NODE_VERSION: 16.9.1
RUBYOPT: '-W:no-deprecated'
# Set locales available for i18n tasks
ENFORCED_LOCALES: "en,fr"
AVAILABLE_LOCALES: "en,fr"
ENFORCED_LOCALES: "en,fr,ca,es"
AVAILABLE_LOCALES: "en,fr,ca,es"

jobs:
todo:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gem "decidim-cache_cleaner"
gem "decidim-decidim_awesome"
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/PopulateTools/decidim-module-extra_user_fields.git", branch: "release/0.27-stable"
gem "decidim-extra_user_fields", git: "https://github.com/OpenSourcePolitics/decidim-module-extra_user_fields.git", branch: "release/0.27-stable"
gem "decidim-friendly_signup", git: "https://github.com/OpenSourcePolitics/decidim-module-friendly_signup.git"
gem "decidim-gallery", git: "https://github.com/OpenSourcePolitics/decidim-module-gallery.git", branch: "fix/nokogiri_deps"
gem "decidim-homepage_interactive_map", git: "https://github.com/OpenSourcePolitics/decidim-module-homepage_interactive_map.git", branch: DECIDIM_BRANCH
Expand Down
22 changes: 12 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ GIT
decidim-extended_socio_demographic_authorization_handler (0.27.0)
decidim-core (~> 0.27)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-extra_user_fields.git
revision: 0716b8d9e89db89ff3b182ad1bb63e92b952d39c
branch: release/0.27-stable
specs:
decidim-extra_user_fields (0.27.2)
country_select (~> 4.0)
decidim-core (>= 0.27.0, < 0.28)
deface (~> 1.5)

GIT
remote: https://github.com/OpenSourcePolitics/decidim-module-friendly_signup.git
revision: 1a054faf964cc6ed07f1bec47cb92f0083a5bcb4
Expand Down Expand Up @@ -84,16 +94,6 @@ GIT
omniauth (~> 2.0)
omniauth-oauth2 (>= 1.7.2, < 2.0)

GIT
remote: https://github.com/PopulateTools/decidim-module-extra_user_fields.git
revision: ef262d6619ef254de1379278f56c4c6af789e54c
branch: release/0.27-stable
specs:
decidim-extra_user_fields (0.27.2)
country_select (~> 4.0)
decidim-core (>= 0.27.0, < 0.28)
deface (~> 1.5)

GIT
remote: https://github.com/sgruhier/foundation_rails_helper.git
revision: bc33600db7a2d16ce3cdc1f8369d0d7e7c4245b5
Expand Down Expand Up @@ -721,6 +721,8 @@ GEM
nio4r (2.7.0)
nokogiri (1.13.4-arm64-darwin)
racc (~> 1.4)
nokogiri (1.13.4-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.13.4-x86_64-linux)
racc (~> 1.4)
oauth (1.1.0)
Expand Down
70 changes: 70 additions & 0 deletions app/views/decidim/account/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<%= alert_box("", "account-notification hide", true) %>
<% add_decidim_page_title(t("profile", scope: "layouts.decidim.user_menu")) %>
<% content_for(:subtitle) { t("profile", scope: "layouts.decidim.user_menu") } %>

<div class="row">
<%= decidim_form_for(@account, url: account_path, method: :put, html: { autocomplete: "on" }) do |f| %>
<div class="columns large-4">
<%= f.upload :avatar %>
</div>

<div class="columns large-8 end">
<% if current_user.unconfirmed_email.present? %>
<div id="email-change-pending" class="callout secondary">
<p><strong><%= t("decidim.account.email_change.title") %></strong></p>
<p><%= t("decidim.account.email_change.body1", unconfirmed_email: current_user.unconfirmed_email) %></p>
<p>
<%== t(
"decidim.account.email_change.body2",
resend_link: link_to(t("decidim.account.email_change.send_again"), resend_confirmation_instructions_account_path, role: :button, method: :post, remote: true),
cancel_link: link_to(t("decidim.account.email_change.cancel"), cancel_email_change_account_path, role: :button, method: :post, remote: true)) %>
</p>
</div>
<% end %>

<%= form_required_explanation %>

<%= f.text_field :name, autocomplete: "name" %>
<%= f.text_field :nickname, autocomplete: "nickname" %>
<%= f.email_field :email, disabled: current_user.unconfirmed_email.present?, autocomplete: "email" %>
<%= f.url_field :personal_url, autocomplete: "url" %>
<%= f.text_area :about, rows: 5 %>

<% if @account.organization.available_locales.size > 1 %>
<%= f.collection_select(
:locale,
@account.organization.available_locales,
:to_s,
->(locale) {locale_name(locale) }
) %>
<% else %>
<%= f.collection_select(
:locale,
@account.organization.available_locales,
:to_s,
->(locale) {locale_name(locale) },
{},
{ disabled: true }
)
%>
<% end %>

<p class="help-text"><%= t(".available_locales_helper") %></p>

<% if @account.errors[:password].any? || @account.errors[:password_confirmation].any? %>
<%= render partial: "password_fields", locals: { form: f } %>
<% else %>
<% if current_organization.sign_in_enabled? %>
<p>
<button type="button" data-toggle="passwordChange" class="link change-password"><%= t ".change_password" %></button>
</p>
<div id="passwordChange" class="toggle-show" data-toggler=".is-expanded">
<%= render partial: "password_fields", locals: { form: f } %>
</div>
<% end %>
<% end %>

<%= f.submit t(".update_account") %>
</div>
<% end %>
</div>
3 changes: 3 additions & 0 deletions config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ ignore_missing:
- decidim.admin.titles.initiatives
- decidim.admin.models.initiatives.fields.*
- decidim.admin.actions.configure
- decidim.account.email_change.*
- decidim.account.show.*
- layouts.decidim.user_menu.profile

# Consider these keys used:
ignore_unused:
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/decidim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
config.available_locales = ENV.fetch("AVAILABLE_LOCALES", "fr").split(",").map(&:to_sym)
else
config.default_locale = ENV.fetch("DEFAULT_LOCALE", "en").to_sym
config.available_locales = ENV.fetch("AVAILABLE_LOCALES", "en,fr").split(",").map(&:to_sym)
config.available_locales = ENV.fetch("AVAILABLE_LOCALES", "en,fr,ca,es").split(",").map(&:to_sym)
end

# Timeout session
Expand Down
2 changes: 2 additions & 0 deletions config/initializers/friendly_signup.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

return unless defined?(Decidim::FriendlySignup)

Decidim::FriendlySignup.configure do |config|
# Override password views or leave the originals (default is true):
config.override_passwords = ENV.fetch("FRIENDLY_SIGNUP_OVERRIDE_PASSWORDS", "1") == "1"
Expand Down
1 change: 1 addition & 0 deletions spec/commands/decidim/create_registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ module Comments
expect(User).to receive(:create!).with(
name: form.name,
nickname: form.nickname,
notifications_sending_frequency: "daily",
email: form.email,
password: form.password,
password_confirmation: form.password_confirmation,
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/decidim_app/k8s/organization_exporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
it "returns the organization columns" do
expect(subject.organization_columns).to eq({
"available_authorizations" => [],
"available_locales" => %w(en fr),
"available_locales" => %w(en fr ca es),
"default_locale" => "en",
"file_upload_settings" => {
"allowed_content_types" => {
Expand Down
Loading

0 comments on commit b67b452

Please sign in to comment.