added brands
This commit is contained in:
3
back-office/app/models/brand.rb
Normal file
3
back-office/app/models/brand.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class Brand < ActiveRecord::Base
|
||||||
|
has_many :items
|
||||||
|
end
|
||||||
@@ -3,6 +3,7 @@ class Item < ActiveRecord::Base
|
|||||||
has_many :multi_media_descriptions
|
has_many :multi_media_descriptions
|
||||||
belongs_to :sub_category
|
belongs_to :sub_category
|
||||||
belongs_to :supplier
|
belongs_to :supplier
|
||||||
|
belongs_to :brand
|
||||||
has_and_belongs_to_many :item_groups, :join_table => 'item_item_groups'
|
has_and_belongs_to_many :item_groups, :join_table => 'item_item_groups'
|
||||||
|
|
||||||
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id, :weight, :supplier_id
|
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id, :weight, :supplier_id
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ def prepare_items_for_mass_display(items)
|
|||||||
:include => [
|
:include => [
|
||||||
:unit ,
|
:unit ,
|
||||||
:multi_media_descriptions ,
|
:multi_media_descriptions ,
|
||||||
:sub_category
|
:sub_category,
|
||||||
|
:brand
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -94,4 +95,4 @@ get '/item/item_group/:item_group_id/offset/:offset/limit/:limit' do |item_group
|
|||||||
|
|
||||||
items = ItemGroup.find(item_group_id).all_items(offset, limit)
|
items = ItemGroup.find(item_group_id).all_items(offset, limit)
|
||||||
prepare_items_for_mass_display(items)
|
prepare_items_for_mass_display(items)
|
||||||
end
|
end
|
||||||
|
|||||||
9
front-api/db/migrate/20150328132019_create_brands.rb
Normal file
9
front-api/db/migrate/20150328132019_create_brands.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class CreateBrands < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :brands do |t|
|
||||||
|
t.string :name
|
||||||
|
end
|
||||||
|
|
||||||
|
add_column :items, :brand_id, :integer
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -11,11 +11,15 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150324044314) do
|
ActiveRecord::Schema.define(version: 20150328132019) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
create_table "brands", force: :cascade do |t|
|
||||||
|
t.string "name"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "carts", force: :cascade do |t|
|
create_table "carts", force: :cascade do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.boolean "ordered", default: false
|
t.boolean "ordered", default: false
|
||||||
@@ -125,6 +129,7 @@ ActiveRecord::Schema.define(version: 20150324044314) do
|
|||||||
t.decimal "weight", precision: 5, scale: 3
|
t.decimal "weight", precision: 5, scale: 3
|
||||||
t.integer "supplier_id"
|
t.integer "supplier_id"
|
||||||
t.integer "delivery_time_estimation_id"
|
t.integer "delivery_time_estimation_id"
|
||||||
|
t.integer "brand_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "link_banners", force: :cascade do |t|
|
create_table "link_banners", force: :cascade do |t|
|
||||||
|
|||||||
3
front-api/models/brand.rb
Normal file
3
front-api/models/brand.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class Brand < ActiveRecord::Base
|
||||||
|
has_many :items
|
||||||
|
end
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
class Item < ActiveRecord::Base
|
class Item < ActiveRecord::Base
|
||||||
belongs_to :unit
|
belongs_to :unit
|
||||||
|
belongs_to :brand
|
||||||
has_many :multi_media_descriptions
|
has_many :multi_media_descriptions
|
||||||
belongs_to :sub_category
|
belongs_to :sub_category
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ var ItemWithDetailsPage = React.createClass({
|
|||||||
<div className="col-md-7">
|
<div className="col-md-7">
|
||||||
<h3> {this.state.item.get('name')}</h3>
|
<h3> {this.state.item.get('name')}</h3>
|
||||||
<div>
|
<div>
|
||||||
|
<div className='h4'> {this.state.item.get('brand').name}</div>
|
||||||
<div className='h4'> {this.state.item.get('list_price')} KM</div>
|
<div className='h4'> {this.state.item.get('list_price')} KM</div>
|
||||||
<div className='h5'>{this.state.item.get('pricePerUnit')}</div>
|
<div className='h5'>{this.state.item.get('pricePerUnit')}</div>
|
||||||
<div> {this.state.item.get('description')}</div>
|
<div> {this.state.item.get('description')}</div>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ var SingleItem = React.createClass({
|
|||||||
<div className="single_item" onClick={itemClick}>
|
<div className="single_item" onClick={itemClick}>
|
||||||
<img src={firstImage.url} className="item_list_image" />
|
<img src={firstImage.url} className="item_list_image" />
|
||||||
<h1> { this.props.item.get('name') }</h1>
|
<h1> { this.props.item.get('name') }</h1>
|
||||||
|
<div>{ this.props.item.get('brand')? this.props.item.get('brand').name : '' } </div>
|
||||||
<div> { this.props.item.get('list_price') } KM </div>
|
<div> { this.props.item.get('list_price') } KM </div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ var Backbone = require('backbone');
|
|||||||
var Globals = require('../globals');
|
var Globals = require('../globals');
|
||||||
|
|
||||||
var Item = Backbone.Model.extend({
|
var Item = Backbone.Model.extend({
|
||||||
urlRoot : Globals.ApiUrl + '/item',
|
urlRoot : Globals.ApiUrl + '/item',
|
||||||
|
defaults : {
|
||||||
|
brand: {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,9 @@ var ItemWithDetails = Backbone.Model.extend({
|
|||||||
var descriptionSuffix = this.get('unit').description_suffix;
|
var descriptionSuffix = this.get('unit').description_suffix;
|
||||||
return (+pricePerUnit).toString() + " KM " + descriptionSuffix;
|
return (+pricePerUnit).toString() + " KM " + descriptionSuffix;
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
defaults : {
|
||||||
|
brand: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user