mno-enterprise-api 3.1.4 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/mno_enterprise/config.js.coffee.erb +7 -1
- data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +3 -27
- data/app/controllers/mno_enterprise/auth/sessions_controller.rb +1 -3
- data/app/controllers/mno_enterprise/jpi/v1/admin/app_answers_controller.rb +26 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/app_comments_controller.rb +28 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/app_instances_controller.rb +16 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/app_reviews_controller.rb +30 -0
- data/app/controllers/mno_enterprise/jpi/v1/admin/invites_controller.rb +1 -1
- data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +55 -37
- data/app/controllers/mno_enterprise/jpi/v1/app_answers_controller.rb +22 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_comments_controller.rb +22 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_feedbacks_controller.rb +14 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +1 -20
- data/app/controllers/mno_enterprise/jpi/v1/app_questions_controller.rb +25 -0
- data/app/controllers/mno_enterprise/jpi/v1/app_reviews_controller.rb +94 -0
- data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +12 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/alerts_controller.rb +5 -0
- data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +1 -76
- data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +1 -18
- data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +1 -83
- data/app/jobs/mno_enterprise/event_logger_job.rb +10 -0
- data/app/views/mno_enterprise/auth/confirmations/new.html.haml +6 -6
- data/app/views/mno_enterprise/auth/passwords/new.html.haml +8 -8
- data/app/views/mno_enterprise/auth/registrations/new.html.haml +1 -0
- data/app/views/mno_enterprise/auth/sessions/new.html.haml +1 -0
- data/app/views/mno_enterprise/auth/shared/_links.html.haml +0 -5
- data/app/views/mno_enterprise/auth/shared/_omniauth.html.haml +10 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_answers/show.json.jbuilder +15 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_comments/show.json.jbuilder +15 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/_app_review.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/app_reviews/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/app_answers/_resource.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/app_answers/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_answers/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_comments/_resource.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_comments/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_comments/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_feedbacks/_comment.json.jbuilder +10 -0
- data/app/views/mno_enterprise/jpi/v1/app_feedbacks/_resource.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/app_feedbacks/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_feedbacks/show.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +9 -0
- data/app/views/mno_enterprise/jpi/v1/app_questions/_answer.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_questions/_resource.json.jbuilder +8 -0
- data/app/views/mno_enterprise/jpi/v1/app_questions/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_questions/show.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/app_reviews/_resource.json.jbuilder +13 -0
- data/app/views/mno_enterprise/jpi/v1/app_reviews/index.json.jbuilder +5 -0
- data/app/views/mno_enterprise/jpi/v1/app_reviews/show.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/base_resource/_app_review.json.jbuilder +17 -0
- data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +9 -1
- data/app/views/mno_enterprise/jpi/v1/impac/alerts/_alert.json.jbuilder +7 -0
- data/app/views/mno_enterprise/jpi/v1/impac/alerts/index.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/alerts/show.json.jbuilder +1 -0
- data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +8 -3
- data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +4 -1
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/impac/widgets/index.json.jbuilder +3 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +4 -0
- data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +1 -2
- data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +1 -1
- data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +3 -2
- data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +2 -2
- data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +2 -2
- data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +11 -5
- data/app/views/mno_enterprise/pages/terms.html.haml +219 -0
- data/app/views/mno_enterprise/provision/_select_organization.html.haml +6 -2
- data/config/initializers/devise.rb +31 -9
- data/config/initializers/devise_log.rb +4 -4
- data/config/routes.rb +41 -6
- data/lib/mno_enterprise/api.rb +1 -0
- data/lib/mno_enterprise/audit_events_listener.rb +28 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/app_instances_controller.rb +45 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +14 -4
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/alerts_controller.rb +76 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +49 -23
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/kpis_controller.rb +167 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/widgets_controller.rb +33 -17
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/marketplace_controller.rb +32 -0
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +68 -28
- data/lib/mno_enterprise/concerns/controllers/jpi/v1/teams_controller.rb +92 -0
- data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +17 -3
- data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +17 -2
- data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +27 -3
- data/lib/mno_enterprise/event_logger.rb +34 -16
- data/lib/mno_enterprise/intercom_events_listener.rb +96 -0
- data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +28 -0
- data/spec/controllers/mno_enterprise/auth/omniauth_callback_controller_spec.rb +34 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/app_answers_controller_spec.rb +45 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/app_comments_controller_spec.rb +45 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/app_instances_controller_spec.rb +31 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/app_reviews_controller_spec.rb +103 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +4 -15
- data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +12 -3
- data/spec/controllers/mno_enterprise/jpi/v1/admin/invites_controller_spec.rb +4 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +15 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +17 -1
- data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +5 -0
- data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +30 -16
- data/spec/controllers/mno_enterprise/jpi/v1/app_answers_controller_spec.rb +74 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_comments_controller_spec.rb +74 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_feedbacks_controller_spec.rb +84 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +36 -22
- data/spec/controllers/mno_enterprise/jpi/v1/app_questions_controller_spec.rb +80 -0
- data/spec/controllers/mno_enterprise/jpi/v1/app_reviews_controller_spec.rb +107 -0
- data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +16 -1
- data/spec/controllers/mno_enterprise/jpi/v1/impac/alerts_controller_spec.rb +82 -0
- data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +147 -10
- data/spec/controllers/mno_enterprise/jpi/v1/impac/widgets_controller_spec.rb +39 -0
- data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +19 -26
- data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +248 -303
- data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +4 -1
- data/spec/controllers/mno_enterprise/pages_controller_spec.rb +21 -0
- data/spec/controllers/mno_enterprise/provision_controller_spec.rb +65 -22
- data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +1 -1
- data/spec/jobs/mno_enterprise/event_logger_job_spec.rb +11 -0
- data/spec/lib/mno_enterprise/audit_events_listener_spec.rb +28 -0
- data/spec/lib/mno_enterprise/intercom_events_listener_spec.rb +110 -0
- data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +81 -46
- data/spec/routing/mno_enterprise/jpi/v1/admin/app_instances_controller_routing_spec.rb +11 -0
- data/spec/routing/mno_enterprise/jpi/v1/admin/app_reviews_controller_routing_spec.rb +19 -0
- data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +9 -2
- data/spec/routing/mno_enterprise/jpi/v1/app_reviews_controller_routing_spec.rb +15 -0
- data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +5 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/alerts_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/dashboards_controller_routing_spec.rb +28 -0
- data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +17 -11
- data/spec/routing/mno_enterprise/jpi/v1/impac/widgets_controller_routing_spec.rb +24 -0
- data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +2 -2
- data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +4 -0
- metadata +178 -9
- data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +0 -25
- data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +0 -93
- data/spec/lib/mno_enterprise/event_logger_spec.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98313610cc252efb1e91c0187d397ba299476e9d
|
4
|
+
data.tar.gz: 7046190053c32c805db818b9b36d2aad461ffb94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f04f1a99e1922cc754a2ec0d3bad296efb151cb40c55f4a3e0ae88baf5a496246cca95697e19025e198d3597cc3761eeab5c4e9ccd19d89c011bb7958e6e5b94
|
7
|
+
data.tar.gz: 41c1785557185b19e3dc80d526313e60b7652a9b7147779c0a53892da2148351b05586f557a78fb67b71f24215885be9bb13f262959a3eba3ef846ae12b9cc57
|
@@ -8,5 +8,11 @@ angular.module('mnoEnterprise.configuration', [])
|
|
8
8
|
enabled: <%= MnoEnterprise.i18n_enabled %>,
|
9
9
|
available_locales: <%= I18n.available_locales.to_json %>
|
10
10
|
})
|
11
|
-
.constant('PRICING_CONFIG', <%= Settings.pricing.to_json %>)
|
11
|
+
.constant('PRICING_CONFIG', <%= Hash(Settings.pricing).to_json %>)
|
12
|
+
.constant('DOCK_CONFIG', <%= Hash(Settings.dock).to_json %>)
|
13
|
+
.constant('DEVELOPER_SECTION_CONFIG', <%= Hash(Settings.developer).to_json %>)
|
14
|
+
.constant('REVIEWS_CONFIG', <%= Hash(Settings.reviews).to_json %>)
|
15
|
+
.constant('MARKETPLACE_CONFIG', <%= Hash(Settings.marketplace).to_json %>)
|
12
16
|
.constant('GOOGLE_TAG_CONTAINER_ID', <%= MnoEnterprise.google_tag_container.to_json %>)
|
17
|
+
.constant('INTERCOM_ID', <%= MnoEnterprise.intercom_app_id.to_json %>)
|
18
|
+
.constant('APP_NAME', <%= MnoEnterprise.app_name.to_json %>)
|
@@ -1,30 +1,6 @@
|
|
1
1
|
module MnoEnterprise
|
2
2
|
class Auth::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
3
|
-
|
4
|
-
# devise :omniauthable, omniauth_providers: [:twitter]
|
5
|
-
|
6
|
-
# You should also create an action method in this controller like this:
|
7
|
-
# def twitter
|
8
|
-
# end
|
9
|
-
|
10
|
-
# More info at:
|
11
|
-
# https://github.com/plataformatec/devise#omniauth
|
12
|
-
|
13
|
-
# GET|POST /resource/auth/twitter
|
14
|
-
# def passthru
|
15
|
-
# super
|
16
|
-
# end
|
17
|
-
|
18
|
-
# GET|POST /users/auth/twitter/callback
|
19
|
-
# def failure
|
20
|
-
# super
|
21
|
-
# end
|
22
|
-
|
23
|
-
# protected
|
24
|
-
|
25
|
-
# The path used when omniauth fails
|
26
|
-
# def after_omniauth_failure_path_for(scope)
|
27
|
-
# super(scope)
|
28
|
-
# end
|
3
|
+
include MnoEnterprise::Concerns::Controllers::Auth::OmniauthCallbacksController
|
29
4
|
end
|
30
|
-
end
|
5
|
+
end
|
6
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::Admin::AppAnswersController < Jpi::V1::Admin::BaseResourceController
|
3
|
+
|
4
|
+
# POST /mnoe/jpi/v1/admin/app_answers
|
5
|
+
def create
|
6
|
+
@app_review = MnoEnterprise::AppAnswer.new(app_answer_params)
|
7
|
+
|
8
|
+
if @app_review.save
|
9
|
+
render :show
|
10
|
+
else
|
11
|
+
render json: @app_review.errors, status: :bad_request
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def app_answer_params
|
16
|
+
# for an admin, the organization does not matter
|
17
|
+
organization_id = current_user.organizations.first.id
|
18
|
+
params.require(:app_answer).permit(:description)
|
19
|
+
.merge(user_id: current_user.id, question_id: parent.id, organization_id: organization_id, app_id: parent.app_id)
|
20
|
+
end
|
21
|
+
|
22
|
+
def parent
|
23
|
+
@parent ||= MnoEnterprise::AppQuestion.find(params[:question_id])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::Admin::AppCommentsController < Jpi::V1::Admin::BaseResourceController
|
3
|
+
|
4
|
+
# POST /mnoe/jpi/v1/admin/app_comments
|
5
|
+
def create
|
6
|
+
@app_review = MnoEnterprise::AppComment.new(app_comment_params)
|
7
|
+
|
8
|
+
if @app_review.save
|
9
|
+
render :show
|
10
|
+
else
|
11
|
+
render json: @app_review.errors, status: :bad_request
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def app_comment_params
|
18
|
+
# for an admin, the organization does not matter
|
19
|
+
organization_id = current_user.organizations.first.id
|
20
|
+
params.require(:app_comment).permit(:description)
|
21
|
+
.merge(user_id: current_user.id, feedback_id: parent.id, organization_id: organization_id, app_id: parent.app_id)
|
22
|
+
end
|
23
|
+
|
24
|
+
def parent
|
25
|
+
@parent ||= MnoEnterprise::AppFeedback.find(params[:feedback_id])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::Admin::AppInstancesController < Jpi::V1::Admin::BaseResourceController
|
3
|
+
|
4
|
+
# DELETE /mnoe/jpi/v1/app_instances/1
|
5
|
+
def destroy
|
6
|
+
app_instance = MnoEnterprise::AppInstance.find(params[:id])
|
7
|
+
|
8
|
+
if app_instance
|
9
|
+
MnoEnterprise::EventLogger.info('app_destroy', current_user.id, 'App destroyed', app_instance)
|
10
|
+
app_instance.terminate
|
11
|
+
end
|
12
|
+
|
13
|
+
head :accepted
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::Admin::AppReviewsController < Jpi::V1::Admin::BaseResourceController
|
3
|
+
# GET /mnoe/jpi/v1/admin/app_reviews
|
4
|
+
def index
|
5
|
+
@app_reviews = MnoEnterprise::AppReview
|
6
|
+
@app_reviews = @app_reviews.limit(params[:limit]) if params[:limit]
|
7
|
+
@app_reviews = @app_reviews.skip(params[:offset]) if params[:offset]
|
8
|
+
@app_reviews = @app_reviews.order_by(params[:order_by]) if params[:order_by]
|
9
|
+
@app_reviews = @app_reviews.where(params[:where]) if params[:where]
|
10
|
+
@app_reviews = @app_reviews.all.fetch
|
11
|
+
response.headers['X-Total-Count'] = @app_reviews.metadata[:pagination][:count]
|
12
|
+
end
|
13
|
+
|
14
|
+
# GET /mnoe/jpi/v1/admin/app_reviews/1
|
15
|
+
def show
|
16
|
+
@app_review = MnoEnterprise::AppReview.find(params[:id])
|
17
|
+
end
|
18
|
+
|
19
|
+
# PATCH /mnoe/jpi/v1/admin/app_reviews/1
|
20
|
+
def update
|
21
|
+
@app_review = MnoEnterprise::AppReview.find(params[:id])
|
22
|
+
@app_review.update(app_review_params)
|
23
|
+
render :show
|
24
|
+
end
|
25
|
+
|
26
|
+
def app_review_params
|
27
|
+
params.require(:app_review).permit(:status, :description).merge(user_id: current_user.id)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -14,7 +14,7 @@ module MnoEnterprise::Jpi::V1::Admin
|
|
14
14
|
send_org_invite(invite)
|
15
15
|
end
|
16
16
|
|
17
|
-
MnoEnterprise::EventLogger.info('user_invite', current_user.id, 'User invited', {user_email: user.email, account_name: @organization.name}
|
17
|
+
MnoEnterprise::EventLogger.info('user_invite', current_user.id, 'User invited', user, {user_email: user.email, account_name: @organization.name})
|
18
18
|
|
19
19
|
@user = user.confirmed? ? invite : user.reload
|
20
20
|
|
@@ -50,6 +50,18 @@ module MnoEnterprise
|
|
50
50
|
render 'show'
|
51
51
|
end
|
52
52
|
|
53
|
+
# PATCH /mnoe/jpi/v1/admin/organizations/1
|
54
|
+
def update
|
55
|
+
# get organization
|
56
|
+
@organization = MnoEnterprise::Organization.find(params[:id])
|
57
|
+
|
58
|
+
update_app_list
|
59
|
+
|
60
|
+
@organization_active_apps = @organization.app_instances.active
|
61
|
+
|
62
|
+
render 'show'
|
63
|
+
end
|
64
|
+
|
53
65
|
# POST /mnoe/jpi/v1/admin/organizations/1/users
|
54
66
|
# Invite a user to the organization (and create it if needed)
|
55
67
|
# This does not send any emails (emails are manually triggered later)
|
@@ -62,60 +74,66 @@ module MnoEnterprise
|
|
62
74
|
|
63
75
|
# Create the invitation
|
64
76
|
invite = @organization.org_invites.create(
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
77
|
+
user_email: user.email,
|
78
|
+
user_role: params[:user][:role],
|
79
|
+
referrer_id: current_user.id,
|
80
|
+
status: 'staged' # Will be updated to 'accepted' for unconfirmed users
|
69
81
|
)
|
70
82
|
|
71
83
|
@user = user.confirmed? ? invite : user.reload
|
72
84
|
end
|
73
85
|
|
74
86
|
protected
|
75
|
-
def organization_permitted_update_params
|
76
|
-
[:name]
|
77
|
-
end
|
78
87
|
|
79
|
-
|
80
|
-
|
81
|
-
|
88
|
+
def organization_permitted_update_params
|
89
|
+
[:name]
|
90
|
+
end
|
82
91
|
|
83
|
-
|
84
|
-
|
85
|
-
|
92
|
+
def organization_update_params
|
93
|
+
params.fetch(:organization, {}).permit(*organization_permitted_update_params)
|
94
|
+
end
|
86
95
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
96
|
+
def user_params
|
97
|
+
params.require(:user).permit(:email, :name, :surname, :phone)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Create an unconfirmed user and skip the confirmation notification
|
101
|
+
# TODO: monkey patch User#confirmation_required? to simplify this? Use refinements?
|
102
|
+
def create_unconfirmed_user(user_params)
|
103
|
+
user = MnoEnterprise::User.new(user_params)
|
104
|
+
user.skip_confirmation_notification!
|
105
|
+
user.save
|
106
|
+
|
107
|
+
# Reset the confirmation field so we can track when the invite is send - #confirmation_sent_at is when the confirmation_token was generated (not sent)
|
108
|
+
# Not ideal as we do 2 saves, and the previous save trigger a call to the backend to validate the token uniqueness
|
109
|
+
user.assign_attributes(confirmation_sent_at: nil, confirmation_token: nil)
|
110
|
+
user.save
|
111
|
+
user
|
112
|
+
end
|
100
113
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
114
|
+
# Update App List to match the list passed in params
|
115
|
+
def update_app_list
|
116
|
+
# Differentiate between a null app_nids params and no app_nids params
|
117
|
+
if params[:organization].key?(:app_nids) && (desired_nids = Array(params[:organization][:app_nids]))
|
105
118
|
|
106
|
-
|
119
|
+
existing_apps = @organization.app_instances.active
|
107
120
|
|
108
|
-
|
109
|
-
|
110
|
-
|
121
|
+
existing_apps.each do |app_instance|
|
122
|
+
desired_nids.delete(app_instance.app.nid) || app_instance.terminate
|
123
|
+
end
|
111
124
|
|
112
|
-
|
125
|
+
desired_nids.each do |nid|
|
126
|
+
begin
|
113
127
|
@organization.app_instances.create(product: nid)
|
128
|
+
rescue => e
|
129
|
+
Rails.logger.error { "#{e.message} #{e.backtrace.join("\n")}" }
|
114
130
|
end
|
115
131
|
|
116
|
-
# Force reload
|
117
|
-
existing_apps.reload
|
118
132
|
end
|
133
|
+
|
134
|
+
# Force reload
|
135
|
+
existing_apps.reload
|
119
136
|
end
|
137
|
+
end
|
120
138
|
end
|
121
139
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::AppAnswersController < Jpi::V1::AppReviewsController
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def scope_app_reviews
|
7
|
+
@app_reviews.where(question_id: params[:question_id])
|
8
|
+
end
|
9
|
+
|
10
|
+
def after_save
|
11
|
+
#do nothing because answers doesn't affect on app rating
|
12
|
+
end
|
13
|
+
|
14
|
+
def review_klass
|
15
|
+
MnoEnterprise::AppAnswer
|
16
|
+
end
|
17
|
+
|
18
|
+
def permitted_params
|
19
|
+
params.require(:app_answer).permit(:rating, :description, :organization_id, :question_id)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::AppCommentsController < Jpi::V1::AppReviewsController
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def scope_app_reviews
|
7
|
+
@app_reviews.where(feedback_id: params[:feedback_id])
|
8
|
+
end
|
9
|
+
|
10
|
+
def after_save
|
11
|
+
#do nothing because comments doesn't affect on app rating
|
12
|
+
end
|
13
|
+
|
14
|
+
def review_klass
|
15
|
+
MnoEnterprise::AppComment
|
16
|
+
end
|
17
|
+
|
18
|
+
def permitted_params
|
19
|
+
params.require(:app_comment).permit(:description, :organization_id, :feedback_id)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::AppFeedbacksController < Jpi::V1::AppReviewsController
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def permitted_params
|
7
|
+
params.require(:app_feedback).permit(:rating, :description, :organization_id)
|
8
|
+
end
|
9
|
+
|
10
|
+
def review_klass
|
11
|
+
MnoEnterprise::AppFeedback
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,24 +1,5 @@
|
|
1
1
|
module MnoEnterprise
|
2
2
|
class Jpi::V1::AppInstancesController < Jpi::V1::BaseResourceController
|
3
|
-
|
4
|
-
# GET /mnoe/jpi/v1/organization/1/apps.json?timestamp=151452452345
|
5
|
-
def index
|
6
|
-
@app_instances = parent_organization.app_instances.select do |i|
|
7
|
-
i.active? && i.updated_at > Time.at(timestamp) && can?(:access,i)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
# DELETE /mnoe/jpi/v1/app_instances/1
|
12
|
-
def destroy
|
13
|
-
app_instance = MnoEnterprise::AppInstance.find(params[:id])
|
14
|
-
|
15
|
-
if app_instance
|
16
|
-
authorize! :manage_app_instances, app_instance.owner
|
17
|
-
MnoEnterprise::EventLogger.info('app_destroy', current_user.id, "App destroyed", app_instance.name,app_instance)
|
18
|
-
app_instance.terminate
|
19
|
-
end
|
20
|
-
|
21
|
-
head :accepted
|
22
|
-
end
|
3
|
+
include MnoEnterprise::Concerns::Controllers::Jpi::V1::AppInstancesController
|
23
4
|
end
|
24
5
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::AppQuestionsController < Jpi::V1::AppReviewsController
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def scope_app_reviews
|
7
|
+
collection = @app_reviews.where(reviewable_id: current_app.id)
|
8
|
+
collection = collection.search(params[:search]) if params[:search].present?
|
9
|
+
|
10
|
+
collection
|
11
|
+
end
|
12
|
+
|
13
|
+
def after_save
|
14
|
+
#do nothing because questions doesn't affect on app rating
|
15
|
+
end
|
16
|
+
|
17
|
+
def permitted_params
|
18
|
+
params.require(:app_question).permit(:description, :organization_id)
|
19
|
+
end
|
20
|
+
|
21
|
+
def review_klass
|
22
|
+
MnoEnterprise::AppQuestion
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module MnoEnterprise
|
2
|
+
class Jpi::V1::AppReviewsController < Jpi::V1::BaseResourceController
|
3
|
+
before_action :ensure_app_exists
|
4
|
+
before_action :find_review, only: [:update, :destroy]
|
5
|
+
|
6
|
+
# GET /mnoe/jpi/v1/marketplace/:id/app_reviews
|
7
|
+
def index
|
8
|
+
@app_reviews = review_klass.approved
|
9
|
+
@app_reviews = @app_reviews.limit(params[:limit]) if params[:limit]
|
10
|
+
@app_reviews = @app_reviews.skip(params[:offset]) if params[:offset]
|
11
|
+
@app_reviews = @app_reviews.order_by(params[:order_by]) if params[:order_by]
|
12
|
+
@app_reviews = @app_reviews.where(params[:where]) if params[:where]
|
13
|
+
|
14
|
+
@app_reviews = scope_app_reviews
|
15
|
+
|
16
|
+
@app_reviews = @app_reviews.all.fetch
|
17
|
+
response.headers['X-Total-Count'] = @app_reviews.metadata[:pagination][:count]
|
18
|
+
end
|
19
|
+
|
20
|
+
# POST /mnoe/jpi/v1/marketplace/:id/app_reviews/:id
|
21
|
+
def show
|
22
|
+
@app_review = review_klass.find(params[:review_id])
|
23
|
+
end
|
24
|
+
|
25
|
+
# POST /mnoe/jpi/v1/marketplace/:id/app_reviews
|
26
|
+
def create
|
27
|
+
# TODO: use the has_many associations -> @app.reviews.build
|
28
|
+
@app_review = review_klass.new(review_params)
|
29
|
+
if @app_review.save
|
30
|
+
after_save
|
31
|
+
render :show
|
32
|
+
else
|
33
|
+
render json: @app_review.errors, status: :bad_request
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
if @app_review.update(permitted_params)
|
39
|
+
after_save
|
40
|
+
render :show
|
41
|
+
else
|
42
|
+
render json: @app_review.errors, status: :bad_request
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def destroy
|
47
|
+
@app_review.destroy
|
48
|
+
after_save
|
49
|
+
|
50
|
+
render :show
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
# scope the app_reviews for the children controller
|
56
|
+
# may be overriden
|
57
|
+
def scope_app_reviews
|
58
|
+
@app_reviews.where(reviewable_id: current_app.id)
|
59
|
+
end
|
60
|
+
|
61
|
+
# perform some additional actions if new review was created
|
62
|
+
# may be overriden
|
63
|
+
def after_save
|
64
|
+
@average_rating = current_app.reload.average_rating
|
65
|
+
end
|
66
|
+
|
67
|
+
def current_app
|
68
|
+
@app ||= MnoEnterprise::App.find(params[:id])
|
69
|
+
end
|
70
|
+
|
71
|
+
def ensure_app_exists
|
72
|
+
render_not_found('App') unless current_app.present?
|
73
|
+
end
|
74
|
+
|
75
|
+
def find_review
|
76
|
+
@app_review = review_klass.find(params[:review_id])
|
77
|
+
unless @app_review.user_id == current_user.id
|
78
|
+
return render json:{ errors: {message: "Review not found (id=#{params[:review_id]})", code: 404} }, status: :not_found
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def review_klass
|
83
|
+
MnoEnterprise::AppReview
|
84
|
+
end
|
85
|
+
|
86
|
+
def permitted_params
|
87
|
+
params.require(:app_review).permit(:rating, :description, :organization_id)
|
88
|
+
end
|
89
|
+
|
90
|
+
def review_params
|
91
|
+
permitted_params.merge(app_id: current_app.id, user_id: current_user.id)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|