mno-enterprise-api 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06a34e4066d4912616b04c98ef5d7a1edeaba36e
4
- data.tar.gz: 29516a4df5d0ddf21261b17e78d43d97743f65bc
3
+ metadata.gz: aca789ccaa3b68b00a79413bbf8e83bcb628036a
4
+ data.tar.gz: ccf5fa38550cb5e74f7004c1271c2a48a264e860
5
5
  SHA512:
6
- metadata.gz: 67aaab3ebbdb8ec01c453b96d53f6d4eae2f0e7cddf2bd5998f461c4e904fc6f760ada7d2f257412c7944a347a55ab7b7868f536e9cbb7106a88485854461053
7
- data.tar.gz: e9b4d84536aaf56dc637caa9997128f288ef77beab1d3cd8ec710b21eef0976d41833f0c28ac5f406706dcae813566b8d5c7563bc45f18ad844559dbc4370e86
6
+ metadata.gz: 302386679ffddde2bd791d19cb18d7b64dc4fadda341372f7622a1b81dce5160505bfcf895fecd2a73ec0bfb683e55a6bed46d26805c03a77b6380122634eee1
7
+ data.tar.gz: deb2aeb804abed9aa8b6fef398cad557224276195885fac6fa5990ebb6eb8810f7997fbb79a4c9e88d8fb20080b62fc9b5521909d8dd70ecc819883dbe3113ac
@@ -1,63 +1,5 @@
1
1
  module MnoEnterprise
2
2
  class Jpi::V1::Impac::WidgetsController < Jpi::V1::BaseResourceController
3
- respond_to :json
4
-
5
- # POST /mnoe/jpi/v1/impac/dashboards/:id/widgets
6
- # -> POST /api/mnoe/v1/dashboards/:id/widgets
7
- def create
8
- if widgets
9
- if @widget = widgets.create(format_attrs(['widget_category','metadata']))
10
- MnoEnterprise::EventLogger.info('widget_create', current_user.id, 'Widget Creation', nil, @widget)
11
- @nocontent = true # no data fetch from Connec!
12
- render 'show'
13
- else
14
- render json: @widget.errors, status: :bad_request
15
- end
16
- else
17
- render json: { errors: "Dashboard id #{params[:id]} doesn't exist" }, status: :not_found
18
- end
19
- end
20
-
21
- # PUT /mnoe/jpi/v1/impac/widgets/:id
22
- def update
23
- if widget.update(format_attrs(['name','metadata']))
24
- @nocontent = !params['metadata']
25
- render 'show'
26
- else
27
- render json: @widget.errors, status: :bad_request
28
- end
29
- end
30
-
31
- # DELETE /mnoe/jpi/v1/impac/dashboards/1
32
- def destroy
33
- if widget.destroy
34
- MnoEnterprise::EventLogger.info('widget_delete', current_user.id, 'Widget Deletion', nil, widget)
35
- head status: :ok
36
- else
37
- render json: 'Unable to destroy widget', status: :bad_request
38
- end
39
- end
40
-
41
-
42
- #=================================================
43
- # Private methods
44
- #=================================================
45
- private
46
-
47
- def widget
48
- @widget ||= MnoEnterprise::Impac::Widget.find(params[:id])
49
- end
50
-
51
- def widgets
52
- @widgets ||= MnoEnterprise::Impac::Dashboard.find(params[:dashboard_id]).widgets
53
- end
54
-
55
- def format_attrs(whitelist)
56
- attrs = (params[:widget] || {}).select { |k,v| whitelist.include?(k.to_s) }
57
- attrs['settings'] = widget ? widget.settings || {} : {}
58
- attrs['settings'].merge!(attrs['metadata']) if attrs['metadata']
59
- attrs.except!('metadata')
60
- end
61
-
3
+ include MnoEnterprise::Concerns::Controllers::Jpi::V1::Impac::WidgetsController
62
4
  end
63
5
  end
@@ -0,0 +1,72 @@
1
+ module MnoEnterprise::Concerns::Controllers::Jpi::V1::Impac::WidgetsController
2
+ extend ActiveSupport::Concern
3
+
4
+ #==================================================================
5
+ # Included methods
6
+ #==================================================================
7
+ # 'included do' causes the included code to be evaluated in the
8
+ # context where it is included rather than being executed in the module's context
9
+ included do
10
+ respond_to :json
11
+ end
12
+
13
+ #==================================================================
14
+ # Instance methods
15
+ #==================================================================
16
+ # POST /mnoe/jpi/v1/impac/dashboards/:id/widgets
17
+ # -> POST /api/mnoe/v1/dashboards/:id/widgets
18
+ def create
19
+ if widgets
20
+ if @widget = widgets.create(format_attrs(['widget_category','metadata']))
21
+ MnoEnterprise::EventLogger.info('widget_create', current_user.id, 'Widget Creation', nil, @widget)
22
+ @nocontent = true # no data fetch from Connec!
23
+ render 'show'
24
+ else
25
+ render json: @widget.errors, status: :bad_request
26
+ end
27
+ else
28
+ render json: { errors: "Dashboard id #{params[:id]} doesn't exist" }, status: :not_found
29
+ end
30
+ end
31
+
32
+ # PUT /mnoe/jpi/v1/impac/widgets/:id
33
+ def update
34
+ if widget.update(format_attrs(['name','metadata']))
35
+ @nocontent = !params['metadata']
36
+ render 'show'
37
+ else
38
+ render json: @widget.errors, status: :bad_request
39
+ end
40
+ end
41
+
42
+ # DELETE /mnoe/jpi/v1/impac/dashboards/1
43
+ def destroy
44
+ if widget.destroy
45
+ MnoEnterprise::EventLogger.info('widget_delete', current_user.id, 'Widget Deletion', nil, widget)
46
+ head status: :ok
47
+ else
48
+ render json: 'Unable to destroy widget', status: :bad_request
49
+ end
50
+ end
51
+
52
+
53
+ #=================================================
54
+ # Private methods
55
+ #=================================================
56
+ private
57
+
58
+ def widget
59
+ @widget ||= MnoEnterprise::Impac::Widget.find(params[:id])
60
+ end
61
+
62
+ def widgets
63
+ @widgets ||= MnoEnterprise::Impac::Dashboard.find(params[:dashboard_id]).widgets
64
+ end
65
+
66
+ def format_attrs(whitelist)
67
+ attrs = (params[:widget] || {}).select { |k,v| whitelist.include?(k.to_s) }
68
+ attrs['settings'] = widget ? widget.settings || {} : {}
69
+ attrs['settings'].merge!(attrs['metadata']) if attrs['metadata']
70
+ attrs.except!('metadata')
71
+ end
72
+ end
@@ -29,7 +29,7 @@ module MnoEnterprise::Concerns::Controllers::OrgInvitesController
29
29
  redirect_path = mnoe_home_path
30
30
 
31
31
  if @org_invite && !@org_invite.expired? && @org_invite.accept!(current_user)
32
- redirect_path += "#/?dhbRefId=#{ @org_invite.organization.id}"
32
+ redirect_path = add_param_to_fragment(redirect_path.to_s, 'dhbRefId', @org_invite.organization.id)
33
33
  message = { notice: "You are now part of #{@org_invite.organization.name}" }
34
34
  yield(:success, @org_invite) if block_given?
35
35
  elsif @org_invite && @org_invite.expired?
@@ -128,7 +128,8 @@ module MnoEnterprise::Concerns::Mailers::SystemNotificationMailer
128
128
  protected
129
129
 
130
130
  def recipient(record, new_user = false)
131
- hash = { email: record.email }
131
+ # Org Invite for unconfirmed users will have the email in #unconfirmed_email
132
+ hash = { email: record.email || record.unconfirmed_email }
132
133
  hash[:name] = "#{record.name} #{record.surname}".strip unless new_user
133
134
  hash
134
135
  end
@@ -8,7 +8,7 @@ module MnoEnterprise
8
8
  describe OrgInvitesController, type: :controller do
9
9
  render_views
10
10
  routes { MnoEnterprise::Engine.routes }
11
-
11
+
12
12
  let(:user) { build(:user) }
13
13
  let(:invite) { build(:org_invite, user: user) }
14
14
  let(:token) { invite.token }
@@ -25,7 +25,7 @@ module MnoEnterprise
25
25
  describe "GET #show" do
26
26
  subject { get :show, id: invite.id, token: token}
27
27
 
28
- let(:success_fragment) { "#/?dhbRefId=#{invite.organization.id}&#{URI.encode_www_form([['flash', {msg: "You are now part of #{invite.organization.name}", type: :success}.to_json]])}" }
28
+ let(:success_fragment) { "#?dhbRefId=#{invite.organization.id}&#{URI.encode_www_form([['flash', {msg: "You are now part of #{invite.organization.name}", type: :success}.to_json]])}" }
29
29
  let(:expired_fragment) { "#?#{URI.encode_www_form([['flash', {msg: "It looks like this invite has expired. Please ask your company administrator to resend the invite.", type: :error}.to_json]])}" }
30
30
  let(:invalid_fragment) { "#?#{URI.encode_www_form([['flash', {msg: "Unfortunately, this invite does not seem to be valid.", type: :error}.to_json]])}" }
31
31
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mno-enterprise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
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-05-12 00:00:00.000000000 Z
12
+ date: 2016-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mno-enterprise-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 2.0.2
20
+ version: 2.0.3
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 2.0.2
27
+ version: 2.0.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: jbuilder
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -262,6 +262,7 @@ files:
262
262
  - lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb
263
263
  - lib/mno_enterprise/concerns/controllers/jpi/v1/deletion_requests_controller.rb
264
264
  - lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb
265
+ - lib/mno_enterprise/concerns/controllers/jpi/v1/impac/widgets_controller.rb
265
266
  - lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb
266
267
  - lib/mno_enterprise/concerns/controllers/org_invites_controller.rb
267
268
  - lib/mno_enterprise/concerns/controllers/pages_controller.rb