vyapari 0.1.5dev10 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/vyapari/admin/base_controller.rb +0 -9
- data/app/controllers/vyapari/admin/countries_controller.rb +2 -2
- data/app/controllers/vyapari/admin/dashboard_controller.rb +1 -3
- data/app/controllers/vyapari/admin/exchange_rates_controller.rb +2 -2
- data/app/controllers/vyapari/admin/regions_controller.rb +1 -1
- data/app/controllers/vyapari/admin/resource_controller.rb +0 -1
- data/app/controllers/vyapari/admin/users_controller.rb +130 -0
- data/app/controllers/vyapari/application_controller.rb +0 -11
- data/app/models/brand.rb +19 -67
- data/app/models/category.rb +19 -63
- data/app/models/country.rb +7 -31
- data/app/models/exchange_rate.rb +7 -32
- data/app/models/product.rb +20 -75
- data/app/models/region.rb +20 -37
- data/app/models/vyapari/application_record.rb +0 -3
- data/app/views/layouts/kuppayam/_footer.html.erb +1 -1
- data/app/views/layouts/kuppayam/_sidebar.html.erb +44 -45
- data/app/views/vyapari/admin/countries/_index.html.erb +1 -1
- data/app/views/vyapari/admin/countries/index.html.erb +3 -19
- data/app/views/vyapari/admin/exchange_rates/_form.html.erb +4 -3
- data/app/views/vyapari/admin/exchange_rates/_index.html.erb +7 -7
- data/app/views/vyapari/admin/exchange_rates/_row.html.erb +3 -3
- data/app/views/vyapari/admin/exchange_rates/_show.html.erb +0 -1
- data/app/views/vyapari/admin/exchange_rates/index.html.erb +3 -19
- data/app/views/vyapari/admin/regions/_index.html.erb +1 -1
- data/app/views/vyapari/admin/regions/index.html.erb +3 -19
- data/app/views/vyapari/admin/users/_form.html.erb +39 -0
- data/app/views/vyapari/admin/users/_index.html.erb +101 -0
- data/app/views/vyapari/admin/users/_row.html.erb +72 -0
- data/app/views/vyapari/admin/users/_show.html.erb +199 -0
- data/app/views/vyapari/admin/{categories → users}/index.html.erb +24 -8
- data/config/routes.rb +5 -66
- data/db/migrate/20170000000200_create_exchange_rates.rb +2 -3
- data/lib/tasks/vyapari_tasks.rake +4 -0
- data/lib/vyapari/version.rb +1 -1
- metadata +15 -167
- data/app/assets/images/vyapari/sample_stock_bundle.csv +0 -1
- data/app/controllers/vyapari/admin/brands_controller.rb +0 -99
- data/app/controllers/vyapari/admin/categories_controller.rb +0 -115
- data/app/controllers/vyapari/admin/products_controller.rb +0 -79
- data/app/controllers/vyapari/admin/stores_controller.rb +0 -67
- data/app/controllers/vyapari/admin/suppliers_controller.rb +0 -67
- data/app/controllers/vyapari/admin/terminals_controller.rb +0 -150
- data/app/controllers/vyapari/store_manager/base_controller.rb +0 -33
- data/app/controllers/vyapari/store_manager/dashboard_controller.rb +0 -31
- data/app/controllers/vyapari/store_manager/reports/invoices_controller.rb +0 -249
- data/app/controllers/vyapari/store_manager/reports/sales_controller.rb +0 -299
- data/app/controllers/vyapari/store_manager/reports/stock_controller.rb +0 -132
- data/app/controllers/vyapari/store_manager/resource_controller.rb +0 -17
- data/app/controllers/vyapari/store_manager/stock_bundles_controller.rb +0 -206
- data/app/controllers/vyapari/store_manager/stock_entries_controller.rb +0 -161
- data/app/controllers/vyapari/terminal_staff/base_controller.rb +0 -38
- data/app/controllers/vyapari/terminal_staff/dashboard_controller.rb +0 -35
- data/app/controllers/vyapari/terminal_staff/invoices_controller.rb +0 -147
- data/app/controllers/vyapari/terminal_staff/line_items_controller.rb +0 -139
- data/app/controllers/vyapari/terminal_staff/resource_controller.rb +0 -17
- data/app/controllers/vyapari/user_dashboard_controller.rb +0 -31
- data/app/models/bank_account.rb +0 -44
- data/app/models/contact.rb +0 -72
- data/app/models/image/brand_image.rb +0 -3
- data/app/models/image/category_image.rb +0 -3
- data/app/models/image/product_image.rb +0 -3
- data/app/models/invoice.rb +0 -256
- data/app/models/line_item.rb +0 -207
- data/app/models/stock_bundle.rb +0 -249
- data/app/models/stock_entry.rb +0 -275
- data/app/models/store.rb +0 -302
- data/app/models/supplier.rb +0 -79
- data/app/models/terminal.rb +0 -158
- data/app/uploaders/brand_image_uploader.rb +0 -14
- data/app/uploaders/category_image_uploader.rb +0 -14
- data/app/uploaders/product_image_uploader.rb +0 -14
- data/app/uploaders/stock_bundle_uploader.rb +0 -10
- data/app/views/layouts/vyapari/_store_manager_menu.html.erb +0 -126
- data/app/views/layouts/vyapari/_terminal_staff_menu.html.erb +0 -106
- data/app/views/layouts/vyapari/store_manager.html.erb +0 -112
- data/app/views/layouts/vyapari/terminal_staff.html.erb +0 -116
- data/app/views/vyapari/admin/brands/_form.html.erb +0 -23
- data/app/views/vyapari/admin/brands/_index.html.erb +0 -89
- data/app/views/vyapari/admin/brands/_row.html.erb +0 -63
- data/app/views/vyapari/admin/brands/_show.html.erb +0 -104
- data/app/views/vyapari/admin/brands/index.html.erb +0 -48
- data/app/views/vyapari/admin/categories/_form.html.erb +0 -28
- data/app/views/vyapari/admin/categories/_index.html.erb +0 -101
- data/app/views/vyapari/admin/categories/_row.html.erb +0 -69
- data/app/views/vyapari/admin/categories/_show.html.erb +0 -115
- data/app/views/vyapari/admin/products/_form.html.erb +0 -32
- data/app/views/vyapari/admin/products/_index.html.erb +0 -58
- data/app/views/vyapari/admin/products/_row.html.erb +0 -30
- data/app/views/vyapari/admin/products/_show.html.erb +0 -81
- data/app/views/vyapari/admin/products/index.html.erb +0 -48
- data/app/views/vyapari/admin/stores/_form.html.erb +0 -37
- data/app/views/vyapari/admin/stores/_index.html.erb +0 -84
- data/app/views/vyapari/admin/stores/_row.html.erb +0 -55
- data/app/views/vyapari/admin/stores/_show.html.erb +0 -110
- data/app/views/vyapari/admin/stores/index.html.erb +0 -48
- data/app/views/vyapari/admin/suppliers/_form.html.erb +0 -32
- data/app/views/vyapari/admin/suppliers/_index.html.erb +0 -58
- data/app/views/vyapari/admin/suppliers/_row.html.erb +0 -30
- data/app/views/vyapari/admin/suppliers/_show.html.erb +0 -81
- data/app/views/vyapari/admin/suppliers/index.html.erb +0 -48
- data/app/views/vyapari/admin/terminals/_form.html.erb +0 -24
- data/app/views/vyapari/admin/terminals/_index.html.erb +0 -75
- data/app/views/vyapari/admin/terminals/_row.html.erb +0 -49
- data/app/views/vyapari/admin/terminals/_show.html.erb +0 -74
- data/app/views/vyapari/store_manager/dashboard/_sales_counts.html.erb +0 -90
- data/app/views/vyapari/store_manager/dashboard/_stock_counts.html.erb +0 -63
- data/app/views/vyapari/store_manager/dashboard/_terminals.html.erb +0 -23
- data/app/views/vyapari/store_manager/dashboard/index.html.erb +0 -64
- data/app/views/vyapari/store_manager/reports/invoices/_index.html.erb +0 -65
- data/app/views/vyapari/store_manager/reports/invoices/index.html.erb +0 -105
- data/app/views/vyapari/store_manager/reports/sales/_index.html.erb +0 -64
- data/app/views/vyapari/store_manager/reports/sales/index.html.erb +0 -105
- data/app/views/vyapari/store_manager/reports/stock/_index.html.erb +0 -72
- data/app/views/vyapari/store_manager/reports/stock/index.html.erb +0 -32
- data/app/views/vyapari/store_manager/stock_bundles/_form.html.erb +0 -99
- data/app/views/vyapari/store_manager/stock_bundles/_index.html.erb +0 -74
- data/app/views/vyapari/store_manager/stock_bundles/_row.html.erb +0 -44
- data/app/views/vyapari/store_manager/stock_bundles/_show.html.erb +0 -110
- data/app/views/vyapari/store_manager/stock_bundles/create.html.erb +0 -57
- data/app/views/vyapari/store_manager/stock_bundles/index.html.erb +0 -36
- data/app/views/vyapari/store_manager/stock_bundles/update.html.erb +0 -57
- data/app/views/vyapari/store_manager/stock_entries/_form.html.erb +0 -50
- data/app/views/vyapari/store_manager/stock_entries/_index.html.erb +0 -80
- data/app/views/vyapari/store_manager/stock_entries/_row.html.erb +0 -33
- data/app/views/vyapari/store_manager/stock_entries/_show.html.erb +0 -110
- data/app/views/vyapari/store_manager/stock_entries/_stock_bundle.html.erb +0 -61
- data/app/views/vyapari/store_manager/stock_entries/index.html.erb +0 -45
- data/app/views/vyapari/terminal_staff/dashboard/_counts.html.erb +0 -131
- data/app/views/vyapari/terminal_staff/dashboard/_invoices.html.erb +0 -44
- data/app/views/vyapari/terminal_staff/dashboard/_search_form.html.erb +0 -6
- data/app/views/vyapari/terminal_staff/dashboard/_search_results.html.erb +0 -24
- data/app/views/vyapari/terminal_staff/dashboard/index.html.erb +0 -56
- data/app/views/vyapari/terminal_staff/dashboard/search.js.erb +0 -12
- data/app/views/vyapari/terminal_staff/invoices/_draft.html.erb +0 -62
- data/app/views/vyapari/terminal_staff/invoices/_form.html.erb +0 -134
- data/app/views/vyapari/terminal_staff/invoices/_index.html.erb +0 -70
- data/app/views/vyapari/terminal_staff/invoices/_row.html.erb +0 -33
- data/app/views/vyapari/terminal_staff/invoices/_show.html.erb +0 -204
- data/app/views/vyapari/terminal_staff/invoices/index.html.erb +0 -35
- data/app/views/vyapari/terminal_staff/invoices/new.js.erb +0 -18
- data/app/views/vyapari/terminal_staff/invoices/show.html.erb +0 -1
- data/app/views/vyapari/terminal_staff/invoices/show.js.erb +0 -13
- data/app/views/vyapari/terminal_staff/line_items/_form.html.erb +0 -40
- data/app/views/vyapari/terminal_staff/line_items/_index.html.erb +0 -96
- data/app/views/vyapari/terminal_staff/line_items/create.js.erb +0 -34
- data/app/views/vyapari/terminal_staff/line_items/destroy.js.erb +0 -25
- data/app/views/vyapari/user_dashboard/index.html.erb +0 -51
- data/db/import_data/brands.csv +0 -7
- data/db/import_data/categories.csv +0 -12
- data/db/import_data/countries.csv +0 -1
- data/db/import_data/dummy/brands.csv +0 -7
- data/db/import_data/dummy/categories.csv +0 -12
- data/db/import_data/dummy/countries.csv +0 -1
- data/db/import_data/dummy/exchange_rates.csv +0 -5
- data/db/import_data/dummy/products-copy.csv +0 -1
- data/db/import_data/dummy/products.csv +0 -1
- data/db/import_data/dummy/products.xlsx +0 -0
- data/db/import_data/dummy/regions.csv +0 -13
- data/db/import_data/dummy/stores.csv +0 -10
- data/db/import_data/dummy/suppliers.csv +0 -14
- data/db/import_data/dummy/terminals.csv +0 -11
- data/db/import_data/exchange_rates.csv +0 -5
- data/db/import_data/regions.csv +0 -13
- data/db/import_data/stores.csv +0 -3
- data/db/import_data/suppliers.csv +0 -14
- data/db/import_data/terminals.csv +0 -3
- data/db/migrate/20170000000203_create_contacts.rb +0 -22
- data/db/migrate/20170000000204_create_bank_accounts.rb +0 -21
- data/db/migrate/20170000000205_create_suppliers.rb +0 -18
- data/db/migrate/20170000000206_create_stores.rb +0 -21
- data/db/migrate/20170000000207_create_terminals.rb +0 -18
- data/db/migrate/20170000000210_create_brands.rb +0 -14
- data/db/migrate/20170000000211_create_categories.rb +0 -22
- data/db/migrate/20170000000212_create_products.rb +0 -29
- data/db/migrate/20170000000213_create_invoices.rb +0 -61
- data/db/migrate/20170000000215_create_stock_bundles.rb +0 -17
- data/db/migrate/20170000000216_create_stock_entries.rb +0 -20
- data/db/sample_reports/products.xlsx +0 -0
- data/lib/tasks/vyapari/all.rake +0 -73
data/app/models/country.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
class Country < Vyapari::ApplicationRecord
|
2
2
|
|
3
|
+
DELETE_MESSAGE = "Cannot delete the country. You should first remove all the cities and exchange rates associated with this country."
|
4
|
+
|
3
5
|
# Validations
|
4
|
-
validates :name, presence: true, length: {minimum: 2, maximum:
|
5
|
-
validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum:
|
6
|
+
validates :name, presence: true, length: {minimum: 2, maximum: 250}, allow_blank: false
|
7
|
+
validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum: 32}, allow_blank: false
|
6
8
|
|
7
9
|
# Associations
|
8
10
|
has_many :regions
|
9
|
-
has_many :
|
11
|
+
has_many :exchange_rates
|
10
12
|
|
11
13
|
# ------------------
|
12
14
|
# Class Methods
|
@@ -19,33 +21,6 @@ class Country < Vyapari::ApplicationRecord
|
|
19
21
|
# => ActiveRecord::Relation object
|
20
22
|
scope :search, lambda {|query| where("LOWER(countries.name) LIKE LOWER('%#{query}%')")}
|
21
23
|
|
22
|
-
# Import Methods
|
23
|
-
# --------------
|
24
|
-
|
25
|
-
def self.save_row_data(row)
|
26
|
-
|
27
|
-
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
28
|
-
|
29
|
-
return if row[:name].blank?
|
30
|
-
|
31
|
-
country = Country.find_by_code(row[:code]) || Country.new
|
32
|
-
country.name = row[:name]
|
33
|
-
country.code = row[:code]
|
34
|
-
|
35
|
-
# Initializing error hash for displaying all errors altogether
|
36
|
-
error_object = Kuppayam::Importer::ErrorHash.new
|
37
|
-
|
38
|
-
if country.valid?
|
39
|
-
country.save!
|
40
|
-
else
|
41
|
-
summary = "Error while saving country: #{country.name}"
|
42
|
-
details = "Error! #{country.errors.full_messages.to_sentence}"
|
43
|
-
error_object.errors << { summary: summary, details: details }
|
44
|
-
end
|
45
|
-
|
46
|
-
return error_object
|
47
|
-
end
|
48
|
-
|
49
24
|
# ------------------
|
50
25
|
# Instance Methods
|
51
26
|
# ------------------
|
@@ -59,7 +34,8 @@ class Country < Vyapari::ApplicationRecord
|
|
59
34
|
end
|
60
35
|
|
61
36
|
def can_be_deleted?
|
62
|
-
if self.regions.any? || self.
|
37
|
+
if self.regions.any? || self.exchange_rates.any?
|
38
|
+
self.errors.add(:base, DELETE_MESSAGE)
|
63
39
|
return false
|
64
40
|
else
|
65
41
|
return true
|
data/app/models/exchange_rate.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
class ExchangeRate < Vyapari::ApplicationRecord
|
2
2
|
|
3
3
|
# Validations
|
4
|
-
validates :
|
5
|
-
validates :
|
6
|
-
validates :value, presence: true, numericality: { greater_than: 0 }
|
4
|
+
validates :currency_name, presence: true, length: {minimum: 2, maximum: 4}, allow_blank: false
|
5
|
+
validates :value, presence: true
|
7
6
|
validates :effective_date, presence: true
|
8
7
|
|
8
|
+
# Associations
|
9
|
+
belongs_to :country
|
10
|
+
|
9
11
|
# ------------------
|
10
12
|
# Class Methods
|
11
13
|
# ------------------
|
@@ -15,41 +17,14 @@ class ExchangeRate < Vyapari::ApplicationRecord
|
|
15
17
|
# == Examples
|
16
18
|
# >>> obj.search(query)
|
17
19
|
# => ActiveRecord::Relation object
|
18
|
-
scope :search, lambda {|query| where("LOWER(exchange_rates.
|
19
|
-
|
20
|
-
def self.save_row_data(row)
|
21
|
-
|
22
|
-
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
23
|
-
|
24
|
-
return if row[:base_currency].blank?
|
25
|
-
|
26
|
-
exchange_rate = ExchangeRate.where("base_currency = ? AND counter_currency = ?", row[:base_currency], row[:counter_currency]).first || ExchangeRate.new
|
27
|
-
|
28
|
-
exchange_rate.base_currency = row[:base_currency]
|
29
|
-
exchange_rate.counter_currency = row[:counter_currency]
|
30
|
-
exchange_rate.value = row[:value]
|
31
|
-
exchange_rate.effective_date = row[:effective_date]
|
32
|
-
|
33
|
-
# Initializing error hash for displaying all errors altogether
|
34
|
-
error_object = Kuppayam::Importer::ErrorHash.new
|
35
|
-
|
36
|
-
if exchange_rate.valid?
|
37
|
-
exchange_rate.save!
|
38
|
-
else
|
39
|
-
summary = "Error while saving exchange_rate: #{exchange_rate.name}"
|
40
|
-
details = "Error! #{exchange_rate.errors.full_messages.to_sentence}"
|
41
|
-
error_object.errors << { summary: summary, details: details }
|
42
|
-
end
|
43
|
-
|
44
|
-
return error_object
|
45
|
-
end
|
20
|
+
scope :search, lambda {|query| joins(:country).where("LOWER(exchange_rates.currency_name) LIKE LOWER('%#{query}%') OR LOWER(countries.name) LIKE LOWER('%#{query}%')")}
|
46
21
|
|
47
22
|
# ------------------
|
48
23
|
# Instance Methods
|
49
24
|
# ------------------
|
50
25
|
|
51
26
|
def display_name
|
52
|
-
"#{self.
|
27
|
+
"#{self.currency_name_was}, #{self.country.try(:name)}"
|
53
28
|
end
|
54
29
|
|
55
30
|
def can_be_edited?
|
data/app/models/product.rb
CHANGED
@@ -4,26 +4,25 @@ class Product < Vyapari::ApplicationRecord
|
|
4
4
|
PUBLISHED = "published"
|
5
5
|
UNPUBLISHED = "unpublished"
|
6
6
|
REMOVED = "removed"
|
7
|
-
|
8
|
-
|
9
|
-
STATUS_REVERSE = {PUBLISHED => "Published", UNPUBLISHED => "Unpublished", REMOVED => "Removed"}
|
7
|
+
STATUS_HASH = {"Published" => PUBLISHED, "Unpublished" => UNPUBLISHED, "Removed" => REMOVED}
|
8
|
+
STATUS_HASH_REVERSE = {PUBLISHED => "Published", UNPUBLISHED => "Unpublished", REMOVED => "Removed"}
|
10
9
|
|
11
10
|
FEATURED_HASH = {"Featured" => true, "Non Featured" => false}
|
12
11
|
FEATURED_HASH_REVERSE = {true => "Featured", false => "Non Featured"}
|
13
12
|
|
14
13
|
# Callbacks
|
14
|
+
before_validation :update_permalink
|
15
15
|
before_validation :update_top_category
|
16
16
|
|
17
17
|
# Validations
|
18
18
|
validates :name, presence: true
|
19
|
-
validates :ean_sku, presence: true
|
20
|
-
|
21
19
|
#validates :description, presence: true
|
22
|
-
validates :
|
20
|
+
validates :permalink, presence: true, uniqueness: true
|
21
|
+
validates :status, :presence=> true, :inclusion => {:in => STATUS_HASH_REVERSE.keys, :presence_of => :status, :message => "%{value} is not a valid status" }
|
23
22
|
|
24
23
|
# Associations
|
25
24
|
has_one :product_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::ProductImage"
|
26
|
-
|
25
|
+
has_one :brochure, :as => :documentable, :dependent => :destroy, :class_name => "Document::Brochure"
|
27
26
|
|
28
27
|
belongs_to :brand
|
29
28
|
belongs_to :category
|
@@ -34,14 +33,14 @@ class Product < Vyapari::ApplicationRecord
|
|
34
33
|
# == Examples
|
35
34
|
# >>> object.search(query)
|
36
35
|
# => ActiveRecord::Relation object
|
37
|
-
scope :search, lambda {|query| joins("
|
38
|
-
where("LOWER(products.
|
39
|
-
LOWER(products.
|
40
|
-
LOWER(products.name) LIKE LOWER('%#{query}%') OR\
|
36
|
+
scope :search, lambda {|query| joins("INNER JOIN categories on categories.id = products.category_id").
|
37
|
+
where("LOWER(products.name) LIKE LOWER('%#{query}%') OR\
|
38
|
+
LOWER(products.permalink) LIKE LOWER('%#{query}%') OR\
|
41
39
|
LOWER(products.one_liner) LIKE LOWER('%#{query}%') OR\
|
42
40
|
LOWER(products.description) LIKE LOWER('%#{query}%') OR\
|
43
41
|
LOWER(categories.name) LIKE LOWER('%#{query}%') OR\
|
44
|
-
LOWER(categories.one_liner) LIKE LOWER('%#{query}%')
|
42
|
+
LOWER(categories.one_liner) LIKE LOWER('%#{query}%') OR\
|
43
|
+
LOWER(categories.description) LIKE LOWER('%#{query}%')")
|
45
44
|
}
|
46
45
|
|
47
46
|
scope :status, lambda { |status| where("LOWER(status)='#{status}'") }
|
@@ -51,57 +50,10 @@ class Product < Vyapari::ApplicationRecord
|
|
51
50
|
scope :unpublished, -> { where(status: UNPUBLISHED) }
|
52
51
|
scope :removed, -> { where(status: REMOVED) }
|
53
52
|
|
54
|
-
def self.save_row_data(row)
|
55
|
-
|
56
|
-
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
57
|
-
|
58
|
-
return if row[:name].blank?
|
59
|
-
|
60
|
-
product = Product.find_by_name(row[:name]) || Product.new
|
61
|
-
|
62
|
-
product.name = row[:name]
|
63
|
-
product.one_liner = row[:one_liner]
|
64
|
-
product.description = row[:description]
|
65
|
-
product.ean_sku = row[:ean_sku].to_s
|
66
|
-
product.reference_number = row[:reference_number]
|
67
|
-
|
68
|
-
product.brand = Brand.find_by_name(row[:brand])
|
69
|
-
product.category = Category.find_by_name(row[:category])
|
70
|
-
product.top_category = product.category.top_category if product.category
|
71
|
-
|
72
|
-
product.featured = row[:featured]
|
73
|
-
product.status = row[:status]
|
74
|
-
product.priority = row[:priority]
|
75
|
-
|
76
|
-
# Initializing error hash for displaying all errors altogether
|
77
|
-
error_object = Kuppayam::Importer::ErrorHash.new
|
78
|
-
|
79
|
-
if product.valid?
|
80
|
-
product.save!
|
81
|
-
else
|
82
|
-
summary = "Error while saving product: #{product.name}"
|
83
|
-
details = "Error! #{product.errors.full_messages.to_sentence}"
|
84
|
-
error_object.errors << { summary: summary, details: details }
|
85
|
-
end
|
86
|
-
return error_object
|
87
|
-
end
|
88
|
-
|
89
53
|
# ------------------
|
90
54
|
# Instance variables
|
91
55
|
# ------------------
|
92
56
|
|
93
|
-
def display_name
|
94
|
-
"#{self.ean_sku} : #{self.name}"
|
95
|
-
end
|
96
|
-
|
97
|
-
def slug
|
98
|
-
self.name.parameterize
|
99
|
-
end
|
100
|
-
|
101
|
-
def to_param
|
102
|
-
"#{id}-#{slug}"
|
103
|
-
end
|
104
|
-
|
105
57
|
# * Return true if the brand is published, else false.
|
106
58
|
# == Examples
|
107
59
|
# >>> brand.published?
|
@@ -153,22 +105,7 @@ class Product < Vyapari::ApplicationRecord
|
|
153
105
|
self.update_attributes(status: REMOVED, featured: false)
|
154
106
|
end
|
155
107
|
|
156
|
-
|
157
|
-
unpublished? or removed?
|
158
|
-
end
|
159
|
-
|
160
|
-
def can_be_unpublished?
|
161
|
-
published? or removed?
|
162
|
-
end
|
163
|
-
|
164
|
-
def can_be_removed?
|
165
|
-
published? or unpublished? or removed?
|
166
|
-
end
|
167
|
-
|
168
|
-
def can_be_edited?
|
169
|
-
true
|
170
|
-
end
|
171
|
-
|
108
|
+
# TODO
|
172
109
|
def can_be_deleted?
|
173
110
|
#if self.jobs.any?
|
174
111
|
# self.errors.add(:base, DELETE_MESSAGE)
|
@@ -179,6 +116,10 @@ class Product < Vyapari::ApplicationRecord
|
|
179
116
|
return true
|
180
117
|
end
|
181
118
|
|
119
|
+
def default_image_url(size="medium")
|
120
|
+
"/assets/defaults/product-#{size}.png"
|
121
|
+
end
|
122
|
+
|
182
123
|
protected
|
183
124
|
|
184
125
|
def update_top_category
|
@@ -191,4 +132,8 @@ class Product < Vyapari::ApplicationRecord
|
|
191
132
|
end
|
192
133
|
end
|
193
134
|
|
135
|
+
def update_permalink
|
136
|
+
self.permalink = "#{id}-#{name.parameterize}" if self.permalink.blank?
|
137
|
+
end
|
138
|
+
|
194
139
|
end
|
data/app/models/region.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
class Region < Vyapari::ApplicationRecord
|
2
2
|
|
3
|
+
DELETE_MESSAGE = "Cannot delete this Region. You should first delete all the dependant data like Company Cities, Jobs, Budgets etc tagged with this Region"
|
4
|
+
|
3
5
|
# Validations
|
4
|
-
validates :name, presence: true, length: {minimum: 2, maximum:
|
5
|
-
validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum:
|
6
|
+
validates :name, presence: true, length: {minimum: 2, maximum: 250}, allow_blank: false
|
7
|
+
validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum: 32}, allow_blank: false
|
6
8
|
validates :country, presence: true
|
7
9
|
|
8
10
|
# Associations
|
9
11
|
belongs_to :country
|
10
|
-
has_many :stores
|
12
|
+
# has_many :stores
|
11
13
|
|
12
14
|
# ------------------
|
13
15
|
# Class Methods
|
@@ -18,35 +20,7 @@ class Region < Vyapari::ApplicationRecord
|
|
18
20
|
# == Examples
|
19
21
|
# >>> obj.search(query)
|
20
22
|
# => ActiveRecord::Relation object
|
21
|
-
scope :search, lambda {|query| joins(:country).where("LOWER(
|
22
|
-
|
23
|
-
# Import Methods
|
24
|
-
# --------------
|
25
|
-
|
26
|
-
def self.save_row_data(row)
|
27
|
-
|
28
|
-
row.headers.each{ |cell| row[cell] = row[cell].to_s.strip }
|
29
|
-
|
30
|
-
return if row[:name].blank?
|
31
|
-
|
32
|
-
region = Region.find_by_code(row[:code]) || Region.new
|
33
|
-
region.name = row[:name]
|
34
|
-
region.code = row[:code]
|
35
|
-
region.country = Country.find_by_code(row[:country]) || Country.find_by_name(row[:country])
|
36
|
-
|
37
|
-
# Initializing error hash for displaying all errors altogether
|
38
|
-
error_object = Kuppayam::Importer::ErrorHash.new
|
39
|
-
|
40
|
-
if region.valid?
|
41
|
-
region.save!
|
42
|
-
else
|
43
|
-
summary = "Error while saving region: #{region.name}"
|
44
|
-
details = "Error! #{region.errors.full_messages.to_sentence}"
|
45
|
-
error_object.errors << { summary: summary, details: details }
|
46
|
-
end
|
47
|
-
|
48
|
-
return error_object
|
49
|
-
end
|
23
|
+
scope :search, lambda {|query| joins(:country).where("LOWER(cities.name) LIKE LOWER('%#{query}%') OR LOWER(countries.name) LIKE LOWER('%#{query}%')")}
|
50
24
|
|
51
25
|
# ------------------
|
52
26
|
# Instance Methods
|
@@ -65,11 +39,20 @@ class Region < Vyapari::ApplicationRecord
|
|
65
39
|
end
|
66
40
|
|
67
41
|
def can_be_deleted?
|
68
|
-
if self.stores.any?
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
42
|
+
# if self.stores.any?
|
43
|
+
# self.errors.add(:base, DELETE_MESSAGE)
|
44
|
+
# return false
|
45
|
+
# else
|
46
|
+
# return true
|
47
|
+
# end
|
48
|
+
return true
|
49
|
+
end
|
50
|
+
|
51
|
+
def report_heading
|
52
|
+
rh = []
|
53
|
+
rh << self.company.try(:name) if self.company.name
|
54
|
+
rh << self.display_name
|
55
|
+
rh.join(", ")
|
73
56
|
end
|
74
57
|
|
75
58
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
<!-- Add your copyright text here -->
|
6
6
|
<div class="footer-text">
|
7
7
|
© 2017
|
8
|
-
<strong>
|
8
|
+
<strong>Kuppayam</strong>
|
9
9
|
|
10
10
|
All rights reserved. <br>developed, maintained and hosted by <a href="http://rightsolutions.io" target="_blank" style="color:red">Right Solutions</a>
|
11
11
|
</div>
|
@@ -26,109 +26,108 @@
|
|
26
26
|
<i class="fa-bars"></i>
|
27
27
|
</a>
|
28
28
|
</div>
|
29
|
+
|
29
30
|
</header>
|
30
31
|
|
32
|
+
|
33
|
+
|
31
34
|
<ul id="main-menu" class="main-menu">
|
32
35
|
|
33
36
|
<!-- add class "multiple-expanded" to allow multiple submenus to open -->
|
34
37
|
|
35
38
|
<!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
|
36
39
|
|
37
|
-
<!-- Dashboard -->
|
38
40
|
<li class="<%= nav_active?('admin/dashboard') ? 'active' : '' %>">
|
39
|
-
<%= link_to raw("<i class=\"linecons-desktop\"></i> <span class='title'>
|
41
|
+
<%= link_to raw("<i class=\"linecons-desktop\"></i> <span class='title'>Dashboard</span>"), vyapari.admin_dashboard_url %>
|
40
42
|
</li>
|
41
|
-
|
42
|
-
<!-- Manage Store -->
|
43
|
-
<li class="<%= nav_active?('store_manager/stores') ? 'active' : '' %>">
|
44
|
-
<%= link_to raw("<i class=\"linecons-shop\"></i> <span class='title'>Manage Store / POS</span>"), vyapari.user_dashboard_url %>
|
45
|
-
</li>
|
46
|
-
|
47
|
-
<!-- Configurations -->
|
48
|
-
<% if @current_user.super_admin? %>
|
43
|
+
|
49
44
|
<li class="">
|
50
|
-
<a href="
|
51
|
-
<i class="linecons-
|
45
|
+
<a href="/xenon/xenon-files/html/dashboard-1.html">
|
46
|
+
<i class="linecons-database"></i>
|
52
47
|
<span class="title">Configurations</span>
|
53
48
|
</a>
|
54
49
|
<ul>
|
55
50
|
|
51
|
+
<li class="<%= nav_class("admin/users") %>">
|
52
|
+
<%= link_to raw("<i class=\"linecons-user\"></i> <span class='title'>Manage Users</span>"), usman.admin_users_url %>
|
53
|
+
</li>
|
54
|
+
|
55
|
+
<li class="<%= nav_class("admin/users") %>">
|
56
|
+
<%= link_to raw("<i class=\"linecons-lock\"></i> <span class='title'>Manage Permissions</span>"), usman.admin_permissions_url %>
|
57
|
+
</li>
|
58
|
+
|
56
59
|
<li class="">
|
57
|
-
<%= link_to raw("<i class=\"linecons-
|
60
|
+
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Features</span>"), usman.admin_features_url %>
|
58
61
|
</li>
|
59
62
|
|
60
63
|
<li class="">
|
61
|
-
<%= link_to raw("<i class=\"linecons-
|
64
|
+
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Roles</span>"), usman.admin_roles_url %>
|
62
65
|
</li>
|
63
66
|
|
64
67
|
<li class="">
|
65
|
-
<%= link_to raw("<i class=\"linecons-
|
68
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Countries</span>"), vyapari.admin_countries_url %>
|
66
69
|
</li>
|
67
70
|
|
68
71
|
<li class="">
|
69
|
-
<%= link_to raw("<i class=\"linecons-
|
72
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Regions</span>"), vyapari.admin_regions_url %>
|
70
73
|
</li>
|
71
74
|
|
72
|
-
<li class="
|
73
|
-
<%= link_to raw("<i class=\"linecons-
|
75
|
+
<li class="">
|
76
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Exchange Rates</span>"), vyapari.admin_exchange_rates_url %>
|
74
77
|
</li>
|
75
78
|
|
76
79
|
</ul>
|
77
80
|
</li>
|
78
|
-
<% end %>
|
79
81
|
|
80
|
-
<!-- Administration -->
|
81
|
-
<% if @current_user.super_admin? || @current_user.has_role?("Site Admin") %>
|
82
82
|
<li class="">
|
83
|
-
<a href="
|
84
|
-
<i class="linecons-
|
85
|
-
<span class="title">
|
83
|
+
<a href="/xenon/xenon-files/html/dashboard-1.html">
|
84
|
+
<i class="linecons-database"></i>
|
85
|
+
<span class="title">Stock Management</span>
|
86
86
|
</a>
|
87
87
|
<ul>
|
88
|
-
|
89
|
-
<li class="<%= nav_class("admin/users") %>">
|
90
|
-
<%= link_to raw("<i class=\"linecons-user\"></i> <span class='title'>Manage Users</span>"), usman.admin_users_url %>
|
91
|
-
</li>
|
92
|
-
|
93
|
-
<li class="">
|
94
|
-
<%= link_to raw("<i class=\"linecons-graduation-cap\"></i> <span class='title'>Manage Roles</span>"), usman.admin_roles_url %>
|
95
|
-
</li>
|
96
|
-
|
97
88
|
<li class="">
|
98
|
-
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage
|
89
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Suppliers</span>"), vyapari.admin_suppliers_url %>
|
99
90
|
</li>
|
100
91
|
|
101
92
|
<li class="">
|
102
|
-
<%= link_to raw("<i class=\"linecons-
|
93
|
+
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Manage Stores</span>"), vyapari.admin_stores_url %>
|
103
94
|
</li>
|
104
|
-
|
95
|
+
|
105
96
|
<li class="">
|
106
|
-
<%= link_to raw("<i class=\"linecons-
|
97
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Brands</span>"), vyapari.admin_brands_url %>
|
107
98
|
</li>
|
108
99
|
|
109
100
|
<li class="">
|
110
|
-
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage
|
101
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Categories</span>"), vyapari.admin_categories_url %>
|
111
102
|
</li>
|
112
103
|
|
113
104
|
</ul>
|
114
105
|
</li>
|
115
|
-
<% end %>
|
116
106
|
|
117
|
-
<% if @current_user.super_admin? %>
|
118
107
|
<li class="">
|
119
|
-
<a href="
|
108
|
+
<a href="/xenon/xenon-files/html/dashboard-1.html">
|
120
109
|
<i class="linecons-database"></i>
|
121
|
-
<span class="title">
|
110
|
+
<span class="title">POS</span>
|
122
111
|
</a>
|
123
112
|
<ul>
|
124
|
-
|
125
113
|
<li class="">
|
126
|
-
<%= link_to raw("<i class=\"linecons-
|
114
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Suppliers</span>"), vyapari.admin_suppliers_url %>
|
115
|
+
</li>
|
116
|
+
|
117
|
+
<li class="">
|
118
|
+
<%= link_to raw("<i class=\"linecons-diamond\"></i> <span class='title'>Manage Stores</span>"), vyapari.admin_stores_url %>
|
119
|
+
</li>
|
120
|
+
|
121
|
+
<li class="">
|
122
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Brands</span>"), vyapari.admin_brands_url %>
|
123
|
+
</li>
|
124
|
+
|
125
|
+
<li class="">
|
126
|
+
<%= link_to raw("<i class=\"linecons-database\"></i> <span class='title'>Manage Categories</span>"), vyapari.admin_categories_url %>
|
127
127
|
</li>
|
128
128
|
|
129
129
|
</ul>
|
130
130
|
</li>
|
131
|
-
<% end %>
|
132
131
|
|
133
132
|
</ul>
|
134
133
|
|