Compare commits
1 Commits
migration_
...
edos_stuff
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb37ff0391 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,7 +11,6 @@
|
||||
/back-office/log/*
|
||||
!/back-office/log/.keep
|
||||
/back-office/tmp
|
||||
/back-office/import.log
|
||||
*.gem
|
||||
*.rbc
|
||||
/front-api/.config
|
||||
|
||||
BIN
back-office/.DS_Store
vendored
Normal file
BIN
back-office/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -31,8 +31,6 @@ gem 'puma'
|
||||
# for uploading images
|
||||
gem 'cloudinary'
|
||||
|
||||
gem 'tabulous'
|
||||
|
||||
# Use ActiveModel has_secure_password
|
||||
# gem 'bcrypt', '~> 3.1.7'
|
||||
|
||||
@@ -56,4 +54,3 @@ group :development, :test do
|
||||
gem 'spring'
|
||||
end
|
||||
|
||||
gem 'elasticsearch'
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
GIT
|
||||
remote: git://github.com/activescaffold/active_scaffold.git
|
||||
revision: 6f637d62c7b4eb7ae49a28f6b8c9b86997a326a3
|
||||
revision: 4693e8a3278702143b1668fb5f6317b1c4f90388
|
||||
branch: master
|
||||
specs:
|
||||
active_scaffold (3.4.17)
|
||||
active_scaffold (3.4.14)
|
||||
rails (>= 3.2.18, < 5)
|
||||
|
||||
GEM
|
||||
@@ -63,22 +63,11 @@ GEM
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.8.0)
|
||||
colored (1.2)
|
||||
columnize (0.9.0)
|
||||
debug_inspector (0.0.2)
|
||||
debugger-linecache (1.2.0)
|
||||
elasticsearch (1.0.9)
|
||||
elasticsearch-api (= 1.0.9)
|
||||
elasticsearch-transport (= 1.0.9)
|
||||
elasticsearch-api (1.0.9)
|
||||
multi_json
|
||||
elasticsearch-transport (1.0.9)
|
||||
faraday
|
||||
multi_json
|
||||
erubis (2.7.0)
|
||||
execjs (2.2.2)
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
font-awesome-rails (4.3.0.0)
|
||||
railties (>= 3.2, < 5.0)
|
||||
globalid (0.3.0)
|
||||
@@ -108,7 +97,6 @@ GEM
|
||||
mini_portile (0.6.2)
|
||||
minitest (5.5.1)
|
||||
multi_json (1.10.1)
|
||||
multipart-post (2.0.0)
|
||||
nested_form (0.3.2)
|
||||
netrc (0.10.2)
|
||||
nokogiri (1.6.5)
|
||||
@@ -189,9 +177,6 @@ GEM
|
||||
actionpack (>= 3.0)
|
||||
activesupport (>= 3.0)
|
||||
sprockets (>= 2.8, < 4.0)
|
||||
tabulous (2.1.3)
|
||||
colored (~> 1.2.0)
|
||||
rails (>= 3.0, < 5.0.0)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.4)
|
||||
tilt (1.4.1)
|
||||
@@ -216,7 +201,6 @@ DEPENDENCIES
|
||||
byebug
|
||||
cloudinary
|
||||
coffee-rails (~> 4.1.0)
|
||||
elasticsearch
|
||||
jbuilder (~> 2.0)
|
||||
jquery-rails
|
||||
jquery-ui-rails
|
||||
@@ -227,7 +211,6 @@ DEPENDENCIES
|
||||
sass-rails (~> 5.0)
|
||||
sdoc (~> 0.4.0)
|
||||
spring
|
||||
tabulous
|
||||
turbolinks
|
||||
uglifier (>= 1.3.0)
|
||||
web-console (~> 2.0)
|
||||
|
||||
BIN
back-office/app/assets/images/.DS_Store
vendored
Normal file
BIN
back-office/app/assets/images/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -1,4 +0,0 @@
|
||||
class DeliveryTimeEstimationsController < ApplicationController
|
||||
active_scaffold :"delivery_time_estimation" do |conf|
|
||||
end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
class ItemGroupsController < ApplicationController
|
||||
active_scaffold :"item_group" do |conf|
|
||||
end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
class ItemInGroupsController < ApplicationController
|
||||
active_scaffold :"item_in_group" do |conf|
|
||||
end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
class LinkBannersController < ApplicationController
|
||||
active_scaffold :"link_banner" do |conf|
|
||||
end
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
class PlacesController < ApplicationController
|
||||
active_scaffold :"place" do |conf|
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
class ReportsController < ApplicationController
|
||||
def items_to_order
|
||||
@report = Item.items_to_order
|
||||
end
|
||||
|
||||
|
||||
def orders_to_confirm
|
||||
@report = Item.orders_to_confirm
|
||||
end
|
||||
|
||||
def orders_to_pack
|
||||
@report = Item.orders_to_pack
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
class SuppliersController < ApplicationController
|
||||
active_scaffold :"supplier" do |conf|
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,2 @@
|
||||
module ApplicationHelper
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
module DeliveryTimeEstimationsHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module ItemGroupsHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module ItemInGroupsHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module LinkBannersHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module PlacesHelper
|
||||
end
|
||||
@@ -1,2 +0,0 @@
|
||||
module SuppliersHelper
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
class Brand < ActiveRecord::Base
|
||||
has_many :items
|
||||
end
|
||||
@@ -1,10 +1,2 @@
|
||||
class Cart < ActiveRecord::Base
|
||||
|
||||
has_many :item_in_carts
|
||||
belongs_to :user
|
||||
belongs_to :delivery_destination
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
class DeliveryTimeEstimation < ActiveRecord::Base
|
||||
end
|
||||
@@ -2,126 +2,6 @@ class Item < ActiveRecord::Base
|
||||
belongs_to :unit
|
||||
has_many :multi_media_descriptions
|
||||
belongs_to :sub_category
|
||||
belongs_to :supplier
|
||||
belongs_to :brand
|
||||
belongs_to :delivery_time_estimation
|
||||
|
||||
|
||||
|
||||
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id, :weight, :supplier_id
|
||||
|
||||
def self.items_to_order
|
||||
items_raw = Item.find_by_sql(%Q{
|
||||
select s.id as supplier_id, i.code as code, i.name as name, sum(iic.count) amount, i.current_input_price
|
||||
from carts c
|
||||
left join item_in_carts iic on iic.cart_id = c.id
|
||||
left join items i on i.id = iic.item_id
|
||||
left join suppliers s on i.supplier_id = s.id
|
||||
where c.confirmed and not (c.packed or c.delivered)
|
||||
group by s.id, i.name, i.code, i.current_input_price
|
||||
order by s.name, amount desc;
|
||||
})
|
||||
|
||||
items_sorted = {}
|
||||
suppliers_sorted = {}
|
||||
|
||||
items_raw.each do |item|
|
||||
items_sorted[item.supplier_id] ||= []
|
||||
suppliers_sorted[item.supplier_id] ||= item.supplier
|
||||
items_sorted[item.supplier_id] << item
|
||||
end
|
||||
|
||||
report_items = []
|
||||
|
||||
complete_sum = 0
|
||||
|
||||
suppliers_sorted.each_pair do |key, value|
|
||||
|
||||
rep_sec = OpenStruct.new # report section
|
||||
rep_sec.supplier = value
|
||||
rep_sec.items = items_sorted[key]
|
||||
rep_sec.sum_amount = rep_sec.items.reduce(0) do |sum, item|
|
||||
sum + (item.current_input_price * item.amount)
|
||||
end
|
||||
complete_sum += rep_sec.sum_amount
|
||||
|
||||
report_items << rep_sec
|
||||
end
|
||||
|
||||
full_report = OpenStruct.new
|
||||
full_report.sections = report_items
|
||||
full_report.full_sum = complete_sum
|
||||
|
||||
return full_report
|
||||
end
|
||||
|
||||
|
||||
def self.orders_to_confirm
|
||||
items_raw = Item.find_by_sql(%Q{
|
||||
select dd.name + ' ' + dd.email + ' ' + dd.phone + ' ' + dd.address as dd_key , dd.*, c.id as order_id,i.code as code, i.name as item, iic.count as amount , i.list_price, iic.count * i.list_price as sum_price
|
||||
from carts c
|
||||
left join delivery_destinations dd on c.delivery_destination_id = dd.id
|
||||
left join item_in_carts iic on iic.cart_id = c.id
|
||||
left join items i on i.id = iic.item_id
|
||||
|
||||
where c.ordered and not(c.canceled_on_check or c.canceled_on_delivery or c.confirmed or c.packed or c.delivered)
|
||||
order by
|
||||
c.created_at, iic.created_at;
|
||||
})
|
||||
return self.format_orders(items_raw)
|
||||
end
|
||||
|
||||
def self.orders_to_pack
|
||||
items_raw = Item.find_by_sql(%Q{
|
||||
select dd.name + ' ' + dd.email + ' ' + dd.phone + ' ' + dd.address as dd_key, dd.*, c.id as order_id,i.code as code, i.name as item, iic.count as amount , i.list_price, iic.count * i.list_price as sum_price
|
||||
from carts c
|
||||
left join delivery_destinations dd on c.delivery_destination_id = dd.id
|
||||
left join item_in_carts iic on iic.cart_id = c.id
|
||||
left join items i on i.id = iic.item_id
|
||||
|
||||
where c.confirmed and not(c.canceled_on_check or c.canceled_on_delivery or c.packed or c.delivered)
|
||||
order by
|
||||
c.created_at, iic.created_at;
|
||||
})
|
||||
return self.format_orders(items_raw)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.format_orders(items_raw)
|
||||
items_sorted = {}
|
||||
|
||||
items_raw.each do |item|
|
||||
items_sorted[item.dd_key] ||= {}
|
||||
items_sorted[item.dd_key][item.order_id] ||= []
|
||||
items_sorted[item.dd_key][item.order_id] << item
|
||||
end
|
||||
|
||||
sections = []
|
||||
complete_sum = 0
|
||||
|
||||
items_sorted.each_pair do |key,values_hash|
|
||||
section = OpenStruct.new
|
||||
section.orders = []
|
||||
|
||||
values_hash.each_pair do |vkey, values|
|
||||
section.delivery_destination = values.first
|
||||
section.sum_amount = 0
|
||||
section.items = []
|
||||
values.each do |item|
|
||||
section.sum_amount += item.sum_price
|
||||
complete_sum += item.sum_price
|
||||
section.items << item
|
||||
end
|
||||
sections << section
|
||||
end
|
||||
end
|
||||
full_report = OpenStruct.new
|
||||
full_report.sections = sections
|
||||
full_report.full_sum = complete_sum
|
||||
|
||||
return full_report
|
||||
end
|
||||
|
||||
|
||||
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id
|
||||
end
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class ItemGroup < ActiveRecord::Base
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -5,12 +5,4 @@ class ItemInCart < ActiveRecord::Base
|
||||
validates_uniqueness_of :item_id, scope: :cart_id
|
||||
validates :item_id, presence: true
|
||||
validates :cart_id, presence: true
|
||||
|
||||
def name
|
||||
if item
|
||||
item.name + " " + count.to_s + " " + price.to_s
|
||||
else
|
||||
" no item "
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
class ItemInGroup < ActiveRecord::Base
|
||||
belongs_to :item_group
|
||||
belongs_to :item
|
||||
|
||||
validates_presence_of :item_group_id
|
||||
validates_presence_of :item_id
|
||||
validates_presence_of :position
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
class LinkBanner < ActiveRecord::Base
|
||||
|
||||
belongs_to :category
|
||||
belongs_to :section
|
||||
belongs_to :sub_category
|
||||
|
||||
validates_presence_of :beginning, :ending, :image_url
|
||||
validate :validate_beginning_before_ending
|
||||
|
||||
def validate_beginning_before_ending
|
||||
if beginning && ending
|
||||
errors.add(:ending, "End date must come after beginning date") if ending <= beginning
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
class MenuItem < ActiveRecord::Base
|
||||
has_many :menu_sub_items
|
||||
end
|
||||
@@ -1,4 +0,0 @@
|
||||
class MenuSubItem < ActiveRecord::Base
|
||||
belongs_to :menu_item
|
||||
has_many :menu_sub_sub_items
|
||||
end
|
||||
@@ -1,3 +0,0 @@
|
||||
class MenuSubSubItem < ActiveRecord::Base
|
||||
belongs_to :menu_sub_item
|
||||
end
|
||||
@@ -1,524 +0,0 @@
|
||||
class Place < ActiveRecord::Base
|
||||
|
||||
|
||||
def self.name_from_code(code)
|
||||
places_bulk = %Q{Aleksandrovac 78255
|
||||
Avtovac 89245
|
||||
Balatun 76310
|
||||
Banja Luka 78000
|
||||
Banovici 75290
|
||||
Batkovic 76312
|
||||
Begov Han 72233
|
||||
Berkovici 88363
|
||||
Bihac 77000
|
||||
Bijela 76204
|
||||
Bijeljina 76300
|
||||
Bijelo Brdo 73263
|
||||
Bileca 89230
|
||||
Biljesevo 72248
|
||||
Bjelimici 88407
|
||||
Blagaj 88201
|
||||
Blatnica 74275
|
||||
Blatnica Kod Mostara 88263
|
||||
Blazuj 71215
|
||||
Bok 76277
|
||||
Boljanic 74322
|
||||
Bosanska Krupa 77240
|
||||
Bosanski Petrovac 77250
|
||||
Bosansko Grahovo 80270
|
||||
Bradina 88408
|
||||
Bratunac 75420
|
||||
Brcko 76000
|
||||
Brcko Distrikt 76100
|
||||
Brekovica 77205
|
||||
Brestovo 74210
|
||||
Brestovsko 71255
|
||||
Breza 71370
|
||||
Brezicani 79208
|
||||
Brezik 76109
|
||||
Brezovo Polje 76216
|
||||
Brijesnica 74206
|
||||
Brijesnica Kod Doboja 74206
|
||||
Brijesnica Mala 74206
|
||||
Brijesnica Velika 74206
|
||||
Brka 76206
|
||||
Brnjic 72243
|
||||
Brocanac 88243
|
||||
Brocanac 88243
|
||||
Brod Kod Foce 73309
|
||||
Brodac 76313
|
||||
Bronzani Majdan 78204
|
||||
Bucici 72290
|
||||
Bugojno 70230
|
||||
Bukinje 75203
|
||||
Buletic 74277
|
||||
Buna 88202
|
||||
Busovaca 72260
|
||||
Buturovicpolje 88409
|
||||
Buzim 77245
|
||||
Cajnice 73280
|
||||
Caparde 75405
|
||||
Capljina 88300
|
||||
Cardak 72224
|
||||
Careva Cuprija 71347
|
||||
Catici 72246
|
||||
Cazin 77220
|
||||
Cecava 74274
|
||||
Celebici 88404
|
||||
Celebici Lusnic 80203
|
||||
Celebici Kod Foce 73307
|
||||
Celic 75246
|
||||
Celinac 78240
|
||||
Cemerno 89243
|
||||
Cerin 88265
|
||||
Cerovica 74211
|
||||
Cerovljani 78403
|
||||
Citluk 88260
|
||||
Coralici 77226
|
||||
Crkvina 76239
|
||||
Crnici 88367
|
||||
Crnjelovo 76328
|
||||
Dejcici 71221
|
||||
Demirovac 79243
|
||||
Derventa 74400
|
||||
Derventa Kod Vlasenice 75444
|
||||
Divin 89233
|
||||
Doboj 74000
|
||||
Doboj Istok 74206
|
||||
Doboj Jug 74203
|
||||
Doborovci 75328
|
||||
Dobosnica 75308
|
||||
Dobretici 77210
|
||||
Dobrinja 71245
|
||||
Dobrljin 79223
|
||||
Dobro Selo 77242
|
||||
Dobrun 73247
|
||||
Dokanj 75206
|
||||
Dolac Na Lasvi 72278
|
||||
Domaljevac 76233
|
||||
Domanovici 88305
|
||||
Donja Mahala 76274
|
||||
Donja Medjidja 76257
|
||||
Donja Slatina 76327
|
||||
Donje Mostre 71305
|
||||
Donji Agici 79228
|
||||
Donji Memici 88343
|
||||
Donji Vakuf 70220
|
||||
Donji Vijacani 78432
|
||||
Donji Vrbljani 79289
|
||||
Donji Zabar 76273
|
||||
Dragaljevac 76323
|
||||
Dragalovci 74209
|
||||
Dragocaj 78215
|
||||
Dreznica 88215
|
||||
Drinjaca 75410
|
||||
Drinovci 88344
|
||||
Drvar 80260
|
||||
Duboki Potok 75358
|
||||
Dubostica 75308
|
||||
Dubrave 78411
|
||||
Dubrave Donje 75274
|
||||
Dubrave Gornje 75273
|
||||
Dubrovik 79227
|
||||
Dugo Polje 74483
|
||||
Djurdjevik 75272
|
||||
Dusanovo 75445
|
||||
Duzice 88342
|
||||
Dvorovi 76311
|
||||
Fajtovci 79264
|
||||
Foca 73300
|
||||
Fojnica 71270
|
||||
Fojnica Kod Gacka 89247
|
||||
Gabela Polje 88306
|
||||
Gacko 89240
|
||||
Glamoc 80230
|
||||
Glavicice 76318
|
||||
Globarica 72230
|
||||
Gojevici 71275
|
||||
Gorazde 73000
|
||||
Gorica 88340
|
||||
Gornja Koprivna 77222
|
||||
Gornja Slatina 76238
|
||||
Gornja Tuzla 75208
|
||||
Gornji Kamengrad 79266
|
||||
Gornji Podgradci 78405
|
||||
Gornji Rahic 76207
|
||||
Gornji Strpci 78439
|
||||
Gornji Teslic 74272
|
||||
Gornji Vakuf Uskoplje 70240
|
||||
Gornji Zovik 76207
|
||||
Grab 89201
|
||||
Grabovica 78227
|
||||
Gracanica 75320
|
||||
Gracanica Kod Bugojna 70233
|
||||
Gracanica Selo 75276
|
||||
Gradac 88392
|
||||
Gradacac 76250
|
||||
Gradiska 78400
|
||||
Grude 88340
|
||||
Guber 80205
|
||||
Listani 80204
|
||||
Guca Gora 72277
|
||||
Hadzici 71240
|
||||
Hajdarevici 72225
|
||||
Haljinici 72245
|
||||
Han Bila 72281
|
||||
Han Pijesak 71360
|
||||
Hrasnica 71212
|
||||
Hrasno 88395
|
||||
Hresa 71144
|
||||
Hrvacani 78436
|
||||
Husino 75216
|
||||
Hutovo 88394
|
||||
Ilidza 71210
|
||||
Ilijas 71380
|
||||
Ilovaca 73208
|
||||
Imljani 78234
|
||||
Izacic 77208
|
||||
Jablanica 88420
|
||||
Jahorina 71423
|
||||
Jajce 70101
|
||||
Janja 76316
|
||||
Janjici 72215
|
||||
Jare 88224
|
||||
Javorani 78233
|
||||
Jelah 74264
|
||||
Jezerski 77241
|
||||
Johova 79244
|
||||
Josanica 73319
|
||||
Josavka 78244
|
||||
Kacuni 72264
|
||||
Kakanj 72240
|
||||
Kalenderovci 74413
|
||||
Kalesija 75260
|
||||
Kalinovik 71230
|
||||
Kamenica 77204
|
||||
Kaonik 72265
|
||||
Kasindo 71213
|
||||
Kazaginac 80246
|
||||
Kifino Selo 88283
|
||||
Kiseljak 71250
|
||||
Kiseljak, Kod Tuzle 75211
|
||||
Kladanj 75280
|
||||
Klakar Donji 74452
|
||||
Kljuc 79280
|
||||
Klobuk 88324
|
||||
Klokotnica 74207
|
||||
Knezevo 78230
|
||||
Skender Vakuf 78230
|
||||
Knezica 79246
|
||||
Knezina 71356
|
||||
Kobas 78423
|
||||
Kocerin 88226
|
||||
Kocicevo 78409
|
||||
Kola 78207
|
||||
Kongora 80244
|
||||
Konjic 88400
|
||||
Konjoder 77249
|
||||
Koprivna 74489
|
||||
Koraj 75247
|
||||
Kornica 76236
|
||||
Kosova 74253
|
||||
Kostric 76276
|
||||
Kotor Varos 78220
|
||||
Kotorsko 74215
|
||||
Kovaci 72226
|
||||
Kozarac 79002
|
||||
Bosanska Dubica 79240
|
||||
Kozluk 75413
|
||||
Kraljeva Sutjeska 72244
|
||||
Kresevo 71260
|
||||
Kriskovci 78256
|
||||
Krupa Na Vrbasu 78206
|
||||
Krusevo 88203
|
||||
Kukulje 78424
|
||||
Kula 71216
|
||||
Kulasi 78443
|
||||
Kulen Vakuf 77206
|
||||
Kupres 80320
|
||||
Laktasi 78250
|
||||
Laminci Sredjani 78407
|
||||
Lamovita 79204
|
||||
Lastva 89208
|
||||
Lasva 72216
|
||||
Liplje 78222
|
||||
Lipnica 75213
|
||||
Lisnja 78434
|
||||
Livno 80101
|
||||
Ljubace 75214
|
||||
Ljubija 79206
|
||||
Ljubinje 88380
|
||||
Ljubomir 89209
|
||||
Ljubuski 88320
|
||||
Ljuti Dolac 88223
|
||||
Loncari 76278
|
||||
Lopare 75240
|
||||
Lukavac 75300
|
||||
Lukavac Mjesto 75301
|
||||
Lukavica 75327
|
||||
Lusci Palanka 79267
|
||||
Maglaj 74250
|
||||
Majevac 74216
|
||||
Mala Kladusa 77235
|
||||
Mala Socanica 74418
|
||||
Malesici 75320
|
||||
Maoca 76208
|
||||
Masici 78410
|
||||
Maslovare 78223
|
||||
Matici 76271
|
||||
Matuzici 74203
|
||||
Medjugorje 88266
|
||||
Medjuvodje 79247
|
||||
Mehurici 72282
|
||||
Mesihovina 80243
|
||||
Milici 75446
|
||||
Miljeno 73283
|
||||
Miljevina 73313
|
||||
Milosevac 74485
|
||||
Miricina 75329
|
||||
Modrica 74480
|
||||
Mokro 71428
|
||||
Mosko 89204
|
||||
Mostar 88000
|
||||
Mostar, Jug 88000
|
||||
Mostar, Jugozapad 88000
|
||||
Mostar, Sjever 88000
|
||||
Mostar, Zapad 88000
|
||||
Mramor 75212
|
||||
Mravinjac 73206
|
||||
Mrkodol 79544
|
||||
Mrkonjic Grad 70260
|
||||
Nemila 72212
|
||||
Neum 88390
|
||||
Nevesinje 88280
|
||||
Nova Bila 72276
|
||||
Nova Topola 78418
|
||||
Bosanski Novi 79220
|
||||
Novi Seher 74254
|
||||
Novi Travnik 72290
|
||||
Nozicko 78428
|
||||
Oborci 70225
|
||||
Obudovac 76235
|
||||
Odzak 76290
|
||||
Vukosavlje 74470
|
||||
Odzak Kod Nevesinja 88285
|
||||
Olovo 71340
|
||||
Omarska 79203
|
||||
Orahova 78406
|
||||
Orahovica Donja 75323
|
||||
Orasje 76270
|
||||
Osinja 74412
|
||||
Osjecani 74225
|
||||
Osmaci 75406
|
||||
Ostra Luka 79263
|
||||
Ostrozac 88423
|
||||
Ostrozac Kod Cazina 77228
|
||||
Otoka 77244
|
||||
Ozimica 72238
|
||||
Palackovci 78437
|
||||
Pale 71420
|
||||
Papraca 75435
|
||||
Pazaric 71243
|
||||
Pecigrad 77227
|
||||
Pelagicevo 76256
|
||||
Perin Han 72112
|
||||
Petrovo 74317
|
||||
Pilica 75412
|
||||
Piskavica 78217
|
||||
Pocitelj 88305
|
||||
Poculica 72252
|
||||
Podgrab 71425
|
||||
Podhum 80209
|
||||
Podlugovi 71387
|
||||
Podnovlje 74217
|
||||
Podorasje Kod Srebrenika 75355
|
||||
Podzvizd 77232
|
||||
Poljice 75303
|
||||
Popovi 75320
|
||||
Posusje 88240
|
||||
Potkozarje 78216
|
||||
Potocani 78435
|
||||
Potoci 88208
|
||||
Praca 73290
|
||||
Prelovo 73245
|
||||
Previja 79287
|
||||
Pribinic 74276
|
||||
Priboj Kod Lopara 75249
|
||||
Prijedor 79101
|
||||
Priluka 80202
|
||||
Prisoje 80245
|
||||
Prnjavor 78430
|
||||
Prolog 80206
|
||||
Prozor 88440
|
||||
Prusac 70223
|
||||
Przici 71335
|
||||
Puhovac 72207
|
||||
Puracic 75305
|
||||
Radisici 88325
|
||||
Rainci Gornji 75268
|
||||
Rakitno 88245
|
||||
Rakovica 71217
|
||||
Rasko Polje 80247
|
||||
Razboj Lijevce 78429
|
||||
Razljevo 76218
|
||||
Ribnik 79288
|
||||
Ripac 77215
|
||||
Rogatica 73220
|
||||
Rudice 79226
|
||||
Rudo 73260
|
||||
Ruzici 88347
|
||||
Bosanski Samac 76230
|
||||
Sanica Gornja 79285
|
||||
Sanski Most 79260
|
||||
Sapna 75411
|
||||
Saracica 78202
|
||||
Sarajevo 71000
|
||||
Sarajevo, Centar 71103
|
||||
Sarajevo, Novi Grad 71160
|
||||
Sarajevo, Novo Sarajevo 71120
|
||||
Sarajevo, Stari Grad 71140
|
||||
Satorovici 76209
|
||||
Sekovici 73305
|
||||
Sekovici 75450
|
||||
Semizovac 71321
|
||||
Seonjaci 76205
|
||||
Serici 75275
|
||||
Sibosnica 75245
|
||||
Sibovska 78433
|
||||
Simin Han 75207
|
||||
Sipovo 78364
|
||||
Siprage 78224
|
||||
Siroki Brijeg 88220
|
||||
Sitnesi 78422
|
||||
Sitnica 79283
|
||||
Skelani 75436
|
||||
Skugric 74261
|
||||
Sladna 75353
|
||||
Slatina Ilidza 78253
|
||||
Smrtici 78438
|
||||
Snjegotina Gornja 74279
|
||||
Sockovac 74323
|
||||
Sokolac 71350
|
||||
Sokolovici 71210
|
||||
Sovici 88345
|
||||
Spionica 75356
|
||||
Srbac 78420
|
||||
Srebrenica 75430
|
||||
Srebrenik 75350
|
||||
Srednje 71385
|
||||
Sreflije 79249
|
||||
Srnice 76258
|
||||
Bosanska Kostajnica 79224
|
||||
Bosanski Brod 74450
|
||||
Istocno Gorazde 73110
|
||||
Istocno Orasje 76278
|
||||
Istocno Sarajevo 71123
|
||||
Stanari 74208
|
||||
Stara Dubrava 78243
|
||||
Stari Majdan 79268
|
||||
Stijena 77224
|
||||
Stjenice 73223
|
||||
Stjepan Polje 75324
|
||||
Stolac 88360
|
||||
Stranjani 72209
|
||||
Stricici 78208
|
||||
Strpci 75305
|
||||
Studenci 88323
|
||||
Stupari 75283
|
||||
Sturlic 77223
|
||||
Suho Polje 75344
|
||||
Sujica 80249
|
||||
Svodna 79229
|
||||
Tarcin 71244
|
||||
Teocak 75414
|
||||
Tesanj 74260
|
||||
Tesanjka 74266
|
||||
Teslic 74270
|
||||
Tihaljina 88348
|
||||
Tinja 75357
|
||||
Tisca 75455
|
||||
Todorovo 77233
|
||||
Tojsici 75265
|
||||
Tolisa 76272
|
||||
Tomina 79265
|
||||
Tomislavgrad 80240
|
||||
Topcic Polje 72213
|
||||
Travnik 72270
|
||||
Trebinja 88375
|
||||
Trebinje 89000
|
||||
Trn 78252
|
||||
Trnava Donja 76335
|
||||
Trnjaci 76310
|
||||
Trnovo 71220
|
||||
Trzacka Rastela 77225
|
||||
Turbe 72283
|
||||
Turija 75306
|
||||
Turjak Kod Bosanske Gradiske 78404
|
||||
Tuzla 75000
|
||||
Ugljevik 76330
|
||||
Ugodnovici 74278
|
||||
Ulog 71233
|
||||
Usora 74230
|
||||
Ustikolina 73250
|
||||
Uvac 73265
|
||||
Vardiste 73249
|
||||
Vares 71330
|
||||
Varoska Rijeka 77245
|
||||
Velika Bukovica 74213
|
||||
Velika Gata 77207
|
||||
Velika Kladusa 77230
|
||||
Velika Obarska 76329
|
||||
Vidosi 88208
|
||||
Vidovice 76275
|
||||
Vinac 70202
|
||||
Vir Kod Posusja 88247
|
||||
Visegrad 73240
|
||||
Visici 88307
|
||||
Visoko 71300
|
||||
Vitez 72250
|
||||
Vitina 88326
|
||||
Vitkovci Donji 74265
|
||||
Vitkovici 73205
|
||||
Vlasenica 75440
|
||||
Vogosca 71320
|
||||
Vojkovici 71123
|
||||
Voljevac 70246
|
||||
Vozuca 72227
|
||||
Vranjak 74488
|
||||
Vrapcici 88113
|
||||
Vrazici 75248
|
||||
Vrbanja Kod Banja Luke 78211
|
||||
Vrbanjci 78225
|
||||
Vrbaska 78408
|
||||
Vrnograc 77231
|
||||
Vrsani 76325
|
||||
Vrsta 77203
|
||||
Vuckovci 76254
|
||||
Vukosavlje 74470
|
||||
Zabar Donji 76273
|
||||
Zaborak 73287
|
||||
Zabrdje 72220
|
||||
Zabrdje 76333
|
||||
Zabrdje Kod Kotor Varosi 78221
|
||||
Zaluzani 78214
|
||||
Zavidovici 72220
|
||||
Zboriste 74451
|
||||
Zelinja 76259
|
||||
Zeljezno Polje 72236
|
||||
Zenica 72000
|
||||
Zepce 72230
|
||||
Zitomislici 88268
|
||||
Zivinice 75270
|
||||
Zupca 71370
|
||||
Zvornik 75400}
|
||||
|
||||
separator = /(.*)\s(\d{5})/
|
||||
places = places_bulk.split("\n")
|
||||
places.each do |place|
|
||||
matches = separator.match(place)
|
||||
return matches[1].strip if matches and matches[2] === code
|
||||
end
|
||||
|
||||
return "<nepoznato mjesto>";
|
||||
end
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
class Supplier < ActiveRecord::Base
|
||||
has_many :items
|
||||
|
||||
validates_uniqueness_of :name
|
||||
validates_presence_of :name
|
||||
end
|
||||
@@ -1,10 +0,0 @@
|
||||
class User < ActiveRecord::Base
|
||||
has_many :carts
|
||||
|
||||
validates_presence_of :first_name, :last_name, :password, :email, :password_confirmation
|
||||
|
||||
validates :email, :uniqueness => {:case_sensitive => false, :message => "Email already exists!"},
|
||||
format: { with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, message: "invalid email" }
|
||||
|
||||
validates :password, confirmation: true, length: { in:6..20, too_short: 'password needs to be at least 6 characters long' }
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
Tabulous.setup do
|
||||
tabs do
|
||||
|
||||
get_from_suppliers_tab do
|
||||
text { 'From suppliers' }
|
||||
link_path { '/' }
|
||||
visible_when { true }
|
||||
enabled_when { true }
|
||||
active_when { in_action('any').of_controller('pictures') }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,32 +0,0 @@
|
||||
<style type="text/css">
|
||||
.tg {border-collapse:collapse;border-spacing:0;}
|
||||
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
|
||||
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
|
||||
</style>
|
||||
<div><%= "report is nil" if @report.nil? %></div>
|
||||
<table class="tg">
|
||||
<tr>
|
||||
<th class="tg-031e">Code</th>
|
||||
<th class="tg-031e">Item name</th>
|
||||
<th class="tg-031e">Amount</th>
|
||||
<th class="tg-031e">Price</th>
|
||||
<th class="tg-031e">Total</th>
|
||||
</tr>
|
||||
|
||||
<% unless @report.nil? %>
|
||||
<% @report.sections.each do |section| %>
|
||||
<tr><td><%= section.supplier.name %></td></tr>
|
||||
<% section.items.each do |item| %>
|
||||
<tr>
|
||||
<td class="tg-031e"><%= item.code %></td>
|
||||
<td class="tg-031e"><%= item.name %></td>
|
||||
<td class="tg-031e"><%= item.amount %></td>
|
||||
<td class="tg-031e"><%= item.current_input_price %></td>
|
||||
<td class="tg-031e"><%= item.current_input_price * item.amount %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr><td>Sub-total: <%= section.sum_amount %></td></tr>
|
||||
<% end %>
|
||||
<tr><td><strong>Total: <%= @report.full_sum %></strong> </td></tr>
|
||||
<% end %>
|
||||
</table>
|
||||
@@ -1,63 +0,0 @@
|
||||
<h1>Orders to confirm</h1>
|
||||
|
||||
<style type="text/css">
|
||||
.tg {border-collapse:collapse;border-spacing:0;}
|
||||
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
|
||||
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
|
||||
</style>
|
||||
<div><%= "report is nil" if @report.nil? %></div>
|
||||
|
||||
|
||||
<% unless @report.nil? %>
|
||||
<% @report.sections.each do |section| %>
|
||||
<div>
|
||||
|
||||
|
||||
<hr>
|
||||
|
||||
<% unless section.delivery_destination.nil? %>
|
||||
<div><%= section.delivery_destination.name %></div>
|
||||
<div><%= section.delivery_destination.address %> </div>
|
||||
<div><%= section.delivery_destination.place %> <%= Place.name_from_code(section.delivery_destination.place) %></div>
|
||||
<div><%= section.delivery_destination.email %></div>
|
||||
<div><strong>+387 <%= section.delivery_destination.phone %></strong></div>
|
||||
|
||||
<% end %>
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
<table class="tg">
|
||||
<tr>
|
||||
<th class="tg-031e">Code</th>
|
||||
<th class="tg-031e">Item name</th>
|
||||
<th class="tg-031e">Amount</th>
|
||||
<th class="tg-031e">Price</th>
|
||||
<th class="tg-031e">Total</th>
|
||||
</tr>
|
||||
<% section.items.each do |item| %>
|
||||
<tr>
|
||||
<td class="tg-031e"><%= item.code %></td>
|
||||
<td class="tg-031e"><%= item.name %></td>
|
||||
<td class="tg-031e"><%= item.amount %></td>
|
||||
<td class="tg-031e"><%= item.list_price %></td>
|
||||
<td class="tg-031e"><%= item.sum_price %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr><td><strong>Total for cart: <%= section.sum_amount %></strong></td></tr>
|
||||
|
||||
</table>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div><a href="<%= rails_admin.edit_url(model_name: 'cart', id: section.delivery_destination.order_id.to_i)%>" >Update Order</a></div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<strong>Total: <%= @report.full_sum %></strong>
|
||||
|
||||
|
||||
<% end %>
|
||||
@@ -22,8 +22,5 @@ module Ribicabackoffice
|
||||
|
||||
# Do not swallow errors in after_commit/after_rollback callbacks.
|
||||
config.active_record.raise_in_transactional_callbacks = true
|
||||
config.assets.precompile += %w(*.svg *.eot *.woff *.ttf *.gif *.png *.ico)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
# PostgreSQL. Versions 8.2 and up are supported.
|
||||
#
|
||||
# Install the pg driver:
|
||||
# gem install pg
|
||||
# On OS X with Homebrew:
|
||||
# gem install pg -- --with-pg-config=/usr/local/bin/pg_config
|
||||
# On OS X with MacPorts:
|
||||
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
|
||||
# On Windows:
|
||||
# gem install pg
|
||||
# Choose the win32 build.
|
||||
# Install PostgreSQL and put its /bin directory on your path.
|
||||
#
|
||||
# Configure Using Gemfile
|
||||
# gem 'pg'
|
||||
#
|
||||
default: &default
|
||||
adapter: postgresql
|
||||
encoding: unicode
|
||||
# For details on connection pooling, see rails configuration guide
|
||||
# http://guides.rubyonrails.org/configuring.html#database-pooling
|
||||
pool: 5
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
database: ribica
|
||||
|
||||
# The specified database role being used to connect to postgres.
|
||||
# To create additional roles in postgres see `$ createuser --help`.
|
||||
# When left blank, postgres will use the default role. This is
|
||||
# the same name as the operating system user that initialized the database.
|
||||
username: postgres
|
||||
|
||||
# The password associated with the postgres role (username).
|
||||
password: testni_hamo2
|
||||
|
||||
# Connect on a TCP socket. Omitted by default since the client uses a
|
||||
# domain socket that doesn't need configuration. Windows does not have
|
||||
# domain sockets, so uncomment these lines.
|
||||
host: localhost
|
||||
|
||||
# The TCP port the server listens on. Defaults to 5432.
|
||||
# If your server runs on a different port number, change accordingly.
|
||||
#port: 5432
|
||||
|
||||
# Schema search path. The server defaults to $user,public
|
||||
#schema_search_path: myapp,sharedapp,public
|
||||
|
||||
# Minimum log levels, in increasing order:
|
||||
# debug5, debug4, debug3, debug2, debug1,
|
||||
# log, notice, warning, error, fatal, and panic
|
||||
# Defaults to warning.
|
||||
#min_messages: notice
|
||||
|
||||
# Warning: The database defined as "test" will be erased and
|
||||
# re-generated from your development database when you run "rake".
|
||||
# Do not set this db to the same as development or production.
|
||||
test:
|
||||
<<: *default
|
||||
database: ribicabackoffice_test
|
||||
|
||||
# As with config/secrets.yml, you never want to store sensitive information,
|
||||
# like your database password, in your source code. If your source code is
|
||||
# ever seen by anyone, they now have access to your database.
|
||||
#
|
||||
# Instead, provide the password as a unix environment variable when you boot
|
||||
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
|
||||
# for a full rundown on how to provide these environment variables in a
|
||||
# production deployment.
|
||||
#
|
||||
# On Heroku and other platform providers, you may have a full connection URL
|
||||
# available as an environment variable. For example:
|
||||
#
|
||||
# DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
|
||||
#
|
||||
# You can use this database configuration with:
|
||||
#
|
||||
# production:
|
||||
# url: <%= ENV['DATABASE_URL'] %>
|
||||
#
|
||||
production:
|
||||
<<: *default
|
||||
database: ribica
|
||||
username: postgres
|
||||
password: testni_hamo2
|
||||
host: localhost
|
||||
@@ -31,9 +31,4 @@ RailsAdmin.config do |config|
|
||||
# history_index
|
||||
# history_show
|
||||
end
|
||||
|
||||
config.navigation_static_links = {
|
||||
'Orders to Confirm' => '../reports/orders_to_confirm',
|
||||
'Items to Order' => '../reports/items_to_order'
|
||||
}
|
||||
end
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
resources :item_in_groups do as_routes end
|
||||
resources :item_groups do as_routes end
|
||||
resources :link_banners do as_routes end
|
||||
resources :delivery_time_estimations do as_routes end
|
||||
resources :suppliers do as_routes end
|
||||
resources :places do as_routes end
|
||||
resources :delivery_destinations do as_routes end
|
||||
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
||||
resources :filter_criteria_values do as_routes end
|
||||
@@ -19,7 +13,6 @@ Rails.application.routes.draw do
|
||||
resources :units do as_routes end
|
||||
resources :sub_categories do as_routes end
|
||||
resources :categories do as_routes end
|
||||
get ':controller(/:action(/:id))'
|
||||
# The priority is based upon order of creation: first created -> highest priority.
|
||||
# See how all your routes lay out with "rake routes".
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# encoding: UTF-8
|
||||
# This file is auto-generated from the current state of the database. Instead
|
||||
# of editing this file, please use the migrations feature of Active Record to
|
||||
# incrementally modify your database, and then regenerate this schema definition.
|
||||
#
|
||||
# Note that this schema.rb definition is the authoritative source for your
|
||||
# database schema. If you need to create the application database on another
|
||||
# system, you should be using db:schema:load, not running all the migrations
|
||||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
||||
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 0) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
# Logfile created on 2015-05-13 06:59:32 +0200 by logger.rb/47272
|
||||
I, [2015-05-13T06:59:32.650998 #35530] INFO -- : Item import starting at 2015-05-13 06:59:32 +0200
|
||||
I, [2015-05-13T06:59:32.651035 #35530] INFO -- : Will be importing items from /Users/senaduka/Downloads/items_for_import.csv
|
||||
E, [2015-05-13T06:59:40.201578 #35530] ERROR -- : Could not import item on row number 608 (Dunjica), reason: Subcategory is missing!
|
||||
I, [2015-05-13T06:59:45.758509 #35530] INFO -- : Rolling back because of errors
|
||||
I, [2015-05-13T06:59:46.065723 #35530] INFO -- : Import done
|
||||
I, [2015-05-13T07:00:24.402397 #35642] INFO -- : Item import starting at 2015-05-13 07:00:24 +0200
|
||||
I, [2015-05-13T07:00:24.402456 #35642] INFO -- : Will be importing items from /Users/senaduka/Downloads/items_for_import.csv
|
||||
I, [2015-05-13T07:00:37.829898 #35642] INFO -- : Import done
|
||||
@@ -1,365 +0,0 @@
|
||||
require 'csv'
|
||||
|
||||
def get_column_lookup
|
||||
columns = [
|
||||
:name,
|
||||
:name_on_ribica,
|
||||
:picture,
|
||||
:brand,
|
||||
:code,
|
||||
:current_input_price,
|
||||
:list_price,
|
||||
:units_in_pack,
|
||||
:description,
|
||||
:stock,
|
||||
:on_display,
|
||||
:tags,
|
||||
:traits,
|
||||
:weight,
|
||||
:delivery_time_estimation,
|
||||
|
||||
:name_unit,
|
||||
:short_name_unit,
|
||||
:description_suffix_unit,
|
||||
:number_of_pieces_suffix_unit,
|
||||
|
||||
:name_sub_category,
|
||||
:order_sub_category,
|
||||
|
||||
:name_supplier,
|
||||
:address_supplier,
|
||||
:postal_code_supplier,
|
||||
:town_supplier,
|
||||
:phone_supplier,
|
||||
:contact_person_supplier,
|
||||
:email_supplier,
|
||||
:note_supplier
|
||||
]
|
||||
|
||||
columns.map.with_index { |x, i| [x, i] }.to_h
|
||||
end
|
||||
|
||||
def lookup_delivery_time_estimation(row, lookup)
|
||||
dte = DeliveryTimeEstimation.where(
|
||||
duration_in_days: row[lookup[:delivery_time_estimation]]
|
||||
).take
|
||||
|
||||
if dte.nil?
|
||||
dte = DeliveryTimeEstimation.new
|
||||
dte.duration_in_days = row[lookup[:delivery_time_estimation]]
|
||||
dte.save!
|
||||
end
|
||||
|
||||
if dte.duration_in_days == 0
|
||||
raise "Delivery time estimation input is missing or incorrect: #{dte.delivery_time_estimation}"
|
||||
end
|
||||
|
||||
return dte
|
||||
end
|
||||
|
||||
def lookup_unit(row, lookup)
|
||||
unit = Unit.where(
|
||||
name: row[lookup[:name_unit]],
|
||||
short_name: row[lookup[:short_name_unit]],
|
||||
description_suffix: row[lookup[:description_suffix_unit]],
|
||||
number_of_pieces_suffix: row[lookup[:number_of_pieces_suffix_unit]]).take
|
||||
|
||||
if unit.nil?
|
||||
new_unit = Unit.new
|
||||
new_unit.name = row[lookup[:name_unit]]
|
||||
new_unit.short_name = "kom" #row[lookup[:short_name_unit]]
|
||||
new_unit.description_suffix = row[lookup[:description_suffix_unit]]
|
||||
new_unit.number_of_pieces_suffix = row[lookup[:number_of_pieces_suffix_unit]]
|
||||
new_unit.save!
|
||||
new_unit
|
||||
else
|
||||
unit
|
||||
end
|
||||
end
|
||||
|
||||
def lookup_brand(row, lookup)
|
||||
brand = Brand.find_by name: row[lookup[:brand]]
|
||||
if brand.nil?
|
||||
new_brand = Brand.new
|
||||
new_brand.name = row[lookup[:brand]]
|
||||
new_brand.save!
|
||||
new_brand
|
||||
else
|
||||
brand
|
||||
end
|
||||
end
|
||||
|
||||
def lookup_supplier(row, lookup)
|
||||
supplier = Supplier.find_by name: row[lookup[:name_supplier]]
|
||||
if supplier.nil?
|
||||
new_supplier = Supplier.new
|
||||
new_supplier.name = row[lookup[:name_supplier]]
|
||||
new_supplier.address = row[lookup[:address_supplier]]
|
||||
new_supplier.postal_code = row[lookup[:postal_code_supplier]]
|
||||
new_supplier.town = row[lookup[:town_supplier]]
|
||||
new_supplier.phone = row[lookup[:phone_supplier]]
|
||||
new_supplier.contact_person = row[lookup[:contact_person_supplier]]
|
||||
new_supplier.email = row[lookup[:email_supplier]]
|
||||
new_supplier.note = row[lookup[:note_supplier]]
|
||||
new_supplier.save!
|
||||
new_supplier
|
||||
else
|
||||
supplier
|
||||
end
|
||||
end
|
||||
|
||||
def resolve_subcategory(str)
|
||||
raise "Subcategory is missing!" if str.nil?
|
||||
|
||||
parts = str.split(">").map{ |s| s.strip }
|
||||
subcategory = parts[2]
|
||||
category = parts[1]
|
||||
section = parts[0]
|
||||
|
||||
if subcategory.to_s == '' || category.to_s == '' || section.to_s == ''
|
||||
raise "Invalid subcategory : #{str}"
|
||||
end
|
||||
|
||||
subcategory = subcategory.downcase
|
||||
category = category.downcase
|
||||
section = section.downcase
|
||||
|
||||
sc = SubCategory.eager_load(category: :section)
|
||||
.where("lower(sub_categories.name) = '#{subcategory}' and lower(categories.name) = '#{category}' and lower(sections.name) = '#{section}'")
|
||||
.take
|
||||
|
||||
return sc unless sc.nil?
|
||||
|
||||
section_in_db = Section.where("lower(name) = '#{section}'").take
|
||||
if section_in_db.nil?
|
||||
section_in_db = Section.new
|
||||
section_in_db.name = section.capitalize
|
||||
section_in_db.save!
|
||||
end
|
||||
|
||||
|
||||
cat_in_db =
|
||||
Category
|
||||
.eager_load(:section)
|
||||
.where("lower(categories.name) = '#{category}' and lower(sections.name) = '#{section}'")
|
||||
.take
|
||||
|
||||
if cat_in_db.nil?
|
||||
cat_in_db = Category.new
|
||||
cat_in_db.name = category.capitalize
|
||||
cat_in_db.section_id = section_in_db.id
|
||||
cat_in_db.save!
|
||||
end
|
||||
|
||||
sub_cat_in_db =
|
||||
SubCategory
|
||||
.eager_load(:category)
|
||||
.where("lower(sub_categories.name) = '#{subcategory}' and lower(categories.name) = '#{category}'")
|
||||
.take
|
||||
|
||||
if sub_cat_in_db.nil?
|
||||
sub_cat_in_db = SubCategory.new
|
||||
sub_cat_in_db.name = subcategory.capitalize
|
||||
sub_cat_in_db.category_id = cat_in_db.id
|
||||
sub_cat_in_db.save!
|
||||
end
|
||||
|
||||
sub_cat_in_db
|
||||
#item.sub_category.order = row[lookup[:order_sub_category]]
|
||||
end
|
||||
|
||||
def handle_multimedia(item, row, index, logger, lookup)
|
||||
multimedia = row[lookup[:picture]]
|
||||
return if multimedia.to_s == ""
|
||||
|
||||
parts = multimedia.split(";").map{ |s| s.strip }
|
||||
|
||||
parts.each do |part|
|
||||
mmd = MultiMediaDescription.new
|
||||
|
||||
if part != "" and not part.start_with? "https://"
|
||||
raise "Invalid url for the image: #{part}"
|
||||
end
|
||||
|
||||
mmd.url = part
|
||||
item.multi_media_descriptions << mmd
|
||||
end
|
||||
end
|
||||
|
||||
def import_single_item(row, index, logger)
|
||||
succes = true
|
||||
begin
|
||||
lookup = get_column_lookup
|
||||
code = row[lookup[:code]]
|
||||
|
||||
item = (Item.find_by code: code) || Item.new
|
||||
item.name = row[lookup[:name_on_ribica]]
|
||||
item.code = code
|
||||
item.current_input_price = row[lookup[:current_input_price]] || 11.00
|
||||
item.list_price = row[lookup[:list_price]] || 12.00
|
||||
item.units_in_pack = row[lookup[:units_in_pack]]
|
||||
item.description = row[lookup[:description]] || "default description"
|
||||
item.stock = row[lookup[:stock]]
|
||||
item.on_display = row[lookup[:on_display]]
|
||||
item.tags = row[lookup[:tags]]
|
||||
item.traits = row[lookup[:traits]]
|
||||
item.weight = row[lookup[:weight]] || 1.0
|
||||
item.delivery_time_estimation = lookup_delivery_time_estimation(row, lookup)
|
||||
|
||||
item.sub_category = resolve_subcategory(row[lookup[:name_sub_category]])
|
||||
# todo multimedia, item groups
|
||||
|
||||
handle_multimedia(item, row, index, logger, lookup)
|
||||
|
||||
item.unit = lookup_unit(row, lookup)
|
||||
item.supplier = lookup_supplier(row, lookup)
|
||||
item.brand = lookup_brand(row, lookup)
|
||||
item.save(validate: false)
|
||||
# logger.info "Successfully imported item with on row position #{index}: #{row[lookup[:name_on_ribica]]}"
|
||||
success = true
|
||||
rescue Exception => e
|
||||
logger.error "Could not import item on row number #{index} (#{row[lookup[:name_on_ribica]]}), reason: #{e}"
|
||||
success = false
|
||||
end
|
||||
|
||||
success
|
||||
end
|
||||
|
||||
def trim_whitespace(row)
|
||||
row.map! do |value|
|
||||
trimmed = value.strip if not value.nil? # value.to_s.strip
|
||||
# puts "trimming '#{value}' to '#{trimmed}'"
|
||||
trimmed
|
||||
end
|
||||
end
|
||||
|
||||
def do_import(validate_only)
|
||||
begin
|
||||
input_file = ENV['INPUT']
|
||||
if input_file.to_s == ""
|
||||
puts "Input file is missing! Please provide input file in form INPUT=somefile.csv"
|
||||
return
|
||||
end
|
||||
|
||||
lookup = get_column_lookup
|
||||
path = Rails.root.join(input_file)
|
||||
|
||||
log_filename = "import.log"
|
||||
log_filename = "import_validate.log" if validate_only
|
||||
|
||||
logger = Logger.new(log_filename)
|
||||
|
||||
logger.info "Item import starting at #{Time.now}"
|
||||
logger.info "Will be importing items from #{path}"
|
||||
|
||||
i = 1
|
||||
should_rollback = false
|
||||
Item.transaction do
|
||||
CSV.foreach(path) do |row|
|
||||
if i != 1
|
||||
trim_whitespace(row)
|
||||
if import_single_item(row, i, logger) == false
|
||||
should_rollback = true
|
||||
end
|
||||
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
|
||||
if validate_only || should_rollback
|
||||
if should_rollback
|
||||
puts "Import failed, please check the import log file for error details."
|
||||
logger.info "Rolling back because of errors"
|
||||
end
|
||||
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
puts "Import failed, please check the import log file for error details."
|
||||
logger.error "Error while importing: #{e}"
|
||||
end
|
||||
logger.info "Import done"
|
||||
end
|
||||
|
||||
namespace :ribica do
|
||||
task copy_sections_to_menu: :environment do
|
||||
Section.transaction do
|
||||
Section.all.each do |section|
|
||||
mi = MenuItem.new
|
||||
mi.title = section.name
|
||||
mi.url = "/sekcija/#{section.id}/#{section.name}"
|
||||
mi.ordinal = section.order
|
||||
|
||||
section.categories.each do |category|
|
||||
msi = MenuSubItem.new
|
||||
msi.title = category.name
|
||||
msi.url = "/sekcija/#{section.name}/kategorija/#{category.id}/#{category.name}"
|
||||
msi.ordinal = section.order
|
||||
mi.menu_sub_items << msi
|
||||
|
||||
category.sub_categories.each do |sub_category|
|
||||
mssi = MenuSubSubItem.new
|
||||
mssi.title = sub_category.name
|
||||
mssi.url = "/podkategorija/#{sub_category.id}/#{sub_category.name}"
|
||||
mssi.ordinal = sub_category.order
|
||||
msi.menu_sub_sub_items << mssi
|
||||
end
|
||||
end
|
||||
mi.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
namespace :ribica do
|
||||
task clear_database: :environment do
|
||||
conn = ActiveRecord::Base.connection
|
||||
|
||||
tables = conn.execute("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';").map { |r| r["table_name"] }
|
||||
tables.delete "schema_migrations"
|
||||
tables.each { |t| conn.execute("TRUNCATE TABLE #{t}") }
|
||||
end
|
||||
end
|
||||
|
||||
namespace :ribica do
|
||||
task validate_items: :environment do
|
||||
do_import true
|
||||
end
|
||||
end
|
||||
|
||||
namespace :ribica do
|
||||
task import_items: :environment do
|
||||
do_import false
|
||||
end
|
||||
end
|
||||
|
||||
namespace :ribica do
|
||||
task reindex: :environment do
|
||||
es_client = Elasticsearch::Client.new log: true
|
||||
|
||||
# first delete the index
|
||||
begin
|
||||
es_client.indices.delete index: 'ribica'
|
||||
rescue
|
||||
logger.warn "Ribica index could not be deleted. Continuing with indexing operation..."
|
||||
end
|
||||
|
||||
# now index items
|
||||
all_items = Item.includes(sub_category: { category: :section }).all.to_a
|
||||
all_items.each do |item|
|
||||
es_client.index index: 'ribica', type: 'items', id: item.id, body: {
|
||||
title: 'Test',
|
||||
name: item.name,
|
||||
code: item.code,
|
||||
description: item.description,
|
||||
sub_category: item.sub_category.name,
|
||||
category: item.sub_category.category.name,
|
||||
section: item.sub_category.category.section.name,
|
||||
brand: item.brand.name
|
||||
}
|
||||
end
|
||||
|
||||
puts "ok!"
|
||||
end
|
||||
end
|
||||
BIN
back-office/public/.DS_Store
vendored
Normal file
BIN
back-office/public/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -1,49 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DeliveryTimeEstimationsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@delivery_time_estimation = delivery_time_estimations(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:delivery_time_estimations)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create delivery_time_estimation" do
|
||||
assert_difference('DeliveryTimeEstimation.count') do
|
||||
post :create, delivery_time_estimation: { duration_in_days: @delivery_time_estimation.duration_in_days, name: @delivery_time_estimation.name }
|
||||
end
|
||||
|
||||
assert_redirected_to delivery_time_estimation_path(assigns(:delivery_time_estimation))
|
||||
end
|
||||
|
||||
test "should show delivery_time_estimation" do
|
||||
get :show, id: @delivery_time_estimation
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @delivery_time_estimation
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update delivery_time_estimation" do
|
||||
patch :update, id: @delivery_time_estimation, delivery_time_estimation: { duration_in_days: @delivery_time_estimation.duration_in_days, name: @delivery_time_estimation.name }
|
||||
assert_redirected_to delivery_time_estimation_path(assigns(:delivery_time_estimation))
|
||||
end
|
||||
|
||||
test "should destroy delivery_time_estimation" do
|
||||
assert_difference('DeliveryTimeEstimation.count', -1) do
|
||||
delete :destroy, id: @delivery_time_estimation
|
||||
end
|
||||
|
||||
assert_redirected_to delivery_time_estimations_path
|
||||
end
|
||||
end
|
||||
@@ -1,49 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemGroupsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@item_group = item_groups(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:item_groups)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create item_group" do
|
||||
assert_difference('ItemGroup.count') do
|
||||
post :create, item_group: { description: @item_group.description, name: @item_group.name, visible: @item_group.visible }
|
||||
end
|
||||
|
||||
assert_redirected_to item_group_path(assigns(:item_group))
|
||||
end
|
||||
|
||||
test "should show item_group" do
|
||||
get :show, id: @item_group
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @item_group
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update item_group" do
|
||||
patch :update, id: @item_group, item_group: { description: @item_group.description, name: @item_group.name, visible: @item_group.visible }
|
||||
assert_redirected_to item_group_path(assigns(:item_group))
|
||||
end
|
||||
|
||||
test "should destroy item_group" do
|
||||
assert_difference('ItemGroup.count', -1) do
|
||||
delete :destroy, id: @item_group
|
||||
end
|
||||
|
||||
assert_redirected_to item_groups_path
|
||||
end
|
||||
end
|
||||
@@ -1,49 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemInGroupsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@item_in_group = item_in_groups(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:item_in_groups)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create item_in_group" do
|
||||
assert_difference('ItemInGroup.count') do
|
||||
post :create, item_in_group: { item_group_id: @item_in_group.item_group_id, item_id: @item_in_group.item_id, position: @item_in_group.position }
|
||||
end
|
||||
|
||||
assert_redirected_to item_in_group_path(assigns(:item_in_group))
|
||||
end
|
||||
|
||||
test "should show item_in_group" do
|
||||
get :show, id: @item_in_group
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @item_in_group
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update item_in_group" do
|
||||
patch :update, id: @item_in_group, item_in_group: { item_group_id: @item_in_group.item_group_id, item_id: @item_in_group.item_id, position: @item_in_group.position }
|
||||
assert_redirected_to item_in_group_path(assigns(:item_in_group))
|
||||
end
|
||||
|
||||
test "should destroy item_in_group" do
|
||||
assert_difference('ItemInGroup.count', -1) do
|
||||
delete :destroy, id: @item_in_group
|
||||
end
|
||||
|
||||
assert_redirected_to item_in_groups_path
|
||||
end
|
||||
end
|
||||
@@ -1,49 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class LinkBannersControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@link_banner = link_banners(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:link_banners)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create link_banner" do
|
||||
assert_difference('LinkBanner.count') do
|
||||
post :create, link_banner: { beginning: @link_banner.beginning, category_id: @link_banner.category_id, checkout_page: @link_banner.checkout_page, ending: @link_banner.ending, footer: @link_banner.footer, header: @link_banner.header, image_url: @link_banner.image_url, item_id: @link_banner.item_id, link_url: @link_banner.link_url, search_result_page: @link_banner.search_result_page, section_id: @link_banner.section_id, start_page: @link_banner.start_page, sub_category_id: @link_banner.sub_category_id, thank_you_page: @link_banner.thank_you_page }
|
||||
end
|
||||
|
||||
assert_redirected_to link_banner_path(assigns(:link_banner))
|
||||
end
|
||||
|
||||
test "should show link_banner" do
|
||||
get :show, id: @link_banner
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @link_banner
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update link_banner" do
|
||||
patch :update, id: @link_banner, link_banner: { beginning: @link_banner.beginning, category_id: @link_banner.category_id, checkout_page: @link_banner.checkout_page, ending: @link_banner.ending, footer: @link_banner.footer, header: @link_banner.header, image_url: @link_banner.image_url, item_id: @link_banner.item_id, link_url: @link_banner.link_url, search_result_page: @link_banner.search_result_page, section_id: @link_banner.section_id, start_page: @link_banner.start_page, sub_category_id: @link_banner.sub_category_id, thank_you_page: @link_banner.thank_you_page }
|
||||
assert_redirected_to link_banner_path(assigns(:link_banner))
|
||||
end
|
||||
|
||||
test "should destroy link_banner" do
|
||||
assert_difference('LinkBanner.count', -1) do
|
||||
delete :destroy, id: @link_banner
|
||||
end
|
||||
|
||||
assert_redirected_to link_banners_path
|
||||
end
|
||||
end
|
||||
@@ -1,49 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PlacesControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@place = places(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:places)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create place" do
|
||||
assert_difference('Place.count') do
|
||||
post :create, place: { delivery_price: @place.delivery_price, name: @place.name, postal_code: @place.postal_code }
|
||||
end
|
||||
|
||||
assert_redirected_to place_path(assigns(:place))
|
||||
end
|
||||
|
||||
test "should show place" do
|
||||
get :show, id: @place
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @place
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update place" do
|
||||
patch :update, id: @place, place: { delivery_price: @place.delivery_price, name: @place.name, postal_code: @place.postal_code }
|
||||
assert_redirected_to place_path(assigns(:place))
|
||||
end
|
||||
|
||||
test "should destroy place" do
|
||||
assert_difference('Place.count', -1) do
|
||||
delete :destroy, id: @place
|
||||
end
|
||||
|
||||
assert_redirected_to places_path
|
||||
end
|
||||
end
|
||||
@@ -1,49 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SuppliersControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@supplier = suppliers(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:suppliers)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create supplier" do
|
||||
assert_difference('Supplier.count') do
|
||||
post :create, supplier: { address: @supplier.address, contact_person: @supplier.contact_person, email: @supplier.email, name: @supplier.name, note: @supplier.note, phone: @supplier.phone, postal_code: @supplier.postal_code, town: @supplier.town }
|
||||
end
|
||||
|
||||
assert_redirected_to supplier_path(assigns(:supplier))
|
||||
end
|
||||
|
||||
test "should show supplier" do
|
||||
get :show, id: @supplier
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @supplier
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update supplier" do
|
||||
patch :update, id: @supplier, supplier: { address: @supplier.address, contact_person: @supplier.contact_person, email: @supplier.email, name: @supplier.name, note: @supplier.note, phone: @supplier.phone, postal_code: @supplier.postal_code, town: @supplier.town }
|
||||
assert_redirected_to supplier_path(assigns(:supplier))
|
||||
end
|
||||
|
||||
test "should destroy supplier" do
|
||||
assert_difference('Supplier.count', -1) do
|
||||
delete :destroy, id: @supplier
|
||||
end
|
||||
|
||||
assert_redirected_to suppliers_path
|
||||
end
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
duration_in_days: 1
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
duration_in_days: 1
|
||||
11
back-office/test/fixtures/item_groups.yml
vendored
11
back-office/test/fixtures/item_groups.yml
vendored
@@ -1,11 +0,0 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
description: MyText
|
||||
visible: false
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
description: MyText
|
||||
visible: false
|
||||
11
back-office/test/fixtures/item_in_groups.yml
vendored
11
back-office/test/fixtures/item_in_groups.yml
vendored
@@ -1,11 +0,0 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
item_id: 1
|
||||
item_group_id: 1
|
||||
position: 1
|
||||
|
||||
two:
|
||||
item_id: 1
|
||||
item_group_id: 1
|
||||
position: 1
|
||||
33
back-office/test/fixtures/link_banners.yml
vendored
33
back-office/test/fixtures/link_banners.yml
vendored
@@ -1,33 +0,0 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
image_url: MyString
|
||||
start_page: false
|
||||
section_id: 1
|
||||
category_id: 1
|
||||
sub_category_id: 1
|
||||
item_id: 1
|
||||
thank_you_page: false
|
||||
search_result_page: false
|
||||
checkout_page: false
|
||||
beginning: 2015-03-22
|
||||
ending: 2015-03-22
|
||||
footer: false
|
||||
header: false
|
||||
link_url: MyString
|
||||
|
||||
two:
|
||||
image_url: MyString
|
||||
start_page: false
|
||||
section_id: 1
|
||||
category_id: 1
|
||||
sub_category_id: 1
|
||||
item_id: 1
|
||||
thank_you_page: false
|
||||
search_result_page: false
|
||||
checkout_page: false
|
||||
beginning: 2015-03-22
|
||||
ending: 2015-03-22
|
||||
footer: false
|
||||
header: false
|
||||
link_url: MyString
|
||||
11
back-office/test/fixtures/places.yml
vendored
11
back-office/test/fixtures/places.yml
vendored
@@ -1,11 +0,0 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
postal_code: MyString
|
||||
delivery_price: 9.99
|
||||
name: MyString
|
||||
|
||||
two:
|
||||
postal_code: MyString
|
||||
delivery_price: 9.99
|
||||
name: MyString
|
||||
21
back-office/test/fixtures/suppliers.yml
vendored
21
back-office/test/fixtures/suppliers.yml
vendored
@@ -1,21 +0,0 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: MyString
|
||||
address: MyString
|
||||
postal_code: MyString
|
||||
town: MyString
|
||||
phone: MyString
|
||||
contact_person: MyString
|
||||
email: MyString
|
||||
note: MyText
|
||||
|
||||
two:
|
||||
name: MyString
|
||||
address: MyString
|
||||
postal_code: MyString
|
||||
town: MyString
|
||||
phone: MyString
|
||||
contact_person: MyString
|
||||
email: MyString
|
||||
note: MyText
|
||||
@@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class DeliveryTimeEstimationTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemGroupTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemInGroupTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class LinkBannerTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class PlaceTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
@@ -1,7 +0,0 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SupplierTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
BIN
front-api/.DS_Store
vendored
Normal file
BIN
front-api/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -14,10 +14,9 @@ platform :ruby do
|
||||
gem "activerecord"
|
||||
end
|
||||
|
||||
gem 'elasticsearch'
|
||||
|
||||
gem "sinatra"
|
||||
gem "sinatra-activerecord"
|
||||
gem "json"
|
||||
gem 'puma'
|
||||
gem "sinatra-contrib"
|
||||
gem 'rerun'
|
||||
|
||||
@@ -24,34 +24,13 @@ GEM
|
||||
bcrypt (3.1.10)
|
||||
bcrypt (3.1.10-java)
|
||||
builder (3.2.2)
|
||||
celluloid (0.16.0)
|
||||
timers (~> 4.0.0)
|
||||
elasticsearch (1.0.8)
|
||||
elasticsearch-api (= 1.0.7)
|
||||
elasticsearch-transport (= 1.0.7)
|
||||
elasticsearch-api (1.0.7)
|
||||
multi_json
|
||||
elasticsearch-transport (1.0.7)
|
||||
faraday
|
||||
multi_json
|
||||
faraday (0.9.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.9.6)
|
||||
ffi (1.9.6-java)
|
||||
hitimes (1.2.2)
|
||||
hitimes (1.2.2-java)
|
||||
i18n (0.7.0)
|
||||
jdbc-postgres (9.3.1102)
|
||||
jruby-openssl (0.9.6-java)
|
||||
json (1.8.1)
|
||||
json (1.8.1-java)
|
||||
listen (2.8.5)
|
||||
celluloid (>= 0.15.2)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9)
|
||||
minitest (5.5.0)
|
||||
multi_json (1.10.1)
|
||||
multipart-post (2.0.0)
|
||||
pg (0.17.1)
|
||||
puma (2.10.2)
|
||||
rack (>= 1.1, < 2.0)
|
||||
@@ -62,11 +41,6 @@ GEM
|
||||
rack
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rb-fsevent (0.9.4)
|
||||
rb-inotify (0.9.5)
|
||||
ffi (>= 0.5.0)
|
||||
rerun (0.10.0)
|
||||
listen (~> 2.7, >= 2.7.3)
|
||||
sinatra (1.4.5)
|
||||
rack (~> 1.4)
|
||||
rack-protection (~> 1.4)
|
||||
@@ -84,8 +58,6 @@ GEM
|
||||
thread_safe (0.3.4)
|
||||
thread_safe (0.3.4-java)
|
||||
tilt (1.4.1)
|
||||
timers (4.0.1)
|
||||
hitimes
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
|
||||
@@ -97,12 +69,10 @@ DEPENDENCIES
|
||||
activerecord
|
||||
activerecord-jdbcpostgresql-adapter
|
||||
bcrypt (~> 3.1.7)
|
||||
elasticsearch
|
||||
jruby-openssl
|
||||
json
|
||||
pg
|
||||
puma
|
||||
rerun
|
||||
sinatra
|
||||
sinatra-activerecord
|
||||
sinatra-contrib
|
||||
|
||||
@@ -3,14 +3,15 @@ require 'sinatra/activerecord'
|
||||
require './config'
|
||||
require 'json'
|
||||
require 'sinatra/cookies'
|
||||
require 'elasticsearch'
|
||||
|
||||
|
||||
Dir[File.dirname(__FILE__) + '/models/*.rb'].each {|file| require file }
|
||||
|
||||
set :bind, '0.0.0.0'
|
||||
|
||||
|
||||
COOKIE_SECRET_KEY = "RibicaMustSucceedInshaallah"
|
||||
|
||||
|
||||
before do
|
||||
content_type :json
|
||||
# TODO: before running to production change this so that only specific
|
||||
|
||||
@@ -1,23 +1,45 @@
|
||||
|
||||
create_the_cart = -> () {
|
||||
# -1 is a placeholder for user id when we implement users
|
||||
# auid will still be used in case user is not logged in
|
||||
Cart.find_or_create(anonymous_id, logged_in_user_id).to_json
|
||||
}
|
||||
post '/cart', &create_the_cart
|
||||
put '/cart', &create_the_cart
|
||||
|
||||
helpers do
|
||||
def anonymous_id
|
||||
auid = cookies[:anonymous_user_id]
|
||||
if auid.nil?
|
||||
auid = AnonymousUser.uid
|
||||
response.set_cookie('anonymous_user_id', :path=> '/', :httponly => true, :value=>auid, :expires=> Time.now + 100.year)
|
||||
end
|
||||
return auid
|
||||
end
|
||||
|
||||
def user_id
|
||||
auth = cookies['ribica_auth']
|
||||
if not auth.nil?
|
||||
auth = decrypt(auth)
|
||||
return User.find_by(id: auth).id
|
||||
end
|
||||
-1
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
get '/cart/init' do
|
||||
auid = anonymous_id
|
||||
Cart.find_or_create(auid, user_id).to_json
|
||||
auid.to_json
|
||||
end
|
||||
|
||||
get '/cart' do
|
||||
Cart.just_find(anonymous_id, logged_in_user_id).to_json
|
||||
# -1 is a placeholder for user id when we implement users
|
||||
# auid will still be used in case user is not logged in
|
||||
Cart.find_or_create(anonymous_id, user_id).to_json
|
||||
end
|
||||
|
||||
# gets number of items in cart for every item
|
||||
get '/cart/item' do
|
||||
Cart.just_find(anonymous_id, logged_in_user_id).item_in_carts.to_json
|
||||
Cart.find_or_create(anonymous_id, user_id).item_in_carts.to_json
|
||||
end
|
||||
|
||||
update_cart_item = ->() {
|
||||
cart_id = Cart.just_find(anonymous_id, logged_in_user_id).id
|
||||
cart_id = Cart.find_or_create(anonymous_id, user_id).id
|
||||
item_id = @json_params["item_id"].to_i
|
||||
count = @json_params["count"].to_i
|
||||
ItemInCart.update_state(cart_id, item_id, count).to_json
|
||||
@@ -27,23 +49,23 @@ post '/cart/item', &update_cart_item
|
||||
|
||||
|
||||
# gets list of items in cart without count
|
||||
get '/cart/item/display' do
|
||||
cart = Cart.just_find(anonymous_id, logged_in_user_id)
|
||||
get '/cart/item/display' do
|
||||
cart = Cart.find_or_create(anonymous_id, user_id)
|
||||
item_ids = cart.item_in_carts.map do |x|
|
||||
x.item_id
|
||||
x.item_id
|
||||
end
|
||||
items = []
|
||||
items = Item.find(item_ids) if cart.item_in_carts.length > 0
|
||||
items = Item.find(item_ids) if cart.item_in_carts.length > 0
|
||||
prepare_items_for_mass_display(items)
|
||||
end
|
||||
|
||||
get '/cart/delivery_destination' do
|
||||
cart = Cart.just_find(anonymous_id, logged_in_user_id)
|
||||
get '/cart/delivery_destination' do
|
||||
cart = Cart.find_or_create(anonymous_id, user_id)
|
||||
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
|
||||
end
|
||||
end
|
||||
|
||||
update_delivery_destination = ->() {
|
||||
cart = Cart.just_find(anonymous_id, logged_in_user_id)
|
||||
cart = Cart.find_or_create(anonymous_id, user_id)
|
||||
allowed_keys = ["name", "address", "place", "postal_code", "phone", "email", "note"]
|
||||
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
|
||||
cart.delivery_destination.update_attributes(params)
|
||||
@@ -54,15 +76,13 @@ put '/cart/delivery_destination', &update_delivery_destination
|
||||
post '/cart/delivery_destination', &update_delivery_destination
|
||||
|
||||
|
||||
post '/cart/confirmation' do
|
||||
anonymous = anonymous_id
|
||||
cart = Cart.just_find(anonymous, logged_in_user_id)
|
||||
post '/cart/confirmation' do
|
||||
cart = Cart.find_or_create(anonymous_id, user_id)
|
||||
if cart.item_in_carts.length > 0
|
||||
cart.ordered = true
|
||||
cart.save!
|
||||
end
|
||||
# since there is no more ordered cart this needs to be done
|
||||
# in order for next call of Cart#just_find to be ready
|
||||
Cart.find_or_create(anonymous, logged_in_user_id)
|
||||
|
||||
Cart.find_or_create(anonymous_id, user_id)
|
||||
"OK".to_json
|
||||
end
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
|
||||
|
||||
get '/category' do
|
||||
Category.eager_load(:sub_categories).order('categories.order, sub_categories.order').all.to_json(:include => [:section, :sub_categories, :filter_criterias =>{:include => :filter_criteria_values} ])
|
||||
Category.order(:name).all.to_json(:include => [:section, :sub_categories, :filter_criterias =>{:include => :filter_criteria_values} ])
|
||||
end
|
||||
|
||||
get '/category/:id' do
|
||||
id = params[:id].to_i
|
||||
Category.eager_load(:sub_categories).order('sub_categories.order').find(id).to_json(:include => [:section, :sub_categories, :filter_criterias =>{:include => :filter_criteria_values}])
|
||||
Category.find(id).to_json(:include => [:section, :sub_categories, :filter_criterias =>{:include => :filter_criteria_values}])
|
||||
end
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
def prepare_items_for_mass_display(items)
|
||||
def prepare_items_for_mass_display(items)
|
||||
items.to_json(
|
||||
:except => [:created_at, :current_input_price, :stock, :on_display],
|
||||
:include => [
|
||||
:include => [
|
||||
:unit ,
|
||||
:multi_media_descriptions ,
|
||||
:sub_category,
|
||||
:brand
|
||||
:sub_category
|
||||
])
|
||||
end
|
||||
|
||||
@@ -15,7 +14,7 @@ end
|
||||
|
||||
|
||||
# gets single item for detailed display (like comments etc. ) # TODO: change when comments are added
|
||||
get '/item/:id' do |id_s|
|
||||
get '/item/:id' do |id_s|
|
||||
item = Item.find(id_s.to_i)
|
||||
prepare_items_for_mass_display(item)
|
||||
end
|
||||
@@ -32,7 +31,7 @@ end
|
||||
get '/item/offset/:offset/limit/:limit' do |offset_s, limit_s|
|
||||
offset, limit = mass_to_i(offset_s, limit_s)
|
||||
return [].to_json if offset_and_limit_invalid?(offset,limit)
|
||||
|
||||
|
||||
items = Item.best_selling(offset,limit)
|
||||
prepare_items_for_mass_display(items)
|
||||
end
|
||||
@@ -42,8 +41,8 @@ end
|
||||
get '/item/section/:section_id/offset/:offset/limit/:limit' do |section_id_s, offset_s, limit_s|
|
||||
section_id, offset, limit = mass_to_i(section_id_s, offset_s, limit_s)
|
||||
input_invalid = offset_and_limit_invalid?(offset,limit) or section_id <= 0
|
||||
return [].to_json if input_invalid
|
||||
|
||||
return [].to_json if input_invalid
|
||||
|
||||
items = Item.best_selling_in_section(section_id, offset, limit)
|
||||
prepare_items_for_mass_display(items)
|
||||
end
|
||||
@@ -53,7 +52,7 @@ end
|
||||
get '/item/category/:category_id/offset/:offset/limit/:limit' do |category_id_s, offset_s, limit_s|
|
||||
category_id, offset, limit = mass_to_i(category_id_s, offset_s, limit_s)
|
||||
input_invalid = offset_and_limit_invalid?(offset,limit) or category_id <= 0
|
||||
return [].to_json if input_invalid
|
||||
return [].to_json if input_invalid
|
||||
|
||||
all_in_cat = filter_by_traits(Item.all_in_category(category_id))
|
||||
items = Item.best_selling_in_category(category_id, offset,limit)
|
||||
@@ -66,41 +65,21 @@ end
|
||||
|
||||
# gets items in sub category ( useful for page showing single sub_category )
|
||||
get '/item/sub_category/:sub_category_id/offset/:offset/limit/:limit' do |sub_category_id_s, offset_s, limit_s|
|
||||
|
||||
sub_category_id, offset, limit = mass_to_i(sub_category_id_s, offset_s, limit_s)
|
||||
input_invalid = offset_and_limit_invalid?(offset,limit) or sub_category_id <= 0
|
||||
return [].to_json if input_invalid
|
||||
|
||||
all_in_sub_cat = filter_by_traits(Item.all_in_sub_category(sub_category_id))
|
||||
return [].to_json if input_invalid
|
||||
|
||||
items = Item.best_selling_in_sub_category(sub_category_id, offset, limit)
|
||||
items = filter_by_traits(items)
|
||||
|
||||
add_total_count_header(all_in_sub_cat.count)
|
||||
|
||||
prepare_items_for_mass_display(items)
|
||||
end
|
||||
|
||||
|
||||
# gets list of items in cart without count
|
||||
get '/cart/item_details' do
|
||||
get '/cart/item_details' do
|
||||
cart = Cart.find_or_create(anonymous_id, -1)
|
||||
item_ids = cart.item_in_carts.map do |x|
|
||||
x.item_id
|
||||
end
|
||||
items = []
|
||||
items = Item.find(item_ids) if cart.item_in_carts.length > 0
|
||||
items = Item.find(item_ids) if cart.item_in_carts.length > 0
|
||||
prepare_items_for_mass_display(items)
|
||||
end
|
||||
|
||||
|
||||
# gets items in sub category ( useful for page showing single sub_category )
|
||||
get '/item/item_group/:item_group_id/offset/:offset/limit/:limit' do |item_group_id_s, offset_s, limit_s|
|
||||
item_group_id, offset, limit = mass_to_i(item_group_id_s, offset_s, limit_s)
|
||||
input_invalid = offset_and_limit_invalid?(offset,limit) or item_group_id <= 0
|
||||
return [].to_json if input_invalid
|
||||
|
||||
items = ItemGroup.find_by_id(item_group_id)
|
||||
return [].to_json if items.nil?
|
||||
prepare_items_for_mass_display(items.all_items(offset, limit))
|
||||
end
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
|
||||
|
||||
get '/link_banner' do
|
||||
LinkBanner.all.to_json
|
||||
end
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
get '/menuitem' do
|
||||
# list all menu items
|
||||
MenuItem.eager_load(menu_sub_items: :menu_sub_sub_items)
|
||||
.order("menu_items.ordinal, menu_sub_items.ordinal, menu_sub_sub_items.ordinal")
|
||||
.to_json(:include => [:menu_sub_items => {:include => :menu_sub_sub_items}])
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
get '/place/:postal_code' do
|
||||
Place.by_code_or_default(params["postal_code"]).to_json
|
||||
end
|
||||
@@ -1,35 +0,0 @@
|
||||
get '/search' do
|
||||
es_client = Elasticsearch::Client.new log: true
|
||||
q = params[:q]
|
||||
|
||||
# for now we do the basic query
|
||||
results = es_client.search index: 'ribica', type: 'items', body: { query: { match: { _all: q } } }
|
||||
ids = results["hits"]["hits"].map do |r|
|
||||
r["_id"]
|
||||
end
|
||||
|
||||
ids_with_score = {}
|
||||
results["hits"]["hits"].each do |r|
|
||||
ids_with_score[r["_id"].to_i] = {:score => r["_score"], :item => nil}
|
||||
end
|
||||
|
||||
if ids.length > 0
|
||||
res = Item.where(:id => ids).to_a
|
||||
# make sure we have correct relevance order, since `where in` does not guarantee order
|
||||
res.each do |ii|
|
||||
ids_with_score[ii.id][:item] = ii
|
||||
end
|
||||
final = []
|
||||
ids_with_score.each do |k,v|
|
||||
final << v
|
||||
end
|
||||
final.sort_by! {|v| -v[:score]}
|
||||
|
||||
final = final.map do |f|
|
||||
f[:item]
|
||||
end
|
||||
prepare_items_for_mass_display(final)
|
||||
else
|
||||
[].to_json
|
||||
end
|
||||
end
|
||||
@@ -1,7 +1,9 @@
|
||||
get '/section' do
|
||||
Section.eager_load(:categories).order('sections.order, categories.order').to_json(:include => :categories)
|
||||
Section.order(:name).all.to_json(:include =>
|
||||
[:categories => { :include => :sub_categories }])
|
||||
end
|
||||
|
||||
get '/section/:id' do
|
||||
Section.eager_load(categories: :sub_categories).order('categories.order, sub_categories.order').find(params[:id].to_i).to_json(:include => [:categories => {:include => :sub_categories}])
|
||||
Section.find(params[:id].to_i).to_json(:include => [
|
||||
:categories => { :include => :sub_categories } ])
|
||||
end
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
get '/subcategory' do
|
||||
SubCategory
|
||||
.eager_load(category: :section)
|
||||
.order(:order)
|
||||
.all
|
||||
.to_json(:include => [filter_criterias: {include: :filter_criteria_values}, category: {include: :section} ])
|
||||
end
|
||||
|
||||
get '/subcategory/:id' do
|
||||
id = params[:id].to_i
|
||||
|
||||
SubCategory
|
||||
.eager_load(category: :section)
|
||||
.order(:order)
|
||||
.find(id)
|
||||
.to_json(:include => [filter_criterias: {include: :filter_criteria_values}, category: {include: :section} ])
|
||||
end
|
||||
@@ -1,24 +1,28 @@
|
||||
|
||||
helpers do
|
||||
def logged_in_user_id
|
||||
auth = cookies['ribica_auth']
|
||||
auth ||= -1
|
||||
return auth.to_i
|
||||
end
|
||||
|
||||
def anonymous_id
|
||||
auid = cookies[:anonymous_user_id]
|
||||
if auid.nil?
|
||||
auid = AnonymousUser.uid
|
||||
response.set_cookie('anonymous_user_id', :path=> '/', :httponly => true, :value=>auid, :expires=> Time.now + 100.year)
|
||||
end
|
||||
return auid
|
||||
end
|
||||
end
|
||||
|
||||
require 'openssl'
|
||||
require "base64"
|
||||
|
||||
post '/user/logout' do
|
||||
response.delete_cookie("ribica_auth", :path => "/")
|
||||
#response.delete_cookie("anonymous_user_id", :path => "/")
|
||||
auid = AnonymousUser.uid
|
||||
response.set_cookie('anonymous_user_id', :path=> '/', :httponly => true, :value=>auid, :expires=> Time.now + 100.year)
|
||||
#Cart.find_or_create(auid, -1)
|
||||
end
|
||||
|
||||
def encrypt(data)
|
||||
cipher = OpenSSL::Cipher.new('AES-128-CBC')
|
||||
cipher.encrypt
|
||||
cipher.key = COOKIE_SECRET_KEY
|
||||
encrypted = cipher.update(data) + cipher.final
|
||||
Base64.encode64(encrypted)
|
||||
end
|
||||
|
||||
def decrypt(data)
|
||||
data = Base64.decode64(data)
|
||||
cipher = OpenSSL::Cipher.new('AES-128-CBC')
|
||||
cipher.decrypt
|
||||
cipher.key = COOKIE_SECRET_KEY
|
||||
decrypted = cipher.update(data) + cipher.final
|
||||
end
|
||||
|
||||
post '/user/login' do
|
||||
@@ -31,7 +35,9 @@ post '/user/login' do
|
||||
res = User.find_by(email: email).try(:authenticate, password) # => false
|
||||
if res
|
||||
#TODO : encrypt this cookie
|
||||
response.set_cookie('ribica_auth', :path=> '/', :httponly => true, :value=>res.id, :expires=>Time.now+100.year)
|
||||
val = encrypt(res.id.to_s)
|
||||
response.set_cookie('ribica_auth', :path=> '/', :httponly => true, :value=>val, :expires=>Time.now+100.year)
|
||||
#Cart.find_or_create(anonymous_id, res.id)
|
||||
res.to_json(except: 'password_digest')
|
||||
else
|
||||
status 401
|
||||
@@ -42,6 +48,7 @@ end
|
||||
get '/user' do
|
||||
auth = cookies['ribica_auth']
|
||||
if not auth.nil?
|
||||
auth = decrypt(auth)
|
||||
return User.find_by(id: auth).to_json(except: 'password_digest')
|
||||
end
|
||||
end
|
||||
@@ -54,7 +61,8 @@ post '/user' do
|
||||
user.from_json(json, false)
|
||||
|
||||
if user.save
|
||||
response.set_cookie('ribica_auth', :path=> '/', :httponly => true, :value=>user.id, :expires=>Time.now+100.year)
|
||||
val = encrypt(user.id.to_s)
|
||||
response.set_cookie('ribica_auth', :path=> '/', :httponly => true, :value=>val, :expires=>Time.now+100.year)
|
||||
user.to_json(except: 'password_digest')
|
||||
else
|
||||
status 400
|
||||
|
||||
@@ -12,7 +12,7 @@ class CreateItems < ActiveRecord::Migration
|
||||
t.integer :stock
|
||||
t.boolean :on_display
|
||||
|
||||
t.timestamps null: false
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
class CreatePlaces < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :places do |t|
|
||||
t.string :postal_code
|
||||
t.decimal :delivery_price
|
||||
t.string :name
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddPriceToItemInCart < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :item_in_carts, :price, :decimal
|
||||
end
|
||||
end
|
||||
@@ -1,16 +0,0 @@
|
||||
class CreateSuppliers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :suppliers do |t|
|
||||
t.string :name
|
||||
t.string :address
|
||||
t.string :postal_code
|
||||
t.string :town
|
||||
t.string :phone
|
||||
t.string :contact_person
|
||||
t.string :email
|
||||
t.text :note
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddSupplierToItem < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :items, :supplier_id, :integer
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddWeigthToItem < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :items, :weight, :decimal, precision: 5, scale: 3
|
||||
end
|
||||
end
|
||||
@@ -1,10 +0,0 @@
|
||||
class AddFlagsToCart < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :carts, :confirmed, :boolean, default: false
|
||||
add_column :carts, :packed, :boolean, default: false
|
||||
add_column :carts, :canceled_on_check, :boolean, default: false
|
||||
add_column :carts, :canceled_on_delivery, :boolean, default: false
|
||||
add_column :carts, :delivered, :boolean, default: false
|
||||
add_column :carts, :internal_note, :text
|
||||
end
|
||||
end
|
||||
@@ -1,19 +0,0 @@
|
||||
class CreateSpecialOffers < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :special_offers do |t|
|
||||
t.string :image_url
|
||||
t.boolean :start_page
|
||||
t.integer :section_id
|
||||
t.integer :category_id
|
||||
t.integer :sub_category_id
|
||||
t.integer :item_id
|
||||
t.boolean :thank_you_page
|
||||
t.boolean :search_result_page
|
||||
t.boolean :checkout_page
|
||||
t.date :beginning
|
||||
t.date :ending
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddSpecialOfferToItem < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :items, :special_offer_id, :integer
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddOrderToSections < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :sections, :order, :integer
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddOrderToCategories < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :categories, :order, :integer
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddOrderToSubcategories < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :sub_categories, :order, :integer
|
||||
end
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
class CreateChildren < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :children do |t|
|
||||
t.string :name
|
||||
t.integer :gender
|
||||
t.date :date_of_birth
|
||||
t.integer :user_id
|
||||
t.boolean :on_the_way
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,10 +0,0 @@
|
||||
class CreateDeliveryTimeEstimations < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :delivery_time_estimations do |t|
|
||||
t.string :name
|
||||
t.integer :duration_in_days
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class AddDeliveryTimeEstimationToItem < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :items, :delivery_time_estimation_id, :integer
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class RemoveSpecialOfferIdFromItem < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :items, :special_offer_id
|
||||
end
|
||||
end
|
||||
@@ -1,25 +0,0 @@
|
||||
class CreateLinkBanners < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :link_banners do |t|
|
||||
t.string :image_url
|
||||
t.boolean :start_page
|
||||
t.integer :section_id
|
||||
t.integer :category_id
|
||||
t.integer :sub_category_id
|
||||
t.integer :item_id
|
||||
t.boolean :thank_you_page
|
||||
t.boolean :search_result_page
|
||||
t.boolean :checkout_page
|
||||
t.date :beginning
|
||||
t.date :ending
|
||||
t.boolean :footer
|
||||
t.boolean :header
|
||||
t.string :link_url
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
drop_table :special_offers
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
class CreateItemGroups < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :item_groups do |t|
|
||||
t.string :name
|
||||
t.text :description
|
||||
t.boolean :visible
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
|
||||
create_join_table :item, :item_groups
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
class CreateMenuItems < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :menu_items do |t|
|
||||
t.string :title
|
||||
t.string :url
|
||||
t.integer :ordinal
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,10 +0,0 @@
|
||||
class CreateMenuSubItems < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :menu_sub_items do |t|
|
||||
t.string :title
|
||||
t.string :url
|
||||
t.integer :ordinal
|
||||
t.integer :menu_item_id
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,9 +0,0 @@
|
||||
class CreateBrands < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :brands do |t|
|
||||
t.string :name
|
||||
end
|
||||
|
||||
add_column :items, :brand_id, :integer
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
class ChangeCodeColumnOnItemsTable < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :items, :code, :string, limit: 30
|
||||
end
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
class ChangeUnitsInPackColumnOnItems < ActiveRecord::Migration
|
||||
def change
|
||||
# t.decimal :units_in_pack, precision: 5, scale: 3
|
||||
change_column :items, :units_in_pack, :decimal, precision: 6, scale: 2
|
||||
end
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user