egov_utils 0.1.18 → 0.1.19

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
  SHA256:
3
- metadata.gz: 645db7eb940442f396800108992bba65e51e538f37f813ace77d2c6e2834fa62
4
- data.tar.gz: e5e345da32a0ca06f627ee8be1fe623eb8f4c67491946a1e58067f6e75195c34
3
+ metadata.gz: 32bbbdd34a0a8981f2000387b993c342e209e88237a230a85ea2262a4d515aa3
4
+ data.tar.gz: 2da793eaa12459a2cde485f4f849aaf342ab0f2aa4a21a031b8859540fa3e734
5
5
  SHA512:
6
- metadata.gz: 6cde297896021821c290807c06ca689e145e1da3d96d1af1c4d654e1263bb2ff94f874eda73a2c079ded8d0f1050eb8c36ca9d79966aee0c1f1ceb564ec20caa
7
- data.tar.gz: 34ea0683107c72945a89726ea377145d75c1f966d41ec1b8600e2204b08fe9693a9d014f461db5483f7c90f720148e89459c98818e33f179b9d383bf049ea8c1
6
+ metadata.gz: 95f36315e2c902ea4ff7acd9936ffaa0a04a8b8e4935ddcff4fe3ffd54c9d84e9233faa257ecf5ab0cba108d24f912f56126771502f5c930b7a364d22f6d0535
7
+ data.tar.gz: f4f497a24f9024f01213dd3375fd65828a2a84e86bea6aa1c7436436eeb1feeeec9fe60eaca1a9a0d2395edd5ca4989a58bacab1e46aeb0bacfcf8b18ea3c31b
@@ -23,6 +23,10 @@ window.eGovUtilities =
23
23
  eGovUtilities.initDatepickers($container)
24
24
  eGovUtilities.initSelect2($container)
25
25
 
26
+ clearBeforeCache: ($container)->
27
+ $container ||= $(document)
28
+ eGovUtilities.destroySelect2($container)
29
+
26
30
  initDatepickers: ($container)->
27
31
  $container ||= $(document)
28
32
  if !Modernizr.inputtypes.date
@@ -37,8 +41,11 @@ window.eGovUtilities =
37
41
 
38
42
  initSelect2: ($container)->
39
43
  $container ||= $(document)
40
- $('[data-provide="select2"]', $container).each (i, el)->
41
- $(el).select2()
44
+ $('[data-provide="select2"]', $container).select2()
45
+
46
+ destroySelect2: ($container)->
47
+ $container ||= $(document)
48
+ $('[data-provide="select2"]', $container).select2('destroy')
42
49
 
43
50
 
44
51
  initModal: (modalId, options)->
@@ -91,3 +98,7 @@ window.eGovUtilities =
91
98
  $(eGovUtilities.setup)
92
99
  $(document).on 'turbolinks:load', (evt)->
93
100
  eGovUtilities.initPage()
101
+
102
+ $(document).on 'turbolinks:before-cache', (evt)->
103
+ eGovUtilities.clearBeforeCache()
104
+
@@ -4,6 +4,10 @@ module EgovUtils
4
4
  validates :name, presence: true, uniqueness: true
5
5
  validates :ldap_uid, uniqueness: true, allow_nil: true
6
6
 
7
+ def self.organizations_by_domains(domains)
8
+ EgovUtils::Organization.where(domain: domains)
9
+ end
10
+
7
11
  def members
8
12
 
9
13
  end
@@ -23,7 +27,11 @@ module EgovUtils
23
27
  end
24
28
 
25
29
  def external_uid
26
- super || auth_source.send(:get_group_dn, sid: ldap_uid)
30
+ super || ( ldap? && ldap_uid && auth_source.send(:get_group_dn, sid: ldap_uid) )
31
+ end
32
+
33
+ def ldap_dn
34
+ ldap? && external_uid
27
35
  end
28
36
 
29
37
  end
@@ -16,5 +16,36 @@ module EgovUtils
16
16
  def auth_source
17
17
  @auth_source ||= EgovUtils::AuthSource.new(provider) if provider.present?
18
18
  end
19
+
20
+ def ldap?
21
+ !!auth_source
22
+ end
23
+
24
+ def ldap_dn
25
+ raise NotImplementedError
26
+ end
27
+
28
+ def ldap_domain
29
+ ldap? && ldap_dn.scan(/dc=([^,]*)/i).flatten.join('.')
30
+ end
31
+
32
+ def organization_by_domain(ldap_domain=self.ldap_domain)
33
+ @organization_by_domain ||= EgovUtils::Organization.where(domain: ldap_domain).first if ldap_domain
34
+ end
35
+
36
+ def organization_key
37
+ organization_by_domain.try(:key)
38
+ end
39
+
40
+ def organization_id(organization_key=self.organization_key)
41
+ EgovUtils::Organization.find_by_key(organization_key).try(:id)
42
+ end
43
+
44
+ def organization_with_suborganizations_keys(organization_key=self.organization_key)
45
+ return [] unless organization_key
46
+ Rails.cache.fetch("organizations/#{organization_key}/org_with_suborgs_keys") do
47
+ [organization_key] + ( organization_key && EgovUtils::Organization.where(superior_id: organization_id(organization_key)).collect(&:key) || [] )
48
+ end
49
+ end
19
50
  end
20
51
  end
@@ -111,7 +111,7 @@ module EgovUtils
111
111
  end
112
112
 
113
113
  def ldap_dn
114
- @ldap_dn = auth_source.send(:get_user_dn, login)[:dn]
114
+ @ldap_dn ||= auth_source.send(:get_user_dn, login)[:dn]
115
115
  end
116
116
 
117
117
  def ldap_groups
@@ -0,0 +1,15 @@
1
+ module EgovUtils
2
+ class Love < ActiveResource::Base
3
+
4
+ def self.config
5
+ YAML.load_file(Rails.root.join('config', 'config.yml'))
6
+ end
7
+
8
+ self.site = "#{config['love_url'] || Rails.configuration.try(:love_url)}/api/v1/"
9
+
10
+ def self.where(clauses = {})
11
+ raise ArgumentError, "expected a clauses Hash, got #{clauses.inspect}" unless clauses.is_a? Hash
12
+ find(:all, params: {f: clauses})
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module EgovUtils
2
+ class Organization < Love
3
+
4
+ def self.find_by_key(key)
5
+ where(key: key).first
6
+ end
7
+
8
+ def self.courts(organization_keys)
9
+ filters = {category_abbrev: ['OS','KS']}
10
+ filters.merge!(key: organization_keys) if organization_keys.present?
11
+ all(params: {f: filters, sort: {'0' => {path: 'category_abbrev'} }})
12
+ end
13
+
14
+ end
15
+ end
@@ -3,6 +3,12 @@ cs:
3
3
  time:
4
4
  formats:
5
5
  default: "%a %d. %B %Y %H:%M"
6
+ time: "%H:%M"
7
+
8
+ bootstrap:
9
+ file_input:
10
+ placeholder: 'Vyberte soubor...'
11
+ button_label: Procházet
6
12
 
7
13
  ministery_justice_name: Ministerstvo spravedlnosti ČR
8
14
  label_no_records: Žádné záznamy k zobrazení
@@ -21,6 +27,7 @@ cs:
21
27
  label_logout: Odhlásit
22
28
  label_signup: Registrovat
23
29
  label_validate_address: Zvalidovat
30
+ label_save: Uložit
24
31
 
25
32
  text_born_on_at: "Narozen %{date} v %{place}"
26
33
 
@@ -46,6 +53,7 @@ cs:
46
53
  password_confirmation: Potvrzení hesla
47
54
  firstname: Jméno
48
55
  lastname: Příjmení
56
+ fullname: Jméno a příjmení
49
57
  egov_utils/address:
50
58
  full_address: Adresa
51
59
  street: Ulice
@@ -0,0 +1,14 @@
1
+ module BootstrapForm
2
+ module CustomFileField
3
+
4
+ def custom_file_field(name, *args)
5
+ options = args.extract_options!.symbolize_keys!
6
+ args << options
7
+ form_group_builder(name, options.reverse_merge(control_class: nil)) do
8
+ html = file_field_without_bootstrap(name, options.merge(class: 'custom-file-input')) + " " + content_tag('span', '', class: ['custom-file-control', options[:class]].compact.join(' '))
9
+ label('', html, class: "custom-file form-control")
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -3,6 +3,7 @@ require 'cancancan'
3
3
  require 'audited'
4
4
  require 'azahara_schema'
5
5
 
6
+ require 'font-awesome-sass'
6
7
  require 'modernizr-rails'
7
8
 
8
9
  module EgovUtils
@@ -73,6 +74,7 @@ module EgovUtils
73
74
  require 'bootstrap_form/datetimepicker'
74
75
  require 'bootstrap_form/fileuid'
75
76
  require 'bootstrap_form/select2'
77
+ require 'bootstrap_form/custom_file_field'
76
78
  BootstrapForm::Helpers::Bootstrap.__send__(:prepend, BootstrapForm::Helpers::Bootstrap4)
77
79
 
78
80
  BootstrapForm::DATE_FORMAT = 'DD/MM/YYYY'
@@ -81,6 +83,7 @@ module EgovUtils
81
83
  BootstrapForm::FormBuilder.__send__(:prepend, BootstrapForm::Datetimepicker)
82
84
  BootstrapForm::FormBuilder.__send__(:prepend, BootstrapForm::Fileuid)
83
85
  BootstrapForm::FormBuilder.__send__(:prepend, BootstrapForm::Select2)
86
+ BootstrapForm::FormBuilder.__send__(:prepend, BootstrapForm::CustomFileField)
84
87
 
85
88
  ActionView::Helpers::Tags::DateField.redefine_method(:format_date) do |value|
86
89
  value.try(:strftime, ruby_format_string)
@@ -1,3 +1,3 @@
1
1
  module EgovUtils
2
- VERSION = '0.1.18'
2
+ VERSION = '0.1.19'
3
3
  end
@@ -0,0 +1,12 @@
1
+ $custom-file-text: (
2
+ placeholder: (
3
+ <% I18n.available_locales.each do |locale| %>
4
+ '<%= locale %>': "<%= I18n.t('bootstrap.file_input.placeholder', locale: locale, default: 'Choose file...') %>",
5
+ <% end %>
6
+ ),
7
+ button-label: (
8
+ <% I18n.available_locales.each do |locale| %>
9
+ '<%= locale %>': "<%= I18n.t('bootstrap.file_input.button_label', locale: locale, default: 'Browse') %>",
10
+ <% end %>
11
+ )
12
+ );
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.1.18
4
+ version: 0.1.19
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: 2017-11-28 00:00:00.000000000 Z
11
+ date: 2017-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: 4.0.0.beta
181
+ - !ruby/object:Gem::Dependency
182
+ name: sass-rails
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '5.0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '5.0'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: font-awesome-sass
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -327,6 +341,8 @@ files:
327
341
  - app/models/egov_utils/person.rb
328
342
  - app/models/egov_utils/principal.rb
329
343
  - app/models/egov_utils/user.rb
344
+ - app/resources/egov_utils/love.rb
345
+ - app/resources/egov_utils/organization.rb
330
346
  - app/schemas/egov_utils/address_schema.rb
331
347
  - app/schemas/egov_utils/person_schema.rb
332
348
  - app/schemas/egov_utils/user_schema.rb
@@ -367,6 +383,7 @@ files:
367
383
  - db/migrate/20171103141234_add_birth_place_and_residence_to_people.rb
368
384
  - db/migrate/20171109172909_add_external_uid_to_groups.rb
369
385
  - db/migrate/20171115142450_add_confirmation_code_to_users.rb
386
+ - lib/bootstrap_form/custom_file_field.rb
370
387
  - lib/bootstrap_form/datetimepicker.rb
371
388
  - lib/bootstrap_form/fileuid.rb
372
389
  - lib/bootstrap_form/helpers/bootstrap4.rb
@@ -474,6 +491,7 @@ files:
474
491
  - vendor/assets/javascripts/select2/i18n/zh-TW.js
475
492
  - vendor/assets/javascripts/select2/select2.js
476
493
  - vendor/assets/javascripts/shieldui-all.min.js
494
+ - vendor/assets/stylesheets/egov_utils/_bootstrap_variables.scss.erb
477
495
  - vendor/assets/stylesheets/select2/select2-bootstrap.css
478
496
  - vendor/assets/stylesheets/select2/select2.css
479
497
  - vendor/assets/stylesheets/shield-custom/all.scss
@@ -503,7 +521,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
503
521
  version: '0'
504
522
  requirements: []
505
523
  rubyforge_project:
506
- rubygems_version: 2.7.2
524
+ rubygems_version: 2.7.3
507
525
  signing_key:
508
526
  specification_version: 4
509
527
  summary: The eGoverment utilities is set of functionalities to support basic eGoverment