dhatu 0.3.0.pre.materialize → 0.3.1.pre.materialize
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/dhatu/application_controller.rb +0 -2
- data/app/controllers/dhatu/career_opportunities_controller.rb +145 -0
- data/app/controllers/dhatu/manufacturers_controller.rb +114 -0
- data/app/controllers/dhatu/products_controller.rb +164 -0
- data/app/controllers/dhatu/resource_controller.rb +1 -0
- data/app/models/dhatu/blog_post.rb +1 -1
- data/app/models/dhatu/booking.rb +1 -1
- data/app/models/dhatu/branch.rb +1 -1
- data/app/models/dhatu/career_opportunity.rb +92 -0
- data/app/models/dhatu/category.rb +1 -1
- data/app/models/dhatu/event.rb +1 -1
- data/app/models/dhatu/manufacturer.rb +113 -0
- data/app/models/dhatu/meta_tag.rb +1 -1
- data/app/models/dhatu/offer.rb +1 -1
- data/app/models/dhatu/page.rb +1 -1
- data/app/models/dhatu/photo_album.rb +1 -1
- data/app/models/dhatu/price.rb +1 -1
- data/app/models/dhatu/product.rb +141 -0
- data/app/models/dhatu/project.rb +1 -1
- data/app/models/dhatu/promotion.rb +1 -1
- data/app/models/dhatu/promotion_attribute.rb +1 -1
- data/app/models/dhatu/promotion_enquiry.rb +1 -1
- data/app/models/dhatu/section.rb +11 -1
- data/app/models/dhatu/service.rb +1 -1
- data/app/models/dhatu/team_member.rb +1 -1
- data/app/models/dhatu/testimonial.rb +1 -1
- data/app/views/dhatu/blog_posts/_form.html.erb +1 -1
- data/app/views/dhatu/blog_posts/_show.html.erb +1 -1
- data/app/views/dhatu/bookings/_show.html.erb +1 -1
- data/app/views/dhatu/branches/_form.html.erb +1 -1
- data/app/views/dhatu/branches/_show.html.erb +1 -1
- data/app/views/dhatu/career_opportunities/_form.html.erb +41 -0
- data/app/views/dhatu/career_opportunities/_index.html.erb +52 -0
- data/app/views/dhatu/career_opportunities/_row.html.erb +26 -0
- data/app/views/dhatu/career_opportunities/_show.html.erb +96 -0
- data/app/views/dhatu/career_opportunities/index.html.erb +52 -0
- data/app/views/dhatu/categories/_show.html.erb +1 -1
- data/app/views/dhatu/dashboard/_index.html.erb +18 -0
- data/app/views/dhatu/events/_form.html.erb +1 -1
- data/app/views/dhatu/events/_show.html.erb +1 -1
- data/app/views/dhatu/manufacturers/_form.html.erb +40 -0
- data/app/views/dhatu/manufacturers/_index.html.erb +56 -0
- data/app/views/dhatu/manufacturers/_row.html.erb +30 -0
- data/app/views/dhatu/manufacturers/_show.html.erb +69 -0
- data/app/views/dhatu/manufacturers/index.html.erb +63 -0
- data/app/views/dhatu/manufacturers/show.html.erb +12 -0
- data/app/views/dhatu/offers/_form.html.erb +1 -1
- data/app/views/dhatu/offers/_show.html.erb +1 -1
- data/app/views/dhatu/pages/_show.html.erb +1 -1
- data/app/views/dhatu/photo_albums/_show.html.erb +1 -1
- data/app/views/dhatu/prices/_show.html.erb +1 -1
- data/app/views/dhatu/products/_form.html.erb +58 -0
- data/app/views/dhatu/products/_index.html.erb +68 -0
- data/app/views/dhatu/products/_row.html.erb +40 -0
- data/app/views/dhatu/products/_show.html.erb +146 -0
- data/app/views/dhatu/products/index.html.erb +63 -0
- data/app/views/dhatu/products/show.html.erb +12 -0
- data/app/views/dhatu/projects/_form.html.erb +1 -1
- data/app/views/dhatu/projects/_show.html.erb +1 -1
- data/app/views/dhatu/promotion_attributes/_show.html.erb +1 -1
- data/app/views/dhatu/promotion_enquiries/_show.html.erb +1 -1
- data/app/views/dhatu/promotions/_form.html.erb +1 -1
- data/app/views/dhatu/promotions/_show.html.erb +1 -1
- data/app/views/dhatu/sections/_form.html.erb +1 -1
- data/app/views/dhatu/sections/_show.html.erb +1 -1
- data/app/views/dhatu/services/_form.html.erb +1 -1
- data/app/views/dhatu/services/_show.html.erb +1 -1
- data/app/views/dhatu/team_members/_form.html.erb +1 -1
- data/app/views/dhatu/team_members/_show.html.erb +1 -1
- data/app/views/dhatu/testimonials/_form.html.erb +1 -1
- data/app/views/dhatu/testimonials/_show.html.erb +1 -1
- data/app/views/layouts/kuppayam/_sidebar.html.erb +18 -0
- data/config/routes.rb +24 -0
- data/db/data/dummy/categories.csv +4 -1
- data/db/data/dummy/products.csv +3 -0
- data/db/migrate/20160803045832_create_events.rb +2 -2
- data/db/migrate/20160803045832_create_offers.rb +2 -2
- data/db/migrate/20171010055101_create_pages.rb +3 -3
- data/db/migrate/20171010055102_create_sections.rb +2 -2
- data/db/migrate/20171012073510_create_testimonials.rb +2 -2
- data/db/migrate/20171012103805_create_team_members.rb +2 -2
- data/db/migrate/20171012103806_create_blog_posts.rb +2 -2
- data/db/migrate/20171014125053_create_branches.rb +2 -2
- data/db/migrate/20171014125054_create_categories.rb +3 -3
- data/db/migrate/20171014125055_create_services.rb +3 -3
- data/db/migrate/20171104163660_create_prices.rb +2 -2
- data/db/migrate/20171104163661_create_bookings.rb +2 -2
- data/db/migrate/20171120145548_create_promotion_and_promotion_enquiries.rb +5 -5
- data/db/migrate/20180101093434_create_projects.rb +3 -3
- data/db/migrate/20180101093436_create_meta_tags.rb +3 -3
- data/db/migrate/20180101093437_create_photo_albums.rb +3 -3
- data/db/migrate/20180101093438_create_manufacturers.rb +17 -0
- data/db/migrate/20180101093439_create_products.rb +29 -0
- data/db/migrate/20180101093449_create_career_opportunities.rb +23 -0
- data/lib/dhatu/version.rb +1 -1
- metadata +29 -7
- data/app/views/dhatu/sections_old/_form.html.erb +0 -171
- data/app/views/dhatu/sections_old/_index.html.erb +0 -53
- data/app/views/dhatu/sections_old/_row.html.erb +0 -26
- data/app/views/dhatu/sections_old/_show.html.erb +0 -208
- data/app/views/dhatu/sections_old/index.html.erb +0 -52
data/app/models/dhatu/booking.rb
CHANGED
data/app/models/dhatu/branch.rb
CHANGED
@@ -0,0 +1,92 @@
|
|
1
|
+
class Dhatu::CareerOpportunity < Dhatu::ApplicationRecord
|
2
|
+
|
3
|
+
# Set Table Name
|
4
|
+
self.table_name = "dhatu_career_opportunities"
|
5
|
+
|
6
|
+
# Including the State Machine Methods
|
7
|
+
include Publishable
|
8
|
+
include Featureable
|
9
|
+
|
10
|
+
# Validations
|
11
|
+
validates :title, presence: true, length: {minimum: 5, maximum: 256}, allow_blank: false
|
12
|
+
validates :sub_title, allow_blank: true, length: {minimum: 5, maximum: 256}, allow_blank: false
|
13
|
+
validates :short_description, presence: true
|
14
|
+
validates :description, presence: true
|
15
|
+
|
16
|
+
# Associations
|
17
|
+
belongs_to :category, optional: true
|
18
|
+
has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
|
19
|
+
|
20
|
+
# Meta Tag Associations
|
21
|
+
has_one :og_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::OgImage"
|
22
|
+
has_many :meta_tags, :as => :meta_taggable, :dependent => :destroy, :class_name => "Dhatu::MetaTag"
|
23
|
+
|
24
|
+
# ------------------
|
25
|
+
# Class Methods
|
26
|
+
# ------------------
|
27
|
+
|
28
|
+
scope :search, lambda { |query| where("LOWER(title) LIKE LOWER('%#{query}%') OR\
|
29
|
+
LOWER(sub_title) LIKE LOWER('%#{query}%') OR\
|
30
|
+
LOWER(short_description) LIKE LOWER('%#{query}%') OR\
|
31
|
+
LOWER(description) LIKE LOWER('%#{query}%')")}
|
32
|
+
|
33
|
+
def self.save_row_data(hsh)
|
34
|
+
# Initializing error hash for displaying all errors altogether
|
35
|
+
error_object = Kuppayam::Importer::ErrorHash.new
|
36
|
+
|
37
|
+
return error_object if hsh[:title].to_s.strip.blank?
|
38
|
+
|
39
|
+
offer = Dhatu::CareerOpportunity.find_by_title(hsh[:title].to_s.strip) || Dhatu::CareerOpportunity.new
|
40
|
+
offer.title = hsh[:title].to_s.strip
|
41
|
+
offer.sub_title = hsh[:sub_title].to_s.strip
|
42
|
+
offer.short_description = hsh[:short_description].to_s.strip
|
43
|
+
offer.description = hsh[:description].to_s.strip
|
44
|
+
|
45
|
+
offer.category = Dhatu::Category.find_by_name(hsh[:category].to_s.strip)
|
46
|
+
|
47
|
+
offer.status = hsh[:status].to_s.strip || PUBLISHED
|
48
|
+
offer.featured = hsh[:featured].to_s.strip == "true"
|
49
|
+
offer.priority = hsh[:priority].to_s.strip || 1
|
50
|
+
|
51
|
+
if offer.valid?
|
52
|
+
begin
|
53
|
+
offer.save!
|
54
|
+
rescue Exception => e
|
55
|
+
summary = "uncaught #{e} exception while handling connection: #{e.message}"
|
56
|
+
details = "Stack trace: #{e.backtrace.map {|l| " #{l}\n"}.join}"
|
57
|
+
error_object.errors << { summary: summary, details: details }
|
58
|
+
end
|
59
|
+
else
|
60
|
+
summary = "Error while saving offer: #{offer.title}"
|
61
|
+
details = "Error! #{offer.errors.full_messages.to_sentence}"
|
62
|
+
error_object.errors << { summary: summary, details: details }
|
63
|
+
end
|
64
|
+
return error_object
|
65
|
+
end
|
66
|
+
|
67
|
+
# ------------------
|
68
|
+
# Instance Methods
|
69
|
+
# ------------------
|
70
|
+
|
71
|
+
# Generic Methods
|
72
|
+
# ---------------
|
73
|
+
def to_param
|
74
|
+
"#{id}-#{title.parameterize[0..32]}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def display_name
|
78
|
+
"#{title_was}"
|
79
|
+
end
|
80
|
+
|
81
|
+
# Permission Methods
|
82
|
+
# ------------------
|
83
|
+
|
84
|
+
def can_be_edited?
|
85
|
+
status?(:published) or status?(:unpublished)
|
86
|
+
end
|
87
|
+
|
88
|
+
def can_be_deleted?
|
89
|
+
status?(:removed)
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
data/app/models/dhatu/event.rb
CHANGED
@@ -0,0 +1,113 @@
|
|
1
|
+
class Dhatu::Manufacturer < ApplicationRecord
|
2
|
+
|
3
|
+
# Set Table Name
|
4
|
+
self.table_name = "dhatu_manufacturers"
|
5
|
+
|
6
|
+
# Validations
|
7
|
+
validates :name, presence: true, length: {minimum: 2, maximum: 128}
|
8
|
+
|
9
|
+
# Associations
|
10
|
+
has_one :logo, :as => :imageable, :dependent => :destroy, :class_name => "Image::LogoImage"
|
11
|
+
|
12
|
+
# Including the State Machine Methods
|
13
|
+
include Publishable
|
14
|
+
|
15
|
+
# ------------------
|
16
|
+
# Class Methods
|
17
|
+
# ------------------
|
18
|
+
|
19
|
+
scope :search, lambda {|query| where("LOWER(dhatu_manufacturers.name) LIKE LOWER('%#{query}%') OR\
|
20
|
+
LOWER(dhatu_manufacturers.description) LIKE LOWER('%#{query}%')")}
|
21
|
+
|
22
|
+
def self.save_row_data(hsh)
|
23
|
+
# Initializing error hash for displaying all errors altogether
|
24
|
+
error_object = Kuppayam::Importer::ErrorHash.new
|
25
|
+
|
26
|
+
return error_object if hsh[:name].to_s.strip.blank?
|
27
|
+
|
28
|
+
manufacturer = Manufacturer.find_by_name(hsh[:name].to_s.strip) || Manufacturer.new
|
29
|
+
|
30
|
+
manufacturer.name = hsh[:name].to_s.strip
|
31
|
+
manufacturer.description = hsh[:description].to_s.strip
|
32
|
+
manufacturer.remarks = hsh[:remarks].to_s.strip
|
33
|
+
manufacturer.website = hsh[:website].to_s.strip
|
34
|
+
manufacturer.status = hsh[:status].to_s.strip == "" ? PUBLISHED : hsh[:status].to_s.strip
|
35
|
+
|
36
|
+
manufacturer.featured = ["true", "t","1","yes","y"].include?(hsh[:featured].to_s.downcase.strip)
|
37
|
+
manufacturer.priority = hsh[:priority].to_s.strip || 1
|
38
|
+
|
39
|
+
## Adding logo image
|
40
|
+
begin
|
41
|
+
image_path = Rails.root.join('db', 'data', 'images', 'manufacturers', "#{hsh[:logo].to_s.strip}")
|
42
|
+
if File.exists?(image_path)
|
43
|
+
manufacturer.build_logo
|
44
|
+
manufacturer.logo.image = File.open(image_path)
|
45
|
+
else
|
46
|
+
puts "Warning! Logo not found for #{manufacturer.name}. #{image_path} doesn't exists"
|
47
|
+
end
|
48
|
+
rescue => e
|
49
|
+
puts "Error during processing: #{$!}"
|
50
|
+
puts "Partner Organisation: #{manufacturer.name}, Image Path: #{image_path}".red
|
51
|
+
#puts "Backtrace:\n\t#{e.backtrace.join("\n\t")}"
|
52
|
+
end if hsh[:logo] && manufacturer.logo.blank?
|
53
|
+
|
54
|
+
if manufacturer.valid?
|
55
|
+
begin
|
56
|
+
manufacturer.save!
|
57
|
+
rescue Exception => e
|
58
|
+
summary = "uncaught #{e} exception while handling connection: #{e.message}"
|
59
|
+
details = "Stack trace: #{e.backtrace.map {|l| " #{l}\n"}.join}"
|
60
|
+
error_object.errors << { summary: summary, details: details }
|
61
|
+
end
|
62
|
+
else
|
63
|
+
summary = "Error while saving manufacturers: #{manufacturer.name}"
|
64
|
+
details = "Error! #{manufacturer.errors.full_messages.to_sentence}"
|
65
|
+
error_object.errors << { summary: summary, details: details }
|
66
|
+
end
|
67
|
+
return error_object
|
68
|
+
end
|
69
|
+
|
70
|
+
# Other Methods
|
71
|
+
# -------------
|
72
|
+
|
73
|
+
# * Return full name
|
74
|
+
# == Examples
|
75
|
+
# >>> partner_organisatioin.display_name
|
76
|
+
# => "Juma Al Majid"
|
77
|
+
def display_name
|
78
|
+
"#{name}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def default_image_url(size="large")
|
82
|
+
"kuppayam/defaults/logo-#{size}.png"
|
83
|
+
end
|
84
|
+
|
85
|
+
# Image Configuration
|
86
|
+
# -------------------
|
87
|
+
def image_configuration
|
88
|
+
{
|
89
|
+
"Image::LogoImage" => {
|
90
|
+
max_upload_limit: 10485760,
|
91
|
+
min_upload_limit: 1024,
|
92
|
+
resolutions: [400, 400],
|
93
|
+
form_upload_image_label: "Upload a new Logo",
|
94
|
+
form_title: "Upload an Logo",
|
95
|
+
form_sub_title: "Please read the instructions below:",
|
96
|
+
form_instructions: [
|
97
|
+
"the filename should be in .jpg / .jpeg or .png format",
|
98
|
+
"the image resolutions should be <strong>400 x 400 Pixels</strong>",
|
99
|
+
"the file size should be greater than 100 Kb and or lesser than <strong>10 MB</strong>"
|
100
|
+
]
|
101
|
+
}
|
102
|
+
}
|
103
|
+
end
|
104
|
+
|
105
|
+
def can_be_edited?
|
106
|
+
status?(:published) or status?(:unpublished)
|
107
|
+
end
|
108
|
+
|
109
|
+
def can_be_deleted?
|
110
|
+
status?(:removed)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -4,7 +4,7 @@ class Dhatu::MetaTag < Dhatu::ApplicationRecord
|
|
4
4
|
META_TYPES = ["Default", "Open Graph", "Twitter", "Facebook", "Other"]
|
5
5
|
|
6
6
|
# Set Table Name
|
7
|
-
self.table_name = "
|
7
|
+
self.table_name = "dhatu_meta_tags"
|
8
8
|
|
9
9
|
# Including the State Machine Methods
|
10
10
|
include Publishable
|
data/app/models/dhatu/offer.rb
CHANGED
data/app/models/dhatu/page.rb
CHANGED
data/app/models/dhatu/price.rb
CHANGED
@@ -0,0 +1,141 @@
|
|
1
|
+
class Dhatu::Product < Dhatu::ApplicationRecord
|
2
|
+
|
3
|
+
# Set Table Name
|
4
|
+
self.table_name = "dhatu_products"
|
5
|
+
|
6
|
+
# Including the State Machine Methods
|
7
|
+
include Publishable
|
8
|
+
include Featureable
|
9
|
+
|
10
|
+
# Callbacks
|
11
|
+
before_validation :update_top_category
|
12
|
+
|
13
|
+
# Validations
|
14
|
+
validates :title, presence: true, length: {minimum: 3, maximum: 250}
|
15
|
+
validates :sub_title, allow_blank: true, length: {minimum: 3, maximum: 250}
|
16
|
+
validate_string :short_description, mandatory: false, format: /.*/i
|
17
|
+
validates :ean_sku, allow_blank: true, length: {minimum: 3, maximum: 250}
|
18
|
+
validates :priority, numericality: true
|
19
|
+
|
20
|
+
# Associations
|
21
|
+
has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
|
22
|
+
has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
|
23
|
+
has_one :brochure, :as => :documentable, :dependent => :destroy, :class_name => "Document::Brochure"
|
24
|
+
|
25
|
+
belongs_to :manufacturer, :class_name => "Dhatu::Manufacturer"
|
26
|
+
belongs_to :category, :class_name => "Dhatu::Category", optional: true
|
27
|
+
belongs_to :top_category, class_name: "Dhatu::Category", optional: true
|
28
|
+
|
29
|
+
# Meta Tag Associations
|
30
|
+
has_one :og_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::OgImage"
|
31
|
+
has_many :meta_tags, :as => :meta_taggable, :dependent => :destroy, :class_name => "Dhatu::MetaTag"
|
32
|
+
|
33
|
+
# ------------------
|
34
|
+
# Class Methods
|
35
|
+
# ------------------
|
36
|
+
|
37
|
+
scope :search, lambda {|query| joins(:manufacturer).where("LOWER(dhatu_products.title) LIKE LOWER('%#{query}%') OR\
|
38
|
+
LOWER(dhatu_products.sub_title) LIKE LOWER('%#{query}%') OR\
|
39
|
+
LOWER(dhatu_products.ean_sku) LIKE LOWER('%#{query}%') OR\
|
40
|
+
LOWER(dhatu_products.reference_number) LIKE LOWER('%#{query}%') OR\
|
41
|
+
LOWER(dhatu_manufacturers.name) LIKE LOWER('%#{query}%') OR\
|
42
|
+
LOWER(dhatu_manufacturers.description) LIKE LOWER('%#{query}%') OR\
|
43
|
+
LOWER(dhatu_products.short_description) LIKE LOWER('%#{query}%') OR\
|
44
|
+
LOWER(dhatu_products.description) LIKE LOWER('%#{query}%')")
|
45
|
+
}
|
46
|
+
|
47
|
+
scope :filter_by_category, lambda { |c| where("category_id = ?", (c.is_a? Dhatu::Category ? c.id : c)) }
|
48
|
+
|
49
|
+
scope :upcoming, lambda { where("created_at >= ?", Time.now) }
|
50
|
+
scope :past, lambda { where("created_at < ?", Time.now) }
|
51
|
+
|
52
|
+
def self.save_row_data(hsh)
|
53
|
+
# Initializing error hash for displaying all errors altogether
|
54
|
+
error_object = Kuppayam::Importer::ErrorHash.new
|
55
|
+
|
56
|
+
return error_object if hsh[:title].to_s.strip.blank?
|
57
|
+
|
58
|
+
product = Dhatu::Product.find_by_title(hsh[:title].to_s.strip) || Dhatu::Product.new
|
59
|
+
product.title = hsh[:title].to_s.strip
|
60
|
+
product.sub_title = hsh[:sub_title].to_s.strip
|
61
|
+
|
62
|
+
product.ean_sku = row[:ean_sku].to_s
|
63
|
+
product.reference_number = row[:reference_number]
|
64
|
+
|
65
|
+
product.manufacturer = Dhatu::Manufacturer.find_by_name(row[:manufacturer])
|
66
|
+
product.category = Dhatu::Category.find_by_name(row[:category])
|
67
|
+
product.top_category = product.category.top_category if product.category
|
68
|
+
|
69
|
+
product.short_description = hsh[:short_description].to_s.strip
|
70
|
+
product.description = hsh[:description].to_s.strip
|
71
|
+
|
72
|
+
product.price = hsh[:price].to_s.strip
|
73
|
+
|
74
|
+
product.status = hsh[:status].to_s.strip.blank? ? PUBLISHED : hsh[:status].to_s.strip
|
75
|
+
product.featured = ["true", "t","1","yes","y"].include?(hsh[:featured].to_s.downcase.strip)
|
76
|
+
product.priority = hsh[:priority].to_s.strip || 1
|
77
|
+
|
78
|
+
if product.valid?
|
79
|
+
begin
|
80
|
+
product.save!
|
81
|
+
rescue Exception => e
|
82
|
+
summary = "uncaught #{e} exception while handling connection: #{e.message}"
|
83
|
+
details = "Stack trace: #{e.backtrace.map {|l| " #{l}\n"}.join}"
|
84
|
+
error_object.errors << { summary: summary, details: details }
|
85
|
+
end
|
86
|
+
else
|
87
|
+
summary = "Error while saving product: #{product.title}"
|
88
|
+
details = "Error! #{product.errors.full_messages.to_sentence}"
|
89
|
+
error_object.errors << { summary: summary, details: details }
|
90
|
+
end
|
91
|
+
return error_object
|
92
|
+
end
|
93
|
+
|
94
|
+
# ------------------
|
95
|
+
# Instance Methods
|
96
|
+
# ------------------
|
97
|
+
|
98
|
+
# Generic Methods
|
99
|
+
# ---------------
|
100
|
+
|
101
|
+
def code
|
102
|
+
self.ean_sku
|
103
|
+
end
|
104
|
+
|
105
|
+
def display_name
|
106
|
+
"#{self.ean_sku_was} : #{self.title_was}"
|
107
|
+
end
|
108
|
+
|
109
|
+
def slug
|
110
|
+
self.title.parameterize[0..32]
|
111
|
+
end
|
112
|
+
|
113
|
+
def to_param
|
114
|
+
"#{id}-#{slug}"
|
115
|
+
end
|
116
|
+
|
117
|
+
# Permission Methods
|
118
|
+
# ------------------
|
119
|
+
|
120
|
+
def can_be_edited?
|
121
|
+
status?(:published) or status?(:unpublished)
|
122
|
+
end
|
123
|
+
|
124
|
+
def can_be_deleted?
|
125
|
+
return false if published? or unpublished?
|
126
|
+
return true
|
127
|
+
end
|
128
|
+
|
129
|
+
protected
|
130
|
+
|
131
|
+
def update_top_category
|
132
|
+
if self.category
|
133
|
+
if self.category.parent
|
134
|
+
self.top_category = self.category.parent
|
135
|
+
else
|
136
|
+
self.top_category = self.category
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|