usps-support 0.1.9 → 0.1.10
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 +4 -4
- data/Gemfile.lock +38 -13
- data/Readme.md +10 -0
- data/lib/usps/support/helpers/badges_helper.rb +4 -1
- data/lib/usps/support/models/hq/members/associate_member.rb +20 -0
- data/lib/usps/support/models/hq/members/base_record.rb +11 -0
- data/lib/usps/support/models/hq/members/district_job.rb +20 -0
- data/lib/usps/support/models/hq/members/district_job_description.rb +12 -0
- data/lib/usps/support/models/hq/members/former_member.rb +39 -0
- data/lib/usps/support/models/hq/members/member.rb +71 -0
- data/lib/usps/support/models/hq/members/national_job.rb +20 -0
- data/lib/usps/support/models/hq/members/national_job_description.rb +21 -0
- data/lib/usps/support/models/hq/members/rank.rb +10 -0
- data/lib/usps/support/models/hq/members/squadron_job.rb +24 -0
- data/lib/usps/support/models/hq/members/squadron_job_description.rb +12 -0
- data/lib/usps/support/models/hq/members.rb +17 -0
- data/lib/usps/support/models/hq/shared_record.rb +13 -0
- data/lib/usps/support/models/hq/squadrons/base_record.rb +11 -0
- data/lib/usps/support/models/hq/squadrons/course_report.rb +15 -0
- data/lib/usps/support/models/hq/squadrons/district.rb +30 -0
- data/lib/usps/support/models/hq/squadrons/former_squadron.rb +17 -0
- data/lib/usps/support/models/hq/squadrons/squadron.rb +27 -0
- data/lib/usps/support/models/hq/squadrons/student.rb +19 -0
- data/lib/usps/support/models/hq/squadrons/website.rb +15 -0
- data/lib/usps/support/models/hq/squadrons.rb +13 -0
- data/lib/usps/support/models/hq.rb +13 -0
- data/lib/usps/support/models/toast.rb +93 -0
- data/lib/usps/support/models.rb +1 -0
- data/lib/usps/support/version.rb +1 -1
- metadata +24 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49b491a2df479090ce6e3f9f4d0db9342a926cc4c75b6aa047eb290bbb7963a1
|
|
4
|
+
data.tar.gz: 0faaee14a9d6dcbae7ec321b39168e06e89d3360a5711129c2b2a7edb216be56
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a0639c72d6518d2b67346235f43c75a57ea19f8f25efd707092a9fadc3ad795da3785087b09e380a57aebcdc0c5775cd957e40a222a7dfbec591e93123d2bfcc
|
|
7
|
+
data.tar.gz: 38878bc66a1af321bc7538febaa99a80f951f6ce02b29f3c3ec66f40419cf537f7142159eddf0cc5bb1b83d7783982d4fd95223bf62a287c05af984a2a8e2f48
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
usps-support (0.1.
|
|
4
|
+
usps-support (0.1.10)
|
|
5
5
|
sassc-rails
|
|
6
6
|
usps-imis-api (~> 0.10.4)
|
|
7
7
|
usps-jwt_auth (~> 1.0.0)
|
|
@@ -9,9 +9,9 @@ PATH
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
actionpack (8.
|
|
13
|
-
actionview (= 8.
|
|
14
|
-
activesupport (= 8.
|
|
12
|
+
actionpack (8.0.4)
|
|
13
|
+
actionview (= 8.0.4)
|
|
14
|
+
activesupport (= 8.0.4)
|
|
15
15
|
nokogiri (>= 1.8.5)
|
|
16
16
|
rack (>= 2.2.4)
|
|
17
17
|
rack-session (>= 1.0.1)
|
|
@@ -19,20 +19,20 @@ GEM
|
|
|
19
19
|
rails-dom-testing (~> 2.2)
|
|
20
20
|
rails-html-sanitizer (~> 1.6)
|
|
21
21
|
useragent (~> 0.16)
|
|
22
|
-
actionview (8.
|
|
23
|
-
activesupport (= 8.
|
|
22
|
+
actionview (8.0.4)
|
|
23
|
+
activesupport (= 8.0.4)
|
|
24
24
|
builder (~> 3.1)
|
|
25
25
|
erubi (~> 1.11)
|
|
26
26
|
rails-dom-testing (~> 2.2)
|
|
27
27
|
rails-html-sanitizer (~> 1.6)
|
|
28
|
-
activesupport (8.
|
|
28
|
+
activesupport (8.0.4)
|
|
29
29
|
base64
|
|
30
|
+
benchmark (>= 0.3)
|
|
30
31
|
bigdecimal
|
|
31
32
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
32
33
|
connection_pool (>= 2.2.5)
|
|
33
34
|
drb
|
|
34
35
|
i18n (>= 1.6, < 2)
|
|
35
|
-
json
|
|
36
36
|
logger (>= 1.4.2)
|
|
37
37
|
minitest (>= 5.1)
|
|
38
38
|
securerandom (>= 0.3)
|
|
@@ -40,6 +40,7 @@ GEM
|
|
|
40
40
|
uri (>= 0.13.1)
|
|
41
41
|
ast (2.4.3)
|
|
42
42
|
base64 (0.3.0)
|
|
43
|
+
benchmark (0.5.0)
|
|
43
44
|
bigdecimal (3.3.1)
|
|
44
45
|
builder (3.3.0)
|
|
45
46
|
colorize (1.1.0)
|
|
@@ -52,8 +53,14 @@ GEM
|
|
|
52
53
|
drb (2.2.3)
|
|
53
54
|
erb (5.1.3)
|
|
54
55
|
erubi (1.13.1)
|
|
56
|
+
ffi (1.17.2-aarch64-linux-gnu)
|
|
57
|
+
ffi (1.17.2-aarch64-linux-musl)
|
|
58
|
+
ffi (1.17.2-arm-linux-gnu)
|
|
59
|
+
ffi (1.17.2-arm-linux-musl)
|
|
55
60
|
ffi (1.17.2-arm64-darwin)
|
|
61
|
+
ffi (1.17.2-x86_64-darwin)
|
|
56
62
|
ffi (1.17.2-x86_64-linux-gnu)
|
|
63
|
+
ffi (1.17.2-x86_64-linux-musl)
|
|
57
64
|
fileutils (1.7.3)
|
|
58
65
|
i18n (1.14.7)
|
|
59
66
|
concurrent-ruby (~> 1.0)
|
|
@@ -72,10 +79,22 @@ GEM
|
|
|
72
79
|
crass (~> 1.0.2)
|
|
73
80
|
nokogiri (>= 1.12.0)
|
|
74
81
|
minitest (5.26.0)
|
|
82
|
+
nokogiri (1.18.10-aarch64-linux-gnu)
|
|
83
|
+
racc (~> 1.4)
|
|
84
|
+
nokogiri (1.18.10-aarch64-linux-musl)
|
|
85
|
+
racc (~> 1.4)
|
|
86
|
+
nokogiri (1.18.10-arm-linux-gnu)
|
|
87
|
+
racc (~> 1.4)
|
|
88
|
+
nokogiri (1.18.10-arm-linux-musl)
|
|
89
|
+
racc (~> 1.4)
|
|
75
90
|
nokogiri (1.18.10-arm64-darwin)
|
|
76
91
|
racc (~> 1.4)
|
|
92
|
+
nokogiri (1.18.10-x86_64-darwin)
|
|
93
|
+
racc (~> 1.4)
|
|
77
94
|
nokogiri (1.18.10-x86_64-linux-gnu)
|
|
78
95
|
racc (~> 1.4)
|
|
96
|
+
nokogiri (1.18.10-x86_64-linux-musl)
|
|
97
|
+
racc (~> 1.4)
|
|
79
98
|
parallel (1.27.0)
|
|
80
99
|
parser (3.3.10.0)
|
|
81
100
|
ast (~> 2.4.1)
|
|
@@ -103,9 +122,9 @@ GEM
|
|
|
103
122
|
rails-html-sanitizer (1.6.2)
|
|
104
123
|
loofah (~> 2.21)
|
|
105
124
|
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
106
|
-
railties (8.
|
|
107
|
-
actionpack (= 8.
|
|
108
|
-
activesupport (= 8.
|
|
125
|
+
railties (8.0.4)
|
|
126
|
+
actionpack (= 8.0.4)
|
|
127
|
+
activesupport (= 8.0.4)
|
|
109
128
|
irb (~> 1.13)
|
|
110
129
|
rackup (>= 1.0.0)
|
|
111
130
|
rake (>= 12.2)
|
|
@@ -199,8 +218,14 @@ GEM
|
|
|
199
218
|
zeitwerk (2.7.3)
|
|
200
219
|
|
|
201
220
|
PLATFORMS
|
|
202
|
-
|
|
203
|
-
|
|
221
|
+
aarch64-linux-gnu
|
|
222
|
+
aarch64-linux-musl
|
|
223
|
+
arm-linux-gnu
|
|
224
|
+
arm-linux-musl
|
|
225
|
+
arm64-darwin
|
|
226
|
+
x86_64-darwin
|
|
227
|
+
x86_64-linux-gnu
|
|
228
|
+
x86_64-linux-musl
|
|
204
229
|
|
|
205
230
|
DEPENDENCIES
|
|
206
231
|
irb
|
data/Readme.md
CHANGED
|
@@ -42,3 +42,13 @@ end
|
|
|
42
42
|
```ruby
|
|
43
43
|
Usps::Supoprt::Models::GitHub.latest_tag('usps-support')
|
|
44
44
|
```
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
module Members
|
|
48
|
+
class Member < Usps::Support::Models::Hq::Members::Member
|
|
49
|
+
has_many :somethings, inverse_of: :member
|
|
50
|
+
|
|
51
|
+
def unique_to_application = 'whatever'
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
```
|
|
@@ -125,14 +125,17 @@ module Usps::Support::Helpers
|
|
|
125
125
|
text&.gsub('-', '--')&.gsub('_', '__')&.gsub(' ', '_')
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
+
# rubocop:disable Metrics/AbcSize
|
|
128
129
|
def timestamp_color(timestamp)
|
|
129
130
|
case Time.zone.at(timestamp.to_i)
|
|
130
131
|
when ...14.days.ago then '63a2c7' # faded :blue
|
|
131
132
|
when 14.days.ago...1.day.ago then :blue
|
|
132
133
|
when 1.day.ago...1.hour.ago, 10.minutes.from_now...1.hour.from_now then :green
|
|
133
|
-
when 1.hour.ago...10.minutes.from_now then :yellowgreen
|
|
134
|
+
when 1.hour.ago...1.minute.ago, 1.minute.from_now...10.minutes.from_now then :yellowgreen
|
|
135
|
+
when 1.minute.ago...1.minute.from_now then :orange
|
|
134
136
|
when 1.hour.from_now.. then :brightgreen
|
|
135
137
|
end
|
|
136
138
|
end
|
|
139
|
+
# rubocop:enable Metrics/AbcSize
|
|
137
140
|
end
|
|
138
141
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# Associate member record
|
|
5
|
+
#
|
|
6
|
+
class AssociateMember < BaseRecord
|
|
7
|
+
self.table_name = :associates
|
|
8
|
+
self.inheritance_column = nil # The database has a `type` column, which confuses with Rails STI
|
|
9
|
+
|
|
10
|
+
belongs_to :member, foreign_key: 'certno', primary_key: 'certno', inverse_of: :associate_memberships
|
|
11
|
+
belongs_to(
|
|
12
|
+
:squadron,
|
|
13
|
+
class_name: 'Squadrons::Squadron', foreign_key: 'squadno', primary_key: 'account', inverse_of: :associate_members
|
|
14
|
+
)
|
|
15
|
+
belongs_to(
|
|
16
|
+
:district,
|
|
17
|
+
class_name: 'Squadrons::District', foreign_key: 'dist', primary_key: 'dist', inverse_of: :associate_members
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# Base record for the HQ VHQAB database
|
|
5
|
+
#
|
|
6
|
+
class BaseRecord < Usps::Support::Models::Hq::SharedRecord
|
|
7
|
+
self.abstract_class = true
|
|
8
|
+
|
|
9
|
+
establish_connection :members
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# District job assignment
|
|
5
|
+
#
|
|
6
|
+
class DistrictJob < BaseRecord
|
|
7
|
+
self.table_name = :djftp
|
|
8
|
+
self.primary_key = %i[certno jobcode year]
|
|
9
|
+
|
|
10
|
+
belongs_to :member, foreign_key: :certno, inverse_of: :district_jobs
|
|
11
|
+
has_one :district_job_description, foreign_key: :jobcode, primary_key: :jobcode, inverse_of: :district_jobs
|
|
12
|
+
|
|
13
|
+
def acting? = acting == 'Y'
|
|
14
|
+
|
|
15
|
+
def description
|
|
16
|
+
desc = district_job_description.jdesc
|
|
17
|
+
acting? ? "#{desc} (Acting)" : desc
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# District job
|
|
5
|
+
#
|
|
6
|
+
class DistrictJobDescription < BaseRecord
|
|
7
|
+
self.table_name = :djdesc
|
|
8
|
+
self.primary_key = :jobcode
|
|
9
|
+
|
|
10
|
+
has_many :district_jobs, foreign_key: :jobcode, primary_key: :jobcode, inverse_of: :district_job_description
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# Former member record
|
|
5
|
+
#
|
|
6
|
+
class FormerMember < BaseRecord
|
|
7
|
+
self.table_name = :abftp2
|
|
8
|
+
self.primary_key = :certificate
|
|
9
|
+
self.inheritance_column = nil # The database has a `type` column, which confuses with Rails STI
|
|
10
|
+
|
|
11
|
+
belongs_to(
|
|
12
|
+
:former_squadron,
|
|
13
|
+
class_name: 'Squadrons::Squadron', foreign_key: 'account', primary_key: 'account', inverse_of: :former_members,
|
|
14
|
+
optional: true
|
|
15
|
+
)
|
|
16
|
+
belongs_to(
|
|
17
|
+
:former_district,
|
|
18
|
+
class_name: 'Squadrons::District', foreign_key: 'district', primary_key: 'dist', inverse_of: :former_members,
|
|
19
|
+
optional: true
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
alias_attribute :member_type, :type
|
|
23
|
+
|
|
24
|
+
# Method aliases to support the expected Members::Member API
|
|
25
|
+
alias squadron former_squadron
|
|
26
|
+
alias_attribute :certno, :certificate
|
|
27
|
+
alias_attribute :first, :firstname
|
|
28
|
+
alias_attribute :last, :lastname
|
|
29
|
+
|
|
30
|
+
def simple_name = [firstname, lastname, '(Deceased)'].join(' ')
|
|
31
|
+
|
|
32
|
+
def sort_name = "#{lastname}, #{firstname}"
|
|
33
|
+
|
|
34
|
+
# rubocop:disable Naming/MethodName
|
|
35
|
+
def iMISid = nil
|
|
36
|
+
alias imis_id iMIDid
|
|
37
|
+
# rubocop:enable Naming/MethodName
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# Regular member record
|
|
5
|
+
#
|
|
6
|
+
class Member < BaseRecord
|
|
7
|
+
self.table_name = :mbftp
|
|
8
|
+
self.primary_key = :certno
|
|
9
|
+
self.filter_attributes = %i[pin answer]
|
|
10
|
+
|
|
11
|
+
INVALID_RANKS = [0, 99].freeze
|
|
12
|
+
|
|
13
|
+
has_many :national_jobs, foreign_key: :certno, inverse_of: :member
|
|
14
|
+
has_many :district_jobs, foreign_key: :certno, inverse_of: :member
|
|
15
|
+
has_many :squadron_jobs, foreign_key: :certno, inverse_of: :member
|
|
16
|
+
belongs_to(
|
|
17
|
+
:squadron,
|
|
18
|
+
class_name: 'Squadrons::Squadron', foreign_key: 'sqdcode', primary_key: 'account', inverse_of: :members
|
|
19
|
+
)
|
|
20
|
+
belongs_to(
|
|
21
|
+
:district,
|
|
22
|
+
class_name: 'Squadrons::District', foreign_key: 'daccount', primary_key: 'account', inverse_of: :members
|
|
23
|
+
)
|
|
24
|
+
has_many(
|
|
25
|
+
:associate_memberships,
|
|
26
|
+
class_name: 'Members::AssociateMember', foreign_key: 'certno', primary_key: 'certno', inverse_of: :member
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
alias_attribute :certificate, :certno
|
|
30
|
+
alias_attribute :member_type, :mbrtype
|
|
31
|
+
alias_attribute :imis_id, :iMISid
|
|
32
|
+
|
|
33
|
+
def as_associate = clone.tap { it.instance_variable_set(:@associate, true) }
|
|
34
|
+
def associate? = @associate.present?
|
|
35
|
+
|
|
36
|
+
def accounts = (squadron_jobs.pluck(:account) + [account]).uniq.map(&:to_s)
|
|
37
|
+
|
|
38
|
+
def district_accounts = district.squadrons.pluck(:account)
|
|
39
|
+
|
|
40
|
+
def rank
|
|
41
|
+
return @rank if @rank
|
|
42
|
+
return unless (raw_rank = read_attribute(:rank))
|
|
43
|
+
return if raw_rank.in?(INVALID_RANKS)
|
|
44
|
+
|
|
45
|
+
normalized_rank = raw_rank.to_s.rjust(2, '0')
|
|
46
|
+
@rank = Members::Rank.find(normalized_rank).RankAbbr
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def full_name
|
|
50
|
+
[
|
|
51
|
+
[rank, first, last].join(' '),
|
|
52
|
+
grade.presence
|
|
53
|
+
].compact.join(', ')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def simple_name = [first, last].join(' ')
|
|
57
|
+
|
|
58
|
+
def sort_name = "#{last}, #{first}"
|
|
59
|
+
|
|
60
|
+
def admin? = certificate.in?(ENV['ADMIN_CERTIFICATES'].split(','))
|
|
61
|
+
|
|
62
|
+
def mailing_address
|
|
63
|
+
[
|
|
64
|
+
full_name,
|
|
65
|
+
address1,
|
|
66
|
+
address2,
|
|
67
|
+
["#{city}, #{state} #{zip5}", zip4].compact_blank.join('-')
|
|
68
|
+
].compact_blank
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# National job assignment
|
|
5
|
+
#
|
|
6
|
+
class NationalJob < BaseRecord
|
|
7
|
+
self.table_name = :njftp
|
|
8
|
+
self.primary_key = %i[certno jobcode year]
|
|
9
|
+
|
|
10
|
+
belongs_to :member, foreign_key: :certno, inverse_of: :national_jobs
|
|
11
|
+
has_one :national_job_description, foreign_key: :jobcode, primary_key: :jobcode, inverse_of: :national_jobs
|
|
12
|
+
|
|
13
|
+
scope :current, -> { where(year: Time.zone.now.year) }
|
|
14
|
+
scope :educational_chair, -> { current.where('jobcode REGEXP ?', '13\d{2}0') }
|
|
15
|
+
scope :educational_leadership, -> { current.where('jobcode REGEXP ?', '13\d{2}[01]') }
|
|
16
|
+
scope :educational_member, -> { current.where('jobcode REGEXP ?', '13\d{2}[012]') }
|
|
17
|
+
|
|
18
|
+
delegate :description, to: :national_job_description
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# National job
|
|
5
|
+
#
|
|
6
|
+
class NationalJobDescription < BaseRecord
|
|
7
|
+
self.table_name = :njdesc
|
|
8
|
+
self.primary_key = :jobcode
|
|
9
|
+
self.inheritance_column = nil # The database has a `type` column, which confuses with Rails STI
|
|
10
|
+
|
|
11
|
+
has_many :national_jobs, foreign_key: :jobcode, primary_key: :jobcode, inverse_of: :national_job_description
|
|
12
|
+
|
|
13
|
+
def description
|
|
14
|
+
return 'Budget Director' if jdesc =~ %r{/Budget Director$}
|
|
15
|
+
|
|
16
|
+
jdesc
|
|
17
|
+
.sub(/^(?:Assistant|Asst\.)?\s?(?:Chr\.|Chair\.|Chairman)? /, '')
|
|
18
|
+
.sub(/ (?:Committee|Cmte|Com\.)$/, '')
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# Squadron job assignment
|
|
5
|
+
#
|
|
6
|
+
class SquadronJob < BaseRecord
|
|
7
|
+
self.table_name = :sjftp
|
|
8
|
+
self.primary_key = %i[certno jobcode year]
|
|
9
|
+
|
|
10
|
+
belongs_to(
|
|
11
|
+
:squadron,
|
|
12
|
+
class_name: 'Squadrons::Squadron', foreign_key: 'account', primary_key: 'account', inverse_of: :squadron_jobs
|
|
13
|
+
)
|
|
14
|
+
belongs_to :member, foreign_key: :certno, inverse_of: :squadron_jobs
|
|
15
|
+
has_one :squadron_job_description, foreign_key: :jobcode, primary_key: :jobcode, inverse_of: :squadron_jobs
|
|
16
|
+
|
|
17
|
+
def acting? = acting == 'Y'
|
|
18
|
+
|
|
19
|
+
def description
|
|
20
|
+
desc = squadron_job_description.jdesc
|
|
21
|
+
acting? ? "#{desc} (Acting)" : desc
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Members
|
|
4
|
+
# Squadron job
|
|
5
|
+
#
|
|
6
|
+
class SquadronJobDescription < BaseRecord
|
|
7
|
+
self.table_name = :sjdesc
|
|
8
|
+
self.primary_key = :jobcode
|
|
9
|
+
|
|
10
|
+
has_many :squadron_jobs, foreign_key: :jobcode, primary_key: :jobcode, inverse_of: :squadron_job_description
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Shared Rails models on the HQ VHQAB database
|
|
4
|
+
#
|
|
5
|
+
module Usps::Support::Models::Hq::Members; end
|
|
6
|
+
|
|
7
|
+
require_relative 'members/base_record'
|
|
8
|
+
require_relative 'members/associate_member'
|
|
9
|
+
require_relative 'members/district_job_description'
|
|
10
|
+
require_relative 'members/district_job'
|
|
11
|
+
require_relative 'members/former_member'
|
|
12
|
+
require_relative 'members/member'
|
|
13
|
+
require_relative 'members/national_job_description'
|
|
14
|
+
require_relative 'members/national_job'
|
|
15
|
+
require_relative 'members/rank'
|
|
16
|
+
require_relative 'members/squadron_job_description'
|
|
17
|
+
require_relative 'members/squadron_job'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq
|
|
4
|
+
# Base record for the HQ VHQAB database
|
|
5
|
+
#
|
|
6
|
+
class SharedRecord < ::ActiveRecord::Base
|
|
7
|
+
self.abstract_class = true
|
|
8
|
+
|
|
9
|
+
after_initialize :readonly!, unless: -> { Rails.env.test? || self.class.allow_hq_database_edits? }
|
|
10
|
+
|
|
11
|
+
def self.allow_hq_database_edits? = false
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Squadrons
|
|
4
|
+
# Base class for models in the WebSites HQ database
|
|
5
|
+
#
|
|
6
|
+
class BaseRecord < Usps::Support::Models::Hq::SharedRecord
|
|
7
|
+
self.abstract_class = true
|
|
8
|
+
|
|
9
|
+
establish_connection :websites
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Squadrons
|
|
4
|
+
# HQ-800 course
|
|
5
|
+
#
|
|
6
|
+
class CourseReport < Website
|
|
7
|
+
self.table_name = :mbrclasses
|
|
8
|
+
|
|
9
|
+
belongs_to :squadron, foreign_key: 'account', primary_key: 'sqnumber', inverse_of: :course_reports
|
|
10
|
+
has_one :classroom, inverse_of: :course_report
|
|
11
|
+
has_many :students, foreign_key: %i[crsid squadno], primary_key: %i[crsid sqnumber], inverse_of: :course_report
|
|
12
|
+
|
|
13
|
+
enum :status, { closed: 'C', ordered: 'O', graded: 'G' }
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Squadrons
|
|
4
|
+
# District organization information
|
|
5
|
+
#
|
|
6
|
+
class District < Website
|
|
7
|
+
has_many :squadrons, inverse_of: :district, foreign_key: 'daccount', primary_key: 'account'
|
|
8
|
+
has_many :former_squadrons, inverse_of: :district, foreign_key: 'daccount', primary_key: 'account'
|
|
9
|
+
|
|
10
|
+
has_many(
|
|
11
|
+
:members,
|
|
12
|
+
class_name: 'Members::Member', foreign_key: 'daccount', primary_key: 'account', inverse_of: :district
|
|
13
|
+
)
|
|
14
|
+
has_many(
|
|
15
|
+
:former_members,
|
|
16
|
+
class_name: 'Members::FormerMember', foreign_key: 'dist', primary_key: 'district', inverse_of: :former_district
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
# Squadrons and Districts are both stored in the same table, along with various historical entries
|
|
20
|
+
default_scope { where("Name REGEXP '^D?[0-9]{2}$'").where.not(account: nil) }
|
|
21
|
+
|
|
22
|
+
# def self.lookup(number) = where("Name REGEXP '^D?0?#{number}$'").first
|
|
23
|
+
|
|
24
|
+
def number = self.Name.sub(/^D/, '').to_i
|
|
25
|
+
|
|
26
|
+
# def name = "District #{number}"
|
|
27
|
+
|
|
28
|
+
# def all_squadrons = (squadrons + former_squadrons).sort_by(&:name)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Squadrons
|
|
4
|
+
# Former Squadron organization information
|
|
5
|
+
#
|
|
6
|
+
class FormerSquadron < Website
|
|
7
|
+
belongs_to :district, inverse_of: :former_squadrons, foreign_key: 'daccount', primary_key: 'account'
|
|
8
|
+
|
|
9
|
+
# Former Squadrons stored in the same table as current Squadrons
|
|
10
|
+
default_scope { where(account: nil).where('Name NOT REGEXP \'^[0-9]{2}\.$\'') }
|
|
11
|
+
|
|
12
|
+
# When a squadron becomes "former", its account is moved into the `plat` column
|
|
13
|
+
alias_attribute :account_number, :plat
|
|
14
|
+
|
|
15
|
+
def name = self.Name.sub(/\.$/, '')
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Squadrons
|
|
4
|
+
# Squadron organization information
|
|
5
|
+
#
|
|
6
|
+
class Squadron < Website
|
|
7
|
+
belongs_to :district, inverse_of: :squadrons, foreign_key: 'daccount', primary_key: 'account'
|
|
8
|
+
has_many(
|
|
9
|
+
:members,
|
|
10
|
+
class_name: 'Members::Member', foreign_key: 'account', primary_key: 'account', inverse_of: :squadron
|
|
11
|
+
)
|
|
12
|
+
has_many(
|
|
13
|
+
:former_members,
|
|
14
|
+
class_name: 'Members::FormerMember', foreign_key: 'account', primary_key: 'account', inverse_of: :former_squadron
|
|
15
|
+
)
|
|
16
|
+
has_many(
|
|
17
|
+
:squadron_jobs,
|
|
18
|
+
class_name: 'Members::SquadronJob', foreign_key: 'account', primary_key: 'account', inverse_of: :squadron
|
|
19
|
+
)
|
|
20
|
+
has_many :classrooms, foreign_key: 'account', primary_key: 'account', inverse_of: :squadron
|
|
21
|
+
has_many :course_reports, foreign_key: 'account', primary_key: 'sqnumber', inverse_of: :squadron
|
|
22
|
+
|
|
23
|
+
default_scope { where.not("Name REGEXP '^D?[0-9]{2}$'").where.not(account: nil) }
|
|
24
|
+
|
|
25
|
+
def name = self.Name.split(/ Sail (&|and)/)[0]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Squadrons
|
|
4
|
+
# HQ-800 student
|
|
5
|
+
#
|
|
6
|
+
class Student < Website
|
|
7
|
+
self.table_name = :students
|
|
8
|
+
self.ignored_columns += %i[validate]
|
|
9
|
+
|
|
10
|
+
belongs_to :course_report, foreign_key: %i[crsid squadno], primary_key: %i[crsid sqnumber], inverse_of: :students
|
|
11
|
+
|
|
12
|
+
alias_attribute :certificate, :certno
|
|
13
|
+
|
|
14
|
+
# Tweak data format to match expected
|
|
15
|
+
def grade=(int_or_string)
|
|
16
|
+
write_attribute(:grade, int_or_string.to_s.rjust(3, '0'))
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models::Hq::Squadrons
|
|
4
|
+
# Base class for records in the websites (i.e. organizations) table
|
|
5
|
+
#
|
|
6
|
+
class Website < BaseRecord
|
|
7
|
+
self.abstract_class = true
|
|
8
|
+
self.table_name = :websites
|
|
9
|
+
self.primary_key = :id
|
|
10
|
+
self.inheritance_column = nil # The database has a `type` column, which confuses with Rails STI
|
|
11
|
+
|
|
12
|
+
# This is a default behavior, that is overwritten by FormerSquadron
|
|
13
|
+
alias_attribute :account_number, :account
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Shared Rails models on the HQ WebSites database
|
|
4
|
+
#
|
|
5
|
+
module Usps::Support::Models::Hq::Squadrons; end
|
|
6
|
+
|
|
7
|
+
require_relative 'squadrons/base_record'
|
|
8
|
+
require_relative 'squadrons/website'
|
|
9
|
+
require_relative 'squadrons/course_report'
|
|
10
|
+
require_relative 'squadrons/district'
|
|
11
|
+
require_relative 'squadrons/former_squadron'
|
|
12
|
+
require_relative 'squadrons/squadron'
|
|
13
|
+
require_relative 'squadrons/student'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models
|
|
4
|
+
# HQ database models
|
|
5
|
+
#
|
|
6
|
+
# Note: This module must be loaded *after* ActiveRecord in the parent application
|
|
7
|
+
#
|
|
8
|
+
module Hq; end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
require_relative 'hq/shared_record'
|
|
12
|
+
require_relative 'hq/members'
|
|
13
|
+
require_relative 'hq/squadrons'
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Usps::Support::Models
|
|
4
|
+
# Toast constructor
|
|
5
|
+
#
|
|
6
|
+
class Toast
|
|
7
|
+
attr_accessor :type, :title, :body, :timeout, :id
|
|
8
|
+
|
|
9
|
+
def self.success(**)
|
|
10
|
+
new(type: :SUCCESS, **)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.notice(**)
|
|
14
|
+
new(type: :NOTICE, **)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.error(**)
|
|
18
|
+
new(type: :ERROR, **)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def initialize(options)
|
|
22
|
+
@type = options[:type] || :NOTICE
|
|
23
|
+
@title = options[:title]
|
|
24
|
+
@body = options[:body]
|
|
25
|
+
@timeout = options[:timeout] || 4_000
|
|
26
|
+
@id = options[:id]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def broadcast!
|
|
30
|
+
BroadcastToastChannel.broadcast!(title, body, timeout:, type:, id:)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def dismiss!
|
|
34
|
+
BroadcastToastChannel.dismiss!(id)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def to_s
|
|
38
|
+
attributes = to_h.map { |key, value| "@#{key}=#{value.inspect}" }.join(' ')
|
|
39
|
+
|
|
40
|
+
"#<Toast:#{object_id} #{attributes}>"
|
|
41
|
+
end
|
|
42
|
+
alias inspect to_s
|
|
43
|
+
|
|
44
|
+
def to_h
|
|
45
|
+
{
|
|
46
|
+
type: type || :NOTICE,
|
|
47
|
+
title:,
|
|
48
|
+
body:,
|
|
49
|
+
timeout:,
|
|
50
|
+
id:
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def to_json(*_)
|
|
55
|
+
validate!
|
|
56
|
+
|
|
57
|
+
JSON.dump(to_h)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Reserved standard Toast configurations
|
|
61
|
+
#
|
|
62
|
+
module Reserved
|
|
63
|
+
IDS = {
|
|
64
|
+
restarting: 10_001
|
|
65
|
+
}.freeze
|
|
66
|
+
|
|
67
|
+
def self.restarting
|
|
68
|
+
Toast.notice(
|
|
69
|
+
title: 'SERVER WILL RESTART SOON',
|
|
70
|
+
body: "Please do not attempt to make any changes for a moment.\n" \
|
|
71
|
+
"We'll let you know when the server's back up.",
|
|
72
|
+
timeout: 0,
|
|
73
|
+
id: IDS[:restarting]
|
|
74
|
+
)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def self.restarted
|
|
78
|
+
Toast.notice(
|
|
79
|
+
title: 'Server Restarted',
|
|
80
|
+
body: 'The server has completed its restart. You can resume working.'
|
|
81
|
+
)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
private
|
|
86
|
+
|
|
87
|
+
def validate!
|
|
88
|
+
raise 'Invalid type' unless type.in?(%i[SUCCESS NOTICE ERROR])
|
|
89
|
+
raise 'No title set' if title.blank?
|
|
90
|
+
raise 'No body set' if body.blank?
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
data/lib/usps/support/models.rb
CHANGED
data/lib/usps/support/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usps-support
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.10
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Julian Fiander
|
|
@@ -75,6 +75,29 @@ files:
|
|
|
75
75
|
- lib/usps/support/models/.rubocop.yml
|
|
76
76
|
- lib/usps/support/models/dynamo_db.rb
|
|
77
77
|
- lib/usps/support/models/git_hub.rb
|
|
78
|
+
- lib/usps/support/models/hq.rb
|
|
79
|
+
- lib/usps/support/models/hq/members.rb
|
|
80
|
+
- lib/usps/support/models/hq/members/associate_member.rb
|
|
81
|
+
- lib/usps/support/models/hq/members/base_record.rb
|
|
82
|
+
- lib/usps/support/models/hq/members/district_job.rb
|
|
83
|
+
- lib/usps/support/models/hq/members/district_job_description.rb
|
|
84
|
+
- lib/usps/support/models/hq/members/former_member.rb
|
|
85
|
+
- lib/usps/support/models/hq/members/member.rb
|
|
86
|
+
- lib/usps/support/models/hq/members/national_job.rb
|
|
87
|
+
- lib/usps/support/models/hq/members/national_job_description.rb
|
|
88
|
+
- lib/usps/support/models/hq/members/rank.rb
|
|
89
|
+
- lib/usps/support/models/hq/members/squadron_job.rb
|
|
90
|
+
- lib/usps/support/models/hq/members/squadron_job_description.rb
|
|
91
|
+
- lib/usps/support/models/hq/shared_record.rb
|
|
92
|
+
- lib/usps/support/models/hq/squadrons.rb
|
|
93
|
+
- lib/usps/support/models/hq/squadrons/base_record.rb
|
|
94
|
+
- lib/usps/support/models/hq/squadrons/course_report.rb
|
|
95
|
+
- lib/usps/support/models/hq/squadrons/district.rb
|
|
96
|
+
- lib/usps/support/models/hq/squadrons/former_squadron.rb
|
|
97
|
+
- lib/usps/support/models/hq/squadrons/squadron.rb
|
|
98
|
+
- lib/usps/support/models/hq/squadrons/student.rb
|
|
99
|
+
- lib/usps/support/models/hq/squadrons/website.rb
|
|
100
|
+
- lib/usps/support/models/toast.rb
|
|
78
101
|
- lib/usps/support/version.rb
|
|
79
102
|
- sig/usps/support.rbs
|
|
80
103
|
homepage: https://github.com/unitedstatespowersquadrons/usps-rails
|