Skip to content

Commit

Permalink
Rilascio versione 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco.loreti committed Oct 8, 2021
1 parent 4603417 commit aad5177
Show file tree
Hide file tree
Showing 122 changed files with 1,727 additions and 1,339 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.0] - 2021-10-08
### Changed
- Add move settings to Settings files
- Add Devise views
- Add differents authentication's systems
- Add inline field update
- Add new fields into User model
- Add demo settings
- Add user samples
- Upgrade to Ruby 3
- Update Manuals
- Update Readme
- Updated Rails libraries
- Updated Javascript libraries
- Update browser requirements
- Remove compatibility with Internet Explorer 11

## [1.0.9] - 2020-12-11
### Changed
- Rails version 6.1
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ group :test do
end

gem 'active_storage_validations'
gem 'caxlsx'
gem 'caxlsx_rails'
gem 'config'
gem 'devise'
Expand Down
55 changes: 27 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ GEM
sshkit (~> 1.2)
capistrano-yarn (2.0.2)
capistrano (~> 3.0)
capistrano3-puma (5.0.4)
capistrano3-puma (5.2.0)
capistrano (~> 3.7)
capistrano-bundler
puma (>= 4.0, < 6.0)
Expand All @@ -104,7 +104,7 @@ GEM
rack-test (>= 0.6.3)
regexp_parser (>= 1.5, < 3.0)
xpath (~> 3.2)
caxlsx (3.1.0)
caxlsx (3.1.1)
htmlentities (~> 4.3, >= 4.3.4)
marcel (~> 1.0)
nokogiri (~> 1.10, >= 1.10.4)
Expand Down Expand Up @@ -136,23 +136,22 @@ GEM
devise_cas_authenticatable (1.10.4)
devise (>= 1.2.0)
rubycas-client (>= 2.2.1)
dry-configurable (0.12.1)
dry-configurable (0.13.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.5, >= 0.5.0)
dry-container (0.8.0)
dry-core (~> 0.6)
dry-container (0.9.0)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.1, >= 0.1.3)
dry-configurable (~> 0.13, >= 0.13.0)
dry-core (0.7.1)
concurrent-ruby (~> 1.0)
dry-equalizer (0.3.0)
dry-inflector (0.2.1)
dry-initializer (3.0.4)
dry-logic (1.2.0)
concurrent-ruby (~> 1.0)
dry-core (~> 0.5, >= 0.5)
dry-schema (1.7.1)
dry-schema (1.8.0)
concurrent-ruby (~> 1.0)
dry-configurable (~> 0.8, >= 0.8.3)
dry-configurable (~> 0.13, >= 0.13.0)
dry-core (~> 0.5, >= 0.5)
dry-initializer (~> 3.0)
dry-logic (~> 1.0)
Expand All @@ -163,13 +162,12 @@ GEM
dry-core (~> 0.5, >= 0.5)
dry-inflector (~> 0.1, >= 0.1.2)
dry-logic (~> 1.0, >= 1.0.2)
dry-validation (1.6.0)
dry-validation (1.7.0)
concurrent-ruby (~> 1.0)
dry-container (~> 0.7, >= 0.7.1)
dry-core (~> 0.4)
dry-equalizer (~> 0.2)
dry-core (~> 0.5, >= 0.5)
dry-initializer (~> 3.0)
dry-schema (~> 1.5, >= 1.5.2)
dry-schema (~> 1.8, >= 1.8.0)
erubi (1.10.0)
factory_bot (6.2.0)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -200,7 +198,7 @@ GEM
nokogiri (>= 1.5.9)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (1.0.1)
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.1)
mini_portile2 (2.6.1)
Expand All @@ -210,19 +208,19 @@ GEM
net-ssh (>= 2.6.5, < 7.0.0)
net-ssh (6.1.0)
nio4r (2.5.8)
nokogiri (1.12.4)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
nokogiri (1.12.4-x64-mingw32)
nokogiri (1.12.5-x64-mingw32)
racc (~> 1.4)
orm_adapter (0.5.0)
pagy (4.11.0)
parallel (1.20.1)
parallel (1.21.0)
parser (3.0.2.0)
ast (~> 2.4.1)
pg (1.2.3)
public_suffix (4.0.6)
puma (5.4.0)
puma (5.5.0)
nio4r (~> 2.0)
racc (1.5.2)
rack (2.2.3)
Expand Down Expand Up @@ -263,22 +261,22 @@ GEM
actionpack (>= 5.0)
railties (>= 5.0)
rexml (3.2.5)
route_translator (10.0.0)
actionpack (>= 5.0.0.1, < 6.2)
activesupport (>= 5.0.0.1, < 6.2)
route_translator (11.0.0)
actionpack (>= 5.2, < 7.0)
activesupport (>= 5.2, < 7.0)
addressable (~> 2.7)
rubocop (1.20.0)
rubocop (1.22.1)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.9.1, < 2.0)
rubocop-ast (>= 1.12.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.11.0)
rubocop-ast (1.12.0)
parser (>= 3.0.1.1)
rubocop-rails (2.11.3)
rubocop-rails (2.12.3)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
Expand Down Expand Up @@ -326,9 +324,9 @@ GEM
turbolinks-source (5.2.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
tzinfo-data (1.2021.1)
tzinfo-data (1.2021.3)
tzinfo (>= 1.0.0)
unicode-display_width (2.0.0)
unicode-display_width (2.1.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.1.0)
Expand All @@ -340,7 +338,7 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (>= 3.0, < 4.0)
webpacker (5.4.2)
webpacker (5.4.3)
activesupport (>= 5.2)
rack-proxy (>= 0.6.1)
railties (>= 5.2)
Expand Down Expand Up @@ -371,6 +369,7 @@ DEPENDENCIES
capistrano-yarn
capistrano3-puma
capybara
caxlsx
caxlsx_rails
config
database_cleaner
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Il codice sorgente del sito progetto è rilasciato sotto licenza MIT License (co
## Repository
Questo repository contiene il codice sorgente del programma per la gestione della sorveglianza sanitaria e della medicina sul lavoro del personale.

Il sito è sviluppato in linguaggio Ruby 2.7, framework Rails 6.0 e webpacker StimulusJS.
Il sito è sviluppato in linguaggio Ruby 3.0, framework Rails 6.1 e webpacker StimulusJS 2.

### Specifiche tecniche progetto
* [Ruby 2.7.x](https://www.ruby-lang.org)
* [Ruby 3.0.x](https://www.ruby-lang.org)
* [RVM](https://rvm.io/)
* [Ruby on Rais 6.0](https://rubyonrails.org/)
* [Ruby on Rais 6.1](https://rubyonrails.org/)
* [NodeJS](https://nodejs.org/)
* [Yarn](https://yarnpkg.com/)
* [Webpacker StimulusJS](https://stimulusjs.org/)
Expand All @@ -59,9 +59,9 @@ Il sito è sviluppato in linguaggio Ruby 2.7, framework Rails 6.0 e webpacker St
### Requisiti tecnici per ambiente server
* Sistema operativo: Linux
* Gestore pacchetto ruby: RVM
* Linguaggio di programmazione: Ruby 2.7
* Framework: Rais 6.0
* Webpacker: StimulusJS
* Linguaggio di programmazione: Ruby 3.0
* Framework: Rails 6.1
* Webpacker: StimulusJS 2.0
* Database: PostgreSQL >= 12.2
* NodeJS: JavaScript runtime >= v13.10
* Package Manager: Yarn >= 1.22
Expand All @@ -70,15 +70,15 @@ Il sito è sviluppato in linguaggio Ruby 2.7, framework Rails 6.0 e webpacker St
* Autenticazione utenti: CAS Server

### Requisiti minimi per i client
* Mozilla Firefox 53, Chrome 58, Microsoft Edge, Internet Explorer 11, Safari 9.0 o altro browser compatibile con HTML 5, CSS 3;
* Per Internet Explorer 11 la modalità di compatibilità deve essere disattivata;
* Mozilla Firefox 80, Chrome 80, Microsoft Edge, Safari o altro browser compatibile con HTML 5, CSS 3;
* Internet Explorer 11 non è supportato;
* Javascript abilitato;
* Cookie abilitati;
* Supporto ai certificati SSL;
* Risoluzione schermo 1024x768.

### Configurazione consigliata per i client
* Mozilla Firefox >= 53, Chrome >= 58, Microsoft Edge, Safari 9.0 o altro browser compatibile con HTML 5 e CSS 3;
* Mozilla Firefox 80, Chrome 80, Microsoft Edge, Safari o altro browser compatibile con HTML 5, CSS 3;
* Javascript abilitato;
* Cookie abilitati;
* Supporto ai certificati SSL;
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# @raise [ActiveRecord::RecordNotFound] if a query can't be resolved
# execute {record_not_found!}
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception, prepend: true
layout :set_layout
before_action :authenticate_user!
before_action :set_locale
Expand Down Expand Up @@ -42,6 +43,14 @@ def admin_in!
access_denied! unless current_user.admin?
end

def translate_errors(errors = [], scope: '')
translated = []
errors.each do |e|
translated << "#{t(e.attribute, scope: scope, default: e.attribute)} #{e.message}"
end
return translated
end

private

# Set locale from `params[:locale]`.
Expand Down
41 changes: 36 additions & 5 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# * before_action :doctor_in!, only: [:report] -> {doctor_in!}
class HomeController < ApplicationController
include Pagy::Backend
before_action :home_redirect, except: [:user]
before_action :home_redirect, except: [:user, :reset_password]
before_action :doctor_in!, only: [:report]

# GET /
Expand All @@ -18,7 +18,7 @@ class HomeController < ApplicationController
# @return [Object] render /home/index
def index
@expire = ''
@users = User.all.left_outer_joins(:categories).distinct
@users = User.all.unsystem.left_outer_joins(:categories).distinct
@start_at = Time.zone.today.at_beginning_of_month
@stop_at = Time.zone.today.end_of_month
@next_start_at = Time.zone.today.at_beginning_of_month.next_month
Expand Down Expand Up @@ -74,12 +74,39 @@ def user
def report
return if params[:report].blank?

@year = params[:report][:year]
@year = params[:report][:year].presence || Time.zone.today.year
@range = 0
@city = params[:report][:city]
@city = params[:report][:city].presence || :roma
get_dates_range(@range, @year)
@users = History.unscoped.joins(:user, :risk).where('users.city=?', User.cities[@city])
@filename = @city.blank? ? 'report-medicina.xlsx' : "#{@city}-#{@year}.xlsx"
respond_to do |format|
format.js
format.xlsx
end
end

# PUT /home/reset_password
#
# Is function for change the user password
# * set @user as current_user
# @return {Object} render /home/new_password
def reset_password
status = :ok
@user = current_user
if user_params[:password] != user_params[:password_confirmation]
@user.errors.add(:password, 'Not valid')
@user.errors.add(:current_password, 'Not valid')
else
@user.password = user_params[:password]
if @user.save
flash.now[:success] = 'Modifica avvenuta con successo'
else
status = 500
flash.now[:error] = 'Si è verificato un errore durante la modifica'
end
end
redirect_to new_user_session_path
end

private
Expand All @@ -102,6 +129,10 @@ def home_redirect
redirect_to home_user_path unless current_user.doctor? || current_user.secretary?
end

def user_params
params.fetch(:user, {}).permit(:password, :current_password, :password_confirmation)
end

def filter_params
params.fetch(:filter, {}).permit(:riepilogo, :city, :postazione)
end
Expand Down Expand Up @@ -132,7 +163,7 @@ def users
when 'blocked' then [nil, :blocked]
else [['audits.expire Between ? And ?', @start_at, @stop_at], :syncable]
end
users_list = User.left_outer_joins(:categories) #.distinct
users_list = User.unsystem.left_outer_joins(:categories) #.distinct
users_list = if %w[locked blocked new].include?(@filters[:riepilogo])
users_list.send(scope).group('users.label, users.id')
else
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def show
# @return [Object] redirect to /home/index
def destroy
current_user = @user
@user.author = current_user.label
@user = User.unscoped.find(current_user.id) if @user.disable!
redirect_to home_index_path(filter: { riepilogo: 'expired' })
end
Expand All @@ -62,7 +63,7 @@ def destroy
# render /users/show
def unlock
@user.enable!
render @user
redirect_to home_index_path(filter: { riepilogo: 'expired' })
end

# PATCH /users/:id
Expand All @@ -72,11 +73,10 @@ def unlock
# * set @response true if @user is updated
# @return [Object] render users/index if @response is true otherwise render users/edit
def update
@response = @user.update(user_params)
if @response
render :show
if @user.update(user_params)
render :show, status: :ok
else
render :edit
render json: { error: translate_errors(@user.errors, scope: 'user').join(', '), status: :unprocessable_entity }, status: 500
end
end

Expand Down Expand Up @@ -159,7 +159,7 @@ def set_user
end

def user_params
params.fetch(:user, {}).permit(:body, :tel, :assegnazione)
params.fetch(:user, {}).permit(:username, :password, :label, :cf, :data_nasc, :citta_nasc, :email, :matr, :denominazione_contratto, :scadenza_rapporto, :body, :city, :location, :telephone, :emergenze, :user_emergenze, :structure, :responsabile, :tel, :assegnazione)
end

def external_user_params
Expand All @@ -178,6 +178,6 @@ def users
search[:postazione] = filter_params[:postazione] if filter_params[:postazione].present?
scope = filter_params[:invisible] == true ? :unscoped : :all

User.send(scope).left_outer_joins(:categories).distinct.where(@text).where(search).order('label asc')
User.send(scope).unsystem.left_outer_joins(:categories).distinct.where(@text).where(search).order('label asc')
end
end
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ def l_time(obj = nil)
# @param [DateTime,Date] obj
# @return [String] localized and formatted date
def l_date(obj = nil)
l(obj, format: :date) if obj.present?
l(obj.try(:to_date), format: :date) if obj.present?
end
end
Loading

0 comments on commit aad5177

Please sign in to comment.