Skip to content

Commit 28d76ab

Browse files
author
Dima
committed
Major changes
1 parent 9c0bab1 commit 28d76ab

31 files changed

+456
-425
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@
1414
# Ignore all logfiles and tempfiles.
1515
/log/*.log
1616
/tmp
17+
database.yml
18+
doc/
19+
*.swp
20+
*~
21+
.project
22+
.DS_Store
23+
.idea
24+
.secret

.idea/.generators

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/.rakeTasks

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/Oriflame.iml

+70-71
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/dataSources.xml

+2-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+169-244
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Gemfile

+9-22
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,29 @@ source 'https://rubygems.org'
33
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
44
gem 'rails', '4.0.1'
55

6-
# Use postgresql as the database for Active Record
7-
gem 'pg'
8-
6+
group :development do
7+
gem 'sqlite3'
8+
end
99

1010
gem 'thin'
1111
gem 'devise'
1212
gem 'activeadmin', github: 'gregbell/active_admin'
1313
gem 'slim-rails'
1414
gem 'bootstrap-sass-rails'
1515
gem 'font-awesome-sass'
16-
gem 'rails_12factor', group: :production
1716

18-
# Use SCSS for stylesheets
17+
group :production do
18+
gem 'rails_12factor'
19+
gem 'pg'
20+
end
21+
22+
1923
gem 'sass-rails', '~> 4.0.0'
2024

21-
# Use Uglifier as compressor for JavaScript assets
2225
gem 'uglifier', '>= 1.3.0'
2326

24-
# Use CoffeeScript for .js.coffee assets and views
2527
gem 'coffee-rails', '~> 4.0.0'
2628

27-
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
28-
# gem 'therubyracer', platforms: :ruby
29-
30-
# Use jquery as the JavaScript library
3129
gem 'jquery-rails'
3230
gem 'jquery-ui-rails'
3331

@@ -42,14 +40,3 @@ group :doc do
4240
gem 'sdoc', require: false
4341
end
4442

45-
# Use ActiveModel has_secure_password
46-
# gem 'bcrypt-ruby', '~> 3.1.2'
47-
48-
# Use unicorn as the app server
49-
# gem 'unicorn'
50-
51-
# Use Capistrano for deployment
52-
# gem 'capistrano', group: :development
53-
54-
# Use debugger
55-
# gem 'debugger', group: [:development, :test]

Gemfile.lock

+2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ GEM
162162
actionpack (>= 3.0)
163163
activesupport (>= 3.0)
164164
sprockets (~> 2.8)
165+
sqlite3 (1.3.8)
165166
temple (0.6.7)
166167
thin (1.6.1)
167168
daemons (>= 1.0.9)
@@ -201,6 +202,7 @@ DEPENDENCIES
201202
sass-rails (~> 4.0.0)
202203
sdoc
203204
slim-rails
205+
sqlite3
204206
thin
205207
turbolinks
206208
uglifier (>= 1.3.0)

Oriflame_development

25 KB
Binary file not shown.

app/admin/category.rb

+1-12
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@ def permitted_params
2828
links
2929
end
3030
end
31-
# See permitted parameters documentation:
32-
# https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
33-
#
34-
# permit_params :list, :of, :attributes, :on, :model
35-
#
36-
# or
37-
#
38-
# permit_params do
39-
# permitted = [:permitted, :attributes]
40-
# permitted << :other if resource.something?
41-
# permitted
42-
# end
31+
4332

4433
end

app/admin/product.rb

+1-26
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,7 @@ def permitted_params
88

99
end
1010

11-
form do |f|
12-
f.inputs "Детали" do
13-
f.input :category_id, label:'Категория', :as => :select, :collection => Category.all.map{|c| ["#{c.name}", c.id]}
14-
f.input :title, label: 'Наименование'
15-
f.input :image_url, label: "Картинка"
16-
f.input :description, label: "Описание"
17-
f.input :about_product, label: "О продукте"
18-
f.input :ingredients, label: "Ингредиенты"
19-
f.input :price, label: "Стоимость"
20-
end
21-
f.actions
22-
end
11+
form partial: 'form'
2312

2413

2514
index title: 'Продукты' do
@@ -38,19 +27,5 @@ def permitted_params
3827
links
3928
end
4029
end
41-
42-
43-
# See permitted parameters documentation:
44-
# https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
45-
#
46-
# permit_params :list, :of, :attributes, :on, :model
47-
#
48-
# or
49-
#
50-
# permit_params do
51-
# permitted = [:permitted, :attributes]
52-
# permitted << :other if resource.something?
53-
# permitted
54-
# end
5530

5631
end

app/assets/javascripts/application.js

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ $(document).ready(function(){
2525
$('.top-header').slideToggle('fast');
2626
return false;
2727
});
28+
$(".modal-wide").on("show.bs.modal", function() {
29+
var height = $(window).height() - 200;
30+
$(this).find(".modal-body").css("max-height", height);
31+
});
2832

2933
});
3034
$(document).ready(ready);

app/assets/stylesheets/application.css.sass

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
*= require jquery.ui.all
1515
*= require_tree .
1616
*/
17-
17+
.notice
18+
position: fixed
19+
z-index: 3
20+
top: 10px
21+
right: 10px
22+
text-align: center
23+
background: rgba(242,222,222,0.8) !important
1824
$link-hover: #ed1c2e
1925
$border-color: #dbdbdb
2026
$head-link-color: #8e8e8e

app/assets/stylesheets/cart.css.sass

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
// Place all the styles related to the Cart controller here.
22
// They will automatically be included in application.css.
33
// You can use Sass (SCSS) here: http://sass-lang.com/
4+
.p_b
5+
border: 1px solid red
6+
min-width: 100px
7+
.modal .modal-dialog
8+
width: 90%
9+
.modal .modal-body
10+
overflow-y: auto

app/controllers/carts_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ def destroy
7979
# Use callbacks to share common setup or constraints between actions.
8080
def set_cart
8181
@cart = Cart.find(params[:id])
82+
rescue ActiveRecord::RecordNotFound
83+
redirect_to root_path, alert: "Корзина не найдена!"
8284
end
8385

8486
# Never trust parameters from the scary internet, only allow the white list through.

app/controllers/categories_controller.rb

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class CategoriesController < ApplicationController
22
before_action :set_category, only: [ :show, :edit, :update, :destroy]
3+
before_filter :authenticate_admin!, except: [:index, :show]
34
respond_to :html, :xml, :json
45

56
def index
@@ -43,6 +44,8 @@ def destroy
4344

4445
def set_category
4546
@category = Category.find(params[:id])
47+
rescue ActiveRecord::RecordNotFound
48+
redirect_to root_path, alert: "Категория не найдена!"
4649
end
4750

4851
def category_params

app/controllers/orders_controller.rb

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def create
5151
# Use callbacks to share common setup or constraints between actions.
5252
def set_order
5353
@order = Order.find(params[:id])
54+
rescue ActiveRecord::RecordNotFound
55+
redirect_to root_path, alert: "Заказ не найден!"
5456
end
5557

5658
# Never trust parameters from the scary internet, only allow the white list through.

app/controllers/products_controller.rb

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class ProductsController < ApplicationController
22

33
before_action :set_product, only: [ :show, :edit, :update, :destroy]
4+
before_filter :authenticate_admin!, except: [:index, :show]
45
respond_to :html, :xml, :json
56

67
def index
@@ -36,6 +37,9 @@ def destroy
3637

3738
def set_product
3839
@category = Product.find(params[:id])
40+
rescue ActiveRecord::RecordNotFound
41+
flash[:alert] = "Продукт не найден!"
42+
redirect_to root_path
3943
end
4044

4145
def product_params
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
= semantic_form_for [:admin, @product], role: 'form' do |f|
2+
.panel-group#accordion
3+
.panel.panel-default
4+
.panel-heading
5+
h4.panel-title
6+
= link_to 'Название/Denumire', '#collapse1', data: { toggle: 'collapse', parrent: 'accordion'}
7+
#collapse1.panel-collapse.collapse
8+
.panel-body
9+
.form-group
10+
.row
11+
.col-xs-10
12+
= f.input :title, :label => 'Ру', class:'form-control'
13+
.col-xs-10
14+
= f.input :title_ro, label: 'Ro', class:'form-control'
15+
.panel.panel-default
16+
.panel-heading
17+
h4.panel-title
18+
= link_to 'Категория/Categoria ', '#collapse8', data: { toggle: 'collapse', parrent: 'accordion'}
19+
#collapse8.panel-collapse.collapse
20+
.panel-body
21+
.form-group
22+
.row
23+
.col-xs-4
24+
= f.input :category_id, :as => :select, :collection => Category.all.map{|c| ["#{c.name}", c.id]}, :label => 'Категория/Categoria', input_html:{class:'form-control'}
25+
.panel.panel-default
26+
.panel-heading
27+
h4.panel-title
28+
= link_to 'Фото/Imaginea', '#collapse9', data: { toggle: 'collapse', parrent: 'accordion'}
29+
#collapse9.panel-collapse.collapse
30+
.panel-body
31+
.form-group
32+
.row
33+
.col-xs-8
34+
= f.input :image_url, label: 'Фото/Imaginea', class:'form-control img-i'
35+
.panel.panel-default
36+
.panel-heading
37+
h4.panel-title
38+
= link_to 'Description', '#collapse3', data: { toggle: 'collapse', parrent: 'accordion'}
39+
#collapse3.panel-collapse.collapse
40+
.panel-body
41+
.form-group
42+
.row
43+
.col-xs-5
44+
= f.input :description, :label => 'Ру', class:'form-control'
45+
.col-xs-5
46+
= f.input :description_ro, label: 'Ro', class:'form-control'
47+
.panel.panel-default
48+
.panel-heading
49+
h4.panel-title
50+
= link_to 'About Product', '#collapse4', data: { toggle: 'collapse', parrent: 'accordion'}
51+
#collapse4.panel-collapse.collapse
52+
.panel-body
53+
.form-group
54+
.row
55+
.col-xs-5
56+
= f.input :about_product, :label => 'Ру', class:'form-control'
57+
.col-xs-5
58+
= f.input :about_product_ro, label: 'Ro', class:'form-control'
59+
.panel.panel-default
60+
.panel-heading
61+
h4.panel-title
62+
= link_to 'Ingredients', '#collapse5', data: { toggle: 'collapse', parrent: 'accordion'}
63+
#collapse5.panel-collapse.collapse
64+
.panel-body
65+
.form-group
66+
.row
67+
.col-xs-5
68+
= f.input :ingredients, :label => 'Ру', class:'form-control'
69+
.col-xs-5
70+
= f.input :ingredients_ro, label: 'Ro', class:'form-control'
71+
.panel.panel-default
72+
.panel-heading
73+
h4.panel-title
74+
= link_to 'Price', '#collapse6', data: { toggle: 'collapse', parrent: 'accordion'}
75+
#collapse6.panel-collapse.collapse
76+
.panel-body
77+
.form-group
78+
.row
79+
.col-xs-5
80+
= f.input :price, :label => 'Цена', class:'form-control'
81+
=f.actions

app/views/carts/_cart.html.slim

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
-if cart.items.empty?
22
h1 Корзина пуста!
33
-else
4+
.col-md-4
5+
| Кольво
6+
.col-md-4
7+
| Name
8+
.col-md-4
9+
| Total Price
410
= render (cart.items)
5-
li
6-
span.label.label-success #{@cart.total_price}
7-
.row-fluid
8-
.col-md-3
9-
= button_to 'Оформить заказ', new_order_path, method: :get, class: 'btn btn-info'
10-
.col-md-3.pull-right
11-
= button_to 'Очитсить корзину', @cart, method: :delete, class: 'btn btn-danger'
11+
.col-md-12.p_b
12+
| Всего:
13+
.label.label-success #{@cart.total_price}
14+
.col-md-12
15+
= button_to 'Оформить заказ', new_order_path, method: :get, class: 'btn btn-info'
16+
= button_to 'Очитсить корзину', @cart, method: :delete, class: 'btn btn-danger'

app/views/carts/show.html.slim

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
p#notice = notice
2-
31
= render @cart
4-
5-
= link_to 'Edit', edit_cart_path(@cart)
6-
'|
7-
= link_to 'Back', carts_path
2+
= link_to 'Edit', edit_cart_path(@cart), class: 'label label-warning'

0 commit comments

Comments
 (0)