dhatu 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/dhatu/blog_posts_controller.rb +5 -5
  3. data/app/controllers/dhatu/bookings_controller.rb +76 -0
  4. data/app/controllers/dhatu/branches_controller.rb +1 -1
  5. data/app/controllers/dhatu/categories_controller.rb +14 -12
  6. data/app/controllers/dhatu/events_controller.rb +7 -9
  7. data/app/controllers/dhatu/offers_controller.rb +6 -8
  8. data/app/controllers/dhatu/prices_controller.rb +90 -0
  9. data/app/controllers/dhatu/sections_controller.rb +5 -5
  10. data/app/controllers/dhatu/services_controller.rb +6 -8
  11. data/app/controllers/dhatu/team_members_controller.rb +5 -7
  12. data/app/controllers/dhatu/testimonials_controller.rb +10 -12
  13. data/app/models/dhatu/booking.rb +55 -0
  14. data/app/models/dhatu/category.rb +11 -13
  15. data/app/models/dhatu/event.rb +2 -1
  16. data/app/models/dhatu/offer.rb +1 -0
  17. data/app/models/dhatu/price.rb +59 -0
  18. data/app/models/dhatu/section.rb +1 -14
  19. data/app/models/dhatu/service.rb +1 -14
  20. data/app/uploaders/category_image_uploader.rb +8 -0
  21. data/app/views/dhatu/blog_posts/_show.html.erb +3 -5
  22. data/app/views/dhatu/bookings/_index.html.erb +48 -0
  23. data/app/views/dhatu/bookings/_row.html.erb +18 -0
  24. data/app/views/dhatu/bookings/_show.html.erb +62 -0
  25. data/app/views/dhatu/bookings/index.html.erb +79 -0
  26. data/app/views/dhatu/bookings/show.js.erb +17 -0
  27. data/app/views/dhatu/categories/_form.html.erb +5 -6
  28. data/app/views/dhatu/categories/_index.html.erb +3 -0
  29. data/app/views/dhatu/categories/_row.html.erb +2 -0
  30. data/app/views/dhatu/categories/_show.html.erb +29 -16
  31. data/app/views/dhatu/categories/index.html.erb +10 -4
  32. data/app/views/dhatu/dashboard/_index.html.erb +12 -0
  33. data/app/views/dhatu/events/_form.html.erb +5 -2
  34. data/app/views/dhatu/offers/_form.html.erb +5 -2
  35. data/app/views/dhatu/prices/_form.html.erb +45 -0
  36. data/app/views/dhatu/prices/_index.html.erb +49 -0
  37. data/app/views/dhatu/prices/_row.html.erb +24 -0
  38. data/app/views/dhatu/prices/_show.html.erb +76 -0
  39. data/app/views/dhatu/prices/index.html.erb +69 -0
  40. data/app/views/dhatu/services/_show.html.erb +1 -0
  41. data/app/views/dhatu/team_members/_form.html.erb +10 -2
  42. data/app/views/dhatu/testimonials/_form.html.erb +21 -8
  43. data/app/views/layouts/kuppayam/_sidebar.html.erb +12 -0
  44. data/config/routes.rb +16 -0
  45. data/lib/dhatu/version.rb +1 -1
  46. data/spec/dummy/spec/factories/blog_post.rb +2 -0
  47. data/spec/dummy/spec/factories/category.rb +51 -0
  48. data/spec/dummy/spec/factories/event.rb +2 -0
  49. data/spec/dummy/spec/factories/offer.rb +1 -1
  50. data/spec/dummy/spec/factories/section.rb +2 -0
  51. metadata +23 -8
@@ -4,7 +4,7 @@ module Dhatu
4
4
  private
5
5
 
6
6
  def permitted_params
7
- params.require("dhatu/team_member").permit(:name, :designation, :status, :featured, :description, :linked_in_url, :google_plus_url, :facebook_url, :twitter_url)
7
+ params.require("dhatu/team_member").permit(:name, :designation, :status, :featured, :description, :linked_in_url, :google_plus_url, :facebook_url, :twitter_url, :priority)
8
8
  end
9
9
 
10
10
  def get_collections
@@ -19,9 +19,7 @@ module Dhatu
19
19
  def apply_filters
20
20
  @relation = @relation.search(@query) if @query
21
21
  @relation = @relation.status(@status) if @status
22
-
23
- @order_by = "created_at desc" unless @order_by
24
- @relation = @relation.order(@order_by)
22
+ @relation = @relation.order("priority ASC, name ASC")
25
23
  end
26
24
 
27
25
  def configure_filter_settings
@@ -70,9 +68,9 @@ module Dhatu
70
68
  {
71
69
  heading: "Manage Team",
72
70
  icon: "fa-group",
73
- description: "Listing all team_members",
74
- links: [{name: "Dashboard", link: dashboard_path, icon: 'fa-dashboard'},
75
- {name: "Manage team_members", link: dhatu.team_members_path, icon: 'fa-group', active: true}]
71
+ description: "Listing all Team",
72
+ links: [{name: "Dashboard", link: breadcrumb_home_path, icon: 'fa-dashboard'},
73
+ {name: "Manage Team", link: dhatu.team_members_path, icon: 'fa-group', active: true}]
76
74
  }
77
75
  end
78
76
 
@@ -4,11 +4,11 @@ module Dhatu
4
4
  private
5
5
 
6
6
  def permitted_params
7
- params.require("dhatu/testimonial").permit(:name, :designation, :organisation, :status, :featured, :statement)
7
+ params.require("dhatu/testimonial").permit(:name, :designation, :organisation, :status, :featured, :statement, :priority)
8
8
  end
9
9
 
10
10
  def get_collections
11
- @relation = Testimonial.includes(:profile_image, :logo_image).where("")
11
+ @relation = Dhatu::Testimonial.includes(:profile_image, :logo_image).where("")
12
12
  params[:st] = "published" if params[:st].nil?
13
13
  parse_filters
14
14
  apply_filters
@@ -19,9 +19,7 @@ module Dhatu
19
19
  def apply_filters
20
20
  @relation = @relation.search(@query) if @query
21
21
  @relation = @relation.status(@status) if @status
22
-
23
- @order_by = "created_at desc" unless @order_by
24
- @relation = @relation.order(@order_by)
22
+ @relation = @relation.order("priority ASC, name ASC")
25
23
  end
26
24
 
27
25
  def configure_filter_settings
@@ -43,9 +41,9 @@ module Dhatu
43
41
  status: {
44
42
  object_filter: false,
45
43
  select_label: "Select Status",
46
- display_hash: Testimonial::STATUS,
44
+ display_hash: Dhatu::Testimonial::STATUS,
47
45
  current_value: @status,
48
- values: Testimonial::STATUS_REVERSE,
46
+ values: Dhatu::Testimonial::STATUS_REVERSE,
49
47
  current_filters: @filters,
50
48
  filters_to_remove: [],
51
49
  filters_to_add: {},
@@ -62,17 +60,17 @@ module Dhatu
62
60
  view_path: "dhatu/testimonials",
63
61
  collection_name: :testimonials,
64
62
  item_name: :testimonial,
65
- class: Testimonial
63
+ class: Dhatu::Testimonial
66
64
  }
67
65
  end
68
66
 
69
67
  def breadcrumbs_configuration
70
68
  {
71
- heading: "Manage testimonials",
69
+ heading: "Manage Testimonials",
72
70
  icon: "fa-comment",
73
- description: "Listing all testimonials",
74
- links: [{name: "Dashboard", link: dashboard_path, icon: 'fa-dashboard'},
75
- {name: "Manage testimonials", link: dhatu.testimonials_path, icon: 'fa-comment', active: true}]
71
+ description: "Listing all Testimonials",
72
+ links: [{name: "Dashboard", link: breadcrumb_home_path, icon: 'fa-dashboard'},
73
+ {name: "Manage Testimonials", link: dhatu.testimonials_path, icon: 'fa-comment', active: true}]
76
74
  }
77
75
  end
78
76
 
@@ -0,0 +1,55 @@
1
+ class Dhatu::Booking < Dhatu::ApplicationRecord
2
+
3
+ # Set Table Name
4
+ self.table_name = "bookings"
5
+
6
+ # Including the State Machine Methods
7
+ include Readable
8
+ include Featureable
9
+
10
+ # Validations
11
+ validates :name, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: false
12
+ # validate_email :email, mandatory: false, allow_blank: true
13
+ validates :mobile, length: {maximum: 250}, allow_blank: true
14
+
15
+ # Associations
16
+ belongs_to :service
17
+
18
+ # ------------------
19
+ # Class Methods
20
+ # ------------------
21
+
22
+ scope :search, lambda {|query| where("LOWER(name) LIKE LOWER('%#{query}%') OR\
23
+ LOWER(email) LIKE LOWER('%#{query}%') OR\
24
+ LOWER(mobile) LIKE LOWER('%#{query}%') OR\
25
+ LOWER(message) LIKE LOWER('%#{query}%')")}
26
+
27
+ scope :upcoming, lambda { where("created_at >= ?", Time.now) }
28
+ scope :past, lambda { where("created_at < ?", Time.now) }
29
+
30
+ # ------------------
31
+ # Instance variables
32
+ # ------------------
33
+
34
+ # Generic Methods
35
+ # ---------------
36
+ def to_param
37
+ "#{id}-#{name.parameterize[0..32]}"
38
+ end
39
+
40
+ def display_name
41
+ "#{name_was}"
42
+ end
43
+
44
+ # Permission Methods
45
+ # ------------------
46
+
47
+ def can_be_edited?
48
+ false
49
+ end
50
+
51
+ def can_be_deleted?
52
+ status?(:removed)
53
+ end
54
+
55
+ end
@@ -93,16 +93,6 @@ class Dhatu::Category < Dhatu::ApplicationRecord
93
93
  # Instance methods
94
94
  # ------------------
95
95
 
96
- # Exclude some attributes info from json output.
97
- def as_json(options={})
98
- options[:except] ||= EXCLUDED_JSON_ATTRIBUTES
99
- options[:include] ||= [:parent, :top_parent, :sub_categories]
100
- #options[:methods] = []
101
- #options[:methods] << :profile_image
102
- json = super(options)
103
- # Hash[*json.map{|k, v| [k, v || ""]}.flatten]
104
- end
105
-
106
96
  # Other Methods
107
97
  # ------------------
108
98
 
@@ -110,6 +100,10 @@ class Dhatu::Category < Dhatu::ApplicationRecord
110
100
  self.name
111
101
  end
112
102
 
103
+ def display_category_type
104
+ self.category_type.try(:demodulize).try(:pluralize).try(:titleize)
105
+ end
106
+
113
107
  def default_image_url(size="medium")
114
108
  "/assets/defaults/category-#{size}.png"
115
109
  end
@@ -133,15 +127,19 @@ class Dhatu::Category < Dhatu::ApplicationRecord
133
127
  end
134
128
 
135
129
  def can_be_unpublished?
136
- published? or archived?
130
+ return false if end_node == false or self.sub_categories.any?
131
+ published? or removed?
137
132
  end
138
133
 
139
134
  def can_be_archived?
140
- unpublished?
135
+ return false if end_node == false or self.sub_categories.any?
136
+ unpublished? or removed?
141
137
  end
142
138
 
143
139
  def can_be_removed?
144
- unpublished? or archived?
140
+ return false if parent.nil?
141
+ return false if end_node == false or self.sub_categories.any?
142
+ published? or unpublished?
145
143
  end
146
144
 
147
145
  # Callback methods
@@ -11,8 +11,9 @@ class Dhatu::Event < Dhatu::ApplicationRecord
11
11
  validates :title, presence: true, length: {minimum: 5, maximum: 500}, allow_blank: false
12
12
  validates :venue, length: {minimum: 3, maximum: 250}, allow_blank: true
13
13
  validates :description, presence: true
14
-
14
+
15
15
  # Associations
16
+ belongs_to :category
16
17
  has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
17
18
  has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
18
19
 
@@ -13,6 +13,7 @@ class Dhatu::Offer < Dhatu::ApplicationRecord
13
13
  validates :description, presence: true
14
14
 
15
15
  # Associations
16
+ belongs_to :category
16
17
  has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
17
18
  has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
18
19
 
@@ -0,0 +1,59 @@
1
+ class Dhatu::Price < Dhatu::ApplicationRecord
2
+
3
+ # Set Table Name
4
+ self.table_name = "prices"
5
+
6
+ # Including the State Machine Methods
7
+ include Publishable
8
+ include Featureable
9
+
10
+ # Validations
11
+ validate_string :title, mandatory: true, min_length: 2, format: /.*/i
12
+ validate_string :sub_title, mandatory: false, format: /.*/i
13
+
14
+ validates :price, presence: true
15
+ validates :category, presence: true
16
+
17
+ # Associations
18
+ belongs_to :category
19
+ has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
20
+
21
+ # ------------------
22
+ # Class Methods
23
+ # ------------------
24
+
25
+ scope :search, lambda {|query| where("LOWER(title) LIKE LOWER('%#{query}%') OR\
26
+ LOWER(sub_title) LIKE LOWER('%#{query}%') OR")
27
+ }
28
+
29
+ scope :filter_by_category, lambda { |c| where("category_id = ?", (c.is_a? Dhatu::Category ? c.id : c)) }
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}-#{title.parameterize[0..32]}"
42
+ end
43
+
44
+ def display_name
45
+ "#{title_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
@@ -6,20 +6,6 @@ class Dhatu::Section < Dhatu::ApplicationRecord
6
6
  # Including the State Machine Methods
7
7
  include Publishable
8
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
9
  # Validations
24
10
  validates :title, presence: true, length: {minimum: 3, maximum: 256}, allow_blank: false
25
11
  validates :sub_title, length: {minimum: 3, maximum: 256}, allow_blank: true
@@ -31,6 +17,7 @@ class Dhatu::Section < Dhatu::ApplicationRecord
31
17
  validates :button_two_link, length: {maximum: 512}, allow_blank: true
32
18
 
33
19
  # Associations
20
+ belongs_to :category
34
21
  has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
35
22
  has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
36
23
 
@@ -5,21 +5,8 @@ class Dhatu::Service < Dhatu::ApplicationRecord
5
5
 
6
6
  # Including the State Machine Methods
7
7
  include Publishable
8
+ include Featureable
8
9
 
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
10
  # Validations
24
11
  validate_string :name, mandatory: true, min_length: 2, format: /.*/i
25
12
  validate_string :one_liner, mandatory: false, format: /.*/i
@@ -4,6 +4,14 @@ class CategoryImageUploader < ImageUploader
4
4
  "uploads/category_images/#{model.id}"
5
5
  end
6
6
 
7
+ version :large do
8
+ process :resize_to_fill => [400, 400]
9
+ end
10
+
11
+ version :medium do
12
+ process :resize_to_fill => [200, 200]
13
+ end
14
+
7
15
  version :small do
8
16
  process :resize_to_fill => [100, 100]
9
17
  end
@@ -35,8 +35,6 @@
35
35
  <tr>
36
36
  <th style="width:25%">Posted At</th>
37
37
  <td style="width:25%"><%= time_tag(@blog_post.posted_at) if @blog_post.posted_at %></td>
38
- <th style="width:25%">Slug</th>
39
- <td style="width:25%"><%= @blog_post.slug %></td>
40
38
  </tr>
41
39
 
42
40
  <tr>
@@ -79,9 +77,9 @@
79
77
  <div class="tab-content">
80
78
  <div class="tab-pane active" id="blog_post_details" style="border: 1px solid #000;min-height:200px;padding:20px;margin-bottom:20px;max-height: 400px;overflow-y: auto;">
81
79
 
82
- <%= clear_tag(20) %>
83
- <%= raw(@blog_post.description) %>
84
- <%= clear_tag(20) %>
80
+ <div class="well">
81
+ <%= raw(@blog_post.description) %>
82
+ </div>
85
83
 
86
84
  </div>
87
85
 
@@ -0,0 +1,48 @@
1
+ <div class="table-responsive">
2
+ <table class="table table-hover members-table middle-align">
3
+ <thead>
4
+ <tr>
5
+ <th style="text-align: center;width:8%">#</th>
6
+ <th style="width:200px">Name</th>
7
+ <th style="width:50%;" >Message</th>
8
+ <!-- <th style="width:100px;" class="hidden-sm hidden-xs">Status</th> -->
9
+ <% if display_manage_links? %>
10
+ <th style="text-align: center;" class="" >Actions</th>
11
+ <% end %>
12
+ </tr>
13
+ </thead>
14
+ <tbody>
15
+ <tr id="tr_booking_0"></tr>
16
+ <% @bookings.each_with_index do |booking, i| %>
17
+ <tr id="tr_booking_<%= booking.id %>">
18
+
19
+ <th scope="row" style="text-align: center;">
20
+ <%= serial_number(i) %>
21
+ </th>
22
+
23
+ <td class="display-link">
24
+ <% if booking.new? || booking.unread? %>
25
+ <%= link_to booking.name, booking_path(booking), remote: true, style: "font-weight:800;" %><br>
26
+ <% else %>
27
+ <%= link_to booking.name, booking_path(booking), remote: true %>
28
+ <% end %>
29
+ &nbsp;<%= display_readable_status(booking) %><br>
30
+ <%= link_to time_ago_in_words(booking.created_at) + " ago", booking_path(booking), remote: true, style: "color:darkred;font-size:10px;" %>
31
+ </td>
32
+
33
+ <td class=""><%= truncate booking.message, length: 30 %></td>
34
+
35
+ <% if display_manage_links? %>
36
+ <td class="action-links" style="width:15%"><%= display_readable_links(booking) %></td>
37
+ <% end %>
38
+ </tr>
39
+ <% end %>
40
+ </tbody>
41
+ </table>
42
+ </div>
43
+
44
+ <div class="row">
45
+ <div class="col-sm-12">
46
+ <%= paginate_kuppayam(@bookings) %>
47
+ </div>
48
+ </div>
@@ -0,0 +1,18 @@
1
+ <tr id="tr_booking_<%= booking.id %>">
2
+ <th scope="row" style="text-align: center;">
3
+ <%= serial_number(i) %>
4
+ </th>
5
+
6
+ <td class="display-link">
7
+ <%= link_to booking.name, booking_path(booking), remote: true %><br>
8
+ <%#= link_to booking.category.try(:display_name), booking_path(booking), remote: true, style: "color:darkred" %>
9
+ </td>
10
+
11
+ <td class=""><%= truncate booking.message, length: 30 %></td>
12
+
13
+ <td class="hidden-sm hidden-xs"><%= display_readable_status(booking) %></td>
14
+
15
+ <% if display_manage_links? %>
16
+ <td class="action-links hidden-sm hidden-xs" style="width:15%"><%= display_readable_links(booking) %></td>
17
+ <% end %>
18
+ </tr>
@@ -0,0 +1,62 @@
1
+ <div id="div_booking_show">
2
+
3
+ <div class="row">
4
+
5
+ <div class="col-md-8 col-sm-12 col-xs-12" style="border-right:1px solid #f1f1f1;">
6
+
7
+ <%= theme_panel_heading(@booking.name) %>
8
+ <%= display_readable_status(@booking) %>
9
+ <%= display_featured(@booking) %>
10
+ <%= clear_tag(10) %>
11
+ <div class="well">
12
+ <%= theme_panel_description(@booking.message) %>
13
+ </div>
14
+ <%= clear_tag(10) %>
15
+
16
+ <% if @current_user.super_admin? %>
17
+ <div class="table-responsive">
18
+ <table class="table table-striped table-condensed table-bordered mb-60">
19
+ <tbody>
20
+
21
+ <tr>
22
+ <th>ID</th><td><%= @booking.id %></td>
23
+ </tr>
24
+
25
+ <tr>
26
+ <th>Featured</th><td><%= @booking.featured ? "Yes" : "No" %></td>
27
+ </tr>
28
+
29
+ <tr>
30
+ <th>Status</th><td><%= @booking.status %></td>
31
+ </tr>
32
+
33
+ <tr>
34
+ <th>Created At</th><td><%= @booking.created_at.strftime("%m/%d/%Y - %H:%M:%S") if @booking.created_at %></td>
35
+ </tr>
36
+
37
+ <tr>
38
+ <th>Updated At</th><td><%= @booking.updated_at.strftime("%m/%d/%Y - %H:%M:%S") if @booking.updated_at %></td>
39
+ </tr>
40
+
41
+ </tbody>
42
+ </table>
43
+ </div>
44
+ <% end %>
45
+
46
+ <%= clear_tag(20) %>
47
+ </div>
48
+
49
+ <% if display_manage_links? %>
50
+ <div class="col-md-4 col-sm-12 col-xs-12">
51
+ <%= display_readable_buttons(@booking) %>
52
+ <%= display_featurable_buttons(@booking) %>
53
+ </div>
54
+ <% end %>
55
+
56
+ </div>
57
+
58
+ <%= link_to "Close", "#", onclick: "closeLargeModal();", class: "btn btn-primary pull-right" %>
59
+
60
+ <%= clear_tag %>
61
+
62
+ </div>