usman 0.3.16 → 0.3.17

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fcb08b50e5aac2d8a62c1a061964395c71374ac
4
- data.tar.gz: 0cebc15bf191aa323cd08a521b1c4562f2b60c3b
3
+ metadata.gz: 90dfdf38247634fc306990e8614e7b571ddfed8e
4
+ data.tar.gz: 89b40578094348208a655d7ae5b0d977aa1d05fc
5
5
  SHA512:
6
- metadata.gz: e5f8bcf10af040d0eed3f78fe66e68d827147ff6f4e82ec08bef2f5c0bc02afffa3fd275973835c332d340691aca060dc121b943f94053b1db1091415ae111f4
7
- data.tar.gz: 0aa4637f4fba44a2b238b4286d26dca60f0d1c78d7f5c5f823a7337ce357f187625a75b8f945e88d0528b081caafa060113b0be0dbd399f28d1d7d8bab5a7258
6
+ metadata.gz: a1f99d78c63f5b3f8efc4b9c04bc66457610b0146ca7be7ada4b1b46fa556dbdc3f1a89166521488ecc6611c5b51154822cba8a744c6365fdb5433e003ffbcc5
7
+ data.tar.gz: d5e8a76b833fb16eb6d3ad68582aea50ccb77a19f1d3f0e5c49df030138b6333f46ace0d7288eac6ef141fd60d4948cd9beeaecd50ae14ad000ede8e36cc25f5
@@ -5,13 +5,18 @@ module Usman
5
5
 
6
6
  private
7
7
 
8
+ def get_resource
9
+ @r_object = @resource_options[:class].find_by_id(params[:id])
10
+ @r_object.categorisable = false if params[:action] == "update"
11
+ end
12
+
8
13
  def get_collections
9
14
  @relation = Feature.where("")
10
15
 
11
16
  parse_filters
12
17
  apply_filters
13
18
 
14
- @features = @r_objects = @relation.includes(:feature_image).page(@current_page).per(@per_page)
19
+ @features = @r_objects = @relation.page(@current_page).per(@per_page)
15
20
 
16
21
  return true
17
22
  end
@@ -1,31 +1,16 @@
1
1
  class Feature < Usman::ApplicationRecord
2
2
 
3
- # Constants
4
- PUBLISHED = "published"
5
- UNPUBLISHED = "unpublished"
6
- DISABLED = "disabled"
7
-
8
- STATUS = {
9
- PUBLISHED => "Published",
10
- UNPUBLISHED => "Un-Published",
11
- DISABLED => "Disabled"
12
- }
13
-
14
- STATUS_REVERSE = {
15
- "Published" => PUBLISHED,
16
- "Un-Published" => UNPUBLISHED,
17
- "Disabled" => DISABLED
18
- }
19
-
20
- # Associations
3
+ # Including the State Machine Methods
4
+ include Publishable
5
+
6
+ # Associations
21
7
  has_many :permissions
22
8
  has_many :users, through: :permissions
23
- has_one :feature_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::FeatureImage"
9
+ # has_one :feature_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::FeatureImage"
24
10
 
25
11
  # Validations
26
12
  validates :name, presence: true, length: {minimum: 3, maximum: 250}
27
- validates :status, :presence => true, :inclusion => {:in => STATUS.keys, :presence_of => :status, :message => "%{value} is not a valid status" }
28
-
13
+
29
14
  # ------------------
30
15
  # Class Methods
31
16
  # ------------------
@@ -38,14 +23,8 @@ class Feature < Usman::ApplicationRecord
38
23
  scope :search, lambda {|query| where("LOWER(name) LIKE LOWER('%#{query}%')")
39
24
  }
40
25
 
41
- scope :status, lambda { |status| where("LOWER(status)='#{status}'") }
42
-
43
26
  scope :categorisable, -> { where(categorisable: true) }
44
27
 
45
- scope :unpublished, -> { where(status: UNPUBLISHED) }
46
- scope :published, -> { where(status: PUBLISHED) }
47
- scope :disabled, -> { where(status: DISABLED) }
48
-
49
28
  def self.save_row_data(hsh)
50
29
 
51
30
  # Initializing error hash for displaying all errors altogether
@@ -77,60 +56,6 @@ class Feature < Usman::ApplicationRecord
77
56
  # Instance Methods
78
57
  # ------------------
79
58
 
80
- # Status Methods
81
- # --------------
82
-
83
- # * Return true if the user is not published, else false.
84
- # == Examples
85
- # >>> feature.published?
86
- # => true
87
- def published?
88
- (status == PUBLISHED)
89
- end
90
-
91
- # * Return true if the user is unpublished, else false.
92
- # == Examples
93
- # >>> feature.unpublished?
94
- # => true
95
- def unpublished?
96
- (status == UNPUBLISHED)
97
- end
98
-
99
- # * Return true if the user is disabled, else false.
100
- # == Examples
101
- # >>> feature.disabled?
102
- # => true
103
- def disabled?
104
- (status == DISABLED)
105
- end
106
-
107
- # change the status to :unpublished
108
- # Return the status
109
- # == Examples
110
- # >>> feature.unpublish!
111
- # => "unpublished"
112
- def unpublish!
113
- self.update_attribute(:status, UNPUBLISHED)
114
- end
115
-
116
- # change the status to :published
117
- # Return the status
118
- # == Examples
119
- # >>> feature.publish!
120
- # => "published"
121
- def publish!
122
- self.update_attribute(:status, PUBLISHED)
123
- end
124
-
125
- # change the status to :suspended
126
- # Return the status
127
- # == Examples
128
- # >>> feature.disable!
129
- # => "disabled"
130
- def disable!
131
- self.update_attribute(:status, DISABLED)
132
- end
133
-
134
59
  # Permission Methods
135
60
  # ------------------
136
61
 
@@ -142,18 +67,6 @@ class Feature < Usman::ApplicationRecord
142
67
  true
143
68
  end
144
69
 
145
- def can_be_published?
146
- unpublished? or disabled?
147
- end
148
-
149
- def can_be_unpublished?
150
- published? or disabled?
151
- end
152
-
153
- def can_be_disabled?
154
- published? or unpublished?
155
- end
156
-
157
70
  # Other Methods
158
71
  # -------------
159
72
 
@@ -3,7 +3,6 @@
3
3
  <thead>
4
4
  <tr>
5
5
  <th style="text-align: center;width:60px">#</th>
6
- <!-- <th style="text-align: center;width:100px"><i class="fa fa-photo"></i></th> -->
7
6
  <th>Name</th>
8
7
  <th>Class Name</th>
9
8
  <th>Categorisable</th>
@@ -26,67 +25,21 @@
26
25
  <% end %>
27
26
  </th>
28
27
 
29
- <!-- <td class="feature-image" style="text-align: center;">
30
- <%#= link_to(feature_path(feature), remote: true) do %>
31
- <%#= display_image(feature, "feature_image.image.small.url", width: "32", height: "auto", class: "img-rectangle", alt: feature.display_name) %>
32
- <% #end %>
33
- </td> -->
34
-
35
- <td class="feature-name"><%= link_to feature.display_name, feature_path(feature), remote: true %></td>
28
+ <td class="feature-name"><%= link_to feature.display_name, feature_path(feature), remote: true %></td>
36
29
 
37
30
  <td class="feature-name"><%= link_to feature.name, feature_path(feature), remote: true %></td>
38
31
 
39
32
  <td><%= feature.display_categorisable %></td>
40
33
 
41
- <td>
42
- <% if feature.unpublished? %>
43
- <span class="ml-5 mt-5 label label-default">Un-Published</span>
44
- <% elsif feature.published? %>
45
- <span class="ml-5 mt-5 label label-success">Published</span>
46
- <% elsif feature.disabled? %>
47
- <span class="ml-5 mt-5 label label-danger">Disabled</span>
48
- <% end %>
49
- </td>
50
-
51
- <% edit_link = edit_feature_path(id: feature.id) %>
52
- <% delete_link = feature_path(id: feature.id) %>
53
-
54
- <% if display_edit_links? %>
55
-
56
- <td class="action-links" style="width:10%">
57
-
58
- <% case feature.status %>
59
- <% when "published" %>
60
- <!-- Un-Publish -->
61
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_feature_path(:id =>feature.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
62
-
63
- <!-- Disable -->
64
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Disable"), update_status_feature_path(:id =>feature.id, :status =>'disabled'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
65
- <% when "unpublished" %>
66
- <!-- Approve -->
67
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_feature_path(:id =>feature.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
68
- <!-- Disable -->
69
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Disable"), update_status_feature_path(:id =>feature.id, :status =>'disabled'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
70
- <% when "disabled" %>
71
- <!-- Un-Publish -->
72
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_feature_path(:id =>feature.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
73
- <!-- Approve -->
74
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_feature_path(:id =>feature.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1",:class=>"feature_status" %>
75
- <% end %>
76
- </td>
77
-
78
- <% end %>
34
+ <td class="hidden-sm hidden-xs"><%= display_publishable_status(feature) %></td>
79
35
 
80
36
  <% if display_manage_links? %>
37
+ <td class="action-links hidden-sm hidden-xs" style="width:10%"><%= display_publishable_links(feature) %></td>
81
38
 
82
- <td class="action-links" style="width:10%">
83
- <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit Feature"), edit_link, :remote=>true, class: "edit" if display_edit_links? %>
84
-
85
- <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" if display_delete_links? %>
86
- </td>
87
-
88
- <% end %>
89
-
39
+ <td class="action-links hidden-sm hidden-xs" style="width:10%">
40
+ <%= display_manage_links(feature, @current_user) %>
41
+ </td>
42
+ <% end %>
90
43
  </tr>
91
44
 
92
45
  <% end %>
@@ -8,65 +8,20 @@
8
8
  <% end %>
9
9
  </th>
10
10
 
11
- <!-- <td class="feature-image" style="text-align: center;">
12
- <%#= link_to(feature_path(feature), remote: true) do %>
13
- <%#= display_image(feature, "feature_image.image.small.url", width: "32", height: "auto", class: "img-rectangle", alt: feature.display_name) %>
14
- <%# end %>
15
- </td> -->
16
-
17
11
  <td class="feature-name"><%= link_to feature.display_name, feature_path(feature), remote: true %></td>
18
-
12
+
19
13
  <td class="feature-name"><%= link_to feature.name, feature_path(feature), remote: true %></td>
20
14
 
21
15
  <td><%= feature.display_categorisable %></td>
22
16
 
23
- <td>
24
- <% if feature.unpublished? %>
25
- <span class="ml-5 mt-5 label label-default">Un-Published</span>
26
- <% elsif feature.published? %>
27
- <span class="ml-5 mt-5 label label-success">Published</span>
28
- <% elsif feature.disabled? %>
29
- <span class="ml-5 mt-5 label label-danger">Disabled</span>
30
- <% end %>
31
- </td>
32
-
33
- <% edit_link = edit_feature_path(id: feature.id) %>
34
- <% delete_link = feature_path(id: feature.id) %>
35
-
36
- <% if display_edit_links? %>
37
-
38
- <td class="action-links" style="width:10%">
39
-
40
- <% case feature.status %>
41
- <% when "published" %>
42
- <!-- Un-Publish -->
43
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_feature_path(:id =>feature.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
44
-
45
- <!-- Disable -->
46
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Disable"), update_status_feature_path(:id =>feature.id, :status =>'disabled'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
47
- <% when "unpublished" %>
48
- <!-- Approve -->
49
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_feature_path(:id =>feature.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
50
- <!-- Disable -->
51
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Disable"), update_status_feature_path(:id =>feature.id, :status =>'disabled'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
52
- <% when "disabled" %>
53
- <!-- Un-Publish -->
54
- <%= link_to raw("<i class=\"fa fa-circle mr-5\"></i> Un-Publish"), update_status_feature_path(:id =>feature.id, :status =>'unpublished'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1", :class=>"feature_status" %>
55
- <!-- Approve -->
56
- <%= link_to raw("<i class=\"fa fa-circle-o mr-5\"></i> Publish"), update_status_feature_path(:id =>feature.id, :status =>'published'), :method =>'PUT', :remote=>true, role: "menuitem", tabindex: "-1",:class=>"feature_status" %>
57
- <% end %>
58
- </td>
59
-
60
- <% end %>
17
+ <td class="hidden-sm hidden-xs"><%= display_publishable_status(feature) %></td>
61
18
 
62
19
  <% if display_manage_links? %>
20
+ <td class="action-links hidden-sm hidden-xs" style="width:10%"><%= display_publishable_links(feature) %></td>
63
21
 
64
- <td class="action-links" style="width:10%">
65
- <%= link_to raw("<i class=\"linecons-pencil\"></i> Edit Feature"), edit_link, :remote=>true, class: "edit" if display_edit_links? %>
66
-
67
- <%= link_to raw("<i class=\"linecons-trash\"></i> Delete"), delete_link, method: :delete, role: "menuitem", tabindex: "-1", data: { confirm: 'Are you sure?' }, :remote=>true, class: "delete" if display_delete_links? %>
22
+ <td class="action-links hidden-sm hidden-xs" style="width:10%">
23
+ <%= display_manage_links(feature, @current_user) %>
68
24
  </td>
69
-
70
25
  <% end %>
71
26
 
72
27
  </tr>
@@ -1,55 +1,48 @@
1
- <% status_hash = {published: "success", unpublished: "default", disabled: "danger"} %>
2
-
3
- <div class="media <%= status_hash[@feature.status.to_sym] %>">
4
-
5
- <div class="pull-left pt-10 pr-10 pb-10" style="width:30%;">
6
- <% if display_edit_links? %>
7
- <%= edit_image(@feature,
8
- "feature_image.image.large.url",
9
- upload_image_link(@feature, :feature_image, nil ),
10
- remove_image_link(@feature, :feature_image, nil ),
11
- image_options: {assoc_name: :feature_image }) %>
12
- <% else %>
13
- <%= display_image(@user, "feature_image.image.large.url", class: "img-inline", alt: @feature.display_name) %>
1
+ <div id="div_blog_post_show">
2
+
3
+ <div class="row">
4
+
5
+ <!-- <div class="col-md-3 col-sm-12 col-xs-12" style="border-right:1px solid #f1f1f1;">
6
+ <%# if display_edit_links? %>
7
+ <%#= edit_image(@feature,
8
+ "feature_image.image.large.url",
9
+ upload_image_link(@feature, :feature_image, nil ),
10
+ remove_image_link(@feature, :feature_image, nil ),
11
+ image_options: {assoc_name: :feature_image }) %>
12
+ <%# else %>
13
+ <%#= display_image(@user, "feature_image.image.large.url", class: "img-inline", alt: @feature.display_name) %>
14
+ <%# end %>
15
+ </div> -->
16
+ <div class="col-md-9 col-sm-12 col-xs-12" style="border-right:1px solid #f1f1f1;">
17
+ <%= theme_panel_heading(@feature.display_name) %>
18
+ <%= theme_panel_sub_heading(@feature.name, "#") %>
19
+ <%= clear_tag(10) %>
20
+ <div class="table-responsive mb-50">
21
+ <table class="table table-striped table-condensed table-bordered">
22
+ <tbody>
23
+
24
+ <tr>
25
+ <th>Created At</th><td><%= @feature.created_at.strftime("%m/%d/%Y - %H:%M:%S") if @feature.created_at %></td>
26
+ </tr>
27
+ <tr>
28
+ <th>Updated At</th><td><%= @feature.updated_at.strftime("%m/%d/%Y - %H:%M:%S") if @feature.updated_at %></td>
29
+ </tr>
30
+
31
+ </tbody>
32
+ </table>
33
+ </div>
34
+ <%= clear_tag(10) %>
35
+ </div>
36
+
37
+ <% if display_manage_links? %>
38
+ <div class="col-md-3 col-sm-12 col-xs-12">
39
+ <%= display_manage_buttons(@feature) %>
40
+ <%= display_publishable_buttons(@feature) %>
41
+ </div>
14
42
  <% end %>
15
43
  </div>
16
44
 
17
- <div class="pull-left ml-10" style="width:65%;">
18
- <h1><%= @feature.name %></h1>
19
- <span class="ml-5 mt-5 label label-<%= status_hash[@feature.status.to_sym] %>"><%= @feature.status.titleize %></span>
20
- <%= clear_tag %>
21
- </div>
22
-
23
- </div>
24
-
25
- <h4 class="mb-20">Technical Details</h4>
26
-
27
- <div class="table-responsive mb-50">
28
- <table class="table table-striped table-condensed table-bordered">
29
- <tbody>
30
-
31
- <tr>
32
- <th>Created At</th><td><%= @feature.created_at.strftime("%m/%d/%Y - %H:%M:%S") if @feature.created_at %></td>
33
- <th>Updated At</th><td><%= @feature.updated_at.strftime("%m/%d/%Y - %H:%M:%S") if @feature.updated_at %></td>
34
- </tr>
35
-
36
- </tbody>
37
- </table>
38
- </div>
39
-
40
- <% if display_manage_links? %>
41
- <div>
42
- <%
43
- edit_link = edit_feature_url(id: @feature.id)
44
- delete_link = feature_url(id: @feature.id)
45
- %>
46
-
47
- <%= link_to raw("<i class=\"fa fa-close mr-5\"></i> <span>Cancel</span>"), "#", onclick: "closeGenericModal();", class: "btn btn-white pull-left" %>
48
-
49
- <%= link_to raw("<i class=\"fa fa-trash mr-5\"></i> <span>Delete</span>"), delete_link, method: :delete, :remote=>true, class: "btn btn-gray pull-right" if display_delete_links? %>
50
-
51
- <%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Edit"), edit_link, method: :get, :remote=>true, class: "btn btn-gray pull-right mr-10" if display_edit_links? %>
52
- </div>
53
- <% end %>
54
-
55
- <%= clear_tag %>
45
+ <%= clear_tag(30) %>
46
+ <%= link_to "Close", "#", onclick: "closeGenericModal();", class: "btn btn-primary pull-right" %>
47
+ <%= clear_tag(10) %>
48
+ </div>
@@ -0,0 +1,5 @@
1
+ class ChangeDisabledToRemovedFeatures < ActiveRecord::Migration[5.1]
2
+ def change
3
+ Feature.where("status = 'disabled'").update_all(status: 'removed')
4
+ end
5
+ end
data/lib/usman/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Usman
2
- VERSION = '0.3.16'
2
+ VERSION = '0.3.17'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.16
4
+ version: 0.3.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - kpvarma
@@ -107,7 +107,7 @@ dependencies:
107
107
  version: '0.1'
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.1.22
110
+ version: 0.1.23
111
111
  type: :runtime
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
@@ -117,7 +117,7 @@ dependencies:
117
117
  version: '0.1'
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 0.1.22
120
+ version: 0.1.23
121
121
  - !ruby/object:Gem::Dependency
122
122
  name: pattana
123
123
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +166,34 @@ dependencies:
166
166
  - - "~>"
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0.8'
169
+ - !ruby/object:Gem::Dependency
170
+ name: state_machines
171
+ requirement: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - "~>"
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ type: :runtime
177
+ prerelease: false
178
+ version_requirements: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - "~>"
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ - !ruby/object:Gem::Dependency
184
+ name: state_machines-activerecord
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ type: :runtime
191
+ prerelease: false
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - "~>"
195
+ - !ruby/object:Gem::Version
196
+ version: '0'
169
197
  - !ruby/object:Gem::Dependency
170
198
  name: aws-sdk-sns
171
199
  requirement: !ruby/object:Gem::Requirement
@@ -547,6 +575,7 @@ files:
547
575
  - db/migrate/20170905041104_add_gender_to_users.rb
548
576
  - db/migrate/20170929083233_add_dummy_to_users.rb
549
577
  - db/migrate/20170929083234_add_categorisable_to_features.rb
578
+ - db/migrate/20170929083235_change_disabled_to_removed_features.rb
550
579
  - lib/tasks/usman/data.rake
551
580
  - lib/tasks/usman/master_data.rake
552
581
  - lib/temp/features.rake