Skip to content

Commit

Permalink
Додані моделі критики авторів, жанрів
Browse files Browse the repository at this point in the history
  • Loading branch information
lakatoshv committed May 27, 2018
1 parent 59cd3fd commit aa39659
Show file tree
Hide file tree
Showing 206 changed files with 2,094 additions and 273 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ gem 'jbuilder', '~> 2.5'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'will_paginate', '~> 3.1.0'

#Devise {autorisation}
gem 'devise'
Expand Down
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ GEM
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
will_paginate (3.1.5)

PLATFORMS
ruby
Expand All @@ -195,6 +196,7 @@ DEPENDENCIES
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)
will_paginate (~> 3.1.0)

BUNDLED WITH
1.14.6
3 changes: 3 additions & 0 deletions app/assets/javascripts/auth.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/zhanr.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/auth.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Auth controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/zhanr.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Zhanr controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
77 changes: 77 additions & 0 deletions app/controllers/auth_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
class AuthController < ApplicationController
before_action :set_auth, only: [:show, :edit, :update, :destroy]

# GET /books
# GET /books.json
def index
@auths = Auth.all
end



# GET /books/1
# GET /books/1.json
def show

end

# GET /books/new
def new
@auth = Auth.new
end

# GET /books/1/edit
def edit
end

# POST /books
# POST /books.json
def create
@auth = Auth.new(book_params)

respond_to do |format|
if @auth.save
format.html { redirect_to @auth, notice: 'Автор успішно доданий' }
format.json { render :show, status: :created, location: @auth }
else
format.html { render :new }
format.json { render json: @auth.errors, status: :unprocessable_entity }
end
end
end

# PATCH/PUT /books/1
# PATCH/PUT /books/1.json
def update
respond_to do |format|
if @book.update(book_params)
format.html { redirect_to @auth, notice: 'Автор успішно змінений' }
format.json { render :show, status: :ok, location: @auth }
else
format.html { render :edit }
format.json { render json: @auth.errors, status: :unprocessable_entity }
end
end
end

# DELETE /books/1
# DELETE /books/1.json
def destroy
@book.destroy
respond_to do |format|
format.html { redirect_to auths_url, notice: 'Книга успішно видалена' }
format.json { head :no_content }
end
end

private
# Use callbacks to share common setup or constraints between actions.
def set_book
@book = Auth.find(params[:id])
end

# Never trust parameters from the scary internet, only allow the white list through.
def book_params
params.require(:auth).permit(:auth, :book)
end
end
3 changes: 3 additions & 0 deletions app/controllers/books_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ def index
else
@books = Book.all
end

end



# GET /books/1
# GET /books/1.json
def show
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/zhanr_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class ZhanrController < ApplicationController
end
2 changes: 2 additions & 0 deletions app/helpers/auth_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module AuthHelper
end
2 changes: 2 additions & 0 deletions app/helpers/zhanr_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module ZhanrHelper
end
3 changes: 3 additions & 0 deletions app/models/auth.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Auth < ApplicationRecord
validates :auth, :book, :presence => true
end
2 changes: 2 additions & 0 deletions app/models/zhanr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Zhanr < ApplicationRecord
end
2 changes: 2 additions & 0 deletions app/views/auth/_auth.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
json.extract! book, :id, :auth, :book
json.url book_url(book, format: :json)
48 changes: 48 additions & 0 deletions app/views/auth/_form.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<% if session[:lang] == "ua"
text ={
:auth => "Назва",
:book => "Автор",
:submit => "Підтвердити"
}
elsif session[:lang] == "en"
text ={
:auth => "Name",
:book => "Author",
:submit => "Submit"
}
elsif session[:lang] == "ru"
text ={
:auth => "Название",
:book => "Автор",
:submit => "Подтвердить"
}
end
%>
<div class="col-md-4 col-md-offset-4">
<%= form_for(auth) do |f| %>
<% if auth.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(auth.errors.count, "error") %> prohibited this auth from being saved:</h2>

<ul>
<% auth.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="form-group">
<label class="col-xs-2 control-label"><%= text[:auth] %></label>
<%= f.text_field :auth, :class => "form-control" %>
</div>

<div class="form-group">
<label class="col-xs-2 control-label"><%= text[:book] %></label>
<%= f.text_field :book, :class => "form-control" %>
</div>
<div class="actions">
<input type="submit" name="submit" class="btn" value=<%= text[:submit] %>>
</div>
<% end %>
</div>
28 changes: 28 additions & 0 deletions app/views/auth/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<% if session[:lang] == "ua"
text ={
:h1 => "Редагування книги",
:show => "Показати",
:back => "Назад"
}
elsif session[:lang] == "en"
text ={
:h1 => "Editing a book",
:show => "Show",
:back => "Back"
}
elsif session[:lang] == "ru"
text ={
:h1 => "Редактирования книги",
:show => "Показать",
:back => "Назад"
}
end
%>
<div class="back">
<h1 class="col-md-6 col-md-offset-3 text-center back"><%= text[:h1] %></h1>

<%= render 'form', book: @book %>

<%= link_to text[:show], @book %> |
<%= link_to text[:back], books_path %>
</div>
77 changes: 77 additions & 0 deletions app/views/auth/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<% if session[:lang] == "ua"
text ={
:label_T => "Назва",
:label_A => "Автор",
:label_Z => "Жанр",
:label_Q => "Кількість сторінок",
:label_D => "Опис",
:label_I => "Адреса до картинки",
:h1 => "Книги",
:show => "Показати",
:edit => "Редагувати",
:delete => "Видалити",
:question => "Ви впевнені?",
:new => "Додати нову книгу",
:back => "Назад"
}
elsif session[:lang] == "en"
text ={
:label_T => "Name",
:label_A => "Author",
:label_Z => "Genre",
:label_Q => "Number of pages",
:label_D => "Description",
:label_I => "Address to the picture",
:h1 => "Books",
:show => "Show",
:edit => "Edit",
:delete => "Remove",
:question => "Are you sure?",
:new => "Add new book",
:back => "Back"
}
elsif session[:lang] == "ru"
text ={
:label_T => "Название",
:label_A => "Автор",
:label_Z => "Жанр",
:label_Q => "Количество страниц",
:label_D => "Описание",
:label_I => "Адрес к картинке",
:h1 => "Книги",
:show => "Показать",
:edit => "Редактировать",
:delete => "Удалить",
:question => "Вы уверены?",
:new => "Добавить новую книгу",
:back => "Назад"
}
end
%>

<p id="notice"><%= notice %></p>

<h1 class="col-md-6 col-md-offset-3 text-center back"><%= text[:h1] %></h1>
<div class="container">
<div class="row">
<% @books.each do |book| %>
<div class="col-lg-3">
<div class="box">
<div class="box-gray aligncenter">
<h3><%= link_to book.title, book, :class => "product" %></h3>
<h4><%= book.auth %></h4>
<div class="icon">

<i class="fa fa-desktop fa-3x"></i>
</div>
<p>
<%= book.mini_description %><br/>
<%= link_to 'Видалити', book, method: :delete, data: { confirm: 'Ви впевнені?' } %>
</p>
</div>
</div>
</div>
<% end %>
</div>
</div>

1 change: 1 addition & 0 deletions app/views/auth/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.array! @books, partial: 'books/book', as: :book
24 changes: 24 additions & 0 deletions app/views/auth/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<% if session[:lang] == "ua"
text ={
:h1 => "Додати нову книгу",
:back => "Назад"
}
elsif session[:lang] == "en"
text ={
:h1 => "Add new book",
:back => "Back"
}
elsif session[:lang] == "ru"
text ={
:h1 => "Добавить новую книгу",
:back => "Назад"
}
end
%>
<div class="back">
<h1 class="col-md-6 col-md-offset-3 text-center back"><%= text[:h1] %></h1>

<%= render 'form', auth: @auth %>

<%= link_to text[:back], auths_path %>
</div>
Loading

0 comments on commit aa39659

Please sign in to comment.