mno-enterprise-api 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -0
  3. data/Rakefile +12 -0
  4. data/app/assets/javascripts/mno_enterprise/angular/loading-page.app.js.coffee +156 -0
  5. data/app/assets/javascripts/mno_enterprise/application.js +13 -0
  6. data/app/controllers/devise/password_expired_controller.rb +55 -0
  7. data/app/controllers/mno_enterprise/auth/confirmations_controller.rb +5 -0
  8. data/app/controllers/mno_enterprise/auth/omniauth_callbacks_controller.rb +30 -0
  9. data/app/controllers/mno_enterprise/auth/passwords_controller.rb +5 -0
  10. data/app/controllers/mno_enterprise/auth/registrations_controller.rb +5 -0
  11. data/app/controllers/mno_enterprise/auth/sessions_controller.rb +7 -0
  12. data/app/controllers/mno_enterprise/auth/unlocks_controller.rb +5 -0
  13. data/app/controllers/mno_enterprise/deletion_requests_controller.rb +5 -0
  14. data/app/controllers/mno_enterprise/impersonate_controller.rb +48 -0
  15. data/app/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller.rb +16 -0
  16. data/app/controllers/mno_enterprise/jpi/v1/admin/base_resource_controller.rb +5 -0
  17. data/app/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller.rb +46 -0
  18. data/app/controllers/mno_enterprise/jpi/v1/admin/invoices_controller.rb +47 -0
  19. data/app/controllers/mno_enterprise/jpi/v1/admin/organizations_controller.rb +27 -0
  20. data/app/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller.rb +14 -0
  21. data/app/controllers/mno_enterprise/jpi/v1/admin/users_controller.rb +63 -0
  22. data/app/controllers/mno_enterprise/jpi/v1/app_instances_controller.rb +24 -0
  23. data/app/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller.rb +36 -0
  24. data/app/controllers/mno_enterprise/jpi/v1/base_resource_controller.rb +32 -0
  25. data/app/controllers/mno_enterprise/jpi/v1/current_users_controller.rb +5 -0
  26. data/app/controllers/mno_enterprise/jpi/v1/deletion_requests_controller.rb +5 -0
  27. data/app/controllers/mno_enterprise/jpi/v1/impac/dashboards_controller.rb +5 -0
  28. data/app/controllers/mno_enterprise/jpi/v1/impac/kpis_controller.rb +80 -0
  29. data/app/controllers/mno_enterprise/jpi/v1/impac/widgets_controller.rb +63 -0
  30. data/app/controllers/mno_enterprise/jpi/v1/industry_bundle_controller.rb +25 -0
  31. data/app/controllers/mno_enterprise/jpi/v1/marketplace_controller.rb +22 -0
  32. data/app/controllers/mno_enterprise/jpi/v1/organizations_controller.rb +5 -0
  33. data/app/controllers/mno_enterprise/jpi/v1/shopping_cart_controller.rb +93 -0
  34. data/app/controllers/mno_enterprise/jpi/v1/teams_controller.rb +88 -0
  35. data/app/controllers/mno_enterprise/org_invites_controller.rb +5 -0
  36. data/app/controllers/mno_enterprise/pages_controller.rb +5 -0
  37. data/app/controllers/mno_enterprise/provision_controller.rb +5 -0
  38. data/app/controllers/mno_enterprise/status_controller.rb +27 -0
  39. data/app/controllers/mno_enterprise/webhook/o_auth_controller.rb +5 -0
  40. data/app/mailers/mno_enterprise/system_notification_mailer.rb +5 -0
  41. data/app/models/mno_enterprise/health_check.rb +16 -0
  42. data/app/views/devise/password_expired/show.html.haml +32 -0
  43. data/app/views/mno_enterprise/auth/confirmations/default/_form.html.haml +49 -0
  44. data/app/views/mno_enterprise/auth/confirmations/default/_lounge.html.haml +34 -0
  45. data/app/views/mno_enterprise/auth/confirmations/default/_show.html.haml +10 -0
  46. data/app/views/mno_enterprise/auth/confirmations/lounge.html.haml +4 -0
  47. data/app/views/mno_enterprise/auth/confirmations/material/_form.html.haml +44 -0
  48. data/app/views/mno_enterprise/auth/confirmations/material/_lounge.html.haml +18 -0
  49. data/app/views/mno_enterprise/auth/confirmations/material/_show.html.haml +21 -0
  50. data/app/views/mno_enterprise/auth/confirmations/new.html.haml +31 -0
  51. data/app/views/mno_enterprise/auth/confirmations/show.html.haml +4 -0
  52. data/app/views/mno_enterprise/auth/mailer/confirmation_instructions.html.haml +4 -0
  53. data/app/views/mno_enterprise/auth/mailer/reset_password_instructions.html.haml +6 -0
  54. data/app/views/mno_enterprise/auth/mailer/unlock_instructions.html.haml +5 -0
  55. data/app/views/mno_enterprise/auth/passwords/edit.html.haml +53 -0
  56. data/app/views/mno_enterprise/auth/passwords/new.html.haml +34 -0
  57. data/app/views/mno_enterprise/auth/registrations/default/_form.html.haml +35 -0
  58. data/app/views/mno_enterprise/auth/registrations/default/_new.html.haml +11 -0
  59. data/app/views/mno_enterprise/auth/registrations/material/_form.html.haml +30 -0
  60. data/app/views/mno_enterprise/auth/registrations/material/_new.html.haml +10 -0
  61. data/app/views/mno_enterprise/auth/registrations/new.html.haml +4 -0
  62. data/app/views/mno_enterprise/auth/sessions/default/_form.html.haml +17 -0
  63. data/app/views/mno_enterprise/auth/sessions/default/_new.html.haml +11 -0
  64. data/app/views/mno_enterprise/auth/sessions/material/_form.html.haml +26 -0
  65. data/app/views/mno_enterprise/auth/sessions/material/_new.html.haml +11 -0
  66. data/app/views/mno_enterprise/auth/sessions/new.html.haml +4 -0
  67. data/app/views/mno_enterprise/auth/shared/_links.html.haml +24 -0
  68. data/app/views/mno_enterprise/auth/unlocks/new.html.haml +10 -0
  69. data/app/views/mno_enterprise/deletion_requests/show.html.haml +131 -0
  70. data/app/views/mno_enterprise/jpi/v1/admin/audit_events/_audit_event.json.jbuilder +5 -0
  71. data/app/views/mno_enterprise/jpi/v1/admin/audit_events/index.json.jbuilder +4 -0
  72. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/_cloud_app.json.jbuilder +1 -0
  73. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/index.json.jbuilder +1 -0
  74. data/app/views/mno_enterprise/jpi/v1/admin/cloud_apps/show.json.jbuilder +1 -0
  75. data/app/views/mno_enterprise/jpi/v1/admin/invoices/_invoice.json.jbuilder +2 -0
  76. data/app/views/mno_enterprise/jpi/v1/admin/invoices/index.json.jbuilder +1 -0
  77. data/app/views/mno_enterprise/jpi/v1/admin/invoices/show.json.jbuilder +2 -0
  78. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_credit_card.json.jbuilder +7 -0
  79. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_invoices.json.jbuilder +8 -0
  80. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_member.json.jbuilder +14 -0
  81. data/app/views/mno_enterprise/jpi/v1/admin/organizations/_organization.json.jbuilder +1 -0
  82. data/app/views/mno_enterprise/jpi/v1/admin/organizations/in_arrears.json.jbuilder +8 -0
  83. data/app/views/mno_enterprise/jpi/v1/admin/organizations/index.json.jbuilder +7 -0
  84. data/app/views/mno_enterprise/jpi/v1/admin/organizations/show.json.jbuilder +11 -0
  85. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/_tenant_invoice.json.jbuilder +5 -0
  86. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/index.json.jbuilder +1 -0
  87. data/app/views/mno_enterprise/jpi/v1/admin/tenant_invoices/show.json.jbuilder +1 -0
  88. data/app/views/mno_enterprise/jpi/v1/admin/users/_user.json.jbuilder +1 -0
  89. data/app/views/mno_enterprise/jpi/v1/admin/users/index.json.jbuilder +2 -0
  90. data/app/views/mno_enterprise/jpi/v1/admin/users/show.json.jbuilder +9 -0
  91. data/app/views/mno_enterprise/jpi/v1/app_instances/_resource.json.jbuilder +23 -0
  92. data/app/views/mno_enterprise/jpi/v1/app_instances/index.json.jbuilder +9 -0
  93. data/app/views/mno_enterprise/jpi/v1/app_instances/show.json.jbuilder +3 -0
  94. data/app/views/mno_enterprise/jpi/v1/billing/index.json.jbuilder +0 -0
  95. data/app/views/mno_enterprise/jpi/v1/current_users/show.json.jbuilder +37 -0
  96. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/_dashboard.json.jbuilder +9 -0
  97. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/index.json.jbuilder +1 -0
  98. data/app/views/mno_enterprise/jpi/v1/impac/dashboards/show.json.jbuilder +1 -0
  99. data/app/views/mno_enterprise/jpi/v1/impac/kpis/_kpi.json.jbuilder +1 -0
  100. data/app/views/mno_enterprise/jpi/v1/impac/kpis/show.json.jbuilder +1 -0
  101. data/app/views/mno_enterprise/jpi/v1/impac/widgets/_widget.json.jbuilder +6 -0
  102. data/app/views/mno_enterprise/jpi/v1/impac/widgets/show.json.jbuilder +1 -0
  103. data/app/views/mno_enterprise/jpi/v1/marketplace/_app.json.jbuilder +14 -0
  104. data/app/views/mno_enterprise/jpi/v1/marketplace/index.json.jbuilder +3 -0
  105. data/app/views/mno_enterprise/jpi/v1/marketplace/show.json.jbuilder +3 -0
  106. data/app/views/mno_enterprise/jpi/v1/organizations/_arrears.json.jbuilder +11 -0
  107. data/app/views/mno_enterprise/jpi/v1/organizations/_billing.json.jbuilder +4 -0
  108. data/app/views/mno_enterprise/jpi/v1/organizations/_credit_card.json.jbuilder +7 -0
  109. data/app/views/mno_enterprise/jpi/v1/organizations/_current_user.json.jbuilder +5 -0
  110. data/app/views/mno_enterprise/jpi/v1/organizations/_invoices.json.jbuilder +8 -0
  111. data/app/views/mno_enterprise/jpi/v1/organizations/_member.json.jbuilder +13 -0
  112. data/app/views/mno_enterprise/jpi/v1/organizations/_organization.json.jbuilder +13 -0
  113. data/app/views/mno_enterprise/jpi/v1/organizations/credit_card.json.jbuilder +1 -0
  114. data/app/views/mno_enterprise/jpi/v1/organizations/index.json.jbuilder +1 -0
  115. data/app/views/mno_enterprise/jpi/v1/organizations/members.json.jbuilder +3 -0
  116. data/app/views/mno_enterprise/jpi/v1/organizations/show.json.jbuilder +15 -0
  117. data/app/views/mno_enterprise/jpi/v1/organizations/show_reduced.json.jbuilder +3 -0
  118. data/app/views/mno_enterprise/jpi/v1/shopping_cart/organizations.json.jbuilder +5 -0
  119. data/app/views/mno_enterprise/jpi/v1/shopping_cart/show.json.jbuilder +59 -0
  120. data/app/views/mno_enterprise/jpi/v1/shopping_cart/show_item.json.jbuilder +34 -0
  121. data/app/views/mno_enterprise/jpi/v1/teams/_team.json.jbuilder +20 -0
  122. data/app/views/mno_enterprise/jpi/v1/teams/index.json.jbuilder +1 -0
  123. data/app/views/mno_enterprise/jpi/v1/teams/show.json.jbuilder +3 -0
  124. data/app/views/mno_enterprise/pages/app_access_unauthorized.html.haml +19 -0
  125. data/app/views/mno_enterprise/pages/app_logout.html.haml +18 -0
  126. data/app/views/mno_enterprise/pages/billing_details_required.html.haml +19 -0
  127. data/app/views/mno_enterprise/pages/loading.html.erb +69 -0
  128. data/app/views/mno_enterprise/provision/_provision_apps.html.haml +42 -0
  129. data/app/views/mno_enterprise/provision/_select_organization.html.haml +17 -0
  130. data/app/views/mno_enterprise/provision/new.html.haml +4 -0
  131. data/app/views/mno_enterprise/webhook/o_auth/authorize.html.haml +26 -0
  132. data/app/views/mno_enterprise/webhook/o_auth/providers/myob.html.haml +29 -0
  133. data/app/views/mno_enterprise/webhook/o_auth/providers/xero.html.haml +34 -0
  134. data/config/initializers/devise.rb +273 -0
  135. data/config/initializers/devise_extension.rb +9 -0
  136. data/config/initializers/devise_log.rb +12 -0
  137. data/config/initializers/health_check.rb +35 -0
  138. data/config/initializers/main_app_version.rb +6 -0
  139. data/config/routes.rb +152 -0
  140. data/lib/mno-enterprise-api.rb +1 -0
  141. data/lib/mno_enterprise/api.rb +14 -0
  142. data/lib/mno_enterprise/api/engine.rb +9 -0
  143. data/lib/mno_enterprise/concerns/controllers/deletion_requests_controller.rb +108 -0
  144. data/lib/mno_enterprise/concerns/controllers/jpi/v1/admin/base_resource_controller.rb +34 -0
  145. data/lib/mno_enterprise/concerns/controllers/jpi/v1/current_users_controller.rb +58 -0
  146. data/lib/mno_enterprise/concerns/controllers/jpi/v1/deletion_requests_controller.rb +69 -0
  147. data/lib/mno_enterprise/concerns/controllers/jpi/v1/impac/dashboards_controller.rb +76 -0
  148. data/lib/mno_enterprise/concerns/controllers/jpi/v1/organizations_controller.rb +180 -0
  149. data/lib/mno_enterprise/concerns/controllers/org_invites_controller.rb +44 -0
  150. data/lib/mno_enterprise/concerns/controllers/pages_controller.rb +78 -0
  151. data/lib/mno_enterprise/concerns/controllers/provision_controller.rb +71 -0
  152. data/lib/mno_enterprise/concerns/controllers/webhook/o_auth_controller.rb +107 -0
  153. data/lib/mno_enterprise/concerns/mailers/system_notification_mailer.rb +158 -0
  154. data/lib/mno_enterprise/event_logger.rb +32 -0
  155. data/spec/controllers/mno_enterprise/auth/confirmation_controller_spec.rb +68 -0
  156. data/spec/controllers/mno_enterprise/deletion_requests_controller_spec.rb +141 -0
  157. data/spec/controllers/mno_enterprise/impersonate_controller_spec.rb +48 -0
  158. data/spec/controllers/mno_enterprise/jpi/v1/admin/audit_events_controller_spec.rb +51 -0
  159. data/spec/controllers/mno_enterprise/jpi/v1/admin/cloud_apps_controller_spec.rb +92 -0
  160. data/spec/controllers/mno_enterprise/jpi/v1/admin/invoices_controller_spec.rb +159 -0
  161. data/spec/controllers/mno_enterprise/jpi/v1/admin/organizations_controller_spec.rb +116 -0
  162. data/spec/controllers/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_spec.rb +92 -0
  163. data/spec/controllers/mno_enterprise/jpi/v1/admin/users_controller_spec.rb +136 -0
  164. data/spec/controllers/mno_enterprise/jpi/v1/app_instances_controller_spec.rb +76 -0
  165. data/spec/controllers/mno_enterprise/jpi/v1/app_instances_sync_controller_spec.rb +94 -0
  166. data/spec/controllers/mno_enterprise/jpi/v1/current_users_controller_spec.rb +128 -0
  167. data/spec/controllers/mno_enterprise/jpi/v1/deletion_requests_controller_spec.rb +72 -0
  168. data/spec/controllers/mno_enterprise/jpi/v1/impac/kpis_controller_spec.rb +80 -0
  169. data/spec/controllers/mno_enterprise/jpi/v1/marketplace_controller_spec.rb +115 -0
  170. data/spec/controllers/mno_enterprise/jpi/v1/organizations_controller_spec.rb +516 -0
  171. data/spec/controllers/mno_enterprise/jpi/v1/team_controller_spec.rb +86 -0
  172. data/spec/controllers/mno_enterprise/org_invites_controller_spec.rb +29 -0
  173. data/spec/controllers/mno_enterprise/pages_controller_spec.rb +49 -0
  174. data/spec/controllers/mno_enterprise/provision_controller_spec.rb +94 -0
  175. data/spec/controllers/mno_enterprise/status_controller_spec.rb +34 -0
  176. data/spec/controllers/mno_enterprise/webhook/o_auth_controller_spec.rb +104 -0
  177. data/spec/lib/mno_enterprise/event_logger_spec.rb +28 -0
  178. data/spec/mailer/mno_enterprise/system_notification_mailer_spec.rb +132 -0
  179. data/spec/rails_helper.rb +94 -0
  180. data/spec/requests/devise/authentication_spec.rb +43 -0
  181. data/spec/requests/devise/registration_spec.rb +64 -0
  182. data/spec/routing/devise/confirmation_routing_spec.rb +20 -0
  183. data/spec/routing/devise/passwords_routing_spec.rb +24 -0
  184. data/spec/routing/devise/registrations_routing_spec.rb +16 -0
  185. data/spec/routing/devise/sessions_routing_spec.rb +20 -0
  186. data/spec/routing/mno_enterprise/deletion_requests_controller_routing_spec.rb +20 -0
  187. data/spec/routing/mno_enterprise/impersonate_controller_routing.spec.rb +15 -0
  188. data/spec/routing/mno_enterprise/jpi/v1/admin/audit_events_controller_routing_spec.rb +11 -0
  189. data/spec/routing/mno_enterprise/jpi/v1/admin/cloud_apps_controller_routing_spec.rb +24 -0
  190. data/spec/routing/mno_enterprise/jpi/v1/admin/invoices_controller_routing_spec.rb +37 -0
  191. data/spec/routing/mno_enterprise/jpi/v1/admin/organizations_controller_routing_spec.rb +20 -0
  192. data/spec/routing/mno_enterprise/jpi/v1/admin/tenant_invoices_controller_routing_spec.rb +16 -0
  193. data/spec/routing/mno_enterprise/jpi/v1/admin/users_controller_routing_spec.rb +24 -0
  194. data/spec/routing/mno_enterprise/jpi/v1/app_instances_controller_routing_spec.rb +12 -0
  195. data/spec/routing/mno_enterprise/jpi/v1/app_instances_sync_controller_routing_spec.rb +15 -0
  196. data/spec/routing/mno_enterprise/jpi/v1/current_users_controller_routing_spec.rb +28 -0
  197. data/spec/routing/mno_enterprise/jpi/v1/deletion_requests_controller_routing_spec.rb +24 -0
  198. data/spec/routing/mno_enterprise/jpi/v1/impac/kpis_controller_routing_spec.rb +22 -0
  199. data/spec/routing/mno_enterprise/jpi/v1/marketplace_controller_routing_spec.rb +16 -0
  200. data/spec/routing/mno_enterprise/jpi/v1/organizations_controller_routing_spec.rb +44 -0
  201. data/spec/routing/mno_enterprise/jpi/v1/teams_controller_routing_spec.rb +36 -0
  202. data/spec/routing/mno_enterprise/org_invites_controller_routing_spec.rb +12 -0
  203. data/spec/routing/mno_enterprise/pages_controller_routing_spec.rb +29 -0
  204. data/spec/routing/mno_enterprise/provision_controller_routing_spec.rb +15 -0
  205. data/spec/routing/mno_enterprise/status_controller_routing_spec.rb +19 -0
  206. data/spec/routing/mno_enterprise/webhook/o_auth_controller_routing_spec.rb +27 -0
  207. data/spec/spec_helper.rb +88 -0
  208. metadata +402 -0
@@ -0,0 +1,22 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::MarketplaceController < ApplicationController
3
+ respond_to :json
4
+
5
+ # GET /mnoe/mnoe/jpi/v1/marketplace
6
+ def index
7
+ @apps = if MnoEnterprise.marketplace_listing
8
+ MnoEnterprise::App.where('nid.in' => MnoEnterprise.marketplace_listing).to_a
9
+ else
10
+ MnoEnterprise::App.all.to_a
11
+ end
12
+
13
+ @categories = MnoEnterprise::App.categories(@apps)
14
+ @categories.delete('Most Popular')
15
+ end
16
+
17
+ # GET /mnoe/jpi/v1/marketplace/1
18
+ def show
19
+ @app = MnoEnterprise::App.find(params[:id])
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::OrganizationsController < Jpi::V1::BaseResourceController
3
+ include MnoEnterprise::Concerns::Controllers::Jpi::V1::OrganizationsController
4
+ end
5
+ end
@@ -0,0 +1,93 @@
1
+ module MnoEnterprise
2
+ class Jpi::V1::ShoppingCartController < ApplicationController
3
+ # before_filter :authenticate_user!, except: [:apps]
4
+ # before_filter :inject_cart_and_authorize, only: [:show,:upsert_item,:remove_item,:checkout]
5
+ #
6
+ # # When a user signs in from the shopping
7
+ # # cart, the CSRF token seems to change therefore
8
+ # # preventing any POST request later on
9
+ # # TODO: We should be able to grab the new CSRF token on
10
+ # # login and inject it in angular
11
+ # skip_before_filter :verify_authenticity_token
12
+ #
13
+ # # GET /mnoe/jpi/v1/shopping_cart/apps
14
+ # # params:
15
+ # # - ensure_apps: [{ app: {id: 16 } }] (as string) -- ensure that some apps are present in the list
16
+ # def apps
17
+ # @apps = App.active.to_a
18
+ #
19
+ # if params[:ensure_apps].present?
20
+ # begin
21
+ # id_list = JSON.parse(params[:ensure_apps]).map { |h| (h['app']||{})['id'] }.compact
22
+ # @apps += App.where(id: id_list).to_a
23
+ # @apps.uniq!
24
+ # rescue
25
+ # end
26
+ # end
27
+ #
28
+ # @apps.sort! { |a,b| a.name <=> b.name }
29
+ #
30
+ # render json: @apps.map { |a| Shopping::Cart.hash_for_app(a) }
31
+ # end
32
+ #
33
+ # # GET /mnoe/jpi/v1/shopping_cart/organizations
34
+ # def organizations
35
+ # @orgs = Organization.accessible_by(Ability.new(current_user)).sort_by { |o| o.name }
36
+ # end
37
+ #
38
+ # # GET /mnoe/jpi/v1/shopping_cart/1
39
+ # def show
40
+ # end
41
+ #
42
+ # # POST /mnoe/jpi/v1/shopping_cart
43
+ # # TODO: add test for bundle parameter on create
44
+ # def create
45
+ # organization = Organization.find(params[:shopping_cart][:organization_id])
46
+ # bundle = params[:shopping_cart][:bundle]
47
+ # authorize! :purchase, organization
48
+ #
49
+ # @cart = Shopping::Cart.create(requestor: current_user, beneficiary: organization, bundle: bundle)
50
+ #
51
+ # render 'show'
52
+ # end
53
+ #
54
+ # # PUT /mnoe/jpi/v1/shopping_cart/1/upsert_item
55
+ # def upsert_item
56
+ # @item = @cart.add_item!(params[:item])
57
+ # render 'show_item'
58
+ # end
59
+ #
60
+ # # PUT /mnoe/jpi/v1/shopping_cart/1/remove_item
61
+ # def remove_item
62
+ # @item = @cart.remove_item!(params[:item])
63
+ # render 'show_item'
64
+ # end
65
+ #
66
+ # # PUT /mnoe/jpi/v1/shopping_cart/1/checkout
67
+ # def checkout
68
+ # if @cart.checkout!(params[:credit_card])
69
+ # render 'show'
70
+ # else
71
+ # render json: @cart.errors, status: :bad_request
72
+ # end
73
+ #
74
+ # end
75
+ #
76
+ # #============================================
77
+ # # Private Methods
78
+ # #============================================
79
+ # private
80
+ # # Inject @cart and authorize access
81
+ # # TODO: use CanCan for authorization
82
+ # def inject_cart_and_authorize
83
+ # @cart = Shopping::Cart.find(params[:id])
84
+ #
85
+ # unless @cart.requestor == current_user
86
+ # render json: { errors: 'unauthorized' }, status: :unauthorized
87
+ # return false
88
+ # end
89
+ #
90
+ # return true
91
+ # end
92
+ end
93
+ end
@@ -0,0 +1,88 @@
1
+ # This controller uses nesting (under organizations) and shallow routes
2
+ module MnoEnterprise
3
+ class Jpi::V1::TeamsController < Jpi::V1::BaseResourceController
4
+ respond_to :json
5
+
6
+ # GET /mnoe/jpi/v1/organizations/:organization_id/teams
7
+ def index
8
+ authorize! :read, parent_organization
9
+ @teams = parent_organization.teams
10
+ end
11
+
12
+ # GET /mnoe/jpi/v1/teams/:id
13
+ def show
14
+ @team = MnoEnterprise::Team.find(params[:id])
15
+ authorize! :read, @team.organization
16
+ end
17
+
18
+ # POST /mnoe/jpi/v1/organizations/:organization_id/teams
19
+ def create
20
+ authorize! :manage_teams, parent_organization
21
+ @team = parent_organization.teams.create(team_params)
22
+
23
+ render 'show'
24
+ end
25
+
26
+ # PUT /mnoe/jpi/v1/teams/:id
27
+ def update
28
+ @team = MnoEnterprise::Team.find(params[:id])
29
+ authorize! :manage_teams, @team.organization
30
+
31
+ # Update regular attributes
32
+ @team.update_attributes(team_params)
33
+
34
+ # # Update permissions
35
+ if params[:team] && params[:team][:app_instances]
36
+ list = params[:team][:app_instances].select { |e| e != {} }
37
+ @team.set_access_to(list)
38
+ end
39
+
40
+ render 'show'
41
+ end
42
+
43
+ # PUT /mnoe/jpi/v1/teams/:id/add_users
44
+ def add_users
45
+ @team = MnoEnterprise::Team.find(params[:id])
46
+ authorize! :manage_teams, @team.organization
47
+
48
+ # Add users
49
+ if params[:team] && params[:team][:users]
50
+ id_list = params[:team][:users].map { |h| h[:id] }.compact
51
+ users = @team.organization.users.where('id.in' => id_list)
52
+ users.each { |u| @team.add_user(u) }
53
+ end
54
+
55
+ render 'show'
56
+ end
57
+
58
+ # PUT /mnoe/jpi/v1/teams/:id/remove_users
59
+ def remove_users
60
+ @team = MnoEnterprise::Team.find(params[:id])
61
+ authorize! :manage_teams, @team.organization
62
+
63
+ # Add users
64
+ if params[:team] && params[:team][:users]
65
+ id_list = params[:team][:users].map { |h| h[:id] }.compact
66
+ users = @team.organization.users.where('id.in' => id_list)
67
+ users.each { |u| @team.remove_user(u) }
68
+ end
69
+
70
+ render 'show'
71
+ end
72
+
73
+ # DELETE /mnoe/jpi/v1/teams/:id
74
+ def destroy
75
+ @team = MnoEnterprise::Team.find(params[:id])
76
+ authorize! :manage_teams, @team.organization
77
+ @team.destroy
78
+
79
+ head :no_content
80
+ end
81
+
82
+ private
83
+
84
+ def team_params
85
+ params.require(:team).permit(:name)
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class OrgInvitesController < ApplicationController
3
+ include MnoEnterprise::Concerns::Controllers::OrgInvitesController
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class PagesController < ApplicationController
3
+ include MnoEnterprise::Concerns::Controllers::PagesController
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class ProvisionController < ApplicationController
3
+ include MnoEnterprise::Concerns::Controllers::ProvisionController
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ # Health Check endpoint
2
+ module MnoEnterprise
3
+ class StatusController < ApplicationController
4
+ # Simple check to see that the app is up
5
+ # Returns:
6
+ # {status: 'Ok'}
7
+ def ping
8
+ render json: {status: 'Ok'}
9
+ end
10
+
11
+ # Version check
12
+ # Returns:
13
+ # {
14
+ # 'app-version': '9061048-6811c4a',
15
+ # 'mno-enterprise-version': '0.0.1',
16
+ # 'env': 'test'
17
+ # }
18
+ def version
19
+ data = {
20
+ 'app-version' => MnoEnterprise::APP_VERSION,
21
+ 'mno-enteprise-version' => MnoEnterprise::VERSION,
22
+ 'env' => Rails.env
23
+ }
24
+ render json: data
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class Webhook::OAuthController < ApplicationController
3
+ include MnoEnterprise::Concerns::Controllers::Webhook::OAuthController
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module MnoEnterprise
2
+ class SystemNotificationMailer < ActionMailer::Base
3
+ include MnoEnterprise::Concerns::Mailers::SystemNotificationMailer
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ module MnoEnterprise
2
+ class HealthCheck
3
+ # Check API connection with Mno-Hub
4
+ # any code that returns blank on success and non blank string upon failure
5
+ def self.perform_mno_hub_check
6
+ # TODO: less expensive test
7
+ if MnoEnterprise::App.first
8
+ ''
9
+ else
10
+ 'MNO-HUB'
11
+ end
12
+ rescue => e
13
+ "MNO-HUB: #{e}. "
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,32 @@
1
+ .registration
2
+ .container
3
+ .row
4
+ .login-box-wrapper
5
+ .login-box-title
6
+ %h2 You password has expired. Please renew it.
7
+ .login-box
8
+ .brand-logo
9
+
10
+ = form_for(resource, as: resource_name, url: mno_enterprise.user_password_expired_path, :html => { method: :put, class: 'form-horizontal' }) do |f|
11
+ = devise_error_messages!
12
+
13
+ .row
14
+ .col-sm-6
15
+ = f.label :current_password, "Current password"
16
+ = f.password_field :current_password, :class => 'form-control'
17
+
18
+ .row
19
+ .col-sm-6
20
+ = f.label :password, "New password"
21
+ = f.password_field :password, :class => 'form-control'
22
+
23
+ .col-sm-6
24
+ = f.label :password_confirmation, "Confirm new password"
25
+ = f.password_field :password_confirmation, :class => 'form-control'
26
+
27
+ %br
28
+
29
+ .row
30
+ .col-sm-12
31
+ .text-center
32
+ = f.submit "Change my password", class: "btn btn-warning"
@@ -0,0 +1,49 @@
1
+ %div{ 'ng-init' => "user = { $pwdScore: {}, name: '#{resource.name}', surname: '#{resource.surname}' }" }
2
+
3
+ = form_for(resource, as: resource_name, :url => mno_enterprise.user_confirmation_finalize_path, :html => { 'name' => 'loginForm', :class => 'autofill-detect text-center' }) do |f|
4
+
5
+ .row
6
+ .col-sm-12
7
+ = f.text_field :name, placeholder: "*First Name", required: true, 'ng-model' => 'user.name', class:'form-control'
8
+
9
+ %br
10
+
11
+ .row
12
+ .col-sm-12
13
+ = f.text_field :surname, placeholder: "*Last Name", required: true, 'ng-model' => 'user.surname', class: 'form-control'
14
+
15
+ - if @phone_required && MnoEnterprise.style.devise.phone_required
16
+ %br
17
+ .row
18
+ .col-sm-12
19
+ .phone
20
+ = f.select :phone_country_code, options_for_select(Country.all.map { |country,code| c = Country.new(code); ["#{c.alpha2} +#{c.country_code}", code]}, MnoEnterprise.app_country), {}, class: 'form-control unstyled'
21
+ = f.text_field :phone, placeholder: "*Phone", required: true, 'ng-model' => 'user.phone_number', class: 'form-control'
22
+
23
+ %br
24
+
25
+ - # Password: two validation styles offered
26
+ .row
27
+ .col-sm-12
28
+ - if !!MnoEnterprise.style.devise.password_complexity_deep_check
29
+ %div{'mno-password' => 'user', form: "loginForm"}
30
+
31
+ .text-center.ng-hide{ 'ng-show' => 'user.$pwdScore.showTip' }
32
+ %small.text-danger Password is not strong enough. Try mixing letters, numbers and cases
33
+
34
+ - else
35
+ .input-group
36
+ = f.password_field :password, :placeholder => "*Choose Password", 'ng-model' => 'user.password', class: 'form-control', 'ng-minlength' => 6, 'mno-password-strength' => true, "password-score" => 'user.$pwdScore', :required => true
37
+ %span.input-group-addon.classic.pw-strength-indicator{'ng-class' => 'user.$pwdScore.class' }
38
+ {{ user.$pwdScore.value }}
39
+
40
+ .text-center.ng-hide{ 'ng-show' => 'user.$pwdScore.showTip' }
41
+ %small.text-danger Password is not strong enough. Try mixing letters, numbers and cases
42
+
43
+
44
+ = f.hidden_field :confirmation_token, value: @confirmation_token
45
+
46
+ %br/
47
+ %div
48
+ %button{ :class => "btn btn-warning btn-login", :type => "submit", 'ng-click' => 'hasClicked = true', 'ng-disabled' => 'loginForm.$invalid', 'ng-hide' => 'hasClicked' } Confirm my account
49
+ %img.ng-hide{ 'ng-src' => asset_path('mno_enterprise/loader-32x32-bg-inverse.gif'), 'ng-show' => 'hasClicked' }
@@ -0,0 +1,34 @@
1
+ .banners.promo.dark.darkblue.confirmation-lounge
2
+ .container
3
+ .row
4
+ .col-md-8.col-md-offset-2
5
+ .row
6
+ .align-center
7
+ %i.fa.fa-envelope
8
+ %h4 Congratulations! We've sent you a confirmation link, please check your email inbox.
9
+ %h5 If you did not receive the email please click resend.
10
+
11
+ %div{ 'ng-init' => "email = '#{@resource.email}'"}
12
+ = form_for(@resource, :as => resource_name, :url => mno_enterprise.user_confirmation_path, :html => { 'name' => 'form', :class => 'dark form-horizontal', :autocomplete => "off" }) do |f|
13
+ - unless devise_error_messages!.empty?
14
+ %div
15
+ .alert.alert-error
16
+ %button.close{ 'data-dismiss' => "alert" } ×
17
+ = devise_error_messages!
18
+ .spacer2
19
+ .form-group
20
+ .col-sm-6.col-sm-offset-2
21
+ .input-prepend
22
+ = f.email_field :email, :placeholder => "Email", :required => true, 'ng-model' => 'email', :class => 'input-xlarge'
23
+ .col-sm-2
24
+ %button{ :class => "btn btn-lg btn-warning", :type => "submit", 'ng-click' => 'hasClicked = true', 'ng-disabled' => 'form.$invalid', 'ng-hide' => 'hasClicked' } Resend!
25
+ %img{ class: 'loader-sm', 'ng-src' => asset_path('mno_enterprise/loader-32x32-bg-main.gif'), 'ng-show' => 'hasClicked' }
26
+
27
+ .spacer2
28
+ .row
29
+ .col-md-12
30
+ .align-center
31
+ %h5
32
+ Or if you prefer you can send an email to our
33
+ = mail_to support_email, "customer care service", subject: "Signup Verification"
34
+ directly and we'll activate it for you.
@@ -0,0 +1,10 @@
1
+ .registration
2
+ .container
3
+ .row
4
+ //.col-md-6.col-md-offset-3
5
+ .login-box-wrapper
6
+ .login-box-title
7
+ %h2 Almost there
8
+ .login-box
9
+ .brand-logo
10
+ = render "mno_enterprise/auth/confirmations/default/form"
@@ -0,0 +1,4 @@
1
+ - if MnoEnterprise.style.design.material
2
+ = render "mno_enterprise/auth/confirmations/material/lounge"
3
+ - else
4
+ = render "mno_enterprise/auth/confirmations/default/lounge"
@@ -0,0 +1,44 @@
1
+ %div{ 'ng-init' => "user = { $pwdScore: {}, name: '#{resource.name}', surname: '#{resource.surname}' }" }
2
+
3
+ = form_for(resource, as: resource_name, :url => mno_enterprise.user_confirmation_finalize_path, :html => { 'name' => 'loginForm', :class => 'text-center' }) do |f|
4
+ = f.hidden_field :confirmation_token, value: @confirmation_token
5
+
6
+ %div{ layout: '', 'layout-sm' => 'column' }
7
+ %md-input-container{ flex: '' }
8
+ %label Name
9
+ = f.text_field :name, required: true, 'ng-model' => 'user.name'
10
+
11
+ %md-input-container{ flex: '' }
12
+ %label Surname
13
+ = f.text_field :surname, required: true, 'ng-model' => 'user.surname'
14
+
15
+
16
+
17
+ - if @phone_required && MnoEnterprise.style.devise.phone_required
18
+ %div{ layout: '', 'layout-sm' => 'column' }
19
+
20
+ %md-input-container
21
+ %md-select{ placeholder: "Ext.", 'ng-model' => "user.phone_country_code", style: 'line-height: 26px;' }
22
+ %md-option{ 'ng-value' => 'opt.alpha2', 'ng-repeat' => "opt in #{ Country.all.map {|cntry, alpha2| {alpha2: alpha2, code: Country.new(alpha2).country_code} }.to_json }" }
23
+ {{ opt.alpha2 }} +{{ opt.code }}
24
+ = f.hidden_field :phone_country_code, 'ng-model' => 'user.phone_country_code'
25
+
26
+ %md-input-container{ flex: '' }
27
+ %label Phone
28
+ = f.text_field :phone, required: true, 'ng-model' => 'user.phone_number'
29
+
30
+ %div{'mno-password' => 'user', form: "loginForm"}
31
+
32
+
33
+ %div
34
+ %button{ class: "md-raised md-accent", 'md-button' => true, type: "submit", 'ng-click' => 'hasClicked = true', 'ng-disabled' => 'loginForm.$invalid' } Create Account
35
+
36
+ %br
37
+
38
+ %div
39
+ %p
40
+ By clicking 'Create Account' you are agreeing to
41
+ = "#{MnoEnterprise.app_name}'s"
42
+ Terms of Use and Privacy Policy
43
+
44
+ %md-progress-linear{ 'md-mode' => "indeterminate", 'ng-show' => 'hasClicked' }