Skip to content

Commit

Permalink
update login customization
Browse files Browse the repository at this point in the history
  • Loading branch information
microstudi committed Oct 8, 2024
1 parent ffebc2c commit 83267c3
Show file tree
Hide file tree
Showing 119 changed files with 398 additions and 353 deletions.
8 changes: 8 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
inherit_gem:
decidim-dev: rubocop-decidim.yml

AllCops:
Exclude:
- 'db/**/*'

RSpec/DescribeClass:
Exclude:
- 'spec/system/**/*'
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ gem "decidim-term_customizer", github: "mainio/decidim-module-term_customizer",
gem "bootsnap", "~> 1.7"
gem "deepl-rb", require: "deepl"
gem "deface"
gem "health_check"
gem "puma"
gem "wicked_pdf", "~> 2.1"
gem "health_check"

group :development, :test do
gem "byebug", "~> 11.0", platform: :mri
Expand Down
30 changes: 7 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -429,16 +429,7 @@ GEM
logger
faraday-net_http (3.3.0)
net-http
ffi (1.17.0-aarch64-linux-gnu)
ffi (1.17.0-aarch64-linux-musl)
ffi (1.17.0-arm-linux-gnu)
ffi (1.17.0-arm-linux-musl)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86-linux-gnu)
ffi (1.17.0-x86-linux-musl)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.0-x86_64-linux-musl)
ffi (1.17.0)
file_validators (3.0.0)
activemodel (>= 3.2)
mime-types (>= 1.0)
Expand Down Expand Up @@ -761,27 +752,20 @@ GEM
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
rubocop-capybara (2.21.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.26.0)
rubocop-ast (1.28.1)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop (~> 1.41)
rubocop-faker (1.1.0)
faker (>= 2.12.0)
rubocop (>= 0.82.0)
rubocop-rails (2.25.1)
rubocop-rails (2.19.1)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
rubocop-rspec (2.31.0)
rubocop (~> 1.40)
rubocop-rspec (2.20.0)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-rspec_rails (~> 2.28)
rubocop-rspec_rails (2.29.0)
rubocop (~> 1.40)
ruby-progressbar (1.13.0)
ruby-vips (2.2.2)
ffi (~> 1.12)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/invites_controller_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module InvitesControllerOverride
extend ActiveSupport::Concern

included do
before_action :ensure_external_invites_allowed, only: :create
before_action :ensure_external_invites_allowed, only: :create # rubocop:disable Rails/LexicallyScopedActionFilter:

def ensure_external_invites_allowed
return unless Rails.application.secrets.dig(:gpc, :disable_external_invites)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ module OmniauthRegistrationsControllerOverride
extend ActiveSupport::Concern

included do
before_action :ensure_user_exists, only: :google_oauth2
before_action :ensure_user_exists, only: :google_oauth2 # rubocop:disable Rails/LexicallyScopedActionFilter:

# if oauth via google is active, we don't want people to register if disabled in system (this is probably a bug in decidim)
def ensure_user_exists
form_params = user_params_from_oauth_hash || params[:user]
@form = form(Decidim::OmniauthRegistrationForm).from_params(form_params)
email = @form.email || verified_email

return if email.present? && Decidim::User.exists?(email: email, organization: current_organization)
return if email.present? && Decidim::User.exists?(email:, organization: current_organization)

# No registration allowed
Rails.logger.info "WARNING: Attempt to register via OAuth: #{email}"
flash[:alert] = I18n.t("email_not_registered", email: email)
flash[:alert] = I18n.t("email_not_registered", email:)
redirect_to decidim.root_path
end

Expand Down
34 changes: 17 additions & 17 deletions app/controllers/concerns/proposals_controller_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
module ProposalsControllerOverride
extend ActiveSupport::Concern

included do
before_action only: [:index] do
session[:proposals_filter_default_type] = params.dig(:filter, :type) if params.dig(:filter, :type).present?
end
# included do
# before_action only: [:index] do
# session[:proposals_filter_default_type] = params.dig(:filter, :type) if params.dig(:filter, :type).present?
# end

def default_filter_params
{
search_text_cont: "",
with_any_origin: default_filter_origin_params,
activity: "all",
with_any_category: default_filter_category_params,
with_any_state: %w(accepted evaluating state_not_published),
with_any_scope: default_filter_scope_params,
related_to: "",
type: session[:proposals_filter_default_type] || "proposals"
}
end
end
# def default_filter_params
# {
# search_text_cont: "",
# with_any_origin: default_filter_origin_params,
# activity: "all",
# with_any_category: default_filter_category_params,
# with_any_state: %w(accepted evaluating state_not_published),
# with_any_scope: default_filter_scope_params,
# related_to: "",
# type: session[:proposals_filter_default_type] || "proposals"
# }
# end
# end
end
2 changes: 1 addition & 1 deletion app/events/decidim/amendable/ready_accepted_event.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen-string_literal: true
# frozen_string_literal: true

module Decidim::Amendable
class ReadyAcceptedEvent < Decidim::Amendable::AmendmentBaseEvent
Expand Down
2 changes: 1 addition & 1 deletion app/events/decidim/amendable/ready_rejected_event.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen-string_literal: true
# frozen_string_literal: true

module Decidim::Amendable
class ReadyRejectedEvent < Decidim::Amendable::AmendmentBaseEvent
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/concerns/card_helper_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def card_for(model, options = {})
# elsif model.is_a?(Decidim::Meetings::Meeting) && leadership_assembly?(model.try(:participatory_space))
# cell "leadership_meeting_m", model
# else
cell "decidim/card", model, options
cell "decidim/card", model, options
# end
end
end
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/concerns/layout_helper_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def extended_navigation_bar(items, max_items: Rails.application.secrets.gpc[:sub
active_item = items.find { |item| item[:active] }

controller.view_context.render partial: "decidim/shared/extended_navigation_bar", locals: {
items: items,
extra_items: extra_items,
active_item: active_item,
max_items: max_items
items:,
extra_items:,
active_item:,
max_items:
}
end
end
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<!-- set_attributes '.columns.large-6.medium-centered > .card'
attributes :class => 'card login_box hide' -->
<!-- set_attributes '.form__wrapper'
attributes :class => 'form__wrapper login_toggle !hidden'
-->
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- replace 'erb[loud]:contains("devise.shared.links.sign_in_with_provider")' -->
<!-- replace "span>erb[loud]:contains('normalize_provider_name(provider).titleize')" -->

<% if provider == :civicrm %>
<%= t("gpc.login.sign_in_civicrm") %>
<% else %>
<%= t("devise.shared.links.sign_in_with_provider", provider: normalize_provider_name(provider).titleize) %>
<%= normalize_provider_name(provider).titleize %>
<% end %>

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<!-- insert_after 'erb[loud]:contains("decidim/devise/shared/omniauth_buttons_mini")' -->
<!-- insert_before ".form__wrapper" -->

<div class="row">
<div class="columns large-8 large-centered">
<%= button_tag t("gpc.login.admin_login"), class: "button expanded hollow", onclick: "$('.login_box').toggleClass('hide');$(this).toggleClass('hollow');" %>
</div>
<div class="flex justify-center mt-10">
<%= button_tag t("gpc.login.admin_login"), type: "button", class: "button button__xs button__transparent-primary", onclick: "$('.login_toggle').toggleClass('!hidden');return false;" %>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<!-- set_attributes '.columns.medium-8.medium-centered'
attributes :class => 'columns medium-8 medium-centered login_box hide'
<!-- set_attributes '.form__wrapper'
attributes :class => 'form__wrapper login_toggle !hidden'
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- set_attributes '.login__modal-links'
attributes :class => 'login__modal-links login_toggle !hidden'
-->
2 changes: 1 addition & 1 deletion app/services/deepl_translator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(resource, field_name, text, target_locale, source_locale)
end

def translate
translation = DeepL.translate text, source_locale, target_locale, tag_handling: tag_handling
translation = DeepL.translate(text, source_locale, target_locale, tag_handling:)

Decidim::MachineTranslationSaveJob.perform_later(
resource,
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/decidim/_head_extra.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
})();
</script>
<!-- End Matomo Code -->
<% end %>
<% end %>
2 changes: 2 additions & 0 deletions bin/rails
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

load File.expand_path("spring", __dir__)
APP_PATH = File.expand_path("../config/application", __dir__)
require_relative "../config/boot"
Expand Down
2 changes: 2 additions & 0 deletions bin/rake
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

load File.expand_path("spring", __dir__)
require_relative "../config/boot"
require "rake"
Expand Down
2 changes: 2 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "fileutils"

# path to your application root.
Expand Down
3 changes: 2 additions & 1 deletion bin/shakapacker
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV["RAILS_ENV"] ||= "development"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup"

Expand Down
3 changes: 2 additions & 1 deletion bin/shakapacker-dev-server
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

ENV["RAILS_ENV"] ||= "development"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)

require "bundler/setup"

Expand Down
3 changes: 2 additions & 1 deletion bin/spring
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# This file loads Spring without loading other gems in the Gemfile in order to be fast.
# It gets overwritten when you run the `spring binstub` command.

if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
if !defined?(Spring) && [nil, "development", "test"].include?(ENV.fetch("RAILS_ENV", nil))
require "bundler"

Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring|
Expand Down
1 change: 0 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
config.active_record.verbose_query_logs = true

# Suppress logger output for asset requests.


# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
Expand Down
6 changes: 3 additions & 3 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@

# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
config.ssl_options = { redirect: { exclude: -> request { request.path =~ /health_check/ } } }
config.ssl_options = { redirect: { exclude: ->(request) { request.path =~ /health_check/ } } }

# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = %w(debug info warn error fatal).include?(ENV.fetch("RAILS_LOG_LEVEL", nil)) ? ENV["RAILS_LOG_LEVEL"] : :info
config.log_level = %w(debug info warn error fatal).include?(ENV.fetch("RAILS_LOG_LEVEL", nil)) ? ENV.fetch("RAILS_LOG_LEVEL", nil) : :info

# Prepend all log lines with the following tags.
config.log_tags = [:request_id]
Expand All @@ -74,7 +74,7 @@
config.active_support.report_deprecations = false

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.log_formatter = Logger::Formatter.new
config.action_mailer.smtp_settings = {
address: Rails.application.secrets.smtp_address,
port: Rails.application.secrets.smtp_port,
Expand Down
1 change: 1 addition & 0 deletions config/initializers/content_security_policy.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# frozen_string_literal: true
# For tuning the Content Security Policy, check the Decidim documentation site
# https://docs.decidim.org/develop/en/customize/content_security_policy
10 changes: 0 additions & 10 deletions config/initializers/custom_admin_iframe.rb

This file was deleted.

2 changes: 1 addition & 1 deletion config/initializers/date_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Rails.application.config.to_prepare do
# allow view overrides to use custom helpers
puts "SKIPPED: Applying date overrides!"
Rails.logger.debug "SKIPPED: Applying date overrides!"
# Decidim::CardMCell.include(ApplicationHelper)
# Decidim::DateRangeCell.include(ApplicationHelper)
end
2 changes: 2 additions & 0 deletions config/initializers/health_check.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

HealthCheck.setup do |config|
config.standard_checks -= ["emailconf"]
end
4 changes: 2 additions & 2 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
environment ENV.fetch("RAILS_ENV", "development")

# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
pidfile ENV.fetch("PIDFILE", "tmp/pids/server.pid")

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class AddSecondaryHostsToOrganizations < ActiveRecord::Migration[5.0]
def change
add_column :decidim_organizations, :secondary_hosts, :string, array: true, default: [], index: true
add_column :decidim_organizations, :secondary_hosts, :string, array: true, default: []
add_index :decidim_organizations, :secondary_hosts
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def self.up
name = s["name"].gsub(/'/, "''")
execute("
UPDATE decidim_scopes
SET name = '#{Hash[locales.map { |locale| [locale, name] }].to_json}',
SET name = '#{locales.index_with { |_locale| name }.to_json}',
code = #{quote(s["id"])}
WHERE id = #{s["id"]}
")
Expand Down
Loading

0 comments on commit 83267c3

Please sign in to comment.