Class: InProgressForm
Defined Under Namespace
Classes: CleanUUID
Constant Summary
collapse
- RETURN_URL_SQL =
"CAST(metadata -> 'returnUrl' AS text)"
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
descendants_using_encryption, lockbox_options, #timestamp_attributes_for_update_in_model, #valid?
Instance Attribute Details
#real_user_uuid ⇒ Object
Returns the value of attribute real_user_uuid.
16
17
18
|
# File 'app/models/in_progress_form.rb', line 16
def real_user_uuid
@real_user_uuid
end
|
#skip_exipry_update ⇒ Object
Returns the value of attribute skip_exipry_update.
16
17
18
|
# File 'app/models/in_progress_form.rb', line 16
def skip_exipry_update
@skip_exipry_update
end
|
Class Method Details
.for_user(user) ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'app/models/in_progress_form.rb', line 67
def self.for_user(user)
user_uuid_forms = InProgressForm.where(user_uuid: user.uuid)
if user.user_account
user_uuid_forms.or(InProgressForm.where(user_account: user.user_account))
else
user_uuid_forms
end
end
|
61
62
63
64
65
|
# File 'app/models/in_progress_form.rb', line 61
def self.form_for_user(form_id, user)
user_uuid_form = InProgressForm.find_by(form_id:, user_uuid: user.uuid)
user_account_form = InProgressForm.find_by(form_id:, user_account: user.user_account) if user.user_account
user_uuid_form || user_account_form
end
|
Instance Method Details
#custom_expires_after ⇒ Object
152
153
154
155
156
|
# File 'app/models/in_progress_form.rb', line 152
def custom_expires_after
options = { form_id:, days_till_expires: }
FormDurations::Worker.build(options).get_duration
end
|
76
77
78
79
80
81
|
# File 'app/models/in_progress_form.rb', line 76
def data_and_metadata
{
formData: JSON.parse(form_data),
metadata:
}
end
|
#days_till_expires ⇒ Object
139
140
141
|
# File 'app/models/in_progress_form.rb', line 139
def days_till_expires
@days_till_expires ||= JSON.parse(form_data)['days_till_expires']
end
|
#default_expires_after ⇒ Object
143
144
145
146
147
148
149
150
|
# File 'app/models/in_progress_form.rb', line 143
def default_expires_after
case form_id
when '21-526EZ', '21P-527EZ', '21P-530V2'
1.year
else
60.days
end
end
|
#expires_after ⇒ ActiveSupport::Duration
Determines an expiration duration based on the UI form_id. If the in_progress_form_custom_expiration feature is enabled, the method can additionally return custom expiration durations whose values are passed in as Strings from the UI.
102
103
104
105
106
107
108
109
|
# File 'app/models/in_progress_form.rb', line 102
def expires_after
@expires_after ||=
if Flipper.enabled?(:in_progress_form_custom_expiration)
custom_expires_after
else
default_expires_after
end
end
|
#id_me_user_uuid ⇒ Object
121
122
123
124
125
|
# File 'app/models/in_progress_form.rb', line 121
def id_me_user_uuid
if user_uuid && !user_uuid.length.in?([20, 21, 22, 23, 32])
errors.add(:user_uuid, "(#{user_uuid}) is not a proper length")
end
end
|
#log_hca_email_diff ⇒ Object
113
114
115
|
# File 'app/models/in_progress_form.rb', line 113
def log_hca_email_diff
HCA::LogEmailDiffJob.perform_async(id, real_user_uuid) if form_id == '1010ez'
end
|
83
84
85
86
87
88
89
90
91
92
|
# File 'app/models/in_progress_form.rb', line 83
def metadata
data = super || {}
last_accessed = updated_at || Time.current
data.merge(
'createdAt' => created_at&.to_time.to_i,
'expiresAt' => expires_at.to_i || (last_accessed + expires_after).to_i,
'lastUpdated' => updated_at.to_i,
'inProgressFormId' => id
)
end
|
127
128
129
|
# File 'app/models/in_progress_form.rb', line 127
def serialize_form_data
self.form_data = form_data.to_json unless form_data.is_a?(String)
end
|
#set_expires_at ⇒ Object
131
132
133
|
# File 'app/models/in_progress_form.rb', line 131
def set_expires_at
self.expires_at = Time.current + expires_after
end
|
#skip_exipry_update_check ⇒ Object
135
136
137
|
# File 'app/models/in_progress_form.rb', line 135
def skip_exipry_update_check
self.skip_exipry_update = expires_at.present?
end
|