dhatu 0.1.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +114 -0
- data/Rakefile +36 -0
- data/app/assets/config/dhatu_manifest.js +2 -0
- data/app/assets/javascripts/dhatu/application.js +13 -0
- data/app/assets/stylesheets/dhatu/application.css +15 -0
- data/app/controllers/dhatu/application_controller.rb +25 -0
- data/app/controllers/dhatu/blog_posts_controller.rb +84 -0
- data/app/controllers/dhatu/contact_informations_controller.rb +84 -0
- data/app/controllers/dhatu/dashboard_controller.rb +24 -0
- data/app/controllers/dhatu/events_controller.rb +84 -0
- data/app/controllers/dhatu/offers_controller.rb +84 -0
- data/app/controllers/dhatu/resource_controller.rb +13 -0
- data/app/controllers/dhatu/sections_controller.rb +83 -0
- data/app/controllers/dhatu/team_members_controller.rb +84 -0
- data/app/controllers/dhatu/testimonials_controller.rb +84 -0
- data/app/helpers/dhatu/application_helper.rb +4 -0
- data/app/jobs/dhatu/application_job.rb +4 -0
- data/app/mailers/dhatu/application_mailer.rb +6 -0
- data/app/models/dhatu/application_record.rb +8 -0
- data/app/models/dhatu/blog_post.rb +62 -0
- data/app/models/dhatu/contact_information.rb +88 -0
- data/app/models/dhatu/event.rb +56 -0
- data/app/models/dhatu/offer.rb +55 -0
- data/app/models/dhatu/section.rb +82 -0
- data/app/models/dhatu/team_member.rb +59 -0
- data/app/models/dhatu/testimonial.rb +57 -0
- data/app/views/dhatu/blog_posts/_form.html.erb +42 -0
- data/app/views/dhatu/blog_posts/_index.html.erb +58 -0
- data/app/views/dhatu/blog_posts/_row.html.erb +28 -0
- data/app/views/dhatu/blog_posts/_show.html.erb +120 -0
- data/app/views/dhatu/blog_posts/index.html.erb +56 -0
- data/app/views/dhatu/contact_informations/_form.html.erb +104 -0
- data/app/views/dhatu/contact_informations/_index.html.erb +51 -0
- data/app/views/dhatu/contact_informations/_row.html.erb +26 -0
- data/app/views/dhatu/contact_informations/_show.html.erb +150 -0
- data/app/views/dhatu/contact_informations/index.html.erb +46 -0
- data/app/views/dhatu/dashboard/_index.html.erb +58 -0
- data/app/views/dhatu/dashboard/index.html.erb +18 -0
- data/app/views/dhatu/events/_form.html.erb +40 -0
- data/app/views/dhatu/events/_index.html.erb +58 -0
- data/app/views/dhatu/events/_row.html.erb +28 -0
- data/app/views/dhatu/events/_show.html.erb +120 -0
- data/app/views/dhatu/events/index.html.erb +45 -0
- data/app/views/dhatu/offers/_form.html.erb +39 -0
- data/app/views/dhatu/offers/_index.html.erb +57 -0
- data/app/views/dhatu/offers/_row.html.erb +28 -0
- data/app/views/dhatu/offers/_show.html.erb +118 -0
- data/app/views/dhatu/offers/index.html.erb +46 -0
- data/app/views/dhatu/sections/_form.html.erb +60 -0
- data/app/views/dhatu/sections/_index.html.erb +53 -0
- data/app/views/dhatu/sections/_row.html.erb +25 -0
- data/app/views/dhatu/sections/_show.html.erb +152 -0
- data/app/views/dhatu/sections/index.html.erb +53 -0
- data/app/views/dhatu/team_members/_form.html.erb +56 -0
- data/app/views/dhatu/team_members/_index.html.erb +62 -0
- data/app/views/dhatu/team_members/_row.html.erb +35 -0
- data/app/views/dhatu/team_members/_show.html.erb +93 -0
- data/app/views/dhatu/team_members/index.html.erb +46 -0
- data/app/views/dhatu/testimonials/_form.html.erb +36 -0
- data/app/views/dhatu/testimonials/_index.html.erb +64 -0
- data/app/views/dhatu/testimonials/_row.html.erb +36 -0
- data/app/views/dhatu/testimonials/_show.html.erb +133 -0
- data/app/views/dhatu/testimonials/index.html.erb +46 -0
- data/app/views/layouts/dhatu/application.html.erb +14 -0
- data/app/views/layouts/kuppayam/_footer.html.erb +25 -0
- data/app/views/layouts/kuppayam/_header.html.erb +43 -0
- data/app/views/layouts/kuppayam/_navbar.html.erb +55 -0
- data/app/views/layouts/kuppayam/_sidebar.html.erb +219 -0
- data/app/views/pattana/dashboard/_index.html.erb +35 -0
- data/config/routes.rb +63 -0
- data/db/master_data/features.csv +16 -0
- data/lib/dhatu.rb +5 -0
- data/lib/dhatu/engine.rb +31 -0
- data/lib/dhatu/factories.rb +7 -0
- data/lib/dhatu/version.rb +3 -0
- data/lib/tasks/dhatu/data.rake +91 -0
- data/lib/tasks/dhatu/master_data.rake +48 -0
- data/spec/dummy/spec/factories/blog_post.rb +48 -0
- data/spec/dummy/spec/factories/blog_post_cover_image.rb +13 -0
- data/spec/dummy/spec/factories/blog_post_gallery_image.rb +13 -0
- data/spec/dummy/spec/factories/contact_information.rb +63 -0
- data/spec/dummy/spec/factories/event.rb +46 -0
- data/spec/dummy/spec/factories/event_cover_image.rb +13 -0
- data/spec/dummy/spec/factories/event_gallery_image.rb +13 -0
- data/spec/dummy/spec/factories/offer.rb +43 -0
- data/spec/dummy/spec/factories/offer_cover_image.rb +13 -0
- data/spec/dummy/spec/factories/offer_gallery_image.rb +13 -0
- data/spec/dummy/spec/factories/section.rb +50 -0
- data/spec/dummy/spec/factories/section_cover_image.rb +13 -0
- data/spec/dummy/spec/factories/section_gallery_image.rb +13 -0
- data/spec/dummy/spec/factories/team_member.rb +47 -0
- data/spec/dummy/spec/factories/test.jpg +0 -0
- data/spec/dummy/spec/factories/testimonial.rb +44 -0
- metadata +520 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
class Dhatu::ContactInformation < Dhatu::ApplicationRecord
|
|
2
|
+
|
|
3
|
+
# Set Table Name
|
|
4
|
+
self.table_name = "contact_informations"
|
|
5
|
+
|
|
6
|
+
# Including the State Machine Methods
|
|
7
|
+
include Publishable
|
|
8
|
+
include Featureable
|
|
9
|
+
|
|
10
|
+
# Validations
|
|
11
|
+
validates :title, presence: true, length: {maximum: 250}
|
|
12
|
+
|
|
13
|
+
validates :address_1, length: {maximum: 250}, allow_blank: true
|
|
14
|
+
validates :address_2, length: {maximum: 250}, allow_blank: true
|
|
15
|
+
validates :address_3, length: {maximum: 250}, allow_blank: true
|
|
16
|
+
|
|
17
|
+
# validate_email :email, presence: false, allow_blank: false
|
|
18
|
+
validates :landline, length: {maximum: 250}, allow_blank: true
|
|
19
|
+
validates :fax, length: {maximum: 250}, allow_blank: true
|
|
20
|
+
validates :mobile, length: {maximum: 250}, allow_blank: true
|
|
21
|
+
|
|
22
|
+
validates :facebook, format: { with: URI.regexp }, if: Proc.new { |ci| ci.facebook.present? }
|
|
23
|
+
validates :twitter, format: { with: URI.regexp }, if: Proc.new { |ci| ci.twitter.present? }
|
|
24
|
+
validates :google_plus, format: { with: URI.regexp }, if: Proc.new { |ci| ci.google_plus.present? }
|
|
25
|
+
validates :linked_in, format: { with: URI.regexp }, if: Proc.new { |ci| ci.linked_in.present? }
|
|
26
|
+
validates :youtube, format: { with: URI.regexp }, if: Proc.new { |ci| ci.youtube.present? }
|
|
27
|
+
validates :instagram, format: { with: URI.regexp }, if: Proc.new { |ci| ci.instagram.present? }
|
|
28
|
+
validates :tumblr, format: { with: URI.regexp }, if: Proc.new { |ci| ci.tumblr.present? }
|
|
29
|
+
validates :pinterest, format: { with: URI.regexp }, if: Proc.new { |ci| ci.pinterest.present? }
|
|
30
|
+
validates :blog, format: { with: URI.regexp }, if: Proc.new { |ci| ci.blog.present? }
|
|
31
|
+
|
|
32
|
+
# ------------------
|
|
33
|
+
# Class Methods
|
|
34
|
+
# ------------------
|
|
35
|
+
|
|
36
|
+
scope :search, lambda {|query| where("
|
|
37
|
+
LOWER(title) LIKE LOWER('%#{query}%') OR\
|
|
38
|
+
LOWER(address_1) LIKE LOWER('%#{query}%') OR\
|
|
39
|
+
LOWER(address_2) LIKE LOWER('%#{query}%') OR\
|
|
40
|
+
LOWER(address_3) LIKE LOWER('%#{query}%') OR\
|
|
41
|
+
LOWER(email) LIKE LOWER('%#{query}%') OR\
|
|
42
|
+
LOWER(landline) LIKE LOWER('%#{query}%') OR\
|
|
43
|
+
LOWER(fax) LIKE LOWER('%#{query}%') OR\
|
|
44
|
+
LOWER(mobile) LIKE LOWER('%#{query}%') OR\
|
|
45
|
+
LOWER(facebook) LIKE LOWER('%#{query}%') OR\
|
|
46
|
+
LOWER(twitter) LIKE LOWER('%#{query}%') OR\
|
|
47
|
+
LOWER(google_plus) LIKE LOWER('%#{query}%') OR\
|
|
48
|
+
LOWER(linked_in) LIKE LOWER('%#{query}%') OR\
|
|
49
|
+
LOWER(youtube) LIKE LOWER('%#{query}%') OR\
|
|
50
|
+
LOWER(instagram) LIKE LOWER('%#{query}%') OR\
|
|
51
|
+
LOWER(tumblr) LIKE LOWER('%#{query}%') OR\
|
|
52
|
+
LOWER(pinterest) LIKE LOWER('%#{query}%') OR\
|
|
53
|
+
LOWER(blog) LIKE LOWER('%#{query}%')")
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
scope :upcoming, lambda { where("created_at >= ?", Time.now) }
|
|
57
|
+
scope :past, lambda { where("created_at < ?", Time.now) }
|
|
58
|
+
|
|
59
|
+
# ------------------
|
|
60
|
+
# Instance variables
|
|
61
|
+
# ------------------
|
|
62
|
+
|
|
63
|
+
# Generic Methods
|
|
64
|
+
# ---------------
|
|
65
|
+
def to_param
|
|
66
|
+
"#{id}-#{title.parameterize[0..32]}"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def display_name
|
|
70
|
+
"#{title_was}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def display_address
|
|
74
|
+
[self.address_1, self.address_2, self.address_3].compact.uniq.join(", ")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Permission Methods
|
|
78
|
+
# ------------------
|
|
79
|
+
|
|
80
|
+
def can_be_edited?
|
|
81
|
+
status?(:published) or status?(:unpublished)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def can_be_deleted?
|
|
85
|
+
status?(:removed)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
class Dhatu::Event < Dhatu::ApplicationRecord
|
|
2
|
+
|
|
3
|
+
# Set Table Name
|
|
4
|
+
self.table_name = "events"
|
|
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: 500}, allow_blank: false
|
|
12
|
+
validates :venue, length: {minimum: 3, maximum: 250}, allow_blank: true
|
|
13
|
+
validates :description, presence: true
|
|
14
|
+
|
|
15
|
+
# Associations
|
|
16
|
+
has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
|
|
17
|
+
has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
|
|
18
|
+
|
|
19
|
+
# ------------------
|
|
20
|
+
# Class Methods
|
|
21
|
+
# ------------------
|
|
22
|
+
|
|
23
|
+
scope :search, lambda { |query| where("LOWER(title) LIKE LOWER('%#{query}%') OR\
|
|
24
|
+
LOWER(venue) LIKE LOWER('%#{query}%') OR\
|
|
25
|
+
LOWER(description) LIKE LOWER('%#{query}%')") }
|
|
26
|
+
|
|
27
|
+
scope :upcoming, lambda { where("starts_at >= ?", Time.now) }
|
|
28
|
+
scope :past, lambda { where("starts_at < ?", Time.now) }
|
|
29
|
+
|
|
30
|
+
# ------------------
|
|
31
|
+
# Instance Methods
|
|
32
|
+
# ------------------
|
|
33
|
+
|
|
34
|
+
# Generic Methods
|
|
35
|
+
# ---------------
|
|
36
|
+
|
|
37
|
+
def to_param
|
|
38
|
+
"#{id}-#{title.parameterize[0..32]}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def display_name
|
|
42
|
+
"#{title_was}"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Permission Methods
|
|
46
|
+
# ------------------
|
|
47
|
+
|
|
48
|
+
def can_be_edited?
|
|
49
|
+
status?(:published) or status?(:unpublished)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def can_be_deleted?
|
|
53
|
+
status?(:removed)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
class Dhatu::Offer < Dhatu::ApplicationRecord
|
|
2
|
+
|
|
3
|
+
# Set Table Name
|
|
4
|
+
self.table_name = "offers"
|
|
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 :offer_text, presence: true, length: {minimum: 3, maximum: 64}
|
|
13
|
+
validates :description, presence: true
|
|
14
|
+
|
|
15
|
+
# Associations
|
|
16
|
+
has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
|
|
17
|
+
has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
|
|
18
|
+
|
|
19
|
+
# ------------------
|
|
20
|
+
# Class Methods
|
|
21
|
+
# ------------------
|
|
22
|
+
|
|
23
|
+
scope :search, lambda { |query| where("LOWER(title) LIKE LOWER('%#{query}%') OR\
|
|
24
|
+
LOWER(offer_text) LIKE LOWER('%#{query}%') OR\
|
|
25
|
+
LOWER(description) LIKE LOWER('%#{query}%')")}
|
|
26
|
+
|
|
27
|
+
scope :upcoming, lambda { where("starts_at >= ?", Time.now) }
|
|
28
|
+
scope :past, lambda { where("starts_at < ?", Time.now) }
|
|
29
|
+
|
|
30
|
+
# ------------------
|
|
31
|
+
# Instance variables
|
|
32
|
+
# ------------------
|
|
33
|
+
|
|
34
|
+
# Generic Methods
|
|
35
|
+
# ---------------
|
|
36
|
+
def to_param
|
|
37
|
+
"#{id}-#{title.parameterize[0..32]}"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def display_name
|
|
41
|
+
"#{title_was}"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Permission Methods
|
|
45
|
+
# ------------------
|
|
46
|
+
|
|
47
|
+
def can_be_edited?
|
|
48
|
+
status?(:published) or status?(:unpublished)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def can_be_deleted?
|
|
52
|
+
status?(:removed)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
class Dhatu::Section < Dhatu::ApplicationRecord
|
|
2
|
+
|
|
3
|
+
# Set Table Name
|
|
4
|
+
self.table_name = "sections"
|
|
5
|
+
|
|
6
|
+
# Including the State Machine Methods
|
|
7
|
+
include Publishable
|
|
8
|
+
|
|
9
|
+
# Constants
|
|
10
|
+
COVER_IMAGE_INSTRUCTIONS = [
|
|
11
|
+
"the file extension should be .jpg / .jpeg or .png format",
|
|
12
|
+
"the image should be in resolution 750 pixels by 368 pixels, (Portrait Format). (most cameras and camera phones will produce images bigger than this)",
|
|
13
|
+
"the file size should not be less than 20 Kb, or bigger than <strong>1 MB</strong>"
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
# Constants
|
|
17
|
+
GALLERY_IMAGE_INSTRUCTIONS = [
|
|
18
|
+
"the file extension should be .jpg / .jpeg or .png format",
|
|
19
|
+
"the image should be in resolution 750 pixels by 368 pixels, (Portrait Format). (most cameras and camera phones will produce images bigger than this)",
|
|
20
|
+
"the file size should not be less than 20 Kb, or bigger than <strong>1 MB</strong>"
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
# Validations
|
|
24
|
+
validates :title, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: false
|
|
25
|
+
validates :sub_title, length: {minimum: 3, maximum: 256}, allow_blank: true
|
|
26
|
+
validates :short_description, length: {minimum: 10, maximum: 1048}, allow_blank: true
|
|
27
|
+
validates :long_description, length: {minimum: 10}, allow_blank: true
|
|
28
|
+
validates :button_one_text, length: {maximum: 64}, allow_blank: true
|
|
29
|
+
validates :button_two_text, length: {maximum: 64}, allow_blank: true
|
|
30
|
+
validates :button_one_link, length: {maximum: 512}, allow_blank: true
|
|
31
|
+
validates :button_two_link, length: {maximum: 512}, allow_blank: true
|
|
32
|
+
|
|
33
|
+
# Associations
|
|
34
|
+
has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
|
|
35
|
+
has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
|
|
36
|
+
|
|
37
|
+
# ------------------
|
|
38
|
+
# Class Methods
|
|
39
|
+
# ------------------
|
|
40
|
+
|
|
41
|
+
scope :search, lambda {|query| where("LOWER(title) LIKE LOWER('%#{query}%') OR\
|
|
42
|
+
LOWER(sub_title) LIKE LOWER('%#{query}%') OR\
|
|
43
|
+
LOWER(short_description) LIKE LOWER('%#{query}%') OR\
|
|
44
|
+
LOWER(button_one_text) LIKE LOWER('%#{query}%') OR\
|
|
45
|
+
LOWER(button_two_text) LIKE LOWER('%#{query}%') OR\
|
|
46
|
+
LOWER(button_one_link) LIKE LOWER('%#{query}%') OR\
|
|
47
|
+
LOWER(button_two_link) LIKE LOWER('%#{query}%')")
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
scope :upcoming, lambda { where("created_at >= ?", Time.now) }
|
|
51
|
+
scope :past, lambda { where("created_at < ?", Time.now) }
|
|
52
|
+
|
|
53
|
+
def find_by_section_type(st)
|
|
54
|
+
self.where("section_type = ?", st).published.first
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# ------------------
|
|
58
|
+
# Instance variables
|
|
59
|
+
# ------------------
|
|
60
|
+
|
|
61
|
+
# Generic Methods
|
|
62
|
+
# ---------------
|
|
63
|
+
def to_param
|
|
64
|
+
"#{id}-#{title.parameterize[0..32]}"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def display_name
|
|
68
|
+
"#{title_was}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Permission Methods
|
|
72
|
+
# ------------------
|
|
73
|
+
|
|
74
|
+
def can_be_edited?
|
|
75
|
+
status?(:published) or status?(:unpublished)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def can_be_deleted?
|
|
79
|
+
status?(:removed)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
class Dhatu::TeamMember < Dhatu::ApplicationRecord
|
|
2
|
+
|
|
3
|
+
# Set Table Name
|
|
4
|
+
self.table_name = "team_members"
|
|
5
|
+
|
|
6
|
+
# Including the State Machine Methods
|
|
7
|
+
include Publishable
|
|
8
|
+
include Featureable
|
|
9
|
+
|
|
10
|
+
# Validations
|
|
11
|
+
validates :name, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: false
|
|
12
|
+
validates :designation, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: true
|
|
13
|
+
validates :description, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: true
|
|
14
|
+
|
|
15
|
+
# Associations
|
|
16
|
+
has_one :profile_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::ProfileImage"
|
|
17
|
+
|
|
18
|
+
# ------------------
|
|
19
|
+
# Class Methods
|
|
20
|
+
# ------------------
|
|
21
|
+
|
|
22
|
+
scope :search, lambda {|query| where("
|
|
23
|
+
LOWER(name) LIKE LOWER('%#{query}%') OR\
|
|
24
|
+
LOWER(designation) LIKE LOWER('%#{query}%') OR\
|
|
25
|
+
LOWER(status) LIKE LOWER('%#{query}%') OR\
|
|
26
|
+
LOWER(linked_in_url) LIKE LOWER('%#{query}%') OR\
|
|
27
|
+
LOWER(google_plus_url) LIKE LOWER('%#{query}%') OR\
|
|
28
|
+
LOWER(facebook_url) LIKE LOWER('%#{query}%') OR\
|
|
29
|
+
LOWER(twitter_url) LIKE LOWER('%#{query}%')")}
|
|
30
|
+
|
|
31
|
+
scope :upcoming, lambda { where("created_at >= ?", Time.now) }
|
|
32
|
+
scope :past, lambda { where("created_at < ?", Time.now) }
|
|
33
|
+
|
|
34
|
+
# ------------------
|
|
35
|
+
# Instance variables
|
|
36
|
+
# ------------------
|
|
37
|
+
|
|
38
|
+
# Generic Methods
|
|
39
|
+
# ---------------
|
|
40
|
+
def to_param
|
|
41
|
+
"#{id}-#{name.parameterize[0..32]}"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def display_name
|
|
45
|
+
"#{name_was}"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Permission Methods
|
|
49
|
+
# ------------------
|
|
50
|
+
|
|
51
|
+
def can_be_edited?
|
|
52
|
+
status?(:published) or status?(:unpublished)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def can_be_deleted?
|
|
56
|
+
status?(:removed)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
class Dhatu::Testimonial < Dhatu::ApplicationRecord
|
|
2
|
+
|
|
3
|
+
# Set Table Name
|
|
4
|
+
self.table_name = "testimonials"
|
|
5
|
+
|
|
6
|
+
# Including the State Machine Methods
|
|
7
|
+
include Publishable
|
|
8
|
+
include Featureable
|
|
9
|
+
|
|
10
|
+
# Validations
|
|
11
|
+
validates :name, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: false
|
|
12
|
+
validates :designation, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: true
|
|
13
|
+
validates :organisation, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: true
|
|
14
|
+
validates :statement, presence: true, allow_blank: false
|
|
15
|
+
|
|
16
|
+
# Associations
|
|
17
|
+
has_one :profile_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::ProfileImage"
|
|
18
|
+
has_one :logo_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::LogoImage"
|
|
19
|
+
|
|
20
|
+
# ------------------
|
|
21
|
+
# Class Methods
|
|
22
|
+
# ------------------
|
|
23
|
+
|
|
24
|
+
scope :search, lambda {|query| where("LOWER(name) LIKE LOWER('%#{query}%') OR\
|
|
25
|
+
LOWER(designation) LIKE LOWER('%#{query}%') OR\
|
|
26
|
+
LOWER(organisation) LIKE LOWER('%#{query}%') OR\
|
|
27
|
+
LOWER(status) LIKE LOWER('%#{query}%')")}
|
|
28
|
+
|
|
29
|
+
scope :upcoming, lambda { where("created_at >= ?", Time.now) }
|
|
30
|
+
scope :past, lambda { where("created_at < ?", Time.now) }
|
|
31
|
+
|
|
32
|
+
# ------------------
|
|
33
|
+
# Instance variables
|
|
34
|
+
# ------------------
|
|
35
|
+
|
|
36
|
+
# Generic Methods
|
|
37
|
+
# ---------------
|
|
38
|
+
def to_param
|
|
39
|
+
"#{id}-#{name.parameterize[0..32]}"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def display_name
|
|
43
|
+
"#{name_was}"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Permission Methods
|
|
47
|
+
# ------------------
|
|
48
|
+
|
|
49
|
+
def can_be_edited?
|
|
50
|
+
status?(:published) or status?(:unpublished)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def can_be_deleted?
|
|
54
|
+
status?(:removed)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<%= form_for(@blog_post,
|
|
2
|
+
:url => (@blog_post.new_record? ? dhatu.blog_posts_path : dhatu.blog_post_path),
|
|
3
|
+
:method => (@blog_post.new_record? ? :post : :put),
|
|
4
|
+
:remote => true,
|
|
5
|
+
:html => {:id=>"form_blog_post", :class=>"mb-0 form-horizontal"}) do |f| %>
|
|
6
|
+
|
|
7
|
+
<div id="blog_post_form_error">
|
|
8
|
+
<%= @blog_post.errors[:base].to_sentence %>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div class="form-inputs m-15">
|
|
12
|
+
|
|
13
|
+
<%= theme_form_field(@blog_post, :title, form_style: "top-bottom") %>
|
|
14
|
+
|
|
15
|
+
<%= theme_form_field(@blog_post, :slug, form_style: "top-bottom", html_options: {"data-id": @blog_post.id.to_s}) %>
|
|
16
|
+
|
|
17
|
+
<%= theme_form_field(@blog_post, :meta_description, required: true, html_options: {type: :textarea, class: "form-control", style: "height: 80px;"}, form_style: "top-bottom") %>
|
|
18
|
+
|
|
19
|
+
<%= theme_form_field(@blog_post, :description, required: true, html_options: {type: :textarea, class: "form-control wysihtml5", "data-stylesheet-url": "assets/wysiwyg-color.css"}, form_style: "top-bottom") %>
|
|
20
|
+
|
|
21
|
+
<div class="row">
|
|
22
|
+
<div class="col-md-4 pr-20">
|
|
23
|
+
<%= theme_form_field(@blog_post, :posted_at, required: false, html_options: {type: :date}, form_style: "top-bottom") %>
|
|
24
|
+
</div>
|
|
25
|
+
<div class="col-md-4 pl-20">
|
|
26
|
+
<%= theme_form_field(@blog_post, :author, required: false, form_style: "top-bottom") %>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<div>
|
|
33
|
+
<%= submit_tag("Save", :class=>"btn btn-primary pull-right ml-10") %>
|
|
34
|
+
|
|
35
|
+
<%= link_to raw("<i class='fa fa-close mr-5'></i><span>Cancel</span>"), "#", onclick: "closeLargeModal();", class: "pull-right btn btn-white" %>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<%= clear_tag %>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<% end %>
|
|
42
|
+
|