maestrano-connector-rails 0.2.16 → 0.2.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/Gemfile.lock +27 -0
  4. data/VERSION +1 -1
  5. data/app/helpers/maestrano/connector/rails/session_helper.rb +5 -1
  6. data/app/models/maestrano/connector/rails/complex_entity.rb +14 -33
  7. data/app/models/maestrano/connector/rails/concerns/entity.rb +161 -73
  8. data/app/models/maestrano/connector/rails/sub_entity_base.rb +44 -4
  9. data/lib/generators/connector/install_generator.rb +20 -24
  10. data/lib/generators/connector/templates/home_controller.rb +33 -10
  11. data/lib/generators/connector/templates/home_controller_spec.rb +141 -0
  12. data/lib/generators/connector/templates/home_index.haml +103 -0
  13. data/lib/generators/connector/templates/layouts.haml +45 -0
  14. data/lib/generators/connector/templates/oauth_controller.rb +3 -6
  15. data/lib/generators/connector/templates/shared_entities_controller.rb +7 -0
  16. data/lib/generators/connector/templates/shared_entities_controller_spec.rb +23 -0
  17. data/lib/generators/connector/templates/shared_entities_index.haml +41 -0
  18. data/lib/generators/connector/templates/stylesheets/application.sass +24 -0
  19. data/lib/generators/connector/templates/stylesheets/banners.sass +59 -0
  20. data/lib/generators/connector/templates/stylesheets/home.sass +25 -0
  21. data/lib/generators/connector/templates/stylesheets/layout.sass +125 -0
  22. data/lib/generators/connector/templates/stylesheets/spacers.sass +46 -0
  23. data/lib/generators/connector/templates/stylesheets/variables.sass +57 -0
  24. data/lib/generators/connector/templates/sychronizations_controller_spec.rb +22 -0
  25. data/lib/generators/connector/templates/synchronizations_controller.rb +7 -0
  26. data/lib/generators/connector/templates/synchronizations_index.haml +42 -0
  27. data/maestrano-connector-rails.gemspec +29 -6
  28. data/pkg/maestrano-connector-rails-0.2.16.gem +0 -0
  29. data/spec/models/complex_entity_spec.rb +46 -12
  30. data/spec/models/entity_spec.rb +212 -113
  31. data/spec/models/sub_entity_base_spec.rb +59 -0
  32. data/template/maestrano-connector-template.rb +4 -3
  33. data/template/routes.rb +14 -0
  34. metadata +61 -5
  35. data/lib/generators/connector/templates/admin_controller.rb +0 -58
  36. data/lib/generators/connector/templates/admin_index.html.erb +0 -55
  37. data/lib/generators/connector/templates/home_index.html.erb +0 -48
@@ -5,10 +5,7 @@ class OauthController < ApplicationController
5
5
  # should be set according to your needs
6
6
 
7
7
  def request_omniauth
8
- org_uid = params[:org_uid]
9
- organization = Maestrano::Connector::Rails::Organization.find_by_uid(org_uid)
10
-
11
- if organization && is_admin?(current_user, organization)
8
+ if is_admin
12
9
  # TODO
13
10
  # Perform oauth request here. The oauth process should be able to
14
11
  # remember the organization, either by a param in the request or using
@@ -20,7 +17,7 @@ class OauthController < ApplicationController
20
17
 
21
18
  def create_omniauth
22
19
  org_uid = '' # TODO
23
- organization = Maestrano::Connector::Rails::Organization.find_by_uid(org_uid)
20
+ organization = Maestrano::Connector::Rails::Organization.find_by_uid_and_tenant(org_uid, current_user.tenant)
24
21
 
25
22
  if organization && is_admin?(current_user, organization)
26
23
  # TODO
@@ -31,7 +28,7 @@ class OauthController < ApplicationController
31
28
  end
32
29
 
33
30
  def destroy_omniauth
34
- organization = Maestrano::Connector::Rails::Organization.find(params[:organization_id])
31
+ organization = Maestrano::Connector::Rails::Organization.find_by_id(params[:organization_id])
35
32
 
36
33
  if organization && is_admin?(current_user, organization)
37
34
  organization.oauth_uid = nil
@@ -0,0 +1,7 @@
1
+ class SharedEntitiesController < ApplicationController
2
+ def index
3
+ if is_admin
4
+ @idmaps = Maestrano::Connector::Rails::IdMap.where(organization_id: current_organization.id).order(:connec_entity)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe SharedEntitiesController, :type => :controller do
4
+ describe 'index' do
5
+ subject { get :index }
6
+
7
+ it { expect(subject).to be_success }
8
+
9
+ context 'when user is admin' do
10
+ let(:organization) { create(:organization) }
11
+ let(:idmap) { create(:idmap, organization: organization) }
12
+ before {
13
+ allow_any_instance_of(Maestrano::Connector::Rails::SessionHelper).to receive(:current_organization).and_return(organization)
14
+ allow_any_instance_of(ApplicationHelper).to receive(:is_admin).and_return(true)
15
+ }
16
+
17
+ it 'assigns the idmaps' do
18
+ subject
19
+ expect(assigns(:idmaps)).to eq([idmap])
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,41 @@
1
+ / TODO
2
+ / Replace ApplicationName
3
+ .home
4
+ .banners
5
+ .container
6
+ - if is_admin
7
+ .row
8
+ .col-md-10
9
+ %h3 Data Shared
10
+ %small Equivalence between Maestrano's Connec!™ id and ApplicationName id for each of your entities
11
+
12
+ - if @idmaps
13
+ %table.table.table-condensed
14
+ %th Entity name
15
+ %th Connec!™ entity
16
+ %th Connec!™ id
17
+ %th SalesForce entity
18
+ %th SalesForce id
19
+ %th Message
20
+
21
+ - @idmaps.each do |idmap|
22
+ %tr
23
+ %td= idmap.name
24
+ %td= idmap.connec_entity ? idmap.connec_entity.humanize : nil
25
+ %td= idmap.connec_id
26
+ %td= idmap.external_entity ? idmap.external_entity.humanize : nil
27
+ %td= idmap.external_id
28
+ %td= idmap.message
29
+ - else
30
+ .spacer1
31
+ .row
32
+ .col-md-12
33
+ %strong You don't have any data mapped yet
34
+
35
+ - else
36
+ .row.center
37
+ -if current_user
38
+ %h3 You don't have the necessary rights to access this page.
39
+ - else
40
+ %h3 You need to be logged in to access this page
41
+ = button_to "Go back", home_index_path, method: :get, class: 'btn btn-warning'
@@ -0,0 +1,24 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ */
14
+
15
+ @import 'variables'
16
+ @import 'bootstrap-sprockets'
17
+ @import 'bootstrap'
18
+
19
+ @import 'banners'
20
+ @import 'spacers'
21
+
22
+ @import 'layout'
23
+
24
+ @import 'home'
@@ -0,0 +1,59 @@
1
+ .banners
2
+ width: 100%
3
+ padding: 58px 0 58px 0
4
+
5
+ &.small-padding
6
+ padding: 10px 0px 10px 0px
7
+
8
+ &.lightgray
9
+ background-color: $lightgray
10
+
11
+ &.purple
12
+ background-color: $purple
13
+
14
+ &.darkblue
15
+ background-color: $darkblue
16
+ p
17
+ color: $lightgray
18
+ font-size: 1.1em
19
+ font-weight: 300
20
+
21
+ h2
22
+ font-weight: 700
23
+ font-size: 40px
24
+ color: $darkblue
25
+
26
+ h4
27
+ font-weight: 900
28
+ font-size: 14px
29
+ color: $darkblue
30
+
31
+ p
32
+ color: $mediumblue
33
+ font-weight: 300
34
+ font-size: 16px
35
+
36
+ &.promo
37
+ h2
38
+ font-weight: 700
39
+ font-size: 40px
40
+ text-align: center
41
+ color: $darkblue
42
+
43
+ h3
44
+ font-weight: 300
45
+ font-size: 18px
46
+ text-align: center
47
+ color: $darkblue
48
+
49
+ h4
50
+ font-size: 24px
51
+ font-weight: 400
52
+
53
+ h5
54
+ text-align: center
55
+ font-size: 14px
56
+ font-weight: 300
57
+
58
+ &.sticky
59
+ padding: 5px 0
@@ -0,0 +1,25 @@
1
+ .home
2
+ .link-step
3
+ border: solid 1px silver
4
+ padding: 20px
5
+ border-radius: 4px
6
+
7
+ .link-step-number
8
+ padding-top: 7px
9
+
10
+ .link-step-badge
11
+ padding: 10px
12
+ font-size: 20px
13
+ background-color: cornflowerblue
14
+ border-radius: 20px
15
+
16
+ .link-step-description
17
+ padding-top: 17px
18
+
19
+ .link-step-action
20
+ padding-top: 3px
21
+
22
+ .sync-entity
23
+ padding-bottom: 8px
24
+ margin-bottom: 8px
25
+ border-bottom: dashed 1px silver
@@ -0,0 +1,125 @@
1
+ .mno-main-logo
2
+ width: 201px
3
+ height: 51px
4
+ background: image-url('sprites/shared-icons.sprite.png') 0px 0px no-repeat
5
+
6
+ .logo
7
+ height: 51px
8
+
9
+ .navbar
10
+ &.navbar-dashboard
11
+ top: 0px
12
+
13
+ .container-fluid
14
+ .navbar-brand
15
+ position: absolute
16
+ margin-top: -44px
17
+
18
+ .navbar-submenu
19
+ background-color: $purple
20
+ padding: 15px
21
+ margin-top: 14px
22
+ margin-bottom: -1px
23
+ width: 100%
24
+
25
+ ul
26
+ margin: auto
27
+ list-style-type: none
28
+
29
+ li
30
+ display: inline
31
+ margin: 0px 13px
32
+
33
+ a
34
+ color: white
35
+ font-size: 14px
36
+ font-weight: 300
37
+
38
+ &.active
39
+ color: $darkblue
40
+ font-weight: 300
41
+
42
+ .navbar-nav
43
+ &.navbar-right:last-child
44
+ margin-right: 10px
45
+
46
+ li.active
47
+ .navbar-arrow
48
+ position: absolute
49
+ margin-top: 60px
50
+ width: 0
51
+ height: 0
52
+ border-left: 27px solid transparent
53
+ border-right: 27px solid transparent
54
+ margin-left: calc(50% - 27px)
55
+ border-bottom: 20px solid $purple
56
+
57
+ .container-fluid
58
+ .navbar-brand
59
+ margin-left: 20px
60
+ margin-top: -17px
61
+
62
+ &.navbar-inverse
63
+ font-weight: 300
64
+ letter-spacing: 1px
65
+
66
+ ul.nav.navbar-nav
67
+ text-transform: uppercase
68
+
69
+ a
70
+ font-size: $normal
71
+
72
+ ul.nav.navbar-nav.navbar-right
73
+ button
74
+ margin-top: (($navbar-height - $line-height-computed) / 2) - 18
75
+
76
+ a
77
+ text-transform: none
78
+
79
+ .padding-navbar
80
+ margin-top: $navbar-height
81
+
82
+
83
+ // Reduce the height of the navbar if on mobile device
84
+ @media(min-width: 768px)
85
+ .navbar-fixed-top
86
+ min-height: $navbar-desktop-height
87
+ padding-top: 20px
88
+
89
+ .padding-navbar
90
+ margin-top: $navbar-desktop-height
91
+
92
+ .center
93
+ text-align: center
94
+
95
+ .align-right
96
+ text-align: right
97
+
98
+ html, body
99
+ height: 100%
100
+
101
+ .wrapper
102
+ min-height: 100%
103
+ margin-bottom: -$footer-height
104
+
105
+ &:after
106
+ content: ""
107
+ display: block
108
+
109
+ .footer
110
+ padding-top: $navbar-padding
111
+ height: $footer-height
112
+ border-top: 1px solid darken(#e5e5e5, 10%)
113
+ border-bottom: 1px solid darken(#e5e5e5, 10%)
114
+ background-color: $darkblue
115
+
116
+ .copyright
117
+ text-align: center
118
+ font-size: 10px
119
+ color: #f4f4f4
120
+ margin-top: 20px
121
+
122
+
123
+ .banners
124
+ &.sticky-top
125
+ padding-top: 10px
@@ -0,0 +1,46 @@
1
+ $baseSpacerHeight: 20px
2
+ .spacer1
3
+ clear: both
4
+ margin-bottom: $baseSpacerHeight
5
+ .spacer2
6
+ clear: both
7
+ margin-bottom: 2*$baseSpacerHeight
8
+ .spacer3
9
+ clear: both
10
+ margin-bottom: 3*$baseSpacerHeight
11
+ .spacer4
12
+ clear: both
13
+ margin-bottom: 4*$baseSpacerHeight
14
+ .spacer5
15
+ clear: both
16
+ margin-bottom: 5*$baseSpacerHeight
17
+ .spacer6
18
+ clear: both
19
+ margin-bottom: 6*$baseSpacerHeight
20
+ .spacer7
21
+ clear: both
22
+ margin-bottom: 7*$baseSpacerHeight
23
+ .spacer8
24
+ clear: both
25
+ margin-bottom: 8*$baseSpacerHeight
26
+ .spacer9
27
+ clear: both
28
+ margin-bottom: 9*$baseSpacerHeight
29
+ .spacer10
30
+ clear: both
31
+ margin-bottom: 10*$baseSpacerHeight
32
+ .spacer11
33
+ clear: both
34
+ margin-bottom: 11*$baseSpacerHeight
35
+ .spacer12
36
+ clear: both
37
+ margin-bottom: 12*$baseSpacerHeight
38
+ .spacer13
39
+ clear: both
40
+ margin-bottom: 13*$baseSpacerHeight
41
+ .spacer14
42
+ clear: both
43
+ margin-bottom: 14*$baseSpacerHeight
44
+ .spacer15
45
+ clear: both
46
+ margin-bottom: 15*$baseSpacerHeight
@@ -0,0 +1,57 @@
1
+ $screen-lg-min: 1200px
2
+ $screen-md-min: 992px
3
+ $screen-sm-min: 768px
4
+
5
+ /*-----------------------------------------------------------------------*/
6
+ /* Fonts */
7
+ /*-----------------------------------------------------------------------*/
8
+ $font-family-sans-serif: "Lato", "Helvetica Neue", Helvetica, Arial, sans-serif
9
+ $font-family-base: $font-family-sans-serif
10
+
11
+ /*-----------------------------------------------------------------------*/
12
+ /* Color palette */
13
+ /*-----------------------------------------------------------------------*/
14
+ $darkerblue: #16252c
15
+ $darkblue: #17262d
16
+ $darkerblue: darken($darkblue,4%)
17
+ $darkblue2: #25333a
18
+ $mediumblue: #626d6d
19
+ $lightblue: #abc4c6
20
+ $pink: #ed1e79
21
+ $fluroblue: #00e5f0
22
+ $fluroorange: #ff7300
23
+ $flureoyellow: #fbd925
24
+ $flurogreen: #47ff00
25
+ $fluropink: #e01f74
26
+ $darkgreen: #33d375
27
+ $green: #d1e55c
28
+ $purple: #977bf0
29
+ $lightgray: #e6edee
30
+ $bluegray: #abc4c6
31
+ $bluegray2: #35464c
32
+
33
+ $brand-success: $fluroblue
34
+ $brand-warning: $purple
35
+ $brand-info: $fluroblue
36
+ $brand-danger: $fluropink
37
+ $brand-primary: $fluroblue
38
+
39
+ /*-----------------------------------------------------------------------*/
40
+ /* Text Size */
41
+ /*-----------------------------------------------------------------------*/
42
+ $small: 11px
43
+ $normal: 13px
44
+
45
+ /*-----------------------------------------------------------------------*/
46
+ /* Nav bar */
47
+ /*-----------------------------------------------------------------------*/
48
+ $navbar-inverse-bg: $darkblue
49
+ $navbar-height: 40px
50
+ $navbar-inverse-link-color: $lightblue
51
+ $navbar-border-radius: 0px
52
+ $navbar-inverse-border: $darkblue
53
+ $navbar-desktop-height: 80px
54
+ $navbar-inverse-link-active-bg: $navbar-inverse-bg
55
+
56
+ $navbar-padding: 10px
57
+ $footer-height: 50px