egov_utils 0.6.3 → 0.7.0

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: 9b19c8d6e9175e5b472c8b821d611c8cf7e3a19ee1dce31d8056b368bb367fec
4
- data.tar.gz: 5dbcfd93cc21019f96569688aac9023032e9c6900617882b0de4352e87525ce8
3
+ metadata.gz: 585c09c56185466217fcb9c1049174c16ba16a9fc90d234ac02346c941c14968
4
+ data.tar.gz: 3aa699ebeb3b447a91c2496501d60170cb6c24af4eeee4753a57f4dca57fb4e2
5
5
  SHA512:
6
- metadata.gz: 6fcb6a35215f2dbbb0d5468551d21b492d03ee15a5a885758d8ac340cba4cdfed1c0c3d0f9f03b3b7c7e20c171866147e201c42cd82b8e781fbaba8f76e5be5d
7
- data.tar.gz: 3570ce94d514b715bb68016264488bb4f3cfc4a65f11d1deed2a347c90c167442cc4368f11a17485db955d6c9d7f06fdf1d00ea19d95e577a9a81c4fb3eeb25b
6
+ metadata.gz: aac00f0be9b55879ac4012032d64b865dc90ca6c396ec47e24d5473c5231dc1a4cce7497de769fdafa6be13e5b432300b8c9cce7735edcaeaeca42fa6bc0e8dc
7
+ data.tar.gz: a011fdcefb2af10b0810bdcb356969232c22465eb10433113e30a2343747ace35c0ed50c303796128df6d23edbb66f4108fb91ae9af72d8131a9b1cb692135f5
@@ -4,9 +4,9 @@ require_dependency "egov_utils/auth_source"
4
4
  module EgovUtils
5
5
  class UsersController < ApplicationController
6
6
 
7
- skip_before_action :require_login, only: [:new, :create, :confirm]
7
+ skip_before_action :require_login, only: [:new, :create, :confirm, :edit, :update]
8
8
 
9
- load_and_authorize_resource only: [:index, :new, :create, :show, :destroy]
9
+ load_and_authorize_resource only: [:index, :new, :create, :show, :destroy, :edit, :update]
10
10
 
11
11
  def index
12
12
  providers
@@ -46,6 +46,15 @@ module EgovUtils
46
46
  def show
47
47
  end
48
48
 
49
+ def edit
50
+ end
51
+
52
+ def update
53
+ @user.update(update_params)
54
+
55
+ redirect_to users_path, notice: t('activerecord.successful.messages.updated', model: User.model_name.human)
56
+ end
57
+
49
58
  def destroy
50
59
  @user.destroy
51
60
  redirect_to users_path, notice: t('activerecord.successful.messages.destroyed', model: User.model_name.human)
@@ -92,5 +101,9 @@ module EgovUtils
92
101
  params_to_permit << :generate_password if current_user.logged?
93
102
  params.require(:user).permit(*params_to_permit)
94
103
  end
104
+
105
+ def update_params
106
+ params.require(:user).permit(:days_before_inactive)
107
+ end
95
108
  end
96
109
  end
@@ -63,7 +63,16 @@ module EgovUtils
63
63
  end
64
64
  end
65
65
  end
66
- user.update_column(:last_login_at, Time.now) if user && !user.new_record? && user.active?
66
+
67
+ if user && !user.new_record?
68
+ # Check last login
69
+ if user.days_before_inactive && user.last_login_at < (Time.now - user.days_before_inactive.days)
70
+ user.udpate_column(active: false)
71
+ end
72
+
73
+ user.update_column(:last_login_at, Time.now) if user.active?
74
+ end
75
+
67
76
  user
68
77
  end
69
78
 
@@ -14,10 +14,12 @@ module EgovUtils
14
14
  all.detect{ |o| o.key == key }
15
15
  end
16
16
 
17
- def self.courts(organization_keys=nil)
17
+ def self.courts(organization_keys=nil, include_branches: true)
18
18
  all.select do |o|
19
19
  %w{OS KS MS}.include?(o.category_abbrev) &&
20
20
  (organization_keys.nil? || organization_keys.include?(o.key))
21
+ end.tap do |collection|
22
+ collection.select { _1.branch_of_id.nil? } unless include_branches
21
23
  end
22
24
  end
23
25
 
@@ -34,9 +36,10 @@ module EgovUtils
34
36
  where(key: key).first
35
37
  end
36
38
 
37
- def self.courts(organization_keys=nil)
39
+ def self.courts(organization_keys=nil, include_branches: true)
38
40
  filters = {category_abbrev: ['OS','KS', 'MS']}
39
41
  filters.merge!(key: organization_keys) if organization_keys.present?
42
+ filters.merge!(branch_of_id: [nil]) unless include_branches
40
43
  all(params: {f: filters, sort: {'0' => {path: 'category_abbrev'} }})
41
44
  end
42
45
 
@@ -98,25 +98,27 @@ $ ->
98
98
  <% schema.columns.each do |col| %>
99
99
  <%= raw column_for_grid(grid, col) %>
100
100
  <% end %>
101
- <% if can?(:update, schema.model) || (local_assigns.fetch(:allow_delete, false) && can?(:destroy, schema.model)) %>
102
- {
103
- width: 150
104
- title: "<%= t('label_actions') %>"
105
- buttons: [
106
- <% if can?(:read, schema.model) %>
107
- <% local_assigns.fetch(:downloads, {}).each do |format, label| %>
108
- { cls: 'btn btn-sm btn-secondary <%= "download-button-#{format}" %>', caption: '<%= label %>', click: prepareDownload('<%= format %>') },
101
+ <% unless local_assigns.fetch(:disable_actions, false) %>
102
+ <% if can?(:update, schema.model) || (local_assigns.fetch(:allow_delete, false) && can?(:destroy, schema.model)) %>
103
+ {
104
+ width: 150
105
+ title: "<%= t('label_actions') %>"
106
+ buttons: [
107
+ <% if can?(:read, schema.model) %>
108
+ <% local_assigns.fetch(:downloads, {}).each do |format, label| %>
109
+ { cls: 'btn btn-sm btn-secondary <%= "download-button-#{format}" %>', caption: '<%= label %>', click: prepareDownload('<%= format %>') },
110
+ <% end %>
109
111
  <% end %>
110
- <% end %>
111
- <% if can?(:update, schema.model) %>
112
- {cls: 'btn btn-sm btn-primary', caption: '<%= t('label_edit') %>', click: editRecord},
113
- <% end %>
114
- <%= additional_grid_edit_buttons(schema) %>
115
- <% if local_assigns.fetch(:allow_delete, false) && can?(:destroy, schema.model) %>
116
- {commandName: 'delete', caption: '<%= t('label_delete') %>'}
117
- <% end %>
118
- ]
119
- }
112
+ <% if can?(:update, schema.model) %>
113
+ {cls: 'btn btn-sm btn-primary', caption: '<%= t('label_edit') %>', click: editRecord},
114
+ <% end %>
115
+ <%= additional_grid_edit_buttons(schema) %>
116
+ <% if local_assigns.fetch(:allow_delete, false) && can?(:destroy, schema.model) %>
117
+ {commandName: 'delete', caption: '<%= t('label_delete') %>'}
118
+ <% end %>
119
+ ]
120
+ }
121
+ <% end %>
120
122
  <% end %>
121
123
  ],
122
124
  sorting:
@@ -23,6 +23,8 @@
23
23
  = button_to(t('label_delete'), user_path(user), method: :delete, class: 'btn btn-warning btn-sm')
24
24
  - if can?(:manage, user) && user.password_change_possible?
25
25
  = link_to(t('label_change_password'), new_password_path(user), class: 'btn btn-secondary btn-sm')
26
+ - if can?(:edit, user)
27
+ = link_to(t('label_edit'), edit_user_path(user), class: 'btn btn-secondary btn-sm')
26
28
  - unless user.active?
27
29
  = button_to(t('label_approve'), approve_user_path(user), class: 'btn btn-primary btn-sm')
28
30
 
@@ -0,0 +1,4 @@
1
+ = bootstrap_form_for(@user) do |f|
2
+ = f.text_field :days_before_inactive
3
+ .form-actions
4
+ = f.submit
@@ -90,6 +90,7 @@ cs:
90
90
 
91
91
  model_attributes: &my_attributes
92
92
  egov_utils/user:
93
+ days_before_inactive: Počet dní od posledního přihlášení před deaktivací
93
94
  login: Přihlašovací email
94
95
  mail: E-mail
95
96
  password_confirmation: Potvrzení hesla
@@ -137,6 +138,7 @@ cs:
137
138
 
138
139
  model_help_messages: &my_help_messages
139
140
  egov_utils/user:
141
+ days_before_inactive: Pokud ponecháte pole prázdné, uživatelský účet nebude expirovat.
140
142
  generate_password: Heslo bude vygenerováno a posláno uživateli na e-mail, při prvním přihlášení bude heslo muset změnit.
141
143
 
142
144
 
@@ -154,6 +156,8 @@ cs:
154
156
  mail: E-mailová adresa
155
157
 
156
158
  submits: &my_submits
159
+ user:
160
+ update: Aktualizovat uživatele
157
161
  password_change:
158
162
  submit: Změnit heslo
159
163
 
@@ -0,0 +1,5 @@
1
+ class AddDaysBeforeInactiveToEgovUtilsUsers < ActiveRecord::Migration[6.1]
2
+ def change
3
+ add_column :egov_utils_users, :days_before_inactive, :integer, default: 365
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module EgovUtils
2
- VERSION = '0.6.3'
2
+ VERSION = '0.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egov_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Ezr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-29 00:00:00.000000000 Z
11
+ date: 2022-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -581,6 +581,7 @@ files:
581
581
  - app/views/egov_utils/users/_form.html.haml
582
582
  - app/views/egov_utils/users/_ldap_search.html.haml
583
583
  - app/views/egov_utils/users/_users_tab.html.haml
584
+ - app/views/egov_utils/users/edit.html.haml
584
585
  - app/views/egov_utils/users/index.html.haml
585
586
  - app/views/egov_utils/users/new.html.haml
586
587
  - app/views/egov_utils/users/show.html.haml
@@ -613,6 +614,7 @@ files:
613
614
  - db/migrate/20180403141531_join_people_tables.rb
614
615
  - db/migrate/20180403150556_create_egov_utils_legal_people.rb
615
616
  - db/migrate/20180424143207_add_titles_to_natural_people.rb
617
+ - db/migrate/20220331113917_add_days_before_inactive_to_egov_utils_users.rb
616
618
  - lib/azahara_schema_currency.rb
617
619
  - lib/azahara_schema_currency/aggregation_attribute_patch.rb
618
620
  - lib/azahara_schema_currency/association_attribute_patch.rb