mno-enterprise-core 3.3.1 → 3.3.2
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/app/helpers/mno_enterprise/image_helper.rb +4 -0
- data/app/models/mno_enterprise/impac/dashboard.rb +22 -4
- data/app/models/mno_enterprise/impac/widget.rb +1 -1
- data/app/pdf/mno_enterprise/invoice_pdf.rb +7 -5
- data/app/views/system_notifications/confirmation-instructions.html.erb +1 -1
- data/app/views/system_notifications/delete-request-instructions.html.erb +1 -1
- data/app/views/system_notifications/email-change.html.erb +1 -1
- data/app/views/system_notifications/organization-invite-existing-user.html.erb +1 -1
- data/app/views/system_notifications/organization-invite-new-user.html.erb +1 -1
- data/app/views/system_notifications/password-change.html.erb +1 -1
- data/app/views/system_notifications/reconfirmation-instructions.html.erb +1 -1
- data/app/views/system_notifications/registration-instructions.html.erb +1 -1
- data/app/views/system_notifications/reset-password-instructions.html.erb +1 -1
- data/app/views/system_notifications/unlock-instructions.html.erb +1 -1
- data/config/locales/templates/dashboard/marketplace/en.yml +1 -0
- data/config/locales/templates/dashboard/organization/en.yml +4 -1
- data/lib/generators/mno_enterprise/install/templates/config/settings.yml +4 -0
- data/lib/mno_enterprise/concerns/controllers/auth/confirmations_controller.rb +3 -0
- data/lib/mno_enterprise/concerns/controllers/auth/registrations_controller.rb +7 -1
- data/lib/mno_enterprise/concerns/models/ability.rb +1 -1
- data/lib/mno_enterprise/smtp_client.rb +2 -0
- data/lib/mno_enterprise/testing_support/factories/users.rb +1 -0
- data/lib/mno_enterprise/version.rb +1 -1
- data/spec/helpers/image_helper_spec.rb +26 -19
- data/spec/models/mno_enterprise/impac/dashboard_spec.rb +17 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f917a6e753baa8624dce8b43b2bcb11fbcf2181e
|
4
|
+
data.tar.gz: 65f316eaa0ffdc58c30b77fa277c5ab7a719b736
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b7d6482aab8df033971214542cd4812f207c57d428d62501a20c2bffc529bb5b99d6a1ebc566e1ca7737e5bda6ba05b72d1530cb4b09dfdc55addb077613168
|
7
|
+
data.tar.gz: 73a4607b1a631b6654fd83193880abce436ed050800d165497059ef5c32a3ef66fc5a9c71c923582be1685e83ab69a2777f99c354bcf831a2ddd48f0ab543c3e
|
@@ -1,11 +1,16 @@
|
|
1
1
|
module MnoEnterprise
|
2
2
|
class Impac::Dashboard < BaseResource
|
3
3
|
|
4
|
-
attributes :full_name, :widgets_order, :settings, :organization_ids, :widgets_templates, :currency
|
4
|
+
attributes :full_name, :widgets_order, :settings, :organization_ids, :widgets_templates, :currency, :published, :dashboard_type
|
5
5
|
|
6
6
|
has_many :widgets, class_name: 'MnoEnterprise::Impac::Widget'
|
7
7
|
has_many :kpis, class_name: 'MnoEnterprise::Impac::Kpi'
|
8
8
|
belongs_to :owner, polymorphic: true
|
9
|
+
default_scope -> { where(dashboard_type: 'dashboard') }
|
10
|
+
scope :templates, -> { where(dashboard_type: 'template') }
|
11
|
+
scope :published_templates, -> { where(dashboard_type: 'template', published: true) }
|
12
|
+
|
13
|
+
custom_post :copy
|
9
14
|
|
10
15
|
#============================================
|
11
16
|
# Instance methods
|
@@ -16,10 +21,11 @@ module MnoEnterprise
|
|
16
21
|
self.name
|
17
22
|
end
|
18
23
|
|
19
|
-
# Return all the organizations linked to this dashboard and to which
|
20
|
-
# the user
|
24
|
+
# Return all the organizations linked to this dashboard and to which the user has access
|
25
|
+
# If the dashboard is a template, return all the current user's organization
|
21
26
|
def organizations(org_list = nil)
|
22
27
|
if org_list
|
28
|
+
return org_list if dashboard_type == 'template'
|
23
29
|
org_list.to_a.select { |e| self.organization_ids.include?(e.uid) }
|
24
30
|
else
|
25
31
|
MnoEnterprise::Organization.where('uid.in' => self.organization_ids).to_a
|
@@ -40,8 +46,20 @@ module MnoEnterprise
|
|
40
46
|
def to_audit_event
|
41
47
|
{
|
42
48
|
name: name,
|
43
|
-
organization_id: (owner_type == '
|
49
|
+
organization_id: (owner_type == 'Organization') ? owner_id : nil
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
def copy(owner, name, organization_ids)
|
54
|
+
owner_type = owner.class.name.demodulize
|
55
|
+
attrs = {
|
56
|
+
id: self.id,
|
57
|
+
name: name,
|
58
|
+
organization_ids: organization_ids,
|
59
|
+
owner_type: owner_type,
|
60
|
+
owner_id: owner.id
|
44
61
|
}
|
62
|
+
self.class.copy(attrs)
|
45
63
|
end
|
46
64
|
end
|
47
65
|
end
|
@@ -9,7 +9,7 @@ module MnoEnterprise
|
|
9
9
|
|
10
10
|
def to_audit_event
|
11
11
|
|
12
|
-
if settings['organization_ids'].
|
12
|
+
if settings.present? && settings['organization_ids'].present?
|
13
13
|
organization = MnoEnterprise::Organization.find_by(uid: settings['organization_ids'].first)
|
14
14
|
{ name: name, organization_id: organization.id }
|
15
15
|
else
|
@@ -128,7 +128,7 @@ module MnoEnterprise
|
|
128
128
|
@pdf.repeat :all do
|
129
129
|
@pdf.bounding_box([0, @pdf.bounds.top+@format[:header_size]], width: 540, height: @format[:footer_size]) do
|
130
130
|
@pdf.float do
|
131
|
-
@pdf.image main_logo_white_bg_path(true),
|
131
|
+
@pdf.image main_logo_white_bg_path(true), fit: [135, (@format[:footer_size])]
|
132
132
|
end
|
133
133
|
@pdf.move_down 52
|
134
134
|
@pdf.font_size(20) { @pdf.text "#{title} #{@data[:period_month]}", style: :bold, align: :right }
|
@@ -145,9 +145,10 @@ module MnoEnterprise
|
|
145
145
|
@pdf.stroke_horizontal_rule
|
146
146
|
@pdf.move_down 10
|
147
147
|
@pdf.font_size(8) do
|
148
|
-
@pdf.text "<color rgb='999999'>
|
149
|
-
@pdf.text "<color rgb='999999'>
|
150
|
-
@pdf.text "
|
148
|
+
@pdf.text "<color rgb='999999'>This invoice has been generated by Maestrano Pty Ltd on behalf of the #{MnoEnterprise.app_name} platform (the \"Service\").</color>", inline_format: true
|
149
|
+
@pdf.text "<color rgb='999999'>All charges in this invoice are in #{@data[:invoice_currency_name]} (#{@data[:invoice_currency]}). Credit card payments will be processed by Maestrano Pty Ltd.</color>", inline_format: true
|
150
|
+
@pdf.text " ", inline_format: true
|
151
|
+
@pdf.text "<color rgb='999999'>Maestrano Pty Ltd | Suite 504, 46 Market Street, Sydney, NSW 2000, Australia | ABN: 80 152 564 424</color>", inline_format: true
|
151
152
|
end
|
152
153
|
end
|
153
154
|
end
|
@@ -246,11 +247,12 @@ module MnoEnterprise
|
|
246
247
|
@pdf.move_down 10
|
247
248
|
@pdf.indent(5) do
|
248
249
|
@pdf.font_size(8) do
|
250
|
+
@pdf.text "<color rgb='999999'> This charge will appear as INV #{@data[:invoice_reference]} on your bank statement.</color>", inline_format: true
|
249
251
|
@pdf.text "<color rgb='999999'> Charges are all displayed in #{@data[:invoice_currency_name]} (#{@data[:invoice_currency]})</color>", inline_format: true
|
250
252
|
if @data[:invoice_fully_paid]
|
251
253
|
@pdf.text "<color rgb='999999'> No credit card payments required for this invoice</color>", inline_format: true
|
252
254
|
else
|
253
|
-
@pdf.text "<color rgb='999999'> Your designated credit card will be charged on #{@data[:period_charge_date].strftime("%B,%e %Y")} at midnight UTC
|
255
|
+
@pdf.text "<color rgb='999999'> Your designated credit card will be charged on #{@data[:period_charge_date].strftime("%B,%e %Y")} at midnight UTC by Maestrano Pty Ltd as service provider to the #{MnoEnterprise.app_name} platform.</color>", inline_format: true
|
254
256
|
end
|
255
257
|
end
|
256
258
|
end
|
@@ -94,12 +94,15 @@ en:
|
|
94
94
|
cancel: Cancel
|
95
95
|
next: Next
|
96
96
|
invite: Invite
|
97
|
+
roles_info:
|
98
|
+
member: "A <b>Member</b> can see other members and access the company apps"
|
99
|
+
admin: "An <b>Admin</b> can manage other members (except Super Admin users) and manage the company apps"
|
100
|
+
super_admin: "A <b>Super Admin</b> has all power within the company including access to billing management"
|
97
101
|
edition_modal:
|
98
102
|
cancel: Cancel
|
99
103
|
change: Change
|
100
104
|
roles:
|
101
105
|
member: A member can see other members and access the company apps
|
102
|
-
power_user: A Power User can see other members and start idle company apps (on per hour plan)
|
103
106
|
admin: An Admin can manage other members (except Super Admin users) and manage the company apps
|
104
107
|
super_admin: A Super Admin has all power within the company including access to billing management
|
105
108
|
removal_modal:
|
@@ -92,6 +92,9 @@ module MnoEnterprise::Concerns::Controllers::Auth::ConfirmationsController
|
|
92
92
|
end
|
93
93
|
|
94
94
|
if resource.errors.empty?
|
95
|
+
if params[:tos] == "accept"
|
96
|
+
params[:user][:meta_data] = resource.meta_data.merge(tos_accepted_at: Time.current)
|
97
|
+
end
|
95
98
|
resource.assign_attributes(params[:user]) unless resource.confirmed?
|
96
99
|
resource.perform_confirmation(@confirmation_token)
|
97
100
|
resource.save
|
@@ -20,7 +20,8 @@ module MnoEnterprise::Concerns::Controllers::Auth::RegistrationsController
|
|
20
20
|
:surname,
|
21
21
|
:company,
|
22
22
|
:phone,
|
23
|
-
:phone_country_code
|
23
|
+
:phone_country_code,
|
24
|
+
{meta_data: [:tos_accepted_at]}
|
24
25
|
)}
|
25
26
|
end
|
26
27
|
end
|
@@ -44,6 +45,11 @@ module MnoEnterprise::Concerns::Controllers::Auth::RegistrationsController
|
|
44
45
|
|
45
46
|
# POST /resource
|
46
47
|
def create
|
48
|
+
# Filling the time at which TOS were accepted
|
49
|
+
if params[:tos]
|
50
|
+
params[:user][:meta_data] = {tos_accepted_at: Time.current}
|
51
|
+
end
|
52
|
+
|
47
53
|
build_resource(sign_up_params)
|
48
54
|
resource.password ||= Devise.friendly_token
|
49
55
|
|
@@ -144,7 +144,7 @@ module MnoEnterprise::Concerns::Models::Ability
|
|
144
144
|
|
145
145
|
# Abilities for admin user
|
146
146
|
def admin_abilities(user)
|
147
|
-
if user.admin_role.to_s.casecmp('admin').zero?
|
147
|
+
if user.admin_role.to_s.casecmp('admin').zero? || user.admin_role.to_s.casecmp('staff').zero?
|
148
148
|
can :manage_app_instances, MnoEnterprise::Organization
|
149
149
|
end
|
150
150
|
end
|
@@ -3,6 +3,8 @@ require 'action_mailer/railtie'
|
|
3
3
|
module MnoEnterprise
|
4
4
|
# Base class (instantiable) for SMTP adapter
|
5
5
|
class SmtpClient < ActionMailer::Base
|
6
|
+
helper MnoEnterprise::ImageHelper
|
7
|
+
|
6
8
|
# Send SMTP template - terminal mailing part
|
7
9
|
def deliver(template, from, to, vars={}, opts={})
|
8
10
|
@info = vars
|
@@ -3,67 +3,74 @@ require 'rails_helper'
|
|
3
3
|
module MnoEnterprise
|
4
4
|
describe ImageHelper do
|
5
5
|
|
6
|
-
let(:folder) {
|
6
|
+
let(:folder) { '/app/assets/images/mno_enterprise' }
|
7
7
|
let(:root) {"#{Rails.root}#{folder}"}
|
8
8
|
let(:path_engine_main_logo) { "#{MnoEnterprise::Engine.root}#{folder}/main-logo.png" }
|
9
9
|
let(:path_main_logo) { "#{root}/main-logo.png" }
|
10
10
|
let(:path_main_logo_white) { "#{root}/main-logo-whitebg.png" }
|
11
11
|
|
12
|
-
describe
|
12
|
+
describe '#main_logo_white_bg_path' do
|
13
13
|
|
14
|
-
context
|
14
|
+
context 'when no logos exist' do
|
15
15
|
|
16
|
-
it
|
17
|
-
expect(helper.main_logo_white_bg_path).to match(
|
16
|
+
it 'returns the engine main-logo filename' do
|
17
|
+
expect(helper.main_logo_white_bg_path).to match('mno_enterprise/main-logo.png')
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it 'returns the engine main-logo full path' do
|
21
21
|
expect(helper.main_logo_white_bg_path(true)).to match(path_engine_main_logo)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
context
|
25
|
+
context 'when main-logo.png exists and main-logo-whitebg.png do not exist' do
|
26
26
|
before { allow(File).to receive(:exists?).with(path_main_logo_white).and_return(false) }
|
27
27
|
before { allow(File).to receive(:exists?).with(path_main_logo).and_return(true) }
|
28
28
|
|
29
|
-
it
|
30
|
-
expect(helper.main_logo_white_bg_path).to match(
|
29
|
+
it 'returns the main-logo filename' do
|
30
|
+
expect(helper.main_logo_white_bg_path).to match('mno_enterprise/main-logo.png')
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'returns the main-logo full path' do
|
34
34
|
expect(helper.main_logo_white_bg_path(true)).to match(path_main_logo)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
context
|
38
|
+
context 'when main-logo-whitebg.png exists' do
|
39
39
|
before { allow(File).to receive(:exists?).with(path_main_logo_white).and_return(true) }
|
40
40
|
|
41
|
-
it
|
42
|
-
expect(helper.main_logo_white_bg_path).to match(
|
41
|
+
it 'returns the filename' do
|
42
|
+
expect(helper.main_logo_white_bg_path).to match('mno_enterprise/main-logo-whitebg.png')
|
43
43
|
end
|
44
44
|
|
45
|
-
it
|
45
|
+
it 'returns the full path' do
|
46
46
|
expect(helper.main_logo_white_bg_path(true)).to match(path_main_logo_white)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
describe
|
51
|
+
describe '#main_logo_path' do
|
52
52
|
|
53
|
-
context
|
53
|
+
context 'when there are no logos' do
|
54
54
|
|
55
|
-
it
|
55
|
+
it 'returns the engines main-logo' do
|
56
56
|
expect(helper.main_logo_path).to match(path_engine_main_logo)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
context
|
60
|
+
context 'when main-logo.png exists' do
|
61
61
|
before { allow(File).to receive(:exists?).with(path_main_logo).and_return(true) }
|
62
62
|
|
63
|
-
it
|
63
|
+
it 'returns the full path' do
|
64
64
|
expect(helper.main_logo_path).to match(path_main_logo)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
|
+
|
69
|
+
describe '#fit_image' do
|
70
|
+
|
71
|
+
it 'returns the style' do
|
72
|
+
expect(helper.fit_image).to match('max-width: 150px; max-height: 150px;')
|
73
|
+
end
|
74
|
+
end
|
68
75
|
end
|
69
76
|
end
|
@@ -2,17 +2,14 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
module MnoEnterprise
|
4
4
|
RSpec.describe Impac::Dashboard, type: :model do
|
5
|
-
|
5
|
+
let(:org1) { build(:organization) }
|
6
|
+
subject(:dashboard) { build(:impac_dashboard, organization_ids: [org1.uid]) }
|
6
7
|
|
7
8
|
describe '#full_name' do
|
8
9
|
subject { dashboard.full_name }
|
9
10
|
it { is_expected.to eq(dashboard.name) }
|
10
11
|
end
|
11
12
|
|
12
|
-
describe '#sorted_widgets' do
|
13
|
-
it 'is pending'
|
14
|
-
end
|
15
|
-
|
16
13
|
describe '#filtered_widgets_templates' do
|
17
14
|
let(:templates) {
|
18
15
|
[
|
@@ -42,5 +39,20 @@ module MnoEnterprise
|
|
42
39
|
end
|
43
40
|
end
|
44
41
|
end
|
42
|
+
|
43
|
+
describe '#organizations(orgs_list)' do
|
44
|
+
subject { dashboard.organizations(orgs_list) }
|
45
|
+
|
46
|
+
let(:org2) { build(:organization) }
|
47
|
+
let(:orgs_list) { [org1, org2] }
|
48
|
+
|
49
|
+
it { is_expected.to eq([org1]) }
|
50
|
+
|
51
|
+
context 'when the dashboard is a template' do
|
52
|
+
let(:dashboard) { build(:impac_dashboard, organization_ids: [org1.uid], dashboard_type: 'template') }
|
53
|
+
|
54
|
+
it { is_expected.to eq([org1, org2]) }
|
55
|
+
end
|
56
|
+
end
|
45
57
|
end
|
46
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mno-enterprise-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arnaud Lachaume
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|