agilibox 1.3.6 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/app/controllers/agilibox/application_controller.rb +2 -4
- data/app/controllers/agilibox/small_data/filters_controller.rb +4 -0
- data/app/emails/agilibox/email.rb +113 -0
- data/app/filters/agilibox/small_data/filter.rb +1 -1
- data/app/mailers/agilibox/application_mailer.rb +2 -0
- data/app/mailers/agilibox/generic_mailer.rb +9 -0
- data/config/locales/attributes.en.yml +12 -0
- data/config/locales/attributes.fr.yml +12 -0
- data/lib/agilibox/config.rb +19 -0
- data/lib/agilibox/engine.rb +1 -0
- data/lib/agilibox/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 698634df72b0e0a386b55326f55b22246c392bbf4488d0c78b0fb97b7f230c4f
|
4
|
+
data.tar.gz: 9cf623860c2e7dc514435ac01116a46948b6d415d0113b765bb239407fd44b72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1da109149aa05456d4d5b156f103788a66e998436218137a5aca38dc9d66a5e78eefdd7df302d2d3dc86708468f2e58e73b0a1067e4a5a227e6642260cdd6f63
|
7
|
+
data.tar.gz: dde577f9d385392ba9aa5546cc1e9882989a58edb1ec5956bdf51cd1f61f1128efa5820e0d3bb812b7eb41512000f34ed26747f23ced3e053310933418d5236e
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
class Agilibox::SmallData::FiltersController < ::Agilibox::ApplicationController
|
2
|
+
skip_after_action :verify_authorized, raise: false
|
3
|
+
skip_after_action :verify_policy_scoped, raise: false
|
4
|
+
skip_before_action :verify_authenticity_token, raise: false
|
5
|
+
|
2
6
|
def create
|
3
7
|
skip_authorization if respond_to?(:skip_authorization)
|
4
8
|
skip_policy_scope if respond_to?(:skip_policy_scope)
|
@@ -0,0 +1,113 @@
|
|
1
|
+
class Agilibox::Email
|
2
|
+
include ActiveModel::Model
|
3
|
+
include Agilibox::ModelToS
|
4
|
+
include Agilibox::ModelI18n
|
5
|
+
|
6
|
+
validates :to, presence: true
|
7
|
+
validates :subject, presence: true
|
8
|
+
validates :body, presence: true
|
9
|
+
|
10
|
+
validate :validate_addr_formats
|
11
|
+
|
12
|
+
attr_accessor(
|
13
|
+
:current_user,
|
14
|
+
:from,
|
15
|
+
:reply_to,
|
16
|
+
:to,
|
17
|
+
:cc,
|
18
|
+
:subject,
|
19
|
+
:body,
|
20
|
+
:attachments,
|
21
|
+
)
|
22
|
+
|
23
|
+
def initialize(*)
|
24
|
+
super
|
25
|
+
assign_default_values
|
26
|
+
end
|
27
|
+
|
28
|
+
def attachment_names
|
29
|
+
attachments.keys.join(", ")
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate_and_deliver
|
33
|
+
ok = valid?
|
34
|
+
deliver if ok
|
35
|
+
ok
|
36
|
+
end
|
37
|
+
|
38
|
+
def data
|
39
|
+
{
|
40
|
+
:from => from,
|
41
|
+
:reply_to => reply_to,
|
42
|
+
:to => to,
|
43
|
+
:cc => cc,
|
44
|
+
:subject => subject,
|
45
|
+
:body => body,
|
46
|
+
:attachments => attachments,
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def deliver
|
51
|
+
deliver_now
|
52
|
+
end
|
53
|
+
|
54
|
+
def deliver_now
|
55
|
+
Agilibox::GenericMailer.generic_email(data).deliver_now
|
56
|
+
end
|
57
|
+
|
58
|
+
def deliver_later
|
59
|
+
Agilibox::GenericMailer.generic_email(data).deliver_later
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def assign_default_values
|
65
|
+
self.from ||= default_from
|
66
|
+
self.reply_to ||= default_reply_to
|
67
|
+
self.to ||= default_to
|
68
|
+
self.cc ||= default_cc
|
69
|
+
self.subject ||= default_subject
|
70
|
+
self.body ||= default_body
|
71
|
+
self.attachments ||= default_attachments
|
72
|
+
end
|
73
|
+
|
74
|
+
def default_from
|
75
|
+
end
|
76
|
+
|
77
|
+
def default_reply_to
|
78
|
+
"#{current_user} <#{current_user.email}>" if current_user
|
79
|
+
end
|
80
|
+
|
81
|
+
def default_to
|
82
|
+
end
|
83
|
+
|
84
|
+
def default_cc
|
85
|
+
end
|
86
|
+
|
87
|
+
def default_subject
|
88
|
+
end
|
89
|
+
|
90
|
+
def default_body
|
91
|
+
end
|
92
|
+
|
93
|
+
def default_attachments
|
94
|
+
{}
|
95
|
+
end
|
96
|
+
|
97
|
+
def validate_addr_formats
|
98
|
+
validate_addr_formats_for(:from)
|
99
|
+
validate_addr_formats_for(:reply_to)
|
100
|
+
validate_addr_formats_for(:to)
|
101
|
+
validate_addr_formats_for(:cc)
|
102
|
+
end
|
103
|
+
|
104
|
+
def validate_addr_formats_for(attr)
|
105
|
+
require "mail"
|
106
|
+
|
107
|
+
string = public_send(attr).to_s
|
108
|
+
return if string.blank?
|
109
|
+
addrs = Mail.new(to: string).to_addrs
|
110
|
+
return true if addrs.any? && addrs.all? { |addr| URI::MailTo::EMAIL_REGEXP.match?(addr) }
|
111
|
+
errors.add(attr, :invalid)
|
112
|
+
end
|
113
|
+
end
|
@@ -94,3 +94,15 @@ en:
|
|
94
94
|
|
95
95
|
labels:
|
96
96
|
<<: *attributes
|
97
|
+
|
98
|
+
activemodel:
|
99
|
+
attributes:
|
100
|
+
agilibox/email:
|
101
|
+
from: "From"
|
102
|
+
reply_to: "Reply to"
|
103
|
+
to: "To"
|
104
|
+
cc: "Copy"
|
105
|
+
subject: "Subject"
|
106
|
+
body: "Message"
|
107
|
+
attachments: "Attachments"
|
108
|
+
attachment_names: "Attachments"
|
@@ -94,3 +94,15 @@ fr:
|
|
94
94
|
|
95
95
|
labels:
|
96
96
|
<<: *attributes
|
97
|
+
|
98
|
+
activemodel:
|
99
|
+
attributes:
|
100
|
+
agilibox/email:
|
101
|
+
from: "Expéditeur"
|
102
|
+
reply_to: "Répondre à"
|
103
|
+
to: "Destinataire"
|
104
|
+
cc: "Copie"
|
105
|
+
subject: "Objet"
|
106
|
+
body: "Message"
|
107
|
+
attachments: "Pièces jointes"
|
108
|
+
attachment_names: "Pièces jointes"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class << Agilibox
|
2
|
+
attr_writer :parent_controller
|
3
|
+
|
4
|
+
def parent_controller
|
5
|
+
@parent_controller ||= [
|
6
|
+
"ApplicationController",
|
7
|
+
"ActionController::Base",
|
8
|
+
].map(&:safe_constantize).compact.first
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_writer :parent_mailer
|
12
|
+
|
13
|
+
def parent_mailer
|
14
|
+
@parent_mailer ||= [
|
15
|
+
"ApplicationMailer",
|
16
|
+
"ActionMailer::Base",
|
17
|
+
].map(&:safe_constantize).compact.first
|
18
|
+
end
|
19
|
+
end
|
data/lib/agilibox/engine.rb
CHANGED
data/lib/agilibox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agilibox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agilidée
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails-i18n
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- app/controllers/agilibox/small_data/filters_controller.rb
|
83
83
|
- app/controllers/concerns/agilibox/api_controller_concern.rb
|
84
84
|
- app/controllers/concerns/agilibox/back_url_concern.rb
|
85
|
+
- app/emails/agilibox/email.rb
|
85
86
|
- app/filters/agilibox/small_data/filter.rb
|
86
87
|
- app/filters/agilibox/small_data/filter_strategy.rb
|
87
88
|
- app/filters/agilibox/small_data/filter_strategy_by_date.rb
|
@@ -118,6 +119,8 @@ files:
|
|
118
119
|
- app/libs/agilibox/phone_number_sanitizer.rb
|
119
120
|
- app/libs/agilibox/sortable_uuid_generator.rb
|
120
121
|
- app/libs/agilibox/token_generator.rb
|
122
|
+
- app/mailers/agilibox/application_mailer.rb
|
123
|
+
- app/mailers/agilibox/generic_mailer.rb
|
121
124
|
- app/models/concerns/agilibox/active_record_uuid_concern.rb
|
122
125
|
- app/models/concerns/agilibox/default_values_concern.rb
|
123
126
|
- app/models/concerns/agilibox/model_i18n.rb
|
@@ -154,6 +157,7 @@ files:
|
|
154
157
|
- lib/agilibox.rb
|
155
158
|
- lib/agilibox/active_model_custom_error_messages.rb
|
156
159
|
- lib/agilibox/active_record_comma_type_cast.rb
|
160
|
+
- lib/agilibox/config.rb
|
157
161
|
- lib/agilibox/core_and_rails_ext.rb
|
158
162
|
- lib/agilibox/cucumber_config.rb
|
159
163
|
- lib/agilibox/cucumber_helpers/agilibox.rb
|