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

Consul portability #51

Open
wants to merge 119 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
f7109de
Manage old and new settings keys for old and new instalations
taitus Sep 6, 2019
a64039b
New setting index page
taitus Sep 3, 2019
bdb7fc8
Remove unused old partials for render every tab
taitus Sep 3, 2019
d1b21df
Add new action settings#show
taitus Sep 3, 2019
0e55764
Add new views templates to render each section of settings
taitus Sep 3, 2019
91170fa
Update specs
taitus Sep 3, 2019
d158a94
Fix i18n tasks: unused and missing
taitus Sep 4, 2019
1ebc424
Force back link to admins settings index
taitus Sep 4, 2019
23143a4
Refactor: Change settings sections by settings groups.
taitus Sep 4, 2019
620a302
Refactor: Remove unnecesary code
taitus Sep 4, 2019
7d9d11d
Adapt new locales structure with existent translations
taitus Sep 4, 2019
040f930
Add to Setting Index page a new section 'Registration with social net…
taitus Jul 11, 2019
9ef5c82
Rename feature settings keys related with social networks login
taitus Jul 11, 2019
e0a5a9e
Move secrets related with 'Registration with social networks' to sett…
taitus Jul 11, 2019
8f052af
Adapt omniauth to new settings keys
taitus Jul 11, 2019
3ca4bf0
Create new setting page 'Social'
taitus Sep 4, 2019
b2ab598
Add restart information
taitus Jul 17, 2019
b2256bb
Fix Button into table
agileontheweb Sep 4, 2019
6404a94
Adapt new locales structure with existent translations
taitus Sep 5, 2019
6021adb
Move secrets related with 'Maps' to settings
taitus Jul 29, 2019
0f60550
Adapt code to new settings keys
taitus Jul 29, 2019
3115db8
Update and add specs
taitus Jul 29, 2019
d04cc83
Redirect to request.referer
taitus Sep 6, 2019
8e73da6
Add to Setting Index page a new section 'Advanced Configuration'
taitus Jul 23, 2019
8e11083
Move secrets related with 'http basic authentication' to settings
taitus Jul 23, 2019
7e30761
Adapt application controller to new settings keys
taitus Jul 23, 2019
008feca
Create new setting page 'Advanced Configuration'
taitus Jul 23, 2019
a22df0e
Add Tracking settings to 'Advanced Configuration' page
taitus Jul 24, 2019
906327e
Force back link to admins settings index
taitus Sep 9, 2019
dc3d85e
Add rake task to Release Notes
taitus Sep 23, 2019
b34f7b1
Update locales.
taitus Sep 23, 2019
93cef85
Add to Setting Index page a new section 'SMTP configuration'
taitus Jul 31, 2019
6b42e3c
Add Settings related with 'SMTP Configuration'
taitus Jul 31, 2019
cd6dc5d
Remove code related with smtp credentials on 'config/environments' fo…
taitus Jul 31, 2019
7f4b961
Create new setting page 'SMTP Configuration' to render related settings
taitus Jul 31, 2019
52d1576
Load SMTP settings before action Mailer
taitus Sep 18, 2019
a9f6a72
Retrocompatibility smtp settings for existing installations
taitus Sep 19, 2019
ebc2017
Add new feature 'smtp_configuration'
taitus Sep 19, 2019
632befc
Allow update SMTP Configuration
taitus Sep 19, 2019
86a1a10
Set smtp configuration only when feature smtp_configuration is enable.
taitus Sep 19, 2019
9b730f3
Update smtp settings rake
taitus Sep 19, 2019
b8cad00
Improve locales
taitus Sep 24, 2019
826b7c7
Add to Setting Index page a new section 'Languages and Time Zone'
taitus Jul 31, 2019
61ce474
Add Settings related with 'Default Locale'
taitus Jul 31, 2019
184c884
Add Settings related with 'Available Locales'
taitus Jul 31, 2019
5661e0c
Add Settings related with 'Time Zone'
taitus Jul 31, 2019
0517e63
Adapt 'application.rb' to new default_locale Setting
taitus Jul 31, 2019
8b85120
Adapt 'application.rb' to new available_locales Settings
taitus Jul 31, 2019
d198083
Adapt 'application.rb' to new timezone Setting
taitus Jul 31, 2019
71c365d
Create new setting page 'Regional Configuration' to render related se…
taitus Jul 31, 2019
2bfaecd
Force back link to admins settings index
taitus Sep 9, 2019
f80cd45
Update restart information.
taitus Sep 10, 2019
ce446e0
Do not allow to disable default_locale in the available locales section
taitus Sep 10, 2019
c221374
Fix spec
taitus Sep 10, 2019
6563a4c
Recover value from application instead of Settings
taitus Sep 24, 2019
c902a07
Improve Locales
taitus Sep 24, 2019
2b4cfe7
Fix flacky spec. Stub default per page to 1..
taitus Sep 9, 2019
0fadf0a
Remove JS to render map properly after change tab
taitus Sep 9, 2019
b3e5622
Redirect correctly to proposal dashboard section.
taitus Sep 9, 2019
f8d0876
Remove unnecessary code related with tabs
taitus Sep 9, 2019
61ffcb0
Fix rebase error
taitus Sep 26, 2019
d6850be
Fix rebase error
taitus Sep 27, 2019
5bfba50
Fix smtp configuration
taitus Sep 26, 2019
60d7dc2
Fix Active button
agileontheweb Sep 27, 2019
9d9b177
Fix Scroll
agileontheweb Sep 27, 2019
47629cc
Add new wizard section on admin sidebar menu
taitus Sep 24, 2019
244113e
Add wizard index
taitus Sep 24, 2019
a99a321
Add new wizards installation controller
taitus Sep 24, 2019
0483922
Add new layout for wizards
taitus Sep 24, 2019
214acf7
Add initial step as action new from installation wizard
taitus Sep 24, 2019
4a3b6fa
Add general settings step
taitus Sep 24, 2019
3910c96
Add participation process step
taitus Sep 24, 2019
dc931fe
Add map configuration step
taitus Sep 24, 2019
9f55c55
Add smtp configuration step
taitus Sep 24, 2019
f17f63b
Add regional configuration step
taitus Sep 24, 2019
4b3c71b
Add finish step
taitus Sep 24, 2019
503a929
Add new scss wizard style file
agileontheweb Sep 12, 2019
92e67e2
New: Add padding to structure
agileontheweb Sep 12, 2019
e3737fd
General Settings: Add padding to structure
agileontheweb Sep 12, 2019
500eba2
Partecipation process: Add padding to structure
agileontheweb Sep 12, 2019
aaaffa2
Map: Add padding to structure
agileontheweb Sep 12, 2019
a0cd205
Smtp: Add padding to structure
agileontheweb Sep 12, 2019
eeb5865
Regional: Add padding to structure
agileontheweb Sep 12, 2019
417ca91
Finish: Add padding to structure
agileontheweb Sep 12, 2019
d627bf4
Header: Fix style
agileontheweb Sep 12, 2019
757641c
Add new Wizard yml
agileontheweb Sep 12, 2019
45086cd
Header: Add translations
agileontheweb Sep 12, 2019
221e45e
New: Add translations
agileontheweb Sep 12, 2019
d62e651
General Settings: Add translations
agileontheweb Sep 12, 2019
78b3d4c
Partecipation process: Add translations
agileontheweb Sep 12, 2019
80f3d77
Map: Add translations
agileontheweb Sep 12, 2019
edb36c3
SMTP: Add translations
agileontheweb Sep 12, 2019
1f629fa
Regional: Add translations
agileontheweb Sep 12, 2019
aa7aa07
Finish: Add translations
agileontheweb Sep 12, 2019
0b25a8f
Improve setting helper
taitus Sep 24, 2019
cdb6bc7
Clarify installer controller
taitus Sep 25, 2019
49a3ea3
Avoid disable current_locale as available locale
taitus Sep 25, 2019
b8795d8
Fix spec
taitus Sep 25, 2019
80d968d
Create new en.yml
agileontheweb Sep 25, 2019
3c79144
Translate word to english to spanish
agileontheweb Sep 25, 2019
f62df23
Use appropriate key in the section
agileontheweb Sep 25, 2019
79e199e
ES: Add tag strong in the yml in each section
agileontheweb Sep 25, 2019
b9f5ce8
EN: Change settings to global settings
agileontheweb Sep 25, 2019
f6d9dd4
EN: Add tag strong
agileontheweb Sep 25, 2019
b3d24a2
Responsive: Fix buttons style
agileontheweb Sep 25, 2019
dfeb3dc
Translate: Add configuration word strong
agileontheweb Sep 25, 2019
cef8119
Add Translate in admin/wizards
agileontheweb Sep 25, 2019
5f3439b
Add translate in sidemenu
agileontheweb Sep 25, 2019
f385350
Show active_menu wizards
agileontheweb Sep 25, 2019
b25fecd
Fix step 1 no buttons
agileontheweb Sep 26, 2019
a095508
Add new translation file to i18n-tasks configuration
Senen Sep 27, 2019
bd213c9
Add wizard specs
taitus Sep 27, 2019
4e06b08
Clarify specs
taitus Sep 27, 2019
ffb6a6b
Add to Setting Index page a new section 'SMS Configuration'
taitus Oct 5, 2019
3fb4593
Move secrets related with 'sms service' to settings
taitus Oct 5, 2019
1e2d411
Adapt sms api to new settings keys
taitus Oct 5, 2019
8d07212
Create new setting page 'SMS Configuration'
taitus Oct 5, 2019
b944e93
Add rake task to Release Notes
taitus Oct 5, 2019
bc418a8
Fix smtp configuration key to allow load smtp settings
taitus Oct 11, 2019
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
4 changes: 1 addition & 3 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
//= require globalize
//= require send_admin_notification_alert
//= require modal_download
//= require settings
//= require cookies
//= require columns_selector
//= require budget_edit_associations
Expand Down Expand Up @@ -136,8 +135,7 @@ var initialize_modules = function() {
App.Globalize.initialize();
App.SendAdminNotificationAlert.initialize();
App.ModalDownload.initialize();
App.Settings.initialize();
if ($("#js-columns-selector").length) {
if ( $('#js-columns-selector').length) {
App.ColumnsSelector.initialize();
}
App.BudgetEditAssociations.initialize();
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/foundation_extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
$(window).trigger("resize");
$(document).on("page:before-unload", this.clearSticky);
window.addEventListener("popstate", this.clearSticky, false);
$("#side_menu ul").on("down.zf.accordionMenu", function(e) {
Foundation.reInit($("[data-equalizer]"));
});
$(function() {
if ($(window).width() < 620) {
App.FoundationExtras.mobile_ui_init();
Expand Down
7 changes: 7 additions & 0 deletions app/assets/stylesheets/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ $sidebar-active: #f4fcd0;
color: #fff;
}

@include breakpoint(medium) {
td .enabled,
td .disabled {
padding: $line-height / 2 0;
}
}

th {
background: $brand;
color: #fff;
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@
@import "autocomplete_overrides";
@import "jquery-ui/sortable";
@import "leaflet";
@import "wizard";
46 changes: 46 additions & 0 deletions app/assets/stylesheets/wizard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.wizard {
h3 {
margin-bottom: 0;
}

h3,
.current-step {
display: inline-block;
padding: .7em 0;
}

.current-step {
@include breakpoint(medium) {
margin-left: $line-height;
}
}

.btn-back-step {
margin-right: $line-height;
}

.btn-back-step i {
position: relative;
&:before {
position: absolute;
top: 2px;
left: -20px;
}
}

.v-aligner {
display: flex;
align-items: center;
justify-content: center;
}

.button {
margin-bottom: 0;
}

@include breakpoint(small) {
input.button {
padding: 1em 0;
}
}
}
39 changes: 24 additions & 15 deletions app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,20 @@ class Admin::SettingsController < Admin::BaseController
:poster_feature_short_title_setting, :poster_feature_description_setting

def index
all_settings = Setting.all.group_by { |setting| setting.type }
@configuration_settings = all_settings["configuration"]
@feature_settings = all_settings["feature"]
@participation_processes_settings = all_settings["process"]
@map_configuration_settings = all_settings["map"]
@proposals_settings = all_settings["proposals"]
@remote_census_general_settings = all_settings["remote_census.general"]
@remote_census_request_settings = all_settings["remote_census.request"]
@remote_census_response_settings = all_settings["remote_census.response"]
@uploads_settings = all_settings["uploads"]
@settings_groups = ["configuration", "process", "feature", "map", "uploads", "proposals", "remote_census", "social", "advanced", "smtp", "regional", "sms"].freeze
end

def update
@setting = Setting.find(params[:id])
@setting.update(settings_params)
redirect_to request_referer, notice: t("admin.settings.flash.updated")
redirect_to request.referer, notice: t("admin.settings.flash.updated")
end

def update_map
Setting["map.latitude"] = params[:latitude].to_f
Setting["map.longitude"] = params[:longitude].to_f
Setting["map.zoom"] = params[:zoom].to_i
redirect_to admin_settings_path, notice: t("admin.settings.index.map.flash.update")
redirect_to request.referer, notice: t("admin.settings.index.map.flash.update")
end

def update_content_types
Expand All @@ -43,6 +34,12 @@ def update_content_types
redirect_to admin_settings_path, notice: t("admin.settings.flash.updated")
end

def show
@settings = settings_by_group(params[:id])

render params[:id]
end

private

def settings_params
Expand All @@ -53,8 +50,20 @@ def content_type_params
params.permit(:jpg, :png, :gif, :pdf, :doc, :docx, :xls, :xlsx, :csv, :zip)
end

def request_referer
return request.referer + params[:setting][:tab] if params[:setting][:tab]
request.referer
def settings_by_group(group)
all_settings = Setting.all.group_by { |setting| setting.type }
case group
when "remote_census"
[all_settings["remote_census.general"]] + [all_settings["remote_census.request"]] + [all_settings["remote_census.response"]]
when "social"
[all_settings["social.facebook"]] + [all_settings["social.twitter"]] + [all_settings["social.google"]]
when "advanced"
[all_settings["advanced.auth"]] + [all_settings["advanced.tracking"]]
when "regional"
[all_settings["regional.default_locale"]] + [all_settings["regional.available_locale"]] + [all_settings["regional.time_zone"]]
else
all_settings[group]
end
end

end
51 changes: 51 additions & 0 deletions app/controllers/admin/wizards/installer_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
class Admin::Wizards::InstallerController < Admin::BaseController
layout "wizard"

before_action :set_total_steps
before_action :set_settings, only: :show

def new
end

def show
render params[:id]
end

private

def set_total_steps
@total_steps = 7
end

def set_settings
case params[:id]
when "general_settings"
@settings = [Setting.find_by(key: "org_name"),
Setting.find_by(key: "min_age_to_participate")]
when "participation_process"
@settings = [[Setting.find_by(key: "process.debates"),
Setting.find_by(key: "process.proposals"),
Setting.find_by(key: "votes_for_proposal_success"),
Setting.find_by(key: "process.polls"),
Setting.find_by(key: "process.budgets")]]
when "map"
@settings = [[Setting.find_by(key: "feature.map"),
Setting.find_by(key: "map.latitude"),
Setting.find_by(key: "map.longitude"),
Setting.find_by(key: "map.zoom")]]
when "smtp"
@settings = [Setting.find_by(key: "feature.smtp_configuration"),
Setting.find_by(key: "smtp.address"),
Setting.find_by(key: "smtp.port"),
Setting.find_by(key: "smtp.domain"),
Setting.find_by(key: "smtp.username"),
Setting.find_by(key: "smtp.password"),
Setting.find_by(key: "smtp.authentication"),
Setting.find_by(key: "smtp.enable_starttls_auto")]
when "regional"
all_settings = Setting.all.group_by { |setting| setting.type }
@settings = [all_settings["regional.default_locale"]] + [all_settings["regional.available_locale"]] + [all_settings["regional.time_zone"]]
end
end

end
7 changes: 7 additions & 0 deletions app/controllers/admin/wizards_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Admin::WizardsController < Admin::BaseController

def index
@wizards = ["installation"].freeze
end

end
6 changes: 4 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class ApplicationController < ActionController::Base
include HasFilters
include HasOrders
include AccessDeniedHandler
include RegionalSettings

default_form_builder ConsulFormBuilder
protect_from_forgery with: :exception
Expand All @@ -28,12 +29,13 @@ class ApplicationController < ActionController::Base

def authenticate_http_basic
authenticate_or_request_with_http_basic do |username, password|
username == Rails.application.secrets.http_basic_username && password == Rails.application.secrets.http_basic_password
username == Retrocompatibility.calculate_value("advanced.auth.http_basic_username", "http_basic_username") &&
password == Retrocompatibility.calculate_value("advanced.auth.http_basic_password", "http_basic_password")
end
end

def http_basic_auth_site?
Rails.application.secrets.http_basic_auth
Retrocompatibility.calculate_value("advanced.auth.http_basic_auth", "http_basic_auth")
end

def verify_lock
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/concerns/regional_settings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module RegionalSettings
extend ActiveSupport::Concern

included do
before_action :initialize_regional_settings
end

private

def initialize_regional_settings
Regional::Locales.load_default_and_available_locales
Regional::Timezone.load_timezone
end
end
10 changes: 5 additions & 5 deletions app/controllers/users/omniauth_callbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController

def twitter
sign_in_with :twitter_login, :twitter
sign_in_with :twitter
end

def facebook
sign_in_with :facebook_login, :facebook
sign_in_with :facebook
end

def google_oauth2
sign_in_with :google_login, :google_oauth2
sign_in_with :google_oauth2
end

def after_sign_in_path_for(resource)
Expand All @@ -22,8 +22,8 @@ def after_sign_in_path_for(resource)

private

def sign_in_with(feature, provider)
raise ActionController::RoutingError.new("Not Found") unless Setting["feature.#{feature}"]
def sign_in_with(provider)
raise ActionController::RoutingError.new("Not Found") unless Setting["social.#{provider}.login"]

auth = request.env["omniauth.auth"]

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/admin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def menu_profiles?

def menu_settings?
controllers_names = ["settings", "tags", "geozones", "images", "content_blocks",
"local_census_records", "imports"]
"local_census_records", "imports", "wizards"]
controllers_names.include?(controller_name) &&
controller.class.parent != Admin::Poll::Questions::Answers
end
Expand Down
5 changes: 3 additions & 2 deletions app/helpers/map_locations_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ def prepare_map_settings(map_location, editable, parent_class, investments_coord
map_center_latitude: map_location_latitude(map_location),
map_center_longitude: map_location_longitude(map_location),
map_zoom: map_location_zoom(map_location),
map_tiles_provider: Rails.application.secrets.map_tiles_provider,
map_tiles_provider_attribution: Rails.application.secrets.map_tiles_provider_attribution,
map_tiles_provider: Retrocompatibility.calculate_value("map.tiles_provider", "map_tiles_provider"),
map_tiles_provider_attribution: Retrocompatibility.calculate_value("map.tiles_provider_attribution",
"map_tiles_provider_attribution"),
marker_editable: editable,
marker_remove_selector: "##{map_location_remove_marker_link_id(map_location)}",
latitude_input_selector: "##{map_location_input_id(parent_class, "latitude")}",
Expand Down
55 changes: 49 additions & 6 deletions app/helpers/settings_helper.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,62 @@
module SettingsHelper

def feature?(name)
setting["feature.#{name}"].presence || setting["process.#{name}"].presence
setting["feature.#{name}"].presence || setting["process.#{name}"].presence || setting["social.#{name}"].presence
end

def setting
@all_settings ||= Hash[Setting.all.map { |s| [s.key, s.value.presence] }]
end

def display_setting_name(setting_name)
if setting_name == "setting"
t("admin.settings.setting_name")
else
t("admin.settings.#{setting_name}")
def is_feature?(setting)
social_feature?(setting) ||
advanced_feature?(setting) ||
smtp_feature?(setting) ||
regional_feature?(setting) ||
process_feature?(setting) ||
map_feature?(setting)
end

def social_feature?(setting)
key = setting.key.split(".")
key.first == "social" && key.last == "login"
end

def advanced_feature?(setting)
setting.key == "advanced.auth.http_basic_auth"
end

def smtp_feature?(setting)
setting.key == "smtp.enable_starttls_auto" || setting.key == "feature.smtp_configuration"
end

def process_feature?(setting)
key = setting.key.split(".")
key.first == "process"
end

def map_feature?(setting)
setting.key == "feature.map"
end

def regional_feature?(setting)
key = setting.key.split(".")
key.first == "regional" && key.second == "available_locale"
end

def options_for_default_locale
I18n.available_locales.map do |locale|
[name_for_locale(locale), locale]
end
end

def regional_setting?(setting)
setting.type.rpartition(".").first == "regional"
end

def need_disable_language?(setting)
setting_locale = setting.key.rpartition(".").last.to_sym
setting_locale == I18n.default_locale || setting_locale == I18n.locale
end

end
5 changes: 5 additions & 0 deletions app/mailers/application_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,9 @@ class ApplicationMailer < ActionMailer::Base
helper :application
default from: Proc.new { "#{Setting["mailer_from_name"]} <#{Setting["mailer_from_address"]}>" }
layout "mailer"
before_action :set_smtp_settings

def set_smtp_settings
SmtpConfiguration.set_configuration
end
end
Loading