Skip to content

Commit

Permalink
Maintenance, librivalidi solo codice
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdi2005 committed Nov 9, 2018
1 parent 049607d commit 879c33d
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ gem 'nokogiri', '~> 1.8.5'
# Use ActiveStorage variant
gem 'mini_magick', '~> 4.8'

gem 'turnout'

gem 'pagy'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
Expand Down
8 changes: 7 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ GEM
public_suffix (3.0.3)
puma (3.12.0)
rack (2.0.5)
rack-accept (0.4.5)
rack (>= 0.4)
rack-test (1.1.0)
rack (>= 1.0, < 3)
rails (5.2.1)
Expand Down Expand Up @@ -183,6 +185,9 @@ GEM
turbolinks (5.2.0)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
turnout (1.0.0)
rack
rack-accept (~> 0.4)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.19)
Expand Down Expand Up @@ -224,6 +229,7 @@ DEPENDENCIES
spring
spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5)
turnout
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
Expand All @@ -232,4 +238,4 @@ RUBY VERSION
ruby 2.5.1p57

BUNDLED WITH
1.16.6
1.17.1
13 changes: 12 additions & 1 deletion app/controllers/libri_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,18 @@ def index
unless loggato?
redirect_to login_path
end
@pagy, @libro = pagy(Libro.search(params[:cerca], params[:genere], params[:pagine]))
@ricerca = Libro.search(params[:cerca], params[:genere], params[:pagine])
if params[:disponibili].nil?
@pagy, @libro = pagy(@ricerca)
elsif params[:disponibili] == '1'
@librivalidi = []
@ricerca.each do |libro|
if !Prestito.where(libro: libro, stato: 1).or(Prestito.where(libro: libro, stato: 0)) .any?
@librivalidi.push(libro)
end
end
@pagy, @libro = pagy(Libro.where(id: @librivalidi.map(&:id)))
end
end

def show
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"name": "biblioteca",
"private": true,
"dependencies": {}
"dependencies": {
"jquery-modal": "^0.9.1"
}
}
63 changes: 63 additions & 0 deletions public/maintenance.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Down for Maintenance</title>

<style type="text/css">
*{
font-family: Arial, Helvetica, sans-serif;
}
body{
margin: 0;
background-color: #fff;
}
#page{
position: relative;
width: 550px;
margin: 200px auto;
padding: 75px 0;
text-align: center;
background-color: #eaeaea;
border: solid 1px #ccc;
border-top: solid 10px #666;
-moz-box-shadow: inset 0 2px 10px #ccc;
-webkit-box-shadow: inset 0 2px 10px #ccc;
box-shadow: inset 0 2px 10px #ccc;
}
header, #body{
width: 400px;
margin: 0 auto;
}
h1{
margin: 0;
color: #CC3601;
font-size: 26pt;
border-bottom: solid 4px #666;
}
#reason{
margin: 10px 0;
color: #333;
}
</style>

</head>
<body>

<section id="page">

<header>
<h1>Biblioteca chiusa o in manutenzione</h1>
</header>

<section id="body">
<div>
Ti informiamo che la biblioteca è chiusa o in manutenzione.
<%= reason %>
</div>
</section>

</section>

</body>
</html>
3 changes: 3 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
# yarn lockfile v1


jquery-modal@^0.9.1:
version "0.9.1"
resolved "https://registry.yarnpkg.com/jquery-modal/-/jquery-modal-0.9.1.tgz#f22f13f0efa5ea3f2afaeb7981c1e20114c9d2f2"

0 comments on commit 879c33d

Please sign in to comment.