thecore_backend_commons 2.2.3 → 2.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f7188530770a1ab8068c19305f08dd21a9202e5508eab082d014ba45dcc0c39
4
- data.tar.gz: fdd7d2770fe3f9b3a5706e26d7d7180bffdbe634b6b45b9739204679c65dabfe
3
+ metadata.gz: 3fcecc224766d5f821032c8d6fd553c6aef6bae1d6f57a47511b3cba6a263633
4
+ data.tar.gz: 98575087ff4be3f30c68a85ffb16a34a517e89e495926b243eb7d1ebc89f5c33
5
5
  SHA512:
6
- metadata.gz: 194a36e074e3e0d44eb569981efacf8b0570eb06310728dd664fb2f0b0b3a12bdcdf3c71b9c7d10a8f12fda6be8111ace623148166afe1b7866e524547d7d72f
7
- data.tar.gz: 5523e7af00431e8c6a724ad09be41b74368b94fde124c2a35c6e53f7d737f83db6d4503d21e8327d5725cdf1d751ed1273013dd6bead159a54daa5a7ee3da238
6
+ metadata.gz: 2ff4c636f60705b839aad89b496b73ecb2b671c0ca12c5972497ac297cc76cada7cee4d8238317868e1e6c5eaefac9109b9a838d708b74b7dee4260f013a7061
7
+ data.tar.gz: aa555f4e0735c1e3c3ef35789c9de9793d79b0c4a32f5281c79a78aa6b2a6e32755e688f5139a9ad7c8174ab2417420d3384ef8d63349c16465bfaf1138ce655
@@ -0,0 +1,2 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ end
@@ -0,0 +1,29 @@
1
+ Rails.application.configure do
2
+ # I18n
3
+ config.i18n.available_locales = %w(it en)
4
+ config.i18n.default_locale = :it
5
+ config.time_zone = 'Rome'
6
+ # Active Storage
7
+ config.active_storage.configure(
8
+ :Disk,
9
+ root: Rails.root.join("storage")
10
+ )
11
+ # AFTER INITIALIZE Good place to load things that must have a bit of initialization
12
+ # setup on order to work (and not be overrided).
13
+ config.after_initialize do
14
+ # In development be sure to load all the namespaces
15
+ # in order to have working reflection and meta-programming.
16
+ if Rails.env.development?
17
+ Rails.configuration.eager_load_namespaces.each(&:eager_load!) if Rails.version.to_i == 5 #Rails 5
18
+ Zeitwerk::Loader.eager_load_all if Rails.version.to_i >= 6 #Rails 6
19
+ end
20
+
21
+ # include the extensions
22
+ ActiveRecord::Base.send(:include, ActiveRecordExtensions)
23
+ Integer.send(:include, FixnumConcern)
24
+ String.send(:include, StringConcern)
25
+ RailsAdmin::Config::Actions::Export.send(:include, ExportConcern)
26
+ RailsAdmin::Config::Actions::BulkDelete.send(:include, BulkDeleteConcern)
27
+ User.send(:include, ThecoreBackendCommonsUser)
28
+ end
29
+ end
@@ -0,0 +1,6 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ user:
5
+ one: User
6
+ other: Users
@@ -0,0 +1,5 @@
1
+ it:
2
+ contact_mailer:
3
+ message:
4
+ domain: "Domain: %{domain}"
5
+ from: "From: %{name} - %{email}"
@@ -0,0 +1,19 @@
1
+ en:
2
+ devise:
3
+ failure:
4
+ user:
5
+ invalid: Incorrect login credentials.
6
+ not_found_in_database: Incorrect login credentials.
7
+ mailer:
8
+ password_changed_instructions:
9
+ greeting: Welcome %{recipient}!
10
+ instruction: We sent you this email to inform about password change.
11
+ instruction_2: If you didn't changed password, we ask you to contact our customer service, please.
12
+ shared:
13
+ links:
14
+ sign_out: Log out
15
+ descriptions:
16
+ current_password_needed: (we need your current password to confirm your changes)
17
+ leave_blank: (leave blank if you don't want to change it)
18
+ validations:
19
+ minimum_length: "%{length} characters minimum"
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ current_user: Current user
24
+ hello: "Hello world"
25
+ dashboard: "Dashboard"
26
+ contact: "Contact"
27
+ manage: "Manage"
28
+ sign_out: "Sign Out"
29
+ admin:
30
+ links:
31
+ label: Links
32
+ settings:
33
+ advanced: Advanced
@@ -0,0 +1,20 @@
1
+ it:
2
+ activerecord:
3
+ models:
4
+ user:
5
+ one: Utente
6
+ other: Utenti
7
+ attributes:
8
+ user:
9
+ email: E-Mail
10
+ username: Nome Utente
11
+ code: Codice
12
+ roles: Ruoli
13
+ admin: Amministratore?
14
+ created_at: Data di Creazione
15
+ locked: Bloccato?
16
+ third_party: Ente Terzo?
17
+ password: Password
18
+ password_confirmation: Conferma Password
19
+ descriptions:
20
+ user: In questa sezione dell'applicazione potete cercare nella lista degli utenti in diversi modi usando i filtri o ordinare la lista secondo diversi campi.
@@ -0,0 +1,5 @@
1
+ it:
2
+ contact_mailer:
3
+ message:
4
+ domain: "Dominio: %{domain}"
5
+ from: "Mittente: %{name} - %{email}"
@@ -0,0 +1,19 @@
1
+ it:
2
+ devise:
3
+ failure:
4
+ user:
5
+ invalid: Credenziali di accesso errate.
6
+ not_found_in_database: Credenziali di accesso errate.
7
+ mailer:
8
+ password_changed_instructions:
9
+ greeting: Benvenuto %{recipient}!
10
+ instruction: Le abbiamo inviato questa email per notificarle il fatto che la sua password è stata cambiata.
11
+ instruction_2: Se non è stato lei a richiedere la modifica della password, la preghiamo di contattare il servizio clienti.
12
+ shared:
13
+ links:
14
+ sign_out: Esci
15
+ descriptions:
16
+ current_password_needed: (è necessario inserire la password corrente per autorizzare la modifica)
17
+ leave_blank: (lasciare vuota se non la si vuole modificare)
18
+ validations:
19
+ minimum_length: la lunghezza minima è di %{length} caratteri
@@ -0,0 +1,44 @@
1
+ it:
2
+ current_user: Utente corrente
3
+ hello: "Ciao Mondo"
4
+ dashboard: "Pannello di controllo"
5
+ contact: "Aiutaci a Migliorare"
6
+ manage: "Gestione"
7
+ sign_out: "Uscita"
8
+ advanced: Impostazioni
9
+ main_records: Anagrafiche
10
+ errors:
11
+ messages:
12
+ invalid: contiene caratteri invalidi
13
+ tiered_times:
14
+ dd:
15
+ zero: "0 Giorni"
16
+ one: "%{count} Giorno"
17
+ other: "%{count} Giorni"
18
+ hh:
19
+ zero: "0 Ore"
20
+ one: "%{count} Ora"
21
+ other: "%{count} Ore"
22
+ mm:
23
+ zero: "0 Minuti"
24
+ one: "%{count} Minuto"
25
+ other: "%{count} Minuti"
26
+ ss:
27
+ zero: "0 Secondi"
28
+ one: "%{count} Secondo"
29
+ other: "%{count} Secondi"
30
+ admin:
31
+ links:
32
+ label: Collegamenti
33
+ tools:
34
+ label: "Strumenti"
35
+ settings:
36
+ label: "Impostazioni"
37
+ advanced: Avanzate
38
+ registries: Anagrafiche
39
+ operations: Operatività
40
+ actions:
41
+ charts:
42
+ menu: Analisi
43
+ title: Grafici
44
+ breadcrumb: Grafici
@@ -0,0 +1,10 @@
1
+ module ThecoreBackendCommonsUser
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ devise :rememberable
6
+ devise :trackable
7
+ devise :validatable
8
+ devise :timeoutable, timeout_in: 30.minutes
9
+ end
10
+ end
@@ -0,0 +1,132 @@
1
+ module ActiveRecordExtensions
2
+ extend ActiveSupport::Concern
3
+
4
+ # add your static(class) methods here
5
+ module ClassMethods
6
+ #E.g: Order.top_ten
7
+ def top_ten
8
+ limit(10)
9
+ end
10
+
11
+ def identifier_starts_with letter
12
+ # Se ha name o code o barcode, uso uno di questi:
13
+ column = if self.column_names.include? "name"
14
+ :name
15
+ elsif self.column_names.include? "title"
16
+ :title
17
+ elsif self.column_names.include? "code"
18
+ :code
19
+ elsif self.column_names.include? "barcode"
20
+ :barcode
21
+ end
22
+ # Ecco la ricerca dedicata a Postgres, la facciamo multiplatform? Fatto
23
+ query = "#{letter}%"
24
+ match = arel_table[column].matches(query)
25
+ where(match)
26
+ end
27
+
28
+ def starts_with_a
29
+ identifier_starts_with :a
30
+ end
31
+
32
+ def starts_with_b
33
+ identifier_starts_with :b
34
+ end
35
+
36
+ def starts_with_c
37
+ identifier_starts_with :c
38
+ end
39
+
40
+ def starts_with_d
41
+ identifier_starts_with :d
42
+ end
43
+
44
+ def starts_with_e
45
+ identifier_starts_with :e
46
+ end
47
+
48
+ def starts_with_f
49
+ identifier_starts_with :f
50
+ end
51
+
52
+ def starts_with_g
53
+ identifier_starts_with :g
54
+ end
55
+
56
+ def starts_with_h
57
+ identifier_starts_with :h
58
+ end
59
+
60
+ def starts_with_i
61
+ identifier_starts_with :i
62
+ end
63
+
64
+ def starts_with_j
65
+ identifier_starts_with :j
66
+ end
67
+
68
+ def starts_with_k
69
+ identifier_starts_with :k
70
+ end
71
+
72
+ def starts_with_l
73
+ identifier_starts_with :l
74
+ end
75
+
76
+ def starts_with_m
77
+ identifier_starts_with :m
78
+ end
79
+
80
+ def starts_with_n
81
+ identifier_starts_with :n
82
+ end
83
+
84
+ def starts_with_o
85
+ identifier_starts_with :o
86
+ end
87
+
88
+ def starts_with_p
89
+ identifier_starts_with :p
90
+ end
91
+
92
+ def starts_with_q
93
+ identifier_starts_with :q
94
+ end
95
+
96
+ def starts_with_r
97
+ identifier_starts_with :r
98
+ end
99
+
100
+ def starts_with_s
101
+ identifier_starts_with :s
102
+ end
103
+
104
+ def starts_with_t
105
+ identifier_starts_with :t
106
+ end
107
+
108
+ def starts_with_u
109
+ identifier_starts_with :u
110
+ end
111
+
112
+ def starts_with_v
113
+ identifier_starts_with :v
114
+ end
115
+
116
+ def starts_with_w
117
+ identifier_starts_with :w
118
+ end
119
+
120
+ def starts_with_x
121
+ identifier_starts_with :x
122
+ end
123
+
124
+ def starts_with_y
125
+ identifier_starts_with :y
126
+ end
127
+
128
+ def starts_with_z
129
+ identifier_starts_with :z
130
+ end
131
+ end
132
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,27 @@
1
+ # Date
2
+ # ----------------------------
3
+ #Date::DATE_FORMATS[:default] = "%Y-%m-%d" # 2013-11-03
4
+ Date::DATE_FORMATS[:default] = "%B %e, %Y" # November 3, 2013
5
+ #Date::DATE_FORMATS[:default] = "%e %b %Y" # 3 Nov 2013
6
+ #Date::DATE_FORMATS[:default] = "%Y%m%d" # 20131103
7
+ #Date::DATE_FORMATS[:default] = "%e %b" # 3 Nov
8
+ #Date::DATE_FORMATS[:default] = "" # custom
9
+
10
+ # DateTime
11
+ # ----------------------------
12
+ #DateTime::DATE_FORMATS[:default] = "%Y-%m-%d" # 2013-11-03 14:22:18
13
+ DateTime::DATE_FORMATS[:default] = "%B %e, %Y" # November 3, 2013 14:22
14
+ #DateTime::DATE_FORMATS[:default] = "%e %b %Y" # Sun, 3 Nov 2013 14:22:18 -0700
15
+ #DateTime::DATE_FORMATS[:default] = "%Y%m%d" # 20131103142218
16
+ #DateTime::DATE_FORMATS[:default] = "%e %b" # 3 Nov 14:22
17
+ #DateTime::DATE_FORMATS[:default] = "" # custom
18
+
19
+ # Time
20
+ # ----------------------------
21
+ #Time::DATE_FORMATS[:default] = "%Y-%m-%d %H:%M:%S" # 2013-11-03 14:22:18
22
+ #Time::DATE_FORMATS[:default] = "%B %d, %Y %H:%M" # November 3, 2013 14:22
23
+ #Time::DATE_FORMATS[:default] = "%a, %d %b %Y %H:%M:%S %z" # Sun, 3 Nov 2013 14:22:18 -0700
24
+ #Time::DATE_FORMATS[:default] = "%d %b %H:%M" # 3 Nov 14:22
25
+ #Time::DATE_FORMATS[:default] = "%Y%m%d%H%M%S" # 20131103142218
26
+ Time::DATE_FORMATS[:default] = "%H:%M" # 14:22
27
+ #Time::DATE_FORMATS[:default] = "" # custom
@@ -0,0 +1,23 @@
1
+ require 'active_support/concern'
2
+
3
+ module FixnumConcern
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ def to_tiered_times skip_seconds = false
7
+ # Actual calculations
8
+ mm, ss = self.divmod(60)
9
+ hh, mm = mm.divmod(60)
10
+ dd, hh = hh.divmod(24)
11
+
12
+ # Presentation
13
+ sentence = []
14
+ sentence << I18n.t("tiered_times.dd", count: dd) unless dd.zero?
15
+ sentence << I18n.t("tiered_times.hh", count: hh) unless hh.zero?
16
+ sentence << I18n.t("tiered_times.mm", count: mm) unless mm.zero?
17
+ sentence << I18n.t("tiered_times.ss", count: ss) if !ss.zero? && !skip_seconds
18
+
19
+ # to_sentence è una estensione rails che traduce nella forma più corretta (decisamente migliore del join(", "))
20
+ sentence.to_sentence
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ module ActiveRecord
2
+ module Tasks
3
+ class PostgreSQLDatabaseTasks
4
+ # Allows drop on DBs currently in use.
5
+ def drop
6
+ establish_master_connection
7
+ connection.select_all "select pg_terminate_backend(pg_stat_activity.pid) from pg_stat_activity where datname='#{configuration['database']}' AND state='idle';"
8
+ connection.drop_database configuration['database']
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ # .gsub(/[^A-Za-z0-9]/, " ").split.join("%")
2
+ require 'active_support/concern'
3
+
4
+ module StringConcern
5
+ extend ActiveSupport::Concern
6
+
7
+ def likeize
8
+ # .select{|w| w.length > 2}
9
+ strip.gsub(/[^A-Za-z0-9]/, " ").split.join("%")
10
+ end
11
+ end
@@ -0,0 +1,12 @@
1
+ require 'thecore_rails_admin_export_concern'
2
+ require 'thecore_rails_admin_bulk_delete_concern'
3
+
4
+ require 'date_format'
5
+
6
+ require 'string_extensions'
7
+ require 'integer_extensions'
8
+ require 'active_record_extensions'
9
+
10
+ require 'postgresql_drop_replacement'
11
+
12
+ require 'application_record_loader'
@@ -0,0 +1,16 @@
1
+ require 'active_support/concern'
2
+
3
+ module BulkDeleteConcern
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ # Should the action be visible
7
+ # Edit By taris, it shows the button only if there are records displayed
8
+ register_instance_option :visible? do
9
+ # If not in index, then return true,
10
+ # otherwise it wont' be added to the list
11
+ # of all Actions during rails initialization
12
+ # In index, instead, I show it only if there are records in the current view
13
+ bindings[:controller].action_name == "index" ? (authorized? && !bindings[:controller].instance_variable_get("@objects").blank?) : true
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ require 'active_support/concern'
2
+
3
+ module ExportConcern
4
+ extend ActiveSupport::Concern
5
+ included do
6
+ # Should the action be visible
7
+ # Edit By taris, it shows the button only if there are records displayed
8
+ register_instance_option :visible? do
9
+ # If not in index, then return true,
10
+ # otherwise it wont' be added to the list
11
+ # of all Actions during rails initialization
12
+ # In index, instead, I show it only if there are records in the current view
13
+ bindings[:controller].action_name == "index" ? (authorized? && !bindings[:controller].instance_variable_get("@objects").blank?) : true
14
+ end
15
+ end
16
+ end
@@ -5,6 +5,8 @@ require 'devise-i18n'
5
5
  require 'http_accept_language'
6
6
  require 'rails-i18n'
7
7
 
8
+ require 'patches/thecore'
9
+
8
10
  module ThecoreBackendCommons
9
11
  # Your code goes here...
10
12
  end
@@ -1,3 +1,3 @@
1
1
  module ThecoreBackendCommons
2
- VERSION = '2.2.3'
2
+ VERSION = '2.2.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_backend_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.3
4
+ version: 2.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2020-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_auth_commons
@@ -78,10 +78,28 @@ files:
78
78
  - README.md
79
79
  - Rakefile
80
80
  - app/assets/config/thecore_backend_commons_manifest.js
81
- - config/initializers/after_initialize_thecore_backend_commons.rb
82
- - config/initializers/thecore_backend_commons_application.rb
81
+ - app/jobs/application_job.rb
82
+ - config/initializers/thecore_backend_commons_app_configs.rb
83
+ - config/locales/en.activerecord.yml
84
+ - config/locales/en.contact_mailer.custom.yml
85
+ - config/locales/en.devise.custom.yml
86
+ - config/locales/en.yml
87
+ - config/locales/it.activerecord.yml
88
+ - config/locales/it.contact_mailer.custom.yml
89
+ - config/locales/it.devise.custom.yml
90
+ - config/locales/it.yml
83
91
  - config/routes.rb
84
92
  - db/migrate/20190920115549_create_active_storage_tables.active_storage.rb
93
+ - lib/concerns/thecore_backend_commons_user.rb
94
+ - lib/patches/active_record_extensions.rb
95
+ - lib/patches/application_record_loader.rb
96
+ - lib/patches/date_format.rb
97
+ - lib/patches/integer_extensions.rb
98
+ - lib/patches/postgresql_drop_replacement.rb
99
+ - lib/patches/string_extensions.rb
100
+ - lib/patches/thecore.rb
101
+ - lib/patches/thecore_rails_admin_bulk_delete_concern.rb
102
+ - lib/patches/thecore_rails_admin_export_concern.rb
85
103
  - lib/tasks/thecore_backend_commons_tasks.rake
86
104
  - lib/thecore_backend_commons.rb
87
105
  - lib/thecore_backend_commons/engine.rb
@@ -1,10 +0,0 @@
1
- Rails.application.configure do
2
- config.after_initialize do
3
- # In development be sure to load all the namespaces
4
- # in order to have working reflection and meta-programming.
5
- if Rails.env.development?
6
- Rails.configuration.eager_load_namespaces.each(&:eager_load!) if Rails.version.to_i == 5 #Rails 5
7
- Zeitwerk::Loader.eager_load_all if Rails.version.to_i >= 6 #Rails 6
8
- end
9
- end
10
- end
@@ -1,6 +0,0 @@
1
- Rails.application.config.i18n.available_locales = %w(it en)
2
- Rails.application.config.i18n.default_locale = :en
3
- Rails.application.config.active_storage.configure(
4
- :Disk,
5
- root: Rails.root.join("storage")
6
- )