created items and configured back office ui a bit
This commit is contained in:
3
Gemfile
3
Gemfile
@@ -26,6 +26,9 @@ gem 'sdoc', '~> 0.4.0', group: :doc
|
||||
# great server
|
||||
gem 'puma'
|
||||
|
||||
# for uploading images
|
||||
gem 'cloudinary'
|
||||
|
||||
# Use ActiveModel has_secure_password
|
||||
# gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ GEM
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
arel (6.0.0)
|
||||
aws_cf_signer (0.1.3)
|
||||
binding_of_caller (0.7.2)
|
||||
debug_inspector (>= 0.0.1)
|
||||
builder (3.2.2)
|
||||
@@ -52,6 +53,9 @@ GEM
|
||||
columnize (~> 0.8)
|
||||
debugger-linecache (~> 1.2)
|
||||
slop (~> 3.6)
|
||||
cloudinary (1.0.81)
|
||||
aws_cf_signer
|
||||
rest-client
|
||||
coffee-rails (4.1.0)
|
||||
coffee-script (>= 2.2.0)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
@@ -84,6 +88,7 @@ GEM
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.5.1)
|
||||
multi_json (1.10.1)
|
||||
netrc (0.10.2)
|
||||
nokogiri (1.6.5)
|
||||
mini_portile (~> 0.6.0)
|
||||
pg (0.18.1)
|
||||
@@ -119,6 +124,9 @@ GEM
|
||||
rake (10.4.2)
|
||||
rdoc (4.2.0)
|
||||
json (~> 1.4)
|
||||
rest-client (1.7.2)
|
||||
mime-types (>= 1.16, < 3.0)
|
||||
netrc (~> 0.7)
|
||||
sass (3.4.9)
|
||||
sass-rails (5.0.1)
|
||||
railties (>= 4.0.0, < 5.0)
|
||||
@@ -162,6 +170,7 @@ PLATFORMS
|
||||
DEPENDENCIES
|
||||
active_scaffold!
|
||||
byebug
|
||||
cloudinary
|
||||
coffee-rails (~> 4.1.0)
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
|
||||
5
app/controllers/items_controller.rb
Normal file
5
app/controllers/items_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class ItemsController < ApplicationController
|
||||
active_scaffold :"item" do |conf|
|
||||
conf.columns[:unit].form_ui = :select
|
||||
end
|
||||
end
|
||||
4
app/controllers/media_types_controller.rb
Normal file
4
app/controllers/media_types_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class MediaTypesController < ApplicationController
|
||||
active_scaffold :"media_type" do |conf|
|
||||
end
|
||||
end
|
||||
5
app/controllers/multi_media_descriptions_controller.rb
Normal file
5
app/controllers/multi_media_descriptions_controller.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class MultiMediaDescriptionsController < ApplicationController
|
||||
active_scaffold :"multi_media_description" do |conf|
|
||||
conf.columns[:media_type].form_ui = :select
|
||||
end
|
||||
end
|
||||
4
app/controllers/units_controller.rb
Normal file
4
app/controllers/units_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class UnitsController < ApplicationController
|
||||
active_scaffold :"unit" do |conf|
|
||||
end
|
||||
end
|
||||
4
app/helpers/items_helper.rb
Normal file
4
app/helpers/items_helper.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
module ItemsHelper
|
||||
|
||||
|
||||
end
|
||||
2
app/helpers/media_types_helper.rb
Normal file
2
app/helpers/media_types_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module MediaTypesHelper
|
||||
end
|
||||
2
app/helpers/multi_media_descriptions_helper.rb
Normal file
2
app/helpers/multi_media_descriptions_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module MultiMediaDescriptionsHelper
|
||||
end
|
||||
2
app/helpers/units_helper.rb
Normal file
2
app/helpers/units_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module UnitsHelper
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
class Category < ActiveRecord::Base
|
||||
has_many :sub_categories
|
||||
belongs_to :section
|
||||
end
|
||||
4
app/models/category.rb
Normal file
4
app/models/category.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Category < ActiveRecord::Base
|
||||
has_many :sub_categories
|
||||
belongs_to :section
|
||||
end
|
||||
4
app/models/item.rb
Normal file
4
app/models/item.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Item < ActiveRecord::Base
|
||||
belongs_to :unit
|
||||
has_many :multi_media_descriptions
|
||||
end
|
||||
3
app/models/media_type.rb
Normal file
3
app/models/media_type.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class MediaType < ActiveRecord::Base
|
||||
has_many :multi_media_descriptions
|
||||
end
|
||||
5
app/models/multi_media_description.rb
Normal file
5
app/models/multi_media_description.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class MultiMediaDescription < ActiveRecord::Base
|
||||
belongs_to :item
|
||||
belongs_to :media_type
|
||||
|
||||
end
|
||||
@@ -1,3 +1,3 @@
|
||||
class Section < ActiveRecord::Base
|
||||
has_many :categories
|
||||
has_many :categories
|
||||
end
|
||||
|
||||
2
app/models/unit.rb
Normal file
2
app/models/unit.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Unit < ActiveRecord::Base
|
||||
end
|
||||
@@ -1,12 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Ribicabackoffice</title>
|
||||
<title>Ribica Back Office</title>
|
||||
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
||||
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
||||
<%= csrf_meta_tags %>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<%= link_to "Items", items_path %>
|
||||
<%= link_to "Sections", sections_path %>
|
||||
<%= link_to "Units", units_path %>
|
||||
<%= link_to "Media Types", media_types_path %>
|
||||
</div>
|
||||
|
||||
|
||||
<%= yield %>
|
||||
|
||||
|
||||
19
config/cloudinary.yml
Normal file
19
config/cloudinary.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
---
|
||||
development:
|
||||
cloud_name: lfvt7ps2n
|
||||
api_key: '128267513872316'
|
||||
api_secret: OiLGZbAFd3vcY31ytuYlyBdIi9c
|
||||
enhance_image_tag: true
|
||||
static_image_support: false
|
||||
production:
|
||||
cloud_name: lfvt7ps2n
|
||||
api_key: '128267513872316'
|
||||
api_secret: OiLGZbAFd3vcY31ytuYlyBdIi9c
|
||||
enhance_image_tag: true
|
||||
static_image_support: true
|
||||
test:
|
||||
cloud_name: lfvt7ps2n
|
||||
api_key: '128267513872316'
|
||||
api_secret: OiLGZbAFd3vcY31ytuYlyBdIi9c
|
||||
enhance_image_tag: true
|
||||
static_image_support: false
|
||||
@@ -1,12 +1,17 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
resources :multi_media_descriptions do as_routes end
|
||||
resources :sections do as_routes end
|
||||
resources :media_types do as_routes end
|
||||
resources :items do as_routes end
|
||||
resources :units do as_routes end
|
||||
resources :sub_categories do as_routes end
|
||||
resources :categories do as_routes end
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
# You can have the root of your site routed with "root"
|
||||
# root 'welcome#index'
|
||||
root 'items#index'
|
||||
|
||||
# Example of regular route:
|
||||
# get 'products/:id' => 'catalog#view'
|
||||
|
||||
49
test/controllers/items_controller_test.rb
Normal file
49
test/controllers/items_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@item = items(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:items)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create item" do
|
||||
assert_difference('Item.count') do
|
||||
post :create, item: { code: @item.code, current_input_price: @item.current_input_price, description: @item.description, list_price: @item.list_price, name: @item.name, on_display: @item.on_display, stock: @item.stock, sub_category_id: @item.sub_category_id, unit_id: @item.unit_id, units_in_pack: @item.units_in_pack }
|
||||
end
|
||||
|
||||
assert_redirected_to item_path(assigns(:item))
|
||||
end
|
||||
|
||||
test "should show item" do
|
||||
get :show, id: @item
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @item
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update item" do
|
||||
patch :update, id: @item, item: { code: @item.code, current_input_price: @item.current_input_price, description: @item.description, list_price: @item.list_price, name: @item.name, on_display: @item.on_display, stock: @item.stock, sub_category_id: @item.sub_category_id, unit_id: @item.unit_id, units_in_pack: @item.units_in_pack }
|
||||
assert_redirected_to item_path(assigns(:item))
|
||||
end
|
||||
|
||||
test "should destroy item" do
|
||||
assert_difference('Item.count', -1) do
|
||||
delete :destroy, id: @item
|
||||
end
|
||||
|
||||
assert_redirected_to items_path
|
||||
end
|
||||
end
|
||||
49
test/controllers/media_types_controller_test.rb
Normal file
49
test/controllers/media_types_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MediaTypesControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@media_type = media_types(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:media_types)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create media_type" do
|
||||
assert_difference('MediaType.count') do
|
||||
post :create, media_type: { name: @media_type.name }
|
||||
end
|
||||
|
||||
assert_redirected_to media_type_path(assigns(:media_type))
|
||||
end
|
||||
|
||||
test "should show media_type" do
|
||||
get :show, id: @media_type
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @media_type
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update media_type" do
|
||||
patch :update, id: @media_type, media_type: { name: @media_type.name }
|
||||
assert_redirected_to media_type_path(assigns(:media_type))
|
||||
end
|
||||
|
||||
test "should destroy media_type" do
|
||||
assert_difference('MediaType.count', -1) do
|
||||
delete :destroy, id: @media_type
|
||||
end
|
||||
|
||||
assert_redirected_to media_types_path
|
||||
end
|
||||
end
|
||||
49
test/controllers/multi_media_descriptions_controller_test.rb
Normal file
49
test/controllers/multi_media_descriptions_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MultiMediaDescriptionsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@multi_media_description = multi_media_descriptions(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:multi_media_descriptions)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create multi_media_description" do
|
||||
assert_difference('MultiMediaDescription.count') do
|
||||
post :create, multi_media_description: { item_id: @multi_media_description.item_id, media_type_id: @multi_media_description.media_type_id, url: @multi_media_description.url }
|
||||
end
|
||||
|
||||
assert_redirected_to multi_media_description_path(assigns(:multi_media_description))
|
||||
end
|
||||
|
||||
test "should show multi_media_description" do
|
||||
get :show, id: @multi_media_description
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @multi_media_description
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update multi_media_description" do
|
||||
patch :update, id: @multi_media_description, multi_media_description: { item_id: @multi_media_description.item_id, media_type_id: @multi_media_description.media_type_id, url: @multi_media_description.url }
|
||||
assert_redirected_to multi_media_description_path(assigns(:multi_media_description))
|
||||
end
|
||||
|
||||
test "should destroy multi_media_description" do
|
||||
assert_difference('MultiMediaDescription.count', -1) do
|
||||
delete :destroy, id: @multi_media_description
|
||||
end
|
||||
|
||||
assert_redirected_to multi_media_descriptions_path
|
||||
end
|
||||
end
|
||||
49
test/controllers/units_controller_test.rb
Normal file
49
test/controllers/units_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UnitsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@unit = units(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:units)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create unit" do
|
||||
assert_difference('Unit.count') do
|
||||
post :create, unit: { name: @unit.name, short_name: @unit.short_name }
|
||||
end
|
||||
|
||||
assert_redirected_to unit_path(assigns(:unit))
|
||||
end
|
||||
|
||||
test "should show unit" do
|
||||
get :show, id: @unit
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @unit
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update unit" do
|
||||
patch :update, id: @unit, unit: { name: @unit.name, short_name: @unit.short_name }
|
||||
assert_redirected_to unit_path(assigns(:unit))
|
||||
end
|
||||
|
||||
test "should destroy unit" do
|
||||
assert_difference('Unit.count', -1) do
|
||||
delete :destroy, id: @unit
|
||||
end
|
||||
|
||||
assert_redirected_to units_path
|
||||
end
|
||||
end
|
||||
25
test/fixtures/items.yml
vendored
Normal file
25
test/fixtures/items.yml
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
code: MyString
|
||||
current_input_price: 9.99
|
||||
list_price: 9.99
|
||||
unit_id: 1
|
||||
units_in_pack: 9.99
|
||||
description: MyText
|
||||
sub_category_id: 1
|
||||
stock: 1
|
||||
on_display: false
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
code: MyString
|
||||
current_input_price: 9.99
|
||||
list_price: 9.99
|
||||
unit_id: 1
|
||||
units_in_pack: 9.99
|
||||
description: MyText
|
||||
sub_category_id: 1
|
||||
stock: 1
|
||||
on_display: false
|
||||
7
test/fixtures/media_types.yml
vendored
Normal file
7
test/fixtures/media_types.yml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
11
test/fixtures/multi_media_descriptions.yml
vendored
Normal file
11
test/fixtures/multi_media_descriptions.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
url: MyString
|
||||
item_id: 1
|
||||
media_type_id: 1
|
||||
|
||||
two:
|
||||
url: MyString
|
||||
item_id: 1
|
||||
media_type_id: 1
|
||||
9
test/fixtures/units.yml
vendored
Normal file
9
test/fixtures/units.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
short_name: MyString
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
short_name: MyString
|
||||
7
test/models/item_test.rb
Normal file
7
test/models/item_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/models/media_type_test.rb
Normal file
7
test/models/media_type_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MediaTypeTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/models/multi_media_description_test.rb
Normal file
7
test/models/multi_media_description_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class MultiMediaDescriptionTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/models/unit_test.rb
Normal file
7
test/models/unit_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class UnitTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user