mno-enterprise-core 3.0.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/mno_enterprise/base_resource.rb +1 -0
- data/app/models/mno_enterprise/impac/dashboard.rb +35 -24
- data/app/models/mno_enterprise/user.rb +1 -1
- data/lib/generators/mno_enterprise/install/install_generator.rb +3 -29
- data/lib/generators/mno_enterprise/install/templates/Procfile.dev +1 -1
- data/lib/generators/mno_enterprise/install/templates/config/initializers/mno_enterprise.rb +50 -0
- data/lib/her_extension/model/parse.rb +18 -1
- data/lib/mno_enterprise/concerns/models/organization.rb +1 -1
- data/lib/mno_enterprise/core.rb +8 -0
- data/lib/mno_enterprise/version.rb +1 -1
- data/spec/models/mno_enterprise/impac/dashboard_spec.rb +46 -0
- metadata +16 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c90db7a2040c41d7bdac3c6fc451f911f20a9e0b
|
4
|
+
data.tar.gz: 97d844facb19a294230b73ff698844cb92d544be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c628595de057ec3cffb1ccaf242f0da9fde8543cb2b26f571ff6bc355db0f16b283c956b73440daeec93dedf0882be0de3ae528a287f7d9341ee16cf49aa441
|
7
|
+
data.tar.gz: 2ebbabb8f8ed5df2e7ffb5b47fa0a64ff345cd99e717ba2ab8dfba00a0752dcdb56baf0df9efab6614ce85ec14c8fa442271e7407375ffd053fa43b6c4a9c6f1
|
@@ -3,31 +3,42 @@ module MnoEnterprise
|
|
3
3
|
|
4
4
|
attributes :name, :widgets_order, :organization_ids, :widgets_templates, :currency
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
#============================================
|
11
|
-
# Instance methods
|
12
|
-
#============================================
|
13
|
-
# Return the full name of this dashboard
|
14
|
-
# Currently a simple accessor to the dashboard name (used to include the company name)
|
15
|
-
def full_name
|
16
|
-
self.name
|
17
|
-
end
|
18
|
-
|
19
|
-
# Return all the organizations linked to this dashboard and to which
|
20
|
-
# the user has access
|
21
|
-
def organizations
|
22
|
-
self.organization_ids.map do |uid|
|
23
|
-
MnoEnterprise::Organization.find_by(uid: uid)
|
24
|
-
end
|
25
|
-
end
|
6
|
+
has_many :widgets, class_name: 'MnoEnterprise::Impac::Widget', dependent: :destroy
|
7
|
+
has_many :kpis, class_name: 'MnoEnterprise::Impac::Kpi', dependent: :destroy
|
8
|
+
belongs_to :owner, polymorphic: true
|
26
9
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
10
|
+
#============================================
|
11
|
+
# Instance methods
|
12
|
+
#============================================
|
13
|
+
# Return the full name of this dashboard
|
14
|
+
# Currently a simple accessor to the dashboard name (used to include the company name)
|
15
|
+
def full_name
|
16
|
+
self.name
|
17
|
+
end
|
18
|
+
|
19
|
+
# Return all the organizations linked to this dashboard and to which
|
20
|
+
# the user has access
|
21
|
+
def organizations
|
22
|
+
self.organization_ids.map do |uid|
|
23
|
+
MnoEnterprise::Organization.find_by(uid: uid)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def sorted_widgets
|
28
|
+
order = self.widgets_order.map(&:to_i) | self.widgets.map{|w| w.id }
|
29
|
+
order.map { |id| self.widgets.to_a.find{ |w| w.id == id} }.compact
|
30
|
+
end
|
31
|
+
|
32
|
+
# Filter widgets list based on config
|
33
|
+
def filtered_widgets_templates
|
34
|
+
if MnoEnterprise.widgets_templates_listing
|
35
|
+
return self.widgets_templates.select do |t|
|
36
|
+
MnoEnterprise.widgets_templates_listing.include?(t[:path])
|
37
|
+
end
|
38
|
+
else
|
39
|
+
return self.widgets_templates
|
40
|
+
end
|
41
|
+
end
|
31
42
|
|
32
43
|
def to_audit_event
|
33
44
|
name
|
@@ -47,7 +47,7 @@ module MnoEnterprise
|
|
47
47
|
:remember_created_at, :sign_in_count, :current_sign_in_at, :last_sign_in_at, :current_sign_in_ip,
|
48
48
|
:last_sign_in_ip, :confirmation_token, :confirmed_at, :confirmation_sent_at, :unconfirmed_email,
|
49
49
|
:failed_attempts, :unlock_token, :locked_at, :name, :surname, :company, :phone, :phone_country_code,
|
50
|
-
:geo_country_code, :geo_state_code, :geo_city, :website, :orga_on_create, :sso_session, :current_password_required
|
50
|
+
:geo_country_code, :geo_state_code, :geo_city, :website, :orga_on_create, :sso_session, :current_password_required, :admin_role
|
51
51
|
|
52
52
|
define_model_callbacks :validation #required by Devise
|
53
53
|
devise :remote_authenticatable, :registerable, :recoverable, :rememberable,
|
@@ -6,8 +6,8 @@ module MnoEnterprise
|
|
6
6
|
source_root File.expand_path("../templates", __FILE__)
|
7
7
|
desc "Description:\n Install Maestrano Enterprise Engine in your application\n\n"
|
8
8
|
|
9
|
-
class_option :skip_rspec, type: :boolean, default: false, desc: 'Skip rspec-rails installation'
|
10
|
-
class_option :skip_factory_girl, type: :boolean, default: false, desc: 'Skip factory_girl installation'
|
9
|
+
# class_option :skip_rspec, type: :boolean, default: false, desc: 'Skip rspec-rails installation'
|
10
|
+
# class_option :skip_factory_girl, type: :boolean, default: false, desc: 'Skip factory_girl installation'
|
11
11
|
class_option :skip_frontend, type: :boolean, default: false, desc: 'Skip frontend installation'
|
12
12
|
class_option :skip_admin, type: :boolean, default: false, desc: 'Skip admin installation'
|
13
13
|
|
@@ -90,8 +90,7 @@ module MnoEnterprise
|
|
90
90
|
# Inject engine routes
|
91
91
|
def notify_about_routes
|
92
92
|
if (routes_file = destination_path.join('config', 'routes.rb')).file? && (routes_file.read !~ %r{mount\ MnoEnterprise::Engine})
|
93
|
-
mount = %Q{
|
94
|
-
# This line mount Maestrano Enterprise routes in your application under /mnoe.
|
93
|
+
mount = %Q{ # This line mount Maestrano Enterprise routes in your application under /mnoe.
|
95
94
|
# If you would like to change where this engine is mounted, simply change the :at option to something different
|
96
95
|
#
|
97
96
|
# We ask that you don't use the :as option here, as Mnoe relies on it being the default of "mno_enterprise"
|
@@ -112,31 +111,6 @@ module MnoEnterprise
|
|
112
111
|
end
|
113
112
|
end
|
114
113
|
|
115
|
-
def install_rspec_rails
|
116
|
-
unless options[:skip_rspec]
|
117
|
-
say("\n")
|
118
|
-
@install_rspec = ask_with_default("Would you like to install rspec-rails?")
|
119
|
-
if @install_rspec
|
120
|
-
gem_group :test do
|
121
|
-
gem "rspec-rails"
|
122
|
-
end
|
123
|
-
generate "rspec:install"
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
def install_factory_girl
|
129
|
-
unless options[:skip_factory_girl]
|
130
|
-
say("\n")
|
131
|
-
@install_facto_girl = ask_with_default("Would you like to install factory_girl_rails?")
|
132
|
-
if @install_facto_girl
|
133
|
-
gem_group :test do
|
134
|
-
gem "factory_girl_rails"
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
114
|
def install_summary
|
141
115
|
unless options[:quiet]
|
142
116
|
say("\n\n")
|
@@ -1,2 +1,2 @@
|
|
1
1
|
web: bundle exec puma -p 7000
|
2
|
-
gulp:
|
2
|
+
gulp: cd ./tmp/build/frontend && node_modules/.bin/gulp serve
|
@@ -135,4 +135,54 @@ MnoEnterprise.configure do |config|
|
|
135
135
|
# "xero",
|
136
136
|
# "wordpress"
|
137
137
|
# ]
|
138
|
+
|
139
|
+
#====================================
|
140
|
+
# Impac! widgets templates listing
|
141
|
+
#====================================
|
142
|
+
# config.widgets_templates_listing = nil
|
143
|
+
# config.widgets_templates_listing = [
|
144
|
+
# 'accounts/balance',
|
145
|
+
# 'accounts/comparison',
|
146
|
+
# 'accounts/expenses_revenue',
|
147
|
+
# 'accounts/payable_receivable',
|
148
|
+
# 'accounts/assets_summary',
|
149
|
+
# 'accounts/custom_calculation',
|
150
|
+
# 'accounts/accounting_values/ebitda',
|
151
|
+
# 'accounts/accounting_values/turnover',
|
152
|
+
# 'accounts/accounting_values/workforce_costs',
|
153
|
+
# 'accounts/accounting_values/payroll_taxes_account',
|
154
|
+
# 'accounts/cash_summary',
|
155
|
+
# 'accounts/balance_sheet',
|
156
|
+
# 'accounts/profit_and_loss',
|
157
|
+
# 'invoices/list',
|
158
|
+
# 'invoices/summary',
|
159
|
+
# 'invoices/aged_payables_receivables',
|
160
|
+
# 'hr/workforce_summary',
|
161
|
+
# 'hr/salaries_summary',
|
162
|
+
# 'hr/employees_list',
|
163
|
+
# 'hr/employee_details',
|
164
|
+
# 'hr/payroll_taxes',
|
165
|
+
# 'hr/superannuation_accruals',
|
166
|
+
# 'hr/leaves_balance',
|
167
|
+
# 'hr/payroll_summary',
|
168
|
+
# 'hr/timesheets',
|
169
|
+
# 'sales/summary',
|
170
|
+
# 'sales/list',
|
171
|
+
# 'sales/growth',
|
172
|
+
# 'sales/segmented_turnover',
|
173
|
+
# 'sales/customer_details',
|
174
|
+
# 'sales/margin',
|
175
|
+
# 'sales/aged',
|
176
|
+
# 'sales/comparison',
|
177
|
+
# 'sales/leads_list',
|
178
|
+
# 'sales/number_of_leads',
|
179
|
+
# 'sales/cycle',
|
180
|
+
# 'sales/leads_funnel',
|
181
|
+
# 'sales/opportunities_funnel',
|
182
|
+
# 'sales/top_opportunities',
|
183
|
+
# 'sales/break_even',
|
184
|
+
# 'sales/forecast',
|
185
|
+
# 'sales/performance'
|
186
|
+
# ]
|
187
|
+
|
138
188
|
end
|
@@ -33,7 +33,24 @@ module Her
|
|
33
33
|
filtered_attributes
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
|
+
# @private
|
38
|
+
# TODO: Handle has_one
|
39
|
+
def embeded_params(attributes)
|
40
|
+
associations[:has_many].select { |a| attributes.include?(a[:data_key])}.compact.inject({}) do |hash, association|
|
41
|
+
params = attributes[association[:data_key]].map(&:to_params)
|
42
|
+
# <PATCH> - Return hash
|
43
|
+
next hash if params.empty?
|
44
|
+
# </PATCH>
|
45
|
+
if association[:class_name].constantize.include_root_in_json?
|
46
|
+
root = association[:class_name].constantize.root_element
|
47
|
+
hash[association[:data_key]] = params.map { |n| n[root] }
|
48
|
+
else
|
49
|
+
hash[association[:data_key]] = params
|
50
|
+
end
|
51
|
+
hash
|
52
|
+
end
|
53
|
+
end
|
37
54
|
end
|
38
55
|
end
|
39
56
|
end
|
@@ -37,7 +37,7 @@ module MnoEnterprise::Concerns::Models::Organization
|
|
37
37
|
included do
|
38
38
|
attributes :uid, :name, :account_frozen, :free_trial_end_at, :soa_enabled, :mails, :logo,
|
39
39
|
:latitude, :longitude, :geo_country_code, :geo_state_code, :geo_city, :geo_tz, :geo_currency,
|
40
|
-
:meta_data, :industry, :size
|
40
|
+
:meta_data, :industry, :size, :financial_year_end_month
|
41
41
|
|
42
42
|
scope :in_arrears, -> { where(in_arrears?: true) }
|
43
43
|
|
data/lib/mno_enterprise/core.rb
CHANGED
@@ -210,6 +210,14 @@ module MnoEnterprise
|
|
210
210
|
mattr_accessor :marketplace_listing
|
211
211
|
@@marketplace_listing = nil
|
212
212
|
|
213
|
+
#====================================
|
214
|
+
# Impac! widgets templates listing
|
215
|
+
#====================================
|
216
|
+
# List of widget templates that should be offered on Impac!
|
217
|
+
# if nil, all widget templates available will be offered
|
218
|
+
mattr_accessor :widgets_templates_listing
|
219
|
+
@@widgets_templates_listing = nil
|
220
|
+
|
213
221
|
#====================================
|
214
222
|
# Module Methods
|
215
223
|
#====================================
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
module MnoEnterprise
|
4
|
+
RSpec.describe Impac::Dashboard, type: :model do
|
5
|
+
subject(:dashboard) { build(:impac_dashboard) }
|
6
|
+
|
7
|
+
describe '#full_name' do
|
8
|
+
subject { dashboard.full_name }
|
9
|
+
it { is_expected.to eq(dashboard.name) }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#sorted_widgets' do
|
13
|
+
it 'is pending'
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#filtered_widgets_templates' do
|
17
|
+
let(:templates) {
|
18
|
+
[
|
19
|
+
{path: 'accounts/balance', name: 'Account balance'},
|
20
|
+
{path: 'accounts/comparison', name: 'Accounts comparison'}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
subject(:dashboard) { build(:impac_dashboard, widgets_templates: templates) }
|
24
|
+
|
25
|
+
subject { dashboard.filtered_widgets_templates }
|
26
|
+
|
27
|
+
context 'with no filter' do
|
28
|
+
before { MnoEnterprise.widgets_templates_listing = nil}
|
29
|
+
|
30
|
+
it 'returns all the widgets' do
|
31
|
+
expect(subject).to eq(templates)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with a filter' do
|
36
|
+
let(:filter) { ['accounts/balance'] }
|
37
|
+
before { MnoEnterprise.widgets_templates_listing = filter }
|
38
|
+
|
39
|
+
it 'returns a filtered list' do
|
40
|
+
expect(subject.size).to eq(1)
|
41
|
+
expect(subject.map{|h| h[:path]}).to eq(filter)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
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.0.
|
4
|
+
version: 3.0.1
|
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: 2016-04-
|
12
|
+
date: 2016-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -511,6 +511,7 @@ files:
|
|
511
511
|
- spec/models/mno_enterprise/app_spec.rb
|
512
512
|
- spec/models/mno_enterprise/base_resource_spec.rb
|
513
513
|
- spec/models/mno_enterprise/deletion_request_spec.rb
|
514
|
+
- spec/models/mno_enterprise/impac/dashboard_spec.rb
|
514
515
|
- spec/models/mno_enterprise/invoice_spec.rb
|
515
516
|
- spec/models/mno_enterprise/organization_spec.rb
|
516
517
|
- spec/models/mno_enterprise/user_spec.rb
|
@@ -536,24 +537,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
536
537
|
version: '0'
|
537
538
|
requirements: []
|
538
539
|
rubyforge_project:
|
539
|
-
rubygems_version: 2.
|
540
|
+
rubygems_version: 2.4.8
|
540
541
|
signing_key:
|
541
542
|
specification_version: 4
|
542
543
|
summary: Maestrano Enterprise - Core functionnality
|
543
544
|
test_files:
|
544
|
-
- spec/controllers/mno_enterprise/angular_csrf_spec.rb
|
545
|
-
- spec/controllers/mno_enterprise/i18n_spec.rb
|
546
|
-
- spec/lib/her_extension/her_orm_adapter.rb
|
547
|
-
- spec/lib/her_extension/model/relation_spec.rb
|
548
|
-
- spec/lib/mandrill_client_spec.rb
|
549
|
-
- spec/lib/mno_enterprise/core_engine_spec.rb
|
550
|
-
- spec/mno_enterprise_spec.rb
|
551
|
-
- spec/models/mno_enterprise/app_instance_spec.rb
|
552
545
|
- spec/models/mno_enterprise/app_spec.rb
|
553
|
-
- spec/models/mno_enterprise/
|
546
|
+
- spec/models/mno_enterprise/organization_spec.rb
|
547
|
+
- spec/models/mno_enterprise/app_instance_spec.rb
|
548
|
+
- spec/models/mno_enterprise/impac/dashboard_spec.rb
|
554
549
|
- spec/models/mno_enterprise/deletion_request_spec.rb
|
555
550
|
- spec/models/mno_enterprise/invoice_spec.rb
|
556
|
-
- spec/models/mno_enterprise/organization_spec.rb
|
557
551
|
- spec/models/mno_enterprise/user_spec.rb
|
558
|
-
- spec/
|
552
|
+
- spec/models/mno_enterprise/base_resource_spec.rb
|
559
553
|
- spec/spec_helper.rb
|
554
|
+
- spec/lib/mno_enterprise/core_engine_spec.rb
|
555
|
+
- spec/lib/her_extension/her_orm_adapter.rb
|
556
|
+
- spec/lib/her_extension/model/relation_spec.rb
|
557
|
+
- spec/lib/mandrill_client_spec.rb
|
558
|
+
- spec/rails_helper.rb
|
559
|
+
- spec/controllers/mno_enterprise/i18n_spec.rb
|
560
|
+
- spec/controllers/mno_enterprise/angular_csrf_spec.rb
|
561
|
+
- spec/mno_enterprise_spec.rb
|