vyapari 0.1.5dev10 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/vyapari/admin/base_controller.rb +0 -9
  3. data/app/controllers/vyapari/admin/countries_controller.rb +2 -2
  4. data/app/controllers/vyapari/admin/dashboard_controller.rb +1 -3
  5. data/app/controllers/vyapari/admin/exchange_rates_controller.rb +2 -2
  6. data/app/controllers/vyapari/admin/regions_controller.rb +1 -1
  7. data/app/controllers/vyapari/admin/resource_controller.rb +0 -1
  8. data/app/controllers/vyapari/admin/users_controller.rb +130 -0
  9. data/app/controllers/vyapari/application_controller.rb +0 -11
  10. data/app/models/brand.rb +19 -67
  11. data/app/models/category.rb +19 -63
  12. data/app/models/country.rb +7 -31
  13. data/app/models/exchange_rate.rb +7 -32
  14. data/app/models/product.rb +20 -75
  15. data/app/models/region.rb +20 -37
  16. data/app/models/vyapari/application_record.rb +0 -3
  17. data/app/views/layouts/kuppayam/_footer.html.erb +1 -1
  18. data/app/views/layouts/kuppayam/_sidebar.html.erb +44 -45
  19. data/app/views/vyapari/admin/countries/_index.html.erb +1 -1
  20. data/app/views/vyapari/admin/countries/index.html.erb +3 -19
  21. data/app/views/vyapari/admin/exchange_rates/_form.html.erb +4 -3
  22. data/app/views/vyapari/admin/exchange_rates/_index.html.erb +7 -7
  23. data/app/views/vyapari/admin/exchange_rates/_row.html.erb +3 -3
  24. data/app/views/vyapari/admin/exchange_rates/_show.html.erb +0 -1
  25. data/app/views/vyapari/admin/exchange_rates/index.html.erb +3 -19
  26. data/app/views/vyapari/admin/regions/_index.html.erb +1 -1
  27. data/app/views/vyapari/admin/regions/index.html.erb +3 -19
  28. data/app/views/vyapari/admin/users/_form.html.erb +39 -0
  29. data/app/views/vyapari/admin/users/_index.html.erb +101 -0
  30. data/app/views/vyapari/admin/users/_row.html.erb +72 -0
  31. data/app/views/vyapari/admin/users/_show.html.erb +199 -0
  32. data/app/views/vyapari/admin/{categories → users}/index.html.erb +24 -8
  33. data/config/routes.rb +5 -66
  34. data/db/migrate/20170000000200_create_exchange_rates.rb +2 -3
  35. data/lib/tasks/vyapari_tasks.rake +4 -0
  36. data/lib/vyapari/version.rb +1 -1
  37. metadata +15 -167
  38. data/app/assets/images/vyapari/sample_stock_bundle.csv +0 -1
  39. data/app/controllers/vyapari/admin/brands_controller.rb +0 -99
  40. data/app/controllers/vyapari/admin/categories_controller.rb +0 -115
  41. data/app/controllers/vyapari/admin/products_controller.rb +0 -79
  42. data/app/controllers/vyapari/admin/stores_controller.rb +0 -67
  43. data/app/controllers/vyapari/admin/suppliers_controller.rb +0 -67
  44. data/app/controllers/vyapari/admin/terminals_controller.rb +0 -150
  45. data/app/controllers/vyapari/store_manager/base_controller.rb +0 -33
  46. data/app/controllers/vyapari/store_manager/dashboard_controller.rb +0 -31
  47. data/app/controllers/vyapari/store_manager/reports/invoices_controller.rb +0 -249
  48. data/app/controllers/vyapari/store_manager/reports/sales_controller.rb +0 -299
  49. data/app/controllers/vyapari/store_manager/reports/stock_controller.rb +0 -132
  50. data/app/controllers/vyapari/store_manager/resource_controller.rb +0 -17
  51. data/app/controllers/vyapari/store_manager/stock_bundles_controller.rb +0 -206
  52. data/app/controllers/vyapari/store_manager/stock_entries_controller.rb +0 -161
  53. data/app/controllers/vyapari/terminal_staff/base_controller.rb +0 -38
  54. data/app/controllers/vyapari/terminal_staff/dashboard_controller.rb +0 -35
  55. data/app/controllers/vyapari/terminal_staff/invoices_controller.rb +0 -147
  56. data/app/controllers/vyapari/terminal_staff/line_items_controller.rb +0 -139
  57. data/app/controllers/vyapari/terminal_staff/resource_controller.rb +0 -17
  58. data/app/controllers/vyapari/user_dashboard_controller.rb +0 -31
  59. data/app/models/bank_account.rb +0 -44
  60. data/app/models/contact.rb +0 -72
  61. data/app/models/image/brand_image.rb +0 -3
  62. data/app/models/image/category_image.rb +0 -3
  63. data/app/models/image/product_image.rb +0 -3
  64. data/app/models/invoice.rb +0 -256
  65. data/app/models/line_item.rb +0 -207
  66. data/app/models/stock_bundle.rb +0 -249
  67. data/app/models/stock_entry.rb +0 -275
  68. data/app/models/store.rb +0 -302
  69. data/app/models/supplier.rb +0 -79
  70. data/app/models/terminal.rb +0 -158
  71. data/app/uploaders/brand_image_uploader.rb +0 -14
  72. data/app/uploaders/category_image_uploader.rb +0 -14
  73. data/app/uploaders/product_image_uploader.rb +0 -14
  74. data/app/uploaders/stock_bundle_uploader.rb +0 -10
  75. data/app/views/layouts/vyapari/_store_manager_menu.html.erb +0 -126
  76. data/app/views/layouts/vyapari/_terminal_staff_menu.html.erb +0 -106
  77. data/app/views/layouts/vyapari/store_manager.html.erb +0 -112
  78. data/app/views/layouts/vyapari/terminal_staff.html.erb +0 -116
  79. data/app/views/vyapari/admin/brands/_form.html.erb +0 -23
  80. data/app/views/vyapari/admin/brands/_index.html.erb +0 -89
  81. data/app/views/vyapari/admin/brands/_row.html.erb +0 -63
  82. data/app/views/vyapari/admin/brands/_show.html.erb +0 -104
  83. data/app/views/vyapari/admin/brands/index.html.erb +0 -48
  84. data/app/views/vyapari/admin/categories/_form.html.erb +0 -28
  85. data/app/views/vyapari/admin/categories/_index.html.erb +0 -101
  86. data/app/views/vyapari/admin/categories/_row.html.erb +0 -69
  87. data/app/views/vyapari/admin/categories/_show.html.erb +0 -115
  88. data/app/views/vyapari/admin/products/_form.html.erb +0 -32
  89. data/app/views/vyapari/admin/products/_index.html.erb +0 -58
  90. data/app/views/vyapari/admin/products/_row.html.erb +0 -30
  91. data/app/views/vyapari/admin/products/_show.html.erb +0 -81
  92. data/app/views/vyapari/admin/products/index.html.erb +0 -48
  93. data/app/views/vyapari/admin/stores/_form.html.erb +0 -37
  94. data/app/views/vyapari/admin/stores/_index.html.erb +0 -84
  95. data/app/views/vyapari/admin/stores/_row.html.erb +0 -55
  96. data/app/views/vyapari/admin/stores/_show.html.erb +0 -110
  97. data/app/views/vyapari/admin/stores/index.html.erb +0 -48
  98. data/app/views/vyapari/admin/suppliers/_form.html.erb +0 -32
  99. data/app/views/vyapari/admin/suppliers/_index.html.erb +0 -58
  100. data/app/views/vyapari/admin/suppliers/_row.html.erb +0 -30
  101. data/app/views/vyapari/admin/suppliers/_show.html.erb +0 -81
  102. data/app/views/vyapari/admin/suppliers/index.html.erb +0 -48
  103. data/app/views/vyapari/admin/terminals/_form.html.erb +0 -24
  104. data/app/views/vyapari/admin/terminals/_index.html.erb +0 -75
  105. data/app/views/vyapari/admin/terminals/_row.html.erb +0 -49
  106. data/app/views/vyapari/admin/terminals/_show.html.erb +0 -74
  107. data/app/views/vyapari/store_manager/dashboard/_sales_counts.html.erb +0 -90
  108. data/app/views/vyapari/store_manager/dashboard/_stock_counts.html.erb +0 -63
  109. data/app/views/vyapari/store_manager/dashboard/_terminals.html.erb +0 -23
  110. data/app/views/vyapari/store_manager/dashboard/index.html.erb +0 -64
  111. data/app/views/vyapari/store_manager/reports/invoices/_index.html.erb +0 -65
  112. data/app/views/vyapari/store_manager/reports/invoices/index.html.erb +0 -105
  113. data/app/views/vyapari/store_manager/reports/sales/_index.html.erb +0 -64
  114. data/app/views/vyapari/store_manager/reports/sales/index.html.erb +0 -105
  115. data/app/views/vyapari/store_manager/reports/stock/_index.html.erb +0 -72
  116. data/app/views/vyapari/store_manager/reports/stock/index.html.erb +0 -32
  117. data/app/views/vyapari/store_manager/stock_bundles/_form.html.erb +0 -99
  118. data/app/views/vyapari/store_manager/stock_bundles/_index.html.erb +0 -74
  119. data/app/views/vyapari/store_manager/stock_bundles/_row.html.erb +0 -44
  120. data/app/views/vyapari/store_manager/stock_bundles/_show.html.erb +0 -110
  121. data/app/views/vyapari/store_manager/stock_bundles/create.html.erb +0 -57
  122. data/app/views/vyapari/store_manager/stock_bundles/index.html.erb +0 -36
  123. data/app/views/vyapari/store_manager/stock_bundles/update.html.erb +0 -57
  124. data/app/views/vyapari/store_manager/stock_entries/_form.html.erb +0 -50
  125. data/app/views/vyapari/store_manager/stock_entries/_index.html.erb +0 -80
  126. data/app/views/vyapari/store_manager/stock_entries/_row.html.erb +0 -33
  127. data/app/views/vyapari/store_manager/stock_entries/_show.html.erb +0 -110
  128. data/app/views/vyapari/store_manager/stock_entries/_stock_bundle.html.erb +0 -61
  129. data/app/views/vyapari/store_manager/stock_entries/index.html.erb +0 -45
  130. data/app/views/vyapari/terminal_staff/dashboard/_counts.html.erb +0 -131
  131. data/app/views/vyapari/terminal_staff/dashboard/_invoices.html.erb +0 -44
  132. data/app/views/vyapari/terminal_staff/dashboard/_search_form.html.erb +0 -6
  133. data/app/views/vyapari/terminal_staff/dashboard/_search_results.html.erb +0 -24
  134. data/app/views/vyapari/terminal_staff/dashboard/index.html.erb +0 -56
  135. data/app/views/vyapari/terminal_staff/dashboard/search.js.erb +0 -12
  136. data/app/views/vyapari/terminal_staff/invoices/_draft.html.erb +0 -62
  137. data/app/views/vyapari/terminal_staff/invoices/_form.html.erb +0 -134
  138. data/app/views/vyapari/terminal_staff/invoices/_index.html.erb +0 -70
  139. data/app/views/vyapari/terminal_staff/invoices/_row.html.erb +0 -33
  140. data/app/views/vyapari/terminal_staff/invoices/_show.html.erb +0 -204
  141. data/app/views/vyapari/terminal_staff/invoices/index.html.erb +0 -35
  142. data/app/views/vyapari/terminal_staff/invoices/new.js.erb +0 -18
  143. data/app/views/vyapari/terminal_staff/invoices/show.html.erb +0 -1
  144. data/app/views/vyapari/terminal_staff/invoices/show.js.erb +0 -13
  145. data/app/views/vyapari/terminal_staff/line_items/_form.html.erb +0 -40
  146. data/app/views/vyapari/terminal_staff/line_items/_index.html.erb +0 -96
  147. data/app/views/vyapari/terminal_staff/line_items/create.js.erb +0 -34
  148. data/app/views/vyapari/terminal_staff/line_items/destroy.js.erb +0 -25
  149. data/app/views/vyapari/user_dashboard/index.html.erb +0 -51
  150. data/db/import_data/brands.csv +0 -7
  151. data/db/import_data/categories.csv +0 -12
  152. data/db/import_data/countries.csv +0 -1
  153. data/db/import_data/dummy/brands.csv +0 -7
  154. data/db/import_data/dummy/categories.csv +0 -12
  155. data/db/import_data/dummy/countries.csv +0 -1
  156. data/db/import_data/dummy/exchange_rates.csv +0 -5
  157. data/db/import_data/dummy/products-copy.csv +0 -1
  158. data/db/import_data/dummy/products.csv +0 -1
  159. data/db/import_data/dummy/products.xlsx +0 -0
  160. data/db/import_data/dummy/regions.csv +0 -13
  161. data/db/import_data/dummy/stores.csv +0 -10
  162. data/db/import_data/dummy/suppliers.csv +0 -14
  163. data/db/import_data/dummy/terminals.csv +0 -11
  164. data/db/import_data/exchange_rates.csv +0 -5
  165. data/db/import_data/regions.csv +0 -13
  166. data/db/import_data/stores.csv +0 -3
  167. data/db/import_data/suppliers.csv +0 -14
  168. data/db/import_data/terminals.csv +0 -3
  169. data/db/migrate/20170000000203_create_contacts.rb +0 -22
  170. data/db/migrate/20170000000204_create_bank_accounts.rb +0 -21
  171. data/db/migrate/20170000000205_create_suppliers.rb +0 -18
  172. data/db/migrate/20170000000206_create_stores.rb +0 -21
  173. data/db/migrate/20170000000207_create_terminals.rb +0 -18
  174. data/db/migrate/20170000000210_create_brands.rb +0 -14
  175. data/db/migrate/20170000000211_create_categories.rb +0 -22
  176. data/db/migrate/20170000000212_create_products.rb +0 -29
  177. data/db/migrate/20170000000213_create_invoices.rb +0 -61
  178. data/db/migrate/20170000000215_create_stock_bundles.rb +0 -17
  179. data/db/migrate/20170000000216_create_stock_entries.rb +0 -20
  180. data/db/sample_reports/products.xlsx +0 -0
  181. data/lib/tasks/vyapari/all.rake +0 -73
@@ -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: 128}, allow_blank: false
5
- validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum: 16}, allow_blank: false
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 :stores
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.stores.any?
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
@@ -1,11 +1,13 @@
1
1
  class ExchangeRate < Vyapari::ApplicationRecord
2
2
 
3
3
  # Validations
4
- validates :base_currency, presence: true, length: {minimum: 2, maximum: 6}, allow_blank: false
5
- validates :counter_currency, presence: true, length: {minimum: 2, maximum: 6}, allow_blank: false
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.base_currency) LIKE LOWER('%#{query}%') OR LOWER(exchange_rates.counter_currency) LIKE LOWER('%#{query}%')")}
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.base_currency_was} to #{self.counter_currency_was}"
27
+ "#{self.currency_name_was}, #{self.country.try(:name)}"
53
28
  end
54
29
 
55
30
  def can_be_edited?
@@ -4,26 +4,25 @@ class Product < Vyapari::ApplicationRecord
4
4
  PUBLISHED = "published"
5
5
  UNPUBLISHED = "unpublished"
6
6
  REMOVED = "removed"
7
-
8
- STATUS = {"Published" => PUBLISHED, "Unpublished" => UNPUBLISHED, "Removed" => REMOVED}
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 :status, :presence=> true, :inclusion => {:in => STATUS_REVERSE.keys, :presence_of => :status, :message => "%{value} is not a valid status" }
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
- #has_one :brochure, :as => :documentable, :dependent => :destroy, :class_name => "Document::Brochure"
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("LEFT JOIN categories on categories.id = products.category_id").
38
- where("LOWER(products.ean_sku) LIKE LOWER('%#{query}%') OR\
39
- LOWER(products.reference_number) LIKE LOWER('%#{query}%') OR\
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
- def can_be_published?
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: 128}, allow_blank: false
5
- validates :code, presence: true, uniqueness: true, length: {minimum: 2, maximum: 16}, allow_blank: false
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(regions.name) LIKE LOWER('%#{query}%') OR LOWER(countries.name) LIKE LOWER('%#{query}%')")}
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
- return false
70
- else
71
- return true
72
- end
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
@@ -1,9 +1,6 @@
1
1
  module Vyapari
2
2
  class ApplicationRecord < ActiveRecord::Base
3
3
  self.abstract_class = true
4
-
5
- extend Kuppayam::Importer
6
- extend Kuppayam::Validators
7
4
  end
8
5
  end
9
6
 
@@ -5,7 +5,7 @@
5
5
  <!-- Add your copyright text here -->
6
6
  <div class="footer-text">
7
7
  &copy; 2017
8
- <strong>Company Name</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'>Admin Dashboard</span>"), vyapari.admin_dashboard_url %>
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-params"></i>
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-globe\"></i> <span class='title'>Countries</span>"), vyapari.admin_countries_url %>
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-location\"></i> <span class='title'>Manage Regions</span>"), vyapari.admin_regions_url %>
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-money\"></i> <span class='title'>Exchange Rates</span>"), vyapari.admin_exchange_rates_url %>
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-diamond\"></i> <span class='title'>Features</span>"), usman.admin_features_url %>
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="<%= nav_class("admin/users") %>">
73
- <%= link_to raw("<i class=\"linecons-lock\"></i> <span class='title'>Manage Permissions</span>"), usman.admin_permissions_url %>
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-cog"></i>
85
- <span class="title">Administration</span>
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 Brands</span>"), vyapari.admin_brands_url %>
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-database\"></i> <span class='title'>Manage Categories</span>"), vyapari.admin_categories_url %>
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-shop\"></i> <span class='title'>Manage Stores</span>"), vyapari.admin_stores_url %>
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 Suppliers</span>"), vyapari.admin_suppliers_url %>
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">Monitoring</span>
110
+ <span class="title">POS</span>
122
111
  </a>
123
112
  <ul>
124
-
125
113
  <li class="">
126
- <%= link_to raw("<i class=\"linecons-truck\"></i> <span class='title'>Manage Products</span>"), vyapari.admin_products_url %>
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