Skip to content

Commit aa39659

Browse files
committed
Додані моделі критики авторів, жанрів
1 parent 59cd3fd commit aa39659

File tree

206 files changed

+2094
-273
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+2094
-273
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ gem 'jbuilder', '~> 2.5'
3838

3939
# Use Capistrano for deployment
4040
# gem 'capistrano-rails', group: :development
41+
gem 'will_paginate', '~> 3.1.0'
4142

4243
#Devise {autorisation}
4344
gem 'devise'

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ GEM
171171
websocket-driver (0.6.5)
172172
websocket-extensions (>= 0.1.0)
173173
websocket-extensions (0.1.2)
174+
will_paginate (3.1.5)
174175

175176
PLATFORMS
176177
ruby
@@ -195,6 +196,7 @@ DEPENDENCIES
195196
tzinfo-data
196197
uglifier (>= 1.3.0)
197198
web-console (>= 3.3.0)
199+
will_paginate (~> 3.1.0)
198200

199201
BUNDLED WITH
200202
1.14.6

app/assets/javascripts/auth.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/javascripts/zhanr.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Place all the behaviors and hooks related to the matching controller here.
2+
# All this logic will automatically be available in application.js.
3+
# You can use CoffeeScript in this file: http://coffeescript.org/

app/assets/stylesheets/auth.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the Auth controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/

app/assets/stylesheets/zhanr.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Place all the styles related to the Zhanr controller here.
2+
// They will automatically be included in application.css.
3+
// You can use Sass (SCSS) here: http://sass-lang.com/

app/controllers/auth_controller.rb

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
class AuthController < ApplicationController
2+
before_action :set_auth, only: [:show, :edit, :update, :destroy]
3+
4+
# GET /books
5+
# GET /books.json
6+
def index
7+
@auths = Auth.all
8+
end
9+
10+
11+
12+
# GET /books/1
13+
# GET /books/1.json
14+
def show
15+
16+
end
17+
18+
# GET /books/new
19+
def new
20+
@auth = Auth.new
21+
end
22+
23+
# GET /books/1/edit
24+
def edit
25+
end
26+
27+
# POST /books
28+
# POST /books.json
29+
def create
30+
@auth = Auth.new(book_params)
31+
32+
respond_to do |format|
33+
if @auth.save
34+
format.html { redirect_to @auth, notice: 'Автор успішно доданий' }
35+
format.json { render :show, status: :created, location: @auth }
36+
else
37+
format.html { render :new }
38+
format.json { render json: @auth.errors, status: :unprocessable_entity }
39+
end
40+
end
41+
end
42+
43+
# PATCH/PUT /books/1
44+
# PATCH/PUT /books/1.json
45+
def update
46+
respond_to do |format|
47+
if @book.update(book_params)
48+
format.html { redirect_to @auth, notice: 'Автор успішно змінений' }
49+
format.json { render :show, status: :ok, location: @auth }
50+
else
51+
format.html { render :edit }
52+
format.json { render json: @auth.errors, status: :unprocessable_entity }
53+
end
54+
end
55+
end
56+
57+
# DELETE /books/1
58+
# DELETE /books/1.json
59+
def destroy
60+
@book.destroy
61+
respond_to do |format|
62+
format.html { redirect_to auths_url, notice: 'Книга успішно видалена' }
63+
format.json { head :no_content }
64+
end
65+
end
66+
67+
private
68+
# Use callbacks to share common setup or constraints between actions.
69+
def set_book
70+
@book = Auth.find(params[:id])
71+
end
72+
73+
# Never trust parameters from the scary internet, only allow the white list through.
74+
def book_params
75+
params.require(:auth).permit(:auth, :book)
76+
end
77+
end

app/controllers/books_controller.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ def index
99
else
1010
@books = Book.all
1111
end
12+
1213
end
1314

15+
16+
1417
# GET /books/1
1518
# GET /books/1.json
1619
def show

app/controllers/zhanr_controller.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class ZhanrController < ApplicationController
2+
end

app/helpers/auth_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module AuthHelper
2+
end

app/helpers/zhanr_helper.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
module ZhanrHelper
2+
end

app/models/auth.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Auth < ApplicationRecord
2+
validates :auth, :book, :presence => true
3+
end

app/models/zhanr.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Zhanr < ApplicationRecord
2+
end

app/views/auth/_auth.json.jbuilder

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
json.extract! book, :id, :auth, :book
2+
json.url book_url(book, format: :json)

app/views/auth/_form.html.erb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<% if session[:lang] == "ua"
2+
text ={
3+
:auth => "Назва",
4+
:book => "Автор",
5+
:submit => "Підтвердити"
6+
}
7+
elsif session[:lang] == "en"
8+
text ={
9+
:auth => "Name",
10+
:book => "Author",
11+
:submit => "Submit"
12+
}
13+
elsif session[:lang] == "ru"
14+
text ={
15+
:auth => "Название",
16+
:book => "Автор",
17+
:submit => "Подтвердить"
18+
}
19+
end
20+
%>
21+
<div class="col-md-4 col-md-offset-4">
22+
<%= form_for(auth) do |f| %>
23+
<% if auth.errors.any? %>
24+
<div id="error_explanation">
25+
<h2><%= pluralize(auth.errors.count, "error") %> prohibited this auth from being saved:</h2>
26+
27+
<ul>
28+
<% auth.errors.full_messages.each do |message| %>
29+
<li><%= message %></li>
30+
<% end %>
31+
</ul>
32+
</div>
33+
<% end %>
34+
35+
<div class="form-group">
36+
<label class="col-xs-2 control-label"><%= text[:auth] %></label>
37+
<%= f.text_field :auth, :class => "form-control" %>
38+
</div>
39+
40+
<div class="form-group">
41+
<label class="col-xs-2 control-label"><%= text[:book] %></label>
42+
<%= f.text_field :book, :class => "form-control" %>
43+
</div>
44+
<div class="actions">
45+
<input type="submit" name="submit" class="btn" value=<%= text[:submit] %>>
46+
</div>
47+
<% end %>
48+
</div>

app/views/auth/edit.html.erb

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<% if session[:lang] == "ua"
2+
text ={
3+
:h1 => "Редагування книги",
4+
:show => "Показати",
5+
:back => "Назад"
6+
}
7+
elsif session[:lang] == "en"
8+
text ={
9+
:h1 => "Editing a book",
10+
:show => "Show",
11+
:back => "Back"
12+
}
13+
elsif session[:lang] == "ru"
14+
text ={
15+
:h1 => "Редактирования книги",
16+
:show => "Показать",
17+
:back => "Назад"
18+
}
19+
end
20+
%>
21+
<div class="back">
22+
<h1 class="col-md-6 col-md-offset-3 text-center back"><%= text[:h1] %></h1>
23+
24+
<%= render 'form', book: @book %>
25+
26+
<%= link_to text[:show], @book %> |
27+
<%= link_to text[:back], books_path %>
28+
</div>

app/views/auth/index.html.erb

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<% if session[:lang] == "ua"
2+
text ={
3+
:label_T => "Назва",
4+
:label_A => "Автор",
5+
:label_Z => "Жанр",
6+
:label_Q => "Кількість сторінок",
7+
:label_D => "Опис",
8+
:label_I => "Адреса до картинки",
9+
:h1 => "Книги",
10+
:show => "Показати",
11+
:edit => "Редагувати",
12+
:delete => "Видалити",
13+
:question => "Ви впевнені?",
14+
:new => "Додати нову книгу",
15+
:back => "Назад"
16+
}
17+
elsif session[:lang] == "en"
18+
text ={
19+
:label_T => "Name",
20+
:label_A => "Author",
21+
:label_Z => "Genre",
22+
:label_Q => "Number of pages",
23+
:label_D => "Description",
24+
:label_I => "Address to the picture",
25+
:h1 => "Books",
26+
:show => "Show",
27+
:edit => "Edit",
28+
:delete => "Remove",
29+
:question => "Are you sure?",
30+
:new => "Add new book",
31+
:back => "Back"
32+
}
33+
elsif session[:lang] == "ru"
34+
text ={
35+
:label_T => "Название",
36+
:label_A => "Автор",
37+
:label_Z => "Жанр",
38+
:label_Q => "Количество страниц",
39+
:label_D => "Описание",
40+
:label_I => "Адрес к картинке",
41+
:h1 => "Книги",
42+
:show => "Показать",
43+
:edit => "Редактировать",
44+
:delete => "Удалить",
45+
:question => "Вы уверены?",
46+
:new => "Добавить новую книгу",
47+
:back => "Назад"
48+
}
49+
end
50+
%>
51+
52+
<p id="notice"><%= notice %></p>
53+
54+
<h1 class="col-md-6 col-md-offset-3 text-center back"><%= text[:h1] %></h1>
55+
<div class="container">
56+
<div class="row">
57+
<% @books.each do |book| %>
58+
<div class="col-lg-3">
59+
<div class="box">
60+
<div class="box-gray aligncenter">
61+
<h3><%= link_to book.title, book, :class => "product" %></h3>
62+
<h4><%= book.auth %></h4>
63+
<div class="icon">
64+
65+
<i class="fa fa-desktop fa-3x"></i>
66+
</div>
67+
<p>
68+
<%= book.mini_description %><br/>
69+
<%= link_to 'Видалити', book, method: :delete, data: { confirm: 'Ви впевнені?' } %>
70+
</p>
71+
</div>
72+
</div>
73+
</div>
74+
<% end %>
75+
</div>
76+
</div>
77+

app/views/auth/index.json.jbuilder

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
json.array! @books, partial: 'books/book', as: :book

app/views/auth/new.html.erb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<% if session[:lang] == "ua"
2+
text ={
3+
:h1 => "Додати нову книгу",
4+
:back => "Назад"
5+
}
6+
elsif session[:lang] == "en"
7+
text ={
8+
:h1 => "Add new book",
9+
:back => "Back"
10+
}
11+
elsif session[:lang] == "ru"
12+
text ={
13+
:h1 => "Добавить новую книгу",
14+
:back => "Назад"
15+
}
16+
end
17+
%>
18+
<div class="back">
19+
<h1 class="col-md-6 col-md-offset-3 text-center back"><%= text[:h1] %></h1>
20+
21+
<%= render 'form', auth: @auth %>
22+
23+
<%= link_to text[:back], auths_path %>
24+
</div>

0 commit comments

Comments
 (0)