dhatu 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/dhatu/blog_posts_controller.rb +81 -14
  3. data/app/controllers/dhatu/bookings_controller.rb +51 -5
  4. data/app/controllers/dhatu/branches_controller.rb +42 -8
  5. data/app/controllers/dhatu/categories_controller.rb +86 -47
  6. data/app/controllers/dhatu/events_controller.rb +79 -9
  7. data/app/controllers/dhatu/meta_tags_controller.rb +96 -0
  8. data/app/controllers/dhatu/offers_controller.rb +83 -10
  9. data/app/controllers/dhatu/pages_controller.rb +130 -0
  10. data/app/controllers/dhatu/prices_controller.rb +78 -12
  11. data/app/controllers/dhatu/projects_controller.rb +78 -22
  12. data/app/controllers/dhatu/promotion_enquiries_controller.rb +69 -7
  13. data/app/controllers/dhatu/promotions_controller.rb +46 -2
  14. data/app/controllers/dhatu/resource_controller.rb +4 -0
  15. data/app/controllers/dhatu/sections_controller.rb +41 -8
  16. data/app/controllers/dhatu/services_controller.rb +78 -18
  17. data/app/controllers/dhatu/team_members_controller.rb +41 -8
  18. data/app/controllers/dhatu/testimonials_controller.rb +41 -9
  19. data/app/models/dhatu/blog_post.rb +6 -2
  20. data/app/models/dhatu/category.rb +3 -3
  21. data/app/models/dhatu/event.rb +4 -0
  22. data/app/models/dhatu/meta_tag.rb +48 -0
  23. data/app/models/dhatu/offer.rb +4 -0
  24. data/app/models/dhatu/page.rb +50 -0
  25. data/app/models/dhatu/project.rb +7 -3
  26. data/app/models/dhatu/promotion.rb +1 -0
  27. data/app/models/dhatu/section.rb +8 -12
  28. data/app/models/dhatu/service.rb +7 -3
  29. data/app/models/image/og_image.rb +3 -0
  30. data/app/uploaders/og_image_uploader.rb +15 -0
  31. data/app/views/dhatu/blog_posts/_form.html.erb +1 -1
  32. data/app/views/dhatu/blog_posts/_index.html.erb +1 -1
  33. data/app/views/dhatu/blog_posts/_row.html.erb +1 -1
  34. data/app/views/dhatu/blog_posts/_show.html.erb +1 -1
  35. data/app/views/dhatu/bookings/_index.html.erb +7 -8
  36. data/app/views/dhatu/bookings/_row.html.erb +11 -7
  37. data/app/views/dhatu/bookings/index.html.erb +20 -12
  38. data/app/views/dhatu/branches/_index.html.erb +8 -12
  39. data/app/views/dhatu/branches/_show.html.erb +75 -69
  40. data/app/views/dhatu/branches/index.html.erb +13 -8
  41. data/app/views/dhatu/categories/_category_types.html.erb +27 -0
  42. data/app/views/dhatu/categories/_form.html.erb +2 -2
  43. data/app/views/dhatu/categories/_index.html.erb +114 -89
  44. data/app/views/dhatu/categories/_index_list.html.erb +118 -0
  45. data/app/views/dhatu/categories/_row.html.erb +27 -31
  46. data/app/views/dhatu/categories/_row_list.html.erb +34 -0
  47. data/app/views/dhatu/categories/_show.html.erb +101 -74
  48. data/app/views/dhatu/categories/choose_category_type.html.erb +20 -0
  49. data/app/views/dhatu/categories/index.html.erb +1 -19
  50. data/app/views/dhatu/dashboard/_index.html.erb +53 -42
  51. data/app/views/dhatu/events/_index.html.erb +1 -1
  52. data/app/views/dhatu/events/_row.html.erb +1 -1
  53. data/app/views/dhatu/events/_show.html.erb +99 -75
  54. data/app/views/dhatu/events/index.html.erb +14 -9
  55. data/app/views/dhatu/meta_tags/_form.html.erb +48 -0
  56. data/app/views/dhatu/meta_tags/_index.html.erb +59 -0
  57. data/app/views/dhatu/meta_tags/_row.html.erb +32 -0
  58. data/app/views/dhatu/meta_tags/create.js.erb +29 -0
  59. data/app/views/dhatu/offers/_index.html.erb +8 -8
  60. data/app/views/dhatu/offers/_row.html.erb +1 -1
  61. data/app/views/dhatu/offers/_show.html.erb +85 -81
  62. data/app/views/dhatu/offers/index.html.erb +14 -8
  63. data/app/views/dhatu/pages/_form.html.erb +44 -0
  64. data/app/views/dhatu/pages/_index.html.erb +57 -0
  65. data/app/views/dhatu/pages/_row.html.erb +47 -0
  66. data/app/views/dhatu/pages/_show.html.erb +99 -0
  67. data/app/views/dhatu/pages/index.html.erb +59 -0
  68. data/app/views/dhatu/pages/show.html.erb +12 -0
  69. data/app/views/dhatu/prices/_index.html.erb +6 -6
  70. data/app/views/dhatu/prices/_row.html.erb +3 -2
  71. data/app/views/dhatu/prices/_show.html.erb +34 -45
  72. data/app/views/dhatu/prices/index.html.erb +14 -25
  73. data/app/views/dhatu/projects/_form.html.erb +15 -16
  74. data/app/views/dhatu/projects/_index.html.erb +6 -7
  75. data/app/views/dhatu/projects/_row.html.erb +4 -4
  76. data/app/views/dhatu/projects/_show.html.erb +108 -97
  77. data/app/views/dhatu/projects/index.html.erb +13 -19
  78. data/app/views/dhatu/projects/show.html.erb +12 -0
  79. data/app/views/dhatu/promotion_attributes/_index.html.erb +1 -7
  80. data/app/views/dhatu/promotion_attributes/_row.html.erb +1 -4
  81. data/app/views/dhatu/promotion_enquiries/_index.html.erb +11 -11
  82. data/app/views/dhatu/promotion_enquiries/_row.html.erb +7 -5
  83. data/app/views/dhatu/promotion_enquiries/_show.html.erb +35 -43
  84. data/app/views/dhatu/promotion_enquiries/index.html.erb +20 -12
  85. data/app/views/dhatu/promotions/_index.html.erb +13 -15
  86. data/app/views/dhatu/promotions/_row.html.erb +10 -9
  87. data/app/views/dhatu/promotions/_show.html.erb +190 -93
  88. data/app/views/dhatu/promotions/index.html.erb +0 -8
  89. data/app/views/dhatu/{section_types → section_types1}/_form.html.erb +0 -0
  90. data/app/views/dhatu/{section_types → section_types1}/_index.html.erb +0 -0
  91. data/app/views/dhatu/{section_types → section_types1}/_row.html.erb +0 -0
  92. data/app/views/dhatu/{section_types → section_types1}/_show.html.erb +0 -0
  93. data/app/views/dhatu/{section_types → section_types1}/index.html.erb +0 -0
  94. data/app/views/dhatu/sections/_form.html.erb +116 -11
  95. data/app/views/dhatu/sections/_index.html.erb +6 -3
  96. data/app/views/dhatu/sections/_row.html.erb +5 -2
  97. data/app/views/dhatu/sections/_show.html.erb +168 -132
  98. data/app/views/dhatu/sections/index.html.erb +10 -2
  99. data/app/views/dhatu/services/_form.html.erb +16 -17
  100. data/app/views/dhatu/services/_index.html.erb +6 -7
  101. data/app/views/dhatu/services/_row.html.erb +4 -4
  102. data/app/views/dhatu/services/_show.html.erb +107 -96
  103. data/app/views/dhatu/services/index.html.erb +13 -19
  104. data/app/views/dhatu/team_members/_index.html.erb +5 -6
  105. data/app/views/dhatu/team_members/_row.html.erb +3 -3
  106. data/app/views/dhatu/team_members/_show.html.erb +70 -58
  107. data/app/views/dhatu/team_members/index.html.erb +13 -8
  108. data/app/views/dhatu/testimonials/_index.html.erb +3 -6
  109. data/app/views/dhatu/testimonials/_row.html.erb +2 -3
  110. data/app/views/dhatu/testimonials/_show.html.erb +63 -93
  111. data/app/views/dhatu/testimonials/index.html.erb +13 -8
  112. data/app/views/layouts/kuppayam/_sidebar.html.erb +63 -48
  113. data/app/views/usman/dashboard/_super_admin_index.html.erb +22 -0
  114. data/config/routes.rb +12 -1
  115. data/db/data/dummy/services.csv +1 -1
  116. data/db/migrate/20180101093435_create_pages.rb +14 -0
  117. data/db/migrate/20180101093436_create_meta_tags.rb +19 -0
  118. data/db/migrate/20180101093437_add_page_id_to_sections.rb +5 -0
  119. data/db/migrate/20180101093438_add_priority_to_pages_and_sections.rb +6 -0
  120. data/db/migrate/20180101093439_add_a_ton_of_boolean_fields_to_sections.rb +34 -0
  121. data/db/migrate/20180101093440_add_code_to_sections.rb +19 -0
  122. data/db/migrate/20180101093441_rename_meta_description_all_over.rb +7 -0
  123. data/db/migrate/20180101093442_add_name_to_sections.rb +19 -0
  124. data/lib/dhatu/version.rb +1 -1
  125. metadata +43 -14
  126. data/db/migrate/20171203114529_add_meta_description_to_services.rb +0 -7
@@ -21,6 +21,10 @@ module Dhatu
21
21
  def configure_filter_param_mapping
22
22
  @filter_param_mapping = default_filter_param_mapping
23
23
  @filter_param_mapping[:promotion] = :pr
24
+ @filter_param_mapping[:category] = :ct
25
+ @filter_param_mapping[:category_type] = :ctype
26
+ @filter_param_mapping[:feature] = :ft
27
+ @filter_param_mapping[:featured] = :featured
24
28
  end
25
29
 
26
30
  end
@@ -4,12 +4,11 @@ module Dhatu
4
4
  private
5
5
 
6
6
  def permitted_params
7
- params.require("dhatu/section").permit(:section_type_id, :title, :sub_title, :short_description, :long_description, :button_one_text, :button_two_text, :button_one_link, :button_two_link, :category_id)
7
+ params.require("dhatu/section").permit(:page_id, :name, :title, :sub_title, :code, :short_description, :long_description, :button_one_text, :button_two_text, :button_one_link, :button_two_link, :category_id, :priority, :enable_title, :enable_sub_title, :enable_short_description, :enable_long_description, :enable_button_one, :enable_button_two, :enable_cover_image, :enable_gallery_images)
8
8
  end
9
9
 
10
10
  def get_collections
11
11
  @relation = Dhatu::Section.includes(:cover_image).where("")
12
- params[:st] = "published" if params[:st].nil?
13
12
  parse_filters
14
13
  apply_filters
15
14
  @sections = @r_objects = @relation.page(@current_page).per(@per_page)
@@ -20,7 +19,7 @@ module Dhatu
20
19
  @relation = @relation.search(@query) if @query
21
20
  @relation = @relation.status(@status) if @status
22
21
 
23
- @order_by = "created_at desc" unless @order_by
22
+ @order_by = "priority ASC, created_at desc" unless @order_by
24
23
  @relation = @relation.order(@order_by)
25
24
  end
26
25
 
@@ -42,7 +41,7 @@ module Dhatu
42
41
  @filter_ui_settings = {
43
42
  status: {
44
43
  object_filter: false,
45
- select_label: "Select Status",
44
+ select_label: "Filter by Status",
46
45
  display_hash: Dhatu::Section::STATUS,
47
46
  current_value: @status,
48
47
  values: Dhatu::Section::STATUS_REVERSE,
@@ -57,12 +56,46 @@ module Dhatu
57
56
 
58
57
  def resource_controller_configuration
59
58
  {
60
- page_title: "Sections",
61
- js_view_path: "/kuppayam/workflows/peacock",
62
- view_path: "dhatu/sections",
59
+ page_title: "Manage Sections",
60
+ current_nav: "dhatu/pages",
61
+
62
+ # Resource Names
63
+ class: Dhatu::Section,
63
64
  collection_name: :sections,
64
65
  item_name: :section,
65
- class: Dhatu::Section
66
+
67
+ # Conditions
68
+ get_collections_after_save_resource: false,
69
+ show_modal_after_create: true,
70
+ show_modal_after_update: true,
71
+
72
+ # Model Size can be large or generic
73
+ form_model_size: :large,
74
+ show_model_size: :large,
75
+
76
+ # Layout can be table or feed
77
+ # table uses html tables and feed uses div based boxes
78
+ layout: :table,
79
+
80
+ # "/kuppayam/workflows/default"
81
+ #
82
+ # Default partial opens show and form partial according to the model_size configuration
83
+ # It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed
84
+
85
+ # "/kuppayam/workflows/peacock"
86
+ # "/kuppayam/workflows/parrot"
87
+ #
88
+ # Peacock & Parrot are old ways of doing things and it respects certail configurations
89
+ # Peacock opens show and form partials in large popup where as Parrot opens it in small
90
+ # Both Peacock and Parrot expect table based layout and will reload a single row after create / update
91
+
92
+ # Rendering Paths
93
+ view_path: "dhatu/sections",
94
+ js_view_path: "/kuppayam/workflows/default",
95
+
96
+ # Additional Configurations
97
+ load_wysihtml5: true,
98
+ tagsinput: false
66
99
  }
67
100
  end
68
101
 
@@ -4,28 +4,41 @@ module Dhatu
4
4
  private
5
5
 
6
6
  def permitted_params
7
- params.require("dhatu/service").permit(:name, :meta_description, :permalink, :description, :price, :duration, :category_id, :priority)
7
+ params.require("dhatu/service").permit(:name, :short_description, :permalink, :description, :price, :duration, :category_id, :priority)
8
8
  end
9
9
 
10
- def get_collections
10
+ def load_nested_categories
11
11
  category_ids = Dhatu::Service.distinct.pluck(:category_id)
12
12
  @categories = Dhatu::Category.where(id: category_ids).to_a
13
13
  @categories.unshift(Dhatu::Category.new(id: -1, name: "All"))
14
+ end
14
15
 
15
- @relation = Dhatu::Service.includes(:cover_image).where("")
16
- # params[:st] = "published" if params[:st].nil?
17
-
16
+ def get_collections
17
+ # Checkout the method get_category_filters before using this method
18
+ # load_nested_categories
19
+
20
+ @relation = Dhatu::Service.includes(:cover_image, :category).where("")
21
+
18
22
  parse_filters
19
23
  apply_filters
24
+
20
25
  @services = @r_objects = @relation.page(@current_page).per(@per_page)
21
26
  return true
22
27
  end
23
28
 
24
29
  def apply_filters
25
- @category = Dhatu::Category.find_by_id(params[:ct]) || Dhatu::Category.new(id: -1, name: "All")
26
-
27
- if @category && @category.id != -1
28
- @relation = @relation.where("category_id = ?", @category.id)
30
+ if @category.is_a?(String)
31
+ @category = Dhatu::Category.new(id: -2, name: "IS NOT SET")
32
+ elsif @category.blank?
33
+ @category = Dhatu::Category.new(id: -1, name: "All")
34
+ end
35
+
36
+ if @category
37
+ if @category.persisted?
38
+ @relation = @relation.where("category_id = ?", @category.id)
39
+ elsif @category.id == -2
40
+ @relation = @relation.where("category_id IS NULL")
41
+ end
29
42
  end
30
43
 
31
44
  @relation = @relation.search(@query) if @query
@@ -41,8 +54,9 @@ module Dhatu
41
54
  ],
42
55
 
43
56
  boolean_filters: [],
44
-
45
- reference_filters: [],
57
+ reference_filters: [
58
+ { filter_name: :category, filter_class: Dhatu::Category },
59
+ ],
46
60
  variable_filters: [],
47
61
  }
48
62
  end
@@ -51,27 +65,73 @@ module Dhatu
51
65
  @filter_ui_settings = {
52
66
  status: {
53
67
  object_filter: false,
54
- select_label: "Select Status",
55
- display_hash: Dhatu::Service::STATUS,
68
+ select_label: "Filter by Status",
69
+ display_hash: Dhatu::Service::STATUS_REVERSE,
56
70
  current_value: @status,
57
- values: Dhatu::Service::STATUS_REVERSE,
71
+ values: Dhatu::Service::STATUS,
58
72
  current_filters: @filters,
59
73
  filters_to_remove: [],
60
74
  filters_to_add: {},
61
75
  url_method_name: 'services_url',
62
76
  show_all_filter_on_top: true
77
+ },
78
+ category: {
79
+ object_filter: true,
80
+ select_label: 'Select Category Type',
81
+ current_value: @category,
82
+ values: Dhatu::Category.filter_by_category_type("Dhatu::Service").published.order("priority ASC, name ASC").all,
83
+ current_filters: @filters,
84
+ url_method_name: 'services_url',
85
+ filters_to_remove: [],
86
+ filters_to_add: {},
87
+ show_null_filter_on_top: true,
88
+ show_all_filter_on_top: true
63
89
  }
64
90
  }
65
91
  end
66
92
 
67
93
  def resource_controller_configuration
68
94
  {
69
- page_title: "Services",
70
- js_view_path: "/kuppayam/workflows/peacock",
71
- view_path: "dhatu/services",
95
+ page_title: "Manage Services",
96
+ current_nav: "dhatu/services",
97
+
98
+ # Resource Names
99
+ class: Dhatu::Service,
72
100
  collection_name: :services,
73
101
  item_name: :service,
74
- class: Dhatu::Service
102
+
103
+ # Conditions
104
+ get_collections_after_save_resource: false,
105
+ show_modal_after_create: true,
106
+ show_modal_after_update: true,
107
+
108
+ # Model Size can be large or generic
109
+ form_model_size: :large,
110
+ show_model_size: :large,
111
+
112
+ # Layout can be table or feed
113
+ # table uses html tables and feed uses div based boxes
114
+ layout: :table,
115
+
116
+ # "/kuppayam/workflows/default"
117
+ #
118
+ # Default partial opens show and form partial according to the model_size configuration
119
+ # It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed
120
+
121
+ # "/kuppayam/workflows/peacock"
122
+ # "/kuppayam/workflows/parrot"
123
+ #
124
+ # Peacock & Parrot are old ways of doing things and it respects certail configurations
125
+ # Peacock opens show and form partials in large popup where as Parrot opens it in small
126
+ # Both Peacock and Parrot expect table based layout and will reload a single row after create / update
127
+
128
+ # Rendering Paths
129
+ view_path: "dhatu/services",
130
+ js_view_path: "/kuppayam/workflows/default",
131
+
132
+ # Additional Configurations
133
+ load_wysihtml5: true,
134
+ tagsinput: false
75
135
  }
76
136
  end
77
137
 
@@ -9,7 +9,6 @@ module Dhatu
9
9
 
10
10
  def get_collections
11
11
  @relation = Dhatu::TeamMember.includes(:profile_image).where("")
12
- params[:st] = "published" if params[:st].nil?
13
12
  parse_filters
14
13
  apply_filters
15
14
  @team_members = @r_objects = @relation.page(@current_page).per(@per_page)
@@ -40,10 +39,10 @@ module Dhatu
40
39
  @filter_ui_settings = {
41
40
  status: {
42
41
  object_filter: false,
43
- select_label: "Select Status",
44
- display_hash: Dhatu::TeamMember::STATUS,
42
+ select_label: "Filter by Status",
43
+ display_hash: Dhatu::TeamMember::STATUS_REVERSE,
45
44
  current_value: @status,
46
- values: Dhatu::TeamMember::STATUS_REVERSE,
45
+ values: Dhatu::TeamMember::STATUS,
47
46
  current_filters: @filters,
48
47
  filters_to_remove: [],
49
48
  filters_to_add: {},
@@ -55,12 +54,46 @@ module Dhatu
55
54
 
56
55
  def resource_controller_configuration
57
56
  {
58
- page_title: "Team",
59
- js_view_path: "/kuppayam/workflows/peacock",
60
- view_path: "dhatu/team_members",
57
+ page_title: "Manage Teams",
58
+ current_nav: "dhatu/team_members",
59
+
60
+ # Resource Names
61
+ class: Dhatu::TeamMember,
61
62
  collection_name: :team_members,
62
63
  item_name: :team_member,
63
- class: Dhatu::TeamMember
64
+
65
+ # Conditions
66
+ get_collections_after_save_resource: false,
67
+ show_modal_after_create: true,
68
+ show_modal_after_update: true,
69
+
70
+ # Model Size can be large or generic
71
+ form_model_size: :large,
72
+ show_model_size: :large,
73
+
74
+ # Layout can be table or feed
75
+ # table uses html tables and feed uses div based boxes
76
+ layout: :table,
77
+
78
+ # "/kuppayam/workflows/default"
79
+ #
80
+ # Default partial opens show and form partial according to the model_size configuration
81
+ # It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed
82
+
83
+ # "/kuppayam/workflows/peacock"
84
+ # "/kuppayam/workflows/parrot"
85
+ #
86
+ # Peacock & Parrot are old ways of doing things and it respects certail configurations
87
+ # Peacock opens show and form partials in large popup where as Parrot opens it in small
88
+ # Both Peacock and Parrot expect table based layout and will reload a single row after create / update
89
+
90
+ # Rendering Paths
91
+ view_path: "dhatu/team_members",
92
+ js_view_path: "/kuppayam/workflows/default",
93
+
94
+ # Additional Configurations
95
+ load_wysihtml5: true,
96
+ tagsinput: false
64
97
  }
65
98
  end
66
99
 
@@ -9,7 +9,6 @@ module Dhatu
9
9
 
10
10
  def get_collections
11
11
  @relation = Dhatu::Testimonial.includes(:profile_image, :logo_image).where("")
12
- params[:st] = "published" if params[:st].nil?
13
12
  parse_filters
14
13
  apply_filters
15
14
  @testimonials = @r_objects = @relation.page(@current_page).per(@per_page)
@@ -30,7 +29,6 @@ module Dhatu
30
29
  ],
31
30
 
32
31
  boolean_filters: [],
33
-
34
32
  reference_filters: [],
35
33
  variable_filters: [],
36
34
  }
@@ -40,10 +38,10 @@ module Dhatu
40
38
  @filter_ui_settings = {
41
39
  status: {
42
40
  object_filter: false,
43
- select_label: "Select Status",
44
- display_hash: Dhatu::Testimonial::STATUS,
41
+ select_label: "Filter by Status",
42
+ display_hash: Dhatu::Testimonial::STATUS_REVERSE,
45
43
  current_value: @status,
46
- values: Dhatu::Testimonial::STATUS_REVERSE,
44
+ values: Dhatu::Testimonial::STATUS,
47
45
  current_filters: @filters,
48
46
  filters_to_remove: [],
49
47
  filters_to_add: {},
@@ -55,12 +53,46 @@ module Dhatu
55
53
 
56
54
  def resource_controller_configuration
57
55
  {
58
- page_title: "Testimonials",
59
- js_view_path: "/kuppayam/workflows/peacock",
60
- view_path: "dhatu/testimonials",
56
+ page_title: "Manage Testimonials",
57
+ current_nav: "dhatu/testimonials",
58
+
59
+ # Resource Names
60
+ class: Dhatu::Testimonial,
61
61
  collection_name: :testimonials,
62
62
  item_name: :testimonial,
63
- class: Dhatu::Testimonial
63
+
64
+ # Conditions
65
+ get_collections_after_save_resource: false,
66
+ show_modal_after_create: true,
67
+ show_modal_after_update: true,
68
+
69
+ # Model Size can be large or generic
70
+ form_model_size: :large,
71
+ show_model_size: :large,
72
+
73
+ # Layout can be table or feed
74
+ # table uses html tables and feed uses div based boxes
75
+ layout: :table,
76
+
77
+ # "/kuppayam/workflows/default"
78
+ #
79
+ # Default partial opens show and form partial according to the model_size configuration
80
+ # It also respect the configuration layout and refresh the page element on both cases - i.e layout is table or feed
81
+
82
+ # "/kuppayam/workflows/peacock"
83
+ # "/kuppayam/workflows/parrot"
84
+ #
85
+ # Peacock & Parrot are old ways of doing things and it respects certail configurations
86
+ # Peacock opens show and form partials in large popup where as Parrot opens it in small
87
+ # Both Peacock and Parrot expect table based layout and will reload a single row after create / update
88
+
89
+ # Rendering Paths
90
+ view_path: "dhatu/testimonials",
91
+ js_view_path: "/kuppayam/workflows/default",
92
+
93
+ # Additional Configurations
94
+ load_wysihtml5: true,
95
+ tagsinput: false
64
96
  }
65
97
  end
66
98
 
@@ -13,7 +13,7 @@ class Dhatu::BlogPost < Dhatu::ApplicationRecord
13
13
  validates :author, length: {minimum: 3, maximum: 250}, allow_blank: true
14
14
  validates :description, presence: true
15
15
  validates :posted_at, presence: true
16
- validates :meta_description, presence: true, length: {minimum: 10, maximum: 500}, allow_blank: false
16
+ validates :short_description, presence: true, length: {minimum: 10, maximum: 500}, allow_blank: false
17
17
 
18
18
  validates :category, presence: true
19
19
 
@@ -22,6 +22,10 @@ class Dhatu::BlogPost < Dhatu::ApplicationRecord
22
22
  has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
23
23
  has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
24
24
 
25
+ # Meta Tag Associations
26
+ has_one :og_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::OgImage"
27
+ has_many :meta_tags, :as => :meta_taggable, :dependent => :destroy, :class_name => "Dhatu::MetaTag"
28
+
25
29
  # Serializers
26
30
  serialize :tags, Hash
27
31
 
@@ -54,7 +58,7 @@ class Dhatu::BlogPost < Dhatu::ApplicationRecord
54
58
  blog_post.title = hsh[:title].to_s.strip
55
59
  blog_post.slug = blog_post.title.parameterize[0..64] if blog_post.title
56
60
  blog_post.author = hsh[:author].to_s.strip
57
- blog_post.meta_description = hsh[:meta_description].to_s.strip
61
+ blog_post.short_description = hsh[:short_description].to_s.strip
58
62
  blog_post.description = hsh[:description].to_s.strip
59
63
  blog_post.posted_at = hsh[:posted_at].to_s.strip
60
64
 
@@ -102,9 +102,9 @@ class Dhatu::Category < Dhatu::ApplicationRecord
102
102
  self.name
103
103
  end
104
104
 
105
- def to_param
106
- "#{id}-#{name.parameterize[0..32]}"
107
- end
105
+ # def to_param
106
+ # "#{id}-#{name.parameterize[0..32]}"
107
+ # end
108
108
 
109
109
  def display_category_type
110
110
  self.category_type.try(:demodulize).try(:pluralize).try(:titleize)
@@ -16,6 +16,10 @@ class Dhatu::Event < Dhatu::ApplicationRecord
16
16
  belongs_to :category, optional: true
17
17
  has_one :cover_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::CoverImage"
18
18
  has_many :gallery_images, :as => :imageable, :dependent => :destroy, :class_name => "Image::GalleryImage"
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"
19
23
 
20
24
  # ------------------
21
25
  # Class Methods
@@ -0,0 +1,48 @@
1
+ class Dhatu::MetaTag < Dhatu::ApplicationRecord
2
+
3
+ # Constants
4
+ META_TYPES = ["Default", "Open Graph", "Twitter", "Facebook", "Other"]
5
+
6
+ # Set Table Name
7
+ self.table_name = "meta_tags"
8
+
9
+ # Including the State Machine Methods
10
+ include Publishable
11
+
12
+ # Validations
13
+ validates :meta_type, presence: true, length: {minimum: 3, maximum: 16}, allow_blank: false
14
+ validates :meta_key, presence: true, length: {minimum: 1, maximum: 128}, allow_blank: false
15
+ validates :meta_value, presence: true, length: {minimum: 1, maximum: 1064}, allow_blank: false
16
+
17
+ # Associations
18
+ belongs_to :meta_taggable, :polymorphic => true
19
+
20
+ # ------------------
21
+ # Class Methods
22
+ # ------------------
23
+
24
+ scope :search, lambda { |query| where("LOWER(meta_type) LIKE LOWER('%#{query}%') OR LOWER(meta_key) LIKE LOWER('%#{query}%') OR LOWER(meta_value) LIKE LOWER('%#{query}%')") }
25
+
26
+ # ------------------
27
+ # Instance Methods
28
+ # ------------------
29
+
30
+ # Generic Methods
31
+ # ---------------
32
+
33
+ def display_name
34
+ "#{self.meta_type_was} - #{self.meta_key_was}"
35
+ end
36
+
37
+ # Permission Methods
38
+ # ------------------
39
+
40
+ def can_be_edited?
41
+ status?(:published) or status?(:unpublished)
42
+ end
43
+
44
+ def can_be_deleted?
45
+ status?(:removed)
46
+ end
47
+
48
+ end