usman 0.4.0.pre.materialize → 0.4.1.pre.materialize

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 249944b38740618e19948df32b3b5efb35c4d3c5bc40df91cd17f06804fc6b90
4
- data.tar.gz: 9f14a4c2d4903e35072317db1bf5a687f217ac39a645b22a01dcfd700fb7cce3
3
+ metadata.gz: '01738b467cef0b1a62c4a02c0340955020aef2e7ea3a5be0fddc8d086eab16fa'
4
+ data.tar.gz: bacd00ee623cd2bcb03c96a4a85efde6dc0eb7ec8f4feb4023858984d53f58c7
5
5
  SHA512:
6
- metadata.gz: ed66807d187066a743ec189bc900ebb3861275e1e7bdcb0849ebd997f4e6f61aae77b4200cbcedd061daa0ef8ca51b8aab243789108f341423c2fb1402ba10ef
7
- data.tar.gz: d2a1487af1403b6212739e49a9baf9b771582fdd4e7f3214de4784808f89499ad18ad26ff4e57b3f24170571284eee58d785e99732219c30a9dbcbaa2abd37b0
6
+ metadata.gz: 628102828b6f5050241df26ee76c8a958242eb727cd540282cb9333e8532b5da5c26c062d3f7aca1fc1687642c0f566bb03238e0e99805cbbb8da4a5fb8f23fa
7
+ data.tar.gz: 8f55d8fd594ab5af9bd566d38c253372a9927c818c2c34399040a324f7f76ea0dc9588cad39c7605fd2fcf0f4b2db2a5f30be1b17d6ee6e59b73c443935a9048
@@ -12,6 +12,8 @@ module Usman
12
12
  @user.approve!
13
13
  when "suspended"
14
14
  @user.suspend!
15
+ when "deleted"
16
+ @user.delete!
15
17
  end
16
18
  set_notification(true, I18n.t('status.success'), I18n.t('state.changed', item: default_item_name.titleize, new_state: @r_object.status))
17
19
  render_row
@@ -15,7 +15,10 @@ module Usman
15
15
  end
16
16
 
17
17
  def permission_denied
18
- render :file => "layouts/kuppayam/xenon/401", layout: 'layouts/kuppayam/xenon/blank_with_nav', :status => :unauthorized
18
+ file_path = "layouts/kuppayam/#{@current_layout}/401"
19
+ layout_path = "layouts/kuppayam/#{@current_layout}/blank_with_nav"
20
+
21
+ render :file => file_path, layout: layout_path, :status => :unauthorized
19
22
  end
20
23
 
21
24
  # Returns the default URL to which the system should redirect the user after successful authentication
data/app/models/user.rb CHANGED
@@ -102,6 +102,7 @@ class User < Usman::ApplicationRecord
102
102
 
103
103
  scope :status, lambda { |status| where("LOWER(status)='#{status}'") }
104
104
 
105
+ scope :pending_or_approved, -> { where(status: [PENDING, APPROVED]) }
105
106
  scope :pending, -> { where(status: PENDING) }
106
107
  scope :approved, -> { where(status: APPROVED) }
107
108
  scope :suspended, -> { where(status: SUSPENDED) }
@@ -120,17 +121,17 @@ class User < Usman::ApplicationRecord
120
121
 
121
122
  return if hsh[:name].blank?
122
123
 
123
- user = User.find_by_username(hsh[:username]) || User.new
124
- user.name = hsh[:name]
125
- user.username = hsh[:username]
126
- user.designation_name = hsh[:designation_name]
127
- user.organisation_name = hsh[:organisation_name]
128
- user.email = hsh[:email]
129
- user.phone = hsh[:phone]
124
+ user = User.find_by_username(hsh[:username].to_s.strip) || User.new
125
+ user.name = hsh[:name].to_s.strip
126
+ user.username = hsh[:username].to_s.strip
127
+ user.designation_name = hsh[:designation_name].to_s.strip
128
+ user.organisation_name = hsh[:organisation_name].to_s.strip
129
+ user.email = hsh[:email].to_s.strip
130
+ user.phone = hsh[:phone].to_s.strip
130
131
 
131
132
  user.super_admin = ["true", "t","1","yes","y"].include?(hsh[:super_admin].to_s.downcase.strip)
133
+ user.status = hsh[:status].to_s.strip == "" ? APPROVED : hsh[:status].to_s.strip
132
134
 
133
- user.status = hsh[:status]
134
135
  user.assign_default_password
135
136
 
136
137
  # Initializing error hash for displaying all errors altogether
@@ -214,11 +215,11 @@ class User < Usman::ApplicationRecord
214
215
  end
215
216
 
216
217
  else
217
- puts "Unsupported File encountered'#{path.to_s}'.".red if verbose
218
+ puts "Unsupported File encountered'#{csv_path.to_s}'.".red if verbose
218
219
  return
219
220
  end
220
221
  else
221
- puts "Import File not found at '#{path.to_s}'.".red if verbose
222
+ puts "Import File not found at '#{csv_path.to_s}'.".red if verbose
222
223
  end
223
224
  end
224
225
  end
@@ -413,7 +414,7 @@ class User < Usman::ApplicationRecord
413
414
  end
414
415
 
415
416
  def can_be_marked_as_pending?
416
- approved? or suspended?
417
+ approved? or suspended? or deleted?
417
418
  end
418
419
 
419
420
  def can_be_suspended?
@@ -421,7 +422,7 @@ class User < Usman::ApplicationRecord
421
422
  end
422
423
 
423
424
  def can_be_deleted?
424
- suspended?
425
+ suspended? or pending?
425
426
  end
426
427
 
427
428
  def can_be_edited?
@@ -554,6 +555,14 @@ class User < Usman::ApplicationRecord
554
555
  self.dummy = true
555
556
  end
556
557
 
558
+ def display_last_signed_in
559
+ if self.current_sign_in_at
560
+ self.current_sign_in_at.strftime("%b %d %Y - %H:%M:%S")
561
+ elsif self.last_sign_in_at
562
+ self.last_sign_in_at.strftime("%b %d %Y - %H:%M:%S")
563
+ end
564
+ end
565
+
557
566
  # Image Configuration
558
567
  # -------------------
559
568
  def image_configuration
@@ -109,7 +109,7 @@ namespace 'usman' do
109
109
  destroy_all = false
110
110
  destroy_all = true if ["true", "t","1","yes","y"].include?(ENV["destroy_all"].to_s.downcase.strip)
111
111
 
112
- path = Rails.root.join('db', 'data', "users_roles.csv")
112
+ path = Rails.root.join('db', 'data', 'dummy', "users_roles.csv")
113
113
  path = Usman::Engine.root.join('db', 'data', 'dummy', "users_roles.csv") unless File.exists?(path)
114
114
 
115
115
  # FIXME - Don't know how to clean up a HABTM intermediate table contents
data/lib/usman/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Usman
2
- VERSION = '0.4.0-materialize'
2
+ VERSION = '0.4.1.pre.materialize'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usman
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.pre.materialize
4
+ version: 0.4.1.pre.materialize
5
5
  platform: ruby
6
6
  authors:
7
7
  - kpvarma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-28 00:00:00.000000000 Z
11
+ date: 2018-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -102,42 +102,30 @@ dependencies:
102
102
  name: kuppayam
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - "~>"
106
- - !ruby/object:Gem::Version
107
- version: '0.1'
108
- - - ">="
105
+ - - '='
109
106
  - !ruby/object:Gem::Version
110
- version: 0.1.39
107
+ version: 0.2.1.pre.materialize
111
108
  type: :runtime
112
109
  prerelease: false
113
110
  version_requirements: !ruby/object:Gem::Requirement
114
111
  requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '0.1'
118
- - - ">="
112
+ - - '='
119
113
  - !ruby/object:Gem::Version
120
- version: 0.1.39
114
+ version: 0.2.1.pre.materialize
121
115
  - !ruby/object:Gem::Dependency
122
116
  name: pattana
123
117
  requirement: !ruby/object:Gem::Requirement
124
118
  requirements:
125
- - - "~>"
126
- - !ruby/object:Gem::Version
127
- version: '0.1'
128
- - - ">="
119
+ - - '='
129
120
  - !ruby/object:Gem::Version
130
- version: 0.1.25
121
+ version: 0.2.1.pre.materialize
131
122
  type: :runtime
132
123
  prerelease: false
133
124
  version_requirements: !ruby/object:Gem::Requirement
134
125
  requirements:
135
- - - "~>"
136
- - !ruby/object:Gem::Version
137
- version: '0.1'
138
- - - ">="
126
+ - - '='
139
127
  - !ruby/object:Gem::Version
140
- version: 0.1.25
128
+ version: 0.2.1.pre.materialize
141
129
  - !ruby/object:Gem::Dependency
142
130
  name: bcrypt
143
131
  requirement: !ruby/object:Gem::Requirement