diff --git a/Gemfile b/Gemfile index 3d89962..0a27c86 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index 2f12bc5..0cfdba0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -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 diff --git a/app/assets/javascripts/auth.coffee b/app/assets/javascripts/auth.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/auth.coffee @@ -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/ diff --git a/app/assets/javascripts/zhanr.coffee b/app/assets/javascripts/zhanr.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/zhanr.coffee @@ -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/ diff --git a/app/assets/stylesheets/auth.scss b/app/assets/stylesheets/auth.scss new file mode 100644 index 0000000..f1fe4c6 --- /dev/null +++ b/app/assets/stylesheets/auth.scss @@ -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/ diff --git a/app/assets/stylesheets/zhanr.scss b/app/assets/stylesheets/zhanr.scss new file mode 100644 index 0000000..a26475e --- /dev/null +++ b/app/assets/stylesheets/zhanr.scss @@ -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/ diff --git a/app/controllers/auth_controller.rb b/app/controllers/auth_controller.rb new file mode 100644 index 0000000..037dafd --- /dev/null +++ b/app/controllers/auth_controller.rb @@ -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 diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb index 7fc78cf..fe33d72 100644 --- a/app/controllers/books_controller.rb +++ b/app/controllers/books_controller.rb @@ -9,8 +9,11 @@ def index else @books = Book.all end + end + + # GET /books/1 # GET /books/1.json def show diff --git a/app/controllers/zhanr_controller.rb b/app/controllers/zhanr_controller.rb new file mode 100644 index 0000000..d3d026c --- /dev/null +++ b/app/controllers/zhanr_controller.rb @@ -0,0 +1,2 @@ +class ZhanrController < ApplicationController +end diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb new file mode 100644 index 0000000..31afc3a --- /dev/null +++ b/app/helpers/auth_helper.rb @@ -0,0 +1,2 @@ +module AuthHelper +end diff --git a/app/helpers/zhanr_helper.rb b/app/helpers/zhanr_helper.rb new file mode 100644 index 0000000..0ab8be9 --- /dev/null +++ b/app/helpers/zhanr_helper.rb @@ -0,0 +1,2 @@ +module ZhanrHelper +end diff --git a/app/models/auth.rb b/app/models/auth.rb new file mode 100644 index 0000000..6d17857 --- /dev/null +++ b/app/models/auth.rb @@ -0,0 +1,3 @@ +class Auth < ApplicationRecord + validates :auth, :book, :presence => true +end diff --git a/app/models/zhanr.rb b/app/models/zhanr.rb new file mode 100644 index 0000000..dfe1087 --- /dev/null +++ b/app/models/zhanr.rb @@ -0,0 +1,2 @@ +class Zhanr < ApplicationRecord +end diff --git a/app/views/auth/_auth.json.jbuilder b/app/views/auth/_auth.json.jbuilder new file mode 100644 index 0000000..5238e80 --- /dev/null +++ b/app/views/auth/_auth.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! book, :id, :auth, :book +json.url book_url(book, format: :json) diff --git a/app/views/auth/_form.html.erb b/app/views/auth/_form.html.erb new file mode 100644 index 0000000..ae5c15a --- /dev/null +++ b/app/views/auth/_form.html.erb @@ -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 +%> +
<%= notice %>
+ +
+ <%= book.mini_description %>
+ <%= link_to 'Видалити', book, method: :delete, data: { confirm: 'Ви впевнені?' } %>
+
<%= notice %>
++ <%= @book.title %> +
+ ++ <%= @book.auth %> +
++ <%= text[:label_Z] %> + <%= @book.zhanr %> +
+ ++ <%= text[:label_Q] %> + <%= @book.pages_qty %> +
+ ++ <%= text[:label_D] %> + <%= @book.description %> +
+ ++ <%= text[:label_I] %> + <%= @book.image_url %> +
+<%= notice %>
<%= notice %>
+ +
+ <%= book.mini_description %>
+ <%= link_to 'Видалити', book, method: :delete, data: { confirm: 'Ви впевнені?' } %>
+
<%= notice %>
+ 53: + 54: