mno-enterprise-core 3.0.7 → 3.1.0

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.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/mno_enterprise/login-background.jpg +0 -0
  3. data/app/assets/stylesheets/mno_enterprise/mail.css +27 -0
  4. data/app/helpers/mno_enterprise/application_helper.rb +14 -0
  5. data/app/helpers/mno_enterprise/impersonate_helper.rb +1 -1
  6. data/app/models/mno_enterprise/app.rb +2 -1
  7. data/app/models/mno_enterprise/base_resource.rb +1 -2
  8. data/app/models/mno_enterprise/impac/dashboard.rb +3 -1
  9. data/app/models/mno_enterprise/impac/kpi.rb +1 -1
  10. data/app/models/mno_enterprise/impac/widget.rb +1 -1
  11. data/app/models/mno_enterprise/org_invite.rb +2 -1
  12. data/app/models/mno_enterprise/tenant.rb +2 -4
  13. data/app/models/mno_enterprise/user.rb +6 -0
  14. data/app/pdf/mno_enterprise/invoice_pdf.rb +29 -12
  15. data/app/views/system_notifications/confirmation-instructions.html.erb +26 -0
  16. data/app/views/system_notifications/confirmation-instructions.text.erb +10 -0
  17. data/app/views/system_notifications/delete-request-instructions.html.erb +31 -0
  18. data/app/views/system_notifications/delete-request-instructions.text.erb +15 -0
  19. data/app/views/system_notifications/organization-invite-existing-user.html.erb +30 -0
  20. data/app/views/system_notifications/organization-invite-existing-user.text.erb +13 -0
  21. data/app/views/system_notifications/organization-invite-new-user.html.erb +30 -0
  22. data/app/views/system_notifications/organization-invite-new-user.text.erb +14 -0
  23. data/app/views/system_notifications/reconfirmation-instructions.html.erb +27 -0
  24. data/app/views/system_notifications/reconfirmation-instructions.text.erb +10 -0
  25. data/app/views/system_notifications/registration-instructions.html.erb +27 -0
  26. data/app/views/system_notifications/registration-instructions.text.erb +9 -0
  27. data/app/views/system_notifications/reset-password-instructions.html.erb +27 -0
  28. data/app/views/system_notifications/reset-password-instructions.text.erb +11 -0
  29. data/app/views/system_notifications/unlock-instructions.html.erb +27 -0
  30. data/app/views/system_notifications/unlock-instructions.text.erb +10 -0
  31. data/config/initializers/audit_log.rb +2 -0
  32. data/config/locales/templates/dashboard/organization/en.yml +2 -0
  33. data/config/locales/views/auth/registrations/en.yml +1 -1
  34. data/lib/devise/hooks/impersonatable.rb +14 -0
  35. data/lib/devise_extension.rb +9 -2
  36. data/lib/generators/mno_enterprise/install/templates/config/application.yml +6 -2
  37. data/lib/generators/mno_enterprise/install/templates/config/initializers/mno_enterprise.rb +6 -1
  38. data/lib/generators/mno_enterprise/install/templates/config/settings.yml +2 -0
  39. data/lib/generators/mno_enterprise/install/templates/config/settings/uat.yml +2 -2
  40. data/lib/generators/mno_enterprise/install/templates/stylesheets/main.less +4 -0
  41. data/lib/her_extension/model/relation.rb +0 -13
  42. data/lib/mandrill_client.rb +13 -41
  43. data/lib/mno_enterprise/concerns/models/ability.rb +12 -0
  44. data/lib/mno_enterprise/concerns/models/organization.rb +5 -2
  45. data/lib/mno_enterprise/core.rb +21 -8
  46. data/lib/mno_enterprise/mail_adapters/adapter.rb +51 -0
  47. data/lib/mno_enterprise/mail_adapters/mandrill_adapter.rb +39 -0
  48. data/lib/mno_enterprise/mail_adapters/smtp_adapter.rb +21 -0
  49. data/lib/mno_enterprise/mail_adapters/sparkpost_adapter.rb +56 -0
  50. data/lib/mno_enterprise/mail_adapters/test_adapter.rb +21 -0
  51. data/lib/mno_enterprise/mail_client.rb +28 -0
  52. data/lib/mno_enterprise/smtp_client.rb +32 -0
  53. data/lib/mno_enterprise/testing_support/factories/apps.rb +1 -2
  54. data/lib/mno_enterprise/testing_support/factories/impac/kpis.rb +1 -0
  55. data/lib/mno_enterprise/testing_support/factories/tenant.rb +1 -7
  56. data/lib/mno_enterprise/testing_support/mno_enterprise_api_test_helper.rb +1 -2
  57. data/lib/mno_enterprise/version.rb +1 -1
  58. data/spec/lib/her_extension/model/relation_spec.rb +0 -71
  59. data/spec/lib/mandrill_client_spec.rb +27 -42
  60. data/spec/lib/mno_enterprise/mail_adapters/adapter_spec.rb +29 -0
  61. data/spec/lib/mno_enterprise/mail_adapters/mandrill_adapter_spec.rb +53 -0
  62. data/spec/lib/mno_enterprise/mail_adapters/smtp_adapter_spec.rb +29 -0
  63. data/spec/lib/mno_enterprise/mail_adapters/sparkpost_adapter_spec.rb +60 -0
  64. data/spec/lib/mno_enterprise/mail_client_spec.rb +9 -0
  65. data/spec/lib/mno_enterprise/smtp_client_spec.rb +39 -0
  66. data/spec/models/mno_enterprise/ability_spec.rb +21 -0
  67. data/spec/models/mno_enterprise/base_resource_spec.rb +0 -22
  68. metadata +76 -24
  69. data/lib/her_extension/middleware/mnoe_raise_error.rb +0 -21
  70. data/lib/her_extension/model/associations/belongs_to_association.rb +0 -25
@@ -0,0 +1,14 @@
1
+ Hi there
2
+ =================================================================
3
+
4
+ You have been invited by <%= @info[:ref_full_name] %> to join <%= @info[:organization] %> on our platform!. You can automatically create your account on our platform and join <%= @info[:organization] %> by clicking on the link below:
5
+ <%= @info[:confirmation_link] %>
6
+
7
+ <% if @info[:team]? %>
8
+ By accepting this invite you will automatically join the <%= @info[:team] %> team.
9
+ <% end %>
10
+
11
+
12
+ Regards,
13
+ The Marketplace team
14
+
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ <%= stylesheet_link_tag('mno_enterprise/mail.css') %>
6
+ </head>
7
+ <body>
8
+ <p class="header">
9
+ <%= image_tag('mno_enterprise/main-logo.png') %>
10
+ </p>
11
+
12
+ <p>Hi <%= @info[:first_name] %></p>
13
+
14
+ <p>You have asked to change your email address in the platform. Please confirm this new email address by clicking on the following link</p>
15
+
16
+ <a href="<%= @info[:confirmation_link] %>">Confirm my new email address</a>
17
+
18
+ <p>
19
+ Regards,<br/>
20
+ The Marketplace team
21
+ </p>
22
+
23
+ <p class="footer">
24
+ <%= @info[:company] %>
25
+ </p>
26
+ </body>
27
+ </html>
@@ -0,0 +1,10 @@
1
+ Hi <%= @info[:first_name] %>
2
+ =================================================================
3
+
4
+ You have asked to change your email address in the platform. Please confirm this new email address by clicking on the following link
5
+
6
+ <%= @info[:confirmation_link] %>
7
+
8
+
9
+ Regards,
10
+ The Marketplace team
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ <%= stylesheet_link_tag('mno_enterprise/mail.css') %>
6
+ </head>
7
+ <body>
8
+ <p class="header">
9
+ <%= image_tag('mno_enterprise/main-logo.png') %>
10
+ </p>
11
+
12
+ <p>Hi there,</p>
13
+
14
+ <p>You have been invited to create an account on our platform! You can do so by clicking on the link below:</p>
15
+
16
+ <a href="<%= @info[:registration_link] %>">Create my account</a>
17
+
18
+ <p>
19
+ Regards,<br/>
20
+ The Marketplace team
21
+ </p>
22
+
23
+ <p class="footer">
24
+ <%= @info[:company] %>
25
+ </p>
26
+ </body>
27
+ </html>
@@ -0,0 +1,9 @@
1
+ Hi there,
2
+ =================================================================
3
+ You have been invited to create an account on our platform! You can do so by clicking on the link below:
4
+
5
+ <%= @info[:registration_link] %>
6
+
7
+
8
+ Regards,
9
+ The Marketplace team
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ <%= stylesheet_link_tag('mno_enterprise/mail.css') %>
6
+ </head>
7
+ <body>
8
+ <p class="header">
9
+ <%= image_tag('mno_enterprise/main-logo.png') %>
10
+ </p>
11
+
12
+ <p>Hi <%= @info[:first_name] %></p>
13
+
14
+ <p>You can reset your password by clicking on the following link</p>
15
+
16
+ <a href="<%= @info[:reset_password_link] %>">Reset my password</a>
17
+
18
+ <p>
19
+ Regards,<br/>
20
+ The Marketplace team
21
+ </p>
22
+
23
+ <p class="footer">
24
+ <%= @info[:company] %>
25
+ </p>
26
+ </body>
27
+ </html>
@@ -0,0 +1,11 @@
1
+ Hi <%= @info[:first_name] %>
2
+ =================================================================
3
+
4
+ You can reset your password by clicking on the following link
5
+
6
+ To reset password, please follow this link : <%= @info[:reset_password_link] %>
7
+
8
+
9
+ Regards,
10
+ The Marketplace team
11
+
@@ -0,0 +1,27 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
5
+ <%= stylesheet_link_tag('mno_enterprise/mail.css') %>
6
+ </head>
7
+ <body>
8
+ <p class="header">
9
+ <%= image_tag('mno_enterprise/main-logo.png') %>
10
+ </p>
11
+
12
+ <p>Hi <%= @info[:first_name] %></p>
13
+
14
+ <p>You can unlock your account by clicking on the following link</p>
15
+
16
+ <a href="<%= @info[:unlock_link] %>">Unlock my account</a>
17
+
18
+ <p>
19
+ Regards,<br/>
20
+ The Marketplace team
21
+ </p>
22
+
23
+ <p class="footer">
24
+ <%= @info[:company] %>
25
+ </p>
26
+ </body>
27
+ </html>
@@ -0,0 +1,10 @@
1
+ Hi <%= @info[:first_name] %>
2
+ =================================================================
3
+
4
+ You can unlock your account by clicking on the following link
5
+
6
+ <%= @info[:unlock_link] %>
7
+
8
+
9
+ Regards,
10
+ The Marketplace team
@@ -1,3 +1,5 @@
1
+ # Somehow the whole config/ folder is loaded twice
2
+ # To investigate
1
3
  unless defined? AUDIT_LOG_CONFIG
2
4
  AUDIT_LOG_CONFIG = Rails.application.config_for('audit_log') rescue {}
3
5
  end
@@ -77,6 +77,8 @@ en:
77
77
  edit: Edit
78
78
  remove: Remove
79
79
  invite_modal:
80
+ title_name: "Edit Member: {{name}} {{surname}}"
81
+ title_email: "Edit Member: {{email}}"
80
82
  description: Enter the email addresses of the people you want to invite in your company
81
83
  example: "One address per line, e.g.:"
82
84
  disclaimer: Please note that for security reasons unaccepted invites will automatically expire after 3 days.
@@ -6,4 +6,4 @@ en:
6
6
  title: Sign Up
7
7
  create: Create my account!
8
8
  user_accept: I accept
9
- tos: the Terms of Use
9
+ tos: the Terms of Use
@@ -0,0 +1,14 @@
1
+ # Allow unconfirmed user to be impersonated
2
+ # We override User#confirmation_required? when impersonating
3
+ Warden::Manager.prepend_after_set_user do |record, warden, options|
4
+ impersonator_id = warden.env['rack.session'][:impersonator_user_id]
5
+
6
+ if impersonator_id
7
+ class <<record
8
+ # Callback to overwrite if confirmation is required or not.
9
+ def confirmation_required?
10
+ false
11
+ end
12
+ end
13
+ end
14
+ end
@@ -2,6 +2,9 @@ require 'devise'
2
2
  require 'devise/models/password_expirable'
3
3
  require 'devise/extension_routes'
4
4
 
5
+ # Hook for impersonation
6
+ require 'devise/hooks/impersonatable'
7
+
5
8
  module Devise
6
9
  # Should the password expire (e.g 3.months)
7
10
  mattr_accessor :expire_password_after
@@ -27,6 +30,10 @@ end
27
30
  # modules
28
31
  Devise.add_module :password_expirable, controller: :password_expirable, model: 'devise/models/password_expirable', route: :password_expired
29
32
 
30
- ActiveSupport.on_load(:action_controller) do
31
- include DeviseExtension::Controllers::Helpers
33
+ module DeviseExtension
34
+ class Engine < ::Rails::Engine
35
+ ActiveSupport.on_load(:action_controller) do
36
+ include DeviseExtension::Controllers::Helpers
37
+ end
38
+ end
32
39
  end
@@ -4,8 +4,12 @@
4
4
  tenant_id: my_tenant_id
5
5
  tenant_key: my_tenant_access_key
6
6
 
7
- # Emailing platform - Mandrill (default mandrill)
8
- # mandrill_key: changeme
7
+ # Emailing platform
8
+ # MANDRILL_API_KEY: changeme
9
+ # SPARKPOST_API_KEY: changeme
9
10
 
10
11
  # Rails secret key
11
12
  SECRET_KEY_BASE: <%= SecureRandom.hex(64) %>
13
+
14
+ # Google Tag Manager
15
+ google_tag_container: GTM-TH3MLB
@@ -28,6 +28,11 @@ MnoEnterprise.configure do |config|
28
28
  # Defaulted to Maestrano Enterprise demo account
29
29
  # config.mandrill_key = 'some-mandrill-api-key'
30
30
 
31
+ # Adapter used to send emails
32
+ # Default to :mandrill
33
+ # config.mail_adapter = :mandrill
34
+ # config.mail_adapter = :sparkpost
35
+
31
36
  # Support email address
32
37
  config.support_email = 'support@example.com'
33
38
 
@@ -64,7 +69,7 @@ MnoEnterprise.configure do |config|
64
69
  # Third Party Plugins
65
70
  #===============================================
66
71
  # Google Tag Manager
67
- # config.google_tag_container = nil
72
+ config.google_tag_container = ENV['google_tag_container']
68
73
 
69
74
  #===============================================
70
75
  # API Configuration
@@ -5,3 +5,5 @@ mno:
5
5
  paths:
6
6
  root: /api/mnoe/v1
7
7
  frontend_host:
8
+ pricing:
9
+ enabled: false
@@ -1,6 +1,6 @@
1
1
  impac:
2
2
  protocol: https
3
- host: api-impac-uat.maestrano.io
3
+ host: api-impac.maestrano.com
4
4
  mno:
5
5
  protocol: https
6
- host: uat.maestrano.io
6
+ host: maestrano.com
@@ -19,6 +19,10 @@
19
19
  //--------------------------------------------
20
20
  @import "../../../frontend/src/app/stylesheets/variables";
21
21
 
22
+ // Import custom fonts
23
+ //--------------------------------------------
24
+ @import "../../../frontend/src/fonts/font-faces";
25
+
22
26
  // Import published theme previewer style
23
27
  //--------------------------------------------
24
28
  // Comment this line if you do not plan to use
@@ -26,25 +26,12 @@ module Her
26
26
  # Use filter instead of raw parameters
27
27
  def where(params = {})
28
28
  return self if !params || params.empty?
29
- # If a value is an empty array, it'll be excluded when calling params.to_query, so convert it to nil instead
30
- params.each { |k, v| params[k] = v.presence if v.is_a?(Array) }
31
-
32
29
  self.params[:filter] ||= {}
33
30
  self.params[:filter].merge!(params)
34
31
  self
35
32
  end
36
33
  alias all where
37
34
 
38
- # Patch to unwrap filter when creating
39
- def first_or_create(attributes = {})
40
- fetch.first || create((@params.delete(:filter) || {}).merge(attributes))
41
- end
42
-
43
- # Patch to unwrap filter when creating
44
- def first_or_initialize(attributes = {})
45
- fetch.first || build((@params.delete(:filter) || {}).merge(attributes))
46
- end
47
-
48
35
  # E.g:
49
36
  # Product.order_by('created_at.desc','name.asc')
50
37
  def order_by(*args)
@@ -1,58 +1,30 @@
1
1
  # An interface to the Mandrill API
2
- # Example usage:
3
- # MandrillClient.send_template(template_name(string), template_content(array), message(hash))
2
+ # @example
3
+ # MandrillClient.send_template(template_name(string), template_content(array), message(hash))
4
+ # @deprecated Please use {MnoEnterprise::MailClient}
4
5
  module MandrillClient
5
6
  class << self
6
-
7
- # Store the list of mandrill emails that are pending
8
- # to be sent
9
- # Only used for testing
10
- # E.g: expect { some_action }.to change(MandrillClient.base_deliveries,:count).by(1)
11
- def base_deliveries
12
- @base_deliveries ||= []
13
- end
14
-
15
- # Check whether mailers are in test mode or not
16
- # Emails should not be sent in test mode
17
- def test?
18
- (Rails.configuration.action_mailer.delivery_method || '').to_sym == :test
19
- end
20
-
21
7
  # Return a mandrill client configured with the right API key
8
+ # @deprecated Use MnoEnterprise::MailClient
22
9
  def client
23
10
  @client ||= Mandrill::API.new(MnoEnterprise.mandrill_key)
24
11
  end
25
12
 
26
13
  # Send the provided template with options
27
- # MandrillClient.send_template(template_name(string), template_content(array), message(hash))
14
+ #
15
+ # @example MandrillClient.send_template(template_name(string), template_content(array), message(hash))
16
+ # @deprecated Use MnoEnterprise::MailClient
28
17
  def send_template(*args)
29
- if self.test?
30
- self.base_deliveries.push(args)
31
- else
32
- self.client.messages.send_template(*args)
33
- end
18
+ warn '[DEPRECATION] `MandrillClient` is deprecated. Please use `MnoEnterprise::MailClient` instead.'
19
+ MnoEnterprise::MailClient.adapter.send_template(*args)
34
20
  end
35
21
 
36
22
  # A simpler version of send_template
37
23
  #
38
- # Take in argument:
39
- # template: name of a mandrill template
40
- # from: hash describing the sender. E.g.: { name: "John", email: "john.doe@maestrano.com" }
41
- # to: Array or hash describing the recipient. E.g.: { name: "Jack", email: "jack.doe@maestrano.com" }
42
- # vars: Mandrill email variables. E.g.: { link: "https://mywebsite.com/confirm_account" }
43
- # opts: additional parameters to pass to mandrill. See: https://mandrillapp.com/api/docs/messages.ruby.html
44
- #
24
+ # @deprecated Use MnoEnterprise::MailClient
45
25
  def deliver(template,from,to,vars = {},opts = {})
46
- # Prepare message from args
47
- message = { from_name: from[:name], from_email: from[:email]}
48
- message[:to] = [to].flatten.map { |t| {name: t[:name], email: t[:email], type: (t[:type] || :to) } }
49
- message[:global_merge_vars] = vars.map { |k,v| {name: k.to_s, content: v} }
50
-
51
- # Merge additional mandrill options
52
- message.merge!(opts)
53
-
54
- self.send_template(template,[],message)
26
+ warn '[DEPRECATION] `MandrillClient` is deprecated. Please use `MnoEnterprise::MailClient` instead.'
27
+ MnoEnterprise::MailClient.deliver(template,from,to,vars,opts)
55
28
  end
56
29
  end
57
-
58
- end
30
+ end
@@ -70,6 +70,11 @@ module MnoEnterprise::Concerns::Models::Ability
70
70
  #===================================================
71
71
  impac_abilities(user)
72
72
 
73
+ #===================================================
74
+ # Admin abilities
75
+ #===================================================
76
+ admin_abilities(user)
77
+
73
78
  # Define abilities for the passed in user here. For example:
74
79
  #
75
80
  # user ||= User.new # guest user (not logged in)
@@ -105,4 +110,11 @@ module MnoEnterprise::Concerns::Models::Ability
105
110
  end
106
111
  end
107
112
  end
113
+
114
+ # Abilities for admin user
115
+ def admin_abilities(user)
116
+ if user.admin_role == 'admin'
117
+ can :manage_app_instances, MnoEnterprise::Organization
118
+ end
119
+ end
108
120
  end
@@ -69,8 +69,11 @@ module MnoEnterprise::Concerns::Models::Organization
69
69
  #==================================================================
70
70
  # Return the list of users + active invites
71
71
  # TODO: specs
72
- def members
73
- [self.users,self.org_invites.active].flatten
72
+ #
73
+ # @params [Boolean] show_staged Also displayed staged invites (ie: not sent)
74
+ def members(show_staged=false)
75
+ invites = show_staged ? self.org_invites.active_or_staged : self.org_invites.active
76
+ [self.users, invites].flatten
74
77
  end
75
78
 
76
79
  # Add a user to the organization with the provided role