ucb_rails 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +21 -11
  3. data/Rakefile +1 -1
  4. data/app/assets/images/seal.png +0 -0
  5. data/app/assets/stylesheets/ucb_rails.css.scss +7 -0
  6. data/app/assets/stylesheets/ucb_rails/berkeley-colors.sass +27 -0
  7. data/app/assets/stylesheets/ucb_rails/bootstrap-view-helpers.sass +4 -0
  8. data/app/assets/stylesheets/ucb_rails/branding.sass +66 -0
  9. data/app/assets/stylesheets/ucb_rails/buttons.sass +2 -0
  10. data/app/assets/stylesheets/ucb_rails/common.sass +30 -0
  11. data/app/assets/stylesheets/ucb_rails/nav.sass +51 -0
  12. data/app/assets/stylesheets/ucb_rails/typography.sass +43 -0
  13. data/app/assets/stylesheets/ucb_rails/variables.sass +26 -0
  14. data/app/controllers/ucb_rails/admin/users_controller.rb +2 -2
  15. data/app/controllers/ucb_rails/bootstrap_controller.rb +1 -1
  16. data/app/datatables/ucb_rails/base_datatable.rb +2 -0
  17. data/app/datatables/ucb_rails/users_datatable.rb +11 -10
  18. data/app/models/ucb_rails/configuration/email.rb +1 -1
  19. data/app/models/ucb_rails/ldap_person/entry.rb +20 -13
  20. data/app/models/ucb_rails/ldap_person/finder.rb +16 -4
  21. data/app/models/ucb_rails/ldap_person/test_finder.rb +16 -9
  22. data/app/models/ucb_rails/user.rb +21 -13
  23. data/app/models/ucb_rails/user_ldap_service.rb +11 -10
  24. data/app/models/ucb_rails/user_typeahead.rb +20 -2
  25. data/app/views/ucb_rails/admin/email_test/index.html.haml +1 -1
  26. data/app/views/ucb_rails/admin/users/_form.html.haml +1 -0
  27. data/app/views/ucb_rails/admin/users/_user.html.haml +4 -3
  28. data/app/views/ucb_rails/admin/users/index.html.haml +2 -1
  29. data/app/views/ucb_rails/home/logged_in.html.haml +5 -2
  30. data/config/routes.rb +7 -7
  31. data/lib/generators/ucb_rails/install_generator.rb +10 -1
  32. data/lib/generators/ucb_rails/templates/app/assets/javascripts/application.js +1 -0
  33. data/lib/generators/ucb_rails/templates/app/assets/javascripts/ucb_rails/users_datatable.js +1 -1
  34. data/lib/generators/ucb_rails/templates/app/assets/stylesheets/application.css +1 -0
  35. data/lib/generators/ucb_rails/templates/app/assets/stylesheets/bootstrap_and_overrides.css.scss +4 -3
  36. data/lib/generators/ucb_rails/templates/app/views/layouts/_footer.html.haml +1 -1
  37. data/lib/generators/ucb_rails/templates/app/views/layouts/_navigation.html.haml +22 -19
  38. data/lib/generators/ucb_rails/templates/app/views/layouts/application.html.haml +3 -3
  39. data/lib/ucb_rails.rb +2 -1
  40. data/lib/ucb_rails/version.rb +1 -1
  41. metadata +111 -229
  42. data/lib/generators/ucb_rails/templates/app/assets/stylesheets/ucb_rails.css.scss +0 -56
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 847162c41f4ac6964dfc23f26f0f1d968562bf7e
4
+ data.tar.gz: e7b409a5d0ad22e8ab523a8c79a3e5144a618bf0
5
+ SHA512:
6
+ metadata.gz: 933bdac9da8cdb6aff405a0dc2a37763f4e5171c239cadb58181c1f76663b668650c3c0a38b751bdac204c6290e9d32d92c9b926fb20883321cac254377db96f
7
+ data.tar.gz: a9f654f4b1c10b5b682eb1785b5601a445687dd2e4ea973ae217d089e67fb49544d795ec600d7130e23139100a14226d9d6dd2d6a28588d394d548635c4c6e8e
data/README.md CHANGED
@@ -1,16 +1,11 @@
1
- # UCB Rails
2
-
3
- [![Gem Version](https://badge.fury.io/rb/ucb_rails.png)](http://badge.fury.io/rb/ucb_rails)
4
- [![Build Status](https://travis-ci.org/stevedowney/ucb_rails.png)](https://travis-ci.org/stevedowney/ucb_rails)
5
- [![Coverage Status](https://coveralls.io/repos/stevedowney/ucb_rails/badge.png?branch=master)](https://coveralls.io/r/stevedowney/ucb_rails?branch=master)
6
- [![Code Climate](https://codeclimate.com/github/stevedowney/ucb_rails.png)](https://codeclimate.com/github/stevedowney/ucb_rails)
1
+ # UCB Rails (Rails 4 Compatible, see master branch for Rails 3)
7
2
 
8
3
  Get a jump start on your Rails project at UCB. Includes:
9
4
 
10
5
  * CalNet authentication with [omniauth-cas](https://github.com/dlindahl/omniauth-cas)
11
6
  * LDAP integration with [ucb_ldap](https://rubygems.org/gems/ucb_ldap)
12
7
  * includes several other gems including:
13
- * [bootstrap-view-helpers](https://github.com/stevedowney/bootstrap-view-helpers)
8
+ * [bootstrap-view-helpers](https://github.com/ucb-ist-eas/bootstrap-view-helpers/tree/rails4)
14
9
  * [user_announcements](https://github.com/stevedowney/user_announcements)
15
10
  * [rails_environment](https://github.com/stevedowney/rails_environment)
16
11
 
@@ -20,9 +15,8 @@ Add it to your Gemfile
20
15
 
21
16
  ```ruby
22
17
  gem 'ucb_rails'
23
-
24
- # bleeding edge
25
- gem 'ucb_rails', git: 'https://github.com/stevedowney/ucb_rails'
18
+ # 'bootstrap-view-helpers' needs to be added as well
19
+ gem 'bootstrap-view-helpers', github: 'ucb-ist-eas/bootstrap-view-helpers', branch: 'rails4'
26
20
  ```
27
21
 
28
22
  From the command line, install the `ucb_rails` gem:
@@ -49,7 +43,17 @@ Remove superseded files:
49
43
 
50
44
  ```sh
51
45
  rm public/index.html
52
- rm app/views/layouts/application.html.erb
46
+ ```
47
+
48
+ Add includes to application stylesheet
49
+
50
+ ```ruby
51
+ *= require bootstrap-datepicker3
52
+ ```
53
+
54
+ Add includes to application javascript
55
+ ```ruby
56
+ //= require bootstrap-datepicker
53
57
  ```
54
58
 
55
59
  Restart your server and point your browser to:
@@ -68,4 +72,10 @@ host app (if any) will take precedence.
68
72
  * `current_ldap_person`
69
73
  * `logged_in?`
70
74
 
75
+ ## Upgrading From An Older Version
71
76
 
77
+ If you're upgrading from a version older than March 2015, you'll need to run an extra migration in the project that contains the ucb_rails gem. This will add an `alternate_email` column to your users table.
78
+
79
+ ```
80
+ cp ucb_rails/dummy/db/migrate//20150318234744_add_alternate_email_to_users.rb [YOUR_PROJECT_ROOT]/db/migrate
81
+ ```
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
20
  rdoc.rdoc_files.include('lib/**/*.rb')
21
21
  end
22
22
 
23
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
23
+ APP_RAKEFILE = File.expand_path("../dummy/Rakefile", __FILE__)
24
24
  load 'rails/tasks/engine.rake'
25
25
 
26
26
 
@@ -0,0 +1,7 @@
1
+ @import "ucb_rails/common";
2
+ @import "ucb_rails/branding";
3
+ @import "ucb_rails/typography";
4
+ @import "ucb_rails/nav";
5
+ @import "ucb_rails/buttons";
6
+ @import "ucb_rails/bootstrap-view-helpers";
7
+
@@ -0,0 +1,27 @@
1
+ $pri-blue: #003262
2
+ $pri-yellow: #FDB515
3
+
4
+ $alt-blue: #3B7EA1
5
+ $alt-yellow: #E09E19
6
+
7
+ $neu-gray: #C2B9A7
8
+ $neu-orange: #D9661F
9
+ $neu-green: #B9D3B6
10
+
11
+ $vib-blue: #00B0DA
12
+ $vib-orange: #EE1F60
13
+ $vib-yellow: #CFDD45
14
+
15
+ $bri-blue: #00B2A5
16
+ $bri-orange: #ED4E33
17
+ $bri-yellow: #9DAD33
18
+
19
+ $dar-blue: #53626F
20
+ $dar-orange: #6C3302
21
+ $dar-yellow: #584F29
22
+
23
+ $light-gray: rgba(255, 255, 255, 0.62)
24
+ $medium-gray: #DADADA
25
+ $dark-gray: #A5A5A5
26
+ $light-yellow: #FFF5DF
27
+ $light-blue: #E7F6FF
@@ -0,0 +1,4 @@
1
+ .label-pill
2
+ padding-right: .6em
3
+ padding-left: .6em
4
+ border-radius: 10rem
@@ -0,0 +1,66 @@
1
+
2
+
3
+ body
4
+ background-image: asset-data-url("seal.png")
5
+ background-position: 105% 0px
6
+ background-repeat: no-repeat
7
+ background-size: 36%
8
+ background-attachment: fixed
9
+ background-color: $body-bg
10
+
11
+ h1, h2, h3
12
+ color: #00B0DA
13
+
14
+ .nav-tabs > .active > a, .nav-tabs > .active > a:hover, .nav-tabs > .active > a:focus
15
+ background-color: $body-bg !important
16
+
17
+ html body .nav > li > a:hover, html body .nav > li > a:focus
18
+ background-color: $vib-blue
19
+ color: white
20
+
21
+ html body .form-actions
22
+ background-color: transparent
23
+ border-top: none
24
+
25
+ .nav-list > .active > a, .nav-list > .active > a:hover, .nav-list > .active > a:focus
26
+ border-radius: 3px
27
+
28
+ .nav-header,a
29
+ text-shadow: none !important
30
+
31
+ html body .alert
32
+ display: inline-block
33
+
34
+ html body .sidebar-nav
35
+ padding: 10px 0
36
+
37
+ .nav-header
38
+ border-top: 1px solid white
39
+
40
+ &:first-child
41
+ border-top: 0
42
+
43
+ .nav-header,
44
+ .nav-list a
45
+ padding: 10px 15px
46
+ margin-left: 0
47
+ margin-right: 0
48
+
49
+ .nav-list a
50
+ display: block
51
+
52
+ html body .well
53
+ border: 1px solid $pri-blue
54
+ border-radius: 3px
55
+ background: rgba(245, 245, 245, 0.41)
56
+
57
+ .nav-list
58
+ padding: 0
59
+
60
+ .field_with_errors
61
+ display: inline-block
62
+
63
+ .alert-error, .field_with_errors input, .field_with_errors select
64
+ background-color: #f2dede !important
65
+ border-color: #eed3d7 !important
66
+ color: #b94a48 !important
@@ -0,0 +1,2 @@
1
+ .alert-default
2
+ @include alert-variant($alert-warning-bg, $alert-warning-border, $alert-warning-text)
@@ -0,0 +1,30 @@
1
+
2
+
3
+
4
+
5
+ table
6
+ th.c, td.c
7
+ text-align: center
8
+
9
+ th.min, td.min
10
+ width: 1%
11
+
12
+ #lps-modal
13
+ width: 750px
14
+
15
+ form
16
+ input[type="text"]
17
+ width: 140px
18
+ margin-right: 10px
19
+
20
+ #lps-search
21
+ margin-left: 20px
22
+ margin-right: 10px
23
+
24
+ tr.ldap-result-exists
25
+ opacity: 0.5
26
+
27
+ div.control-group.lps-typeahead
28
+ i.ldap-person-search
29
+ cursor: pointer
30
+
@@ -0,0 +1,51 @@
1
+ .navbar
2
+
3
+ .dropdown-menu .dropdown:hover
4
+ @include gradient-vertical($dropdown-link-hover-bg, darken($dropdown-link-hover-bg, 5%))
5
+ color: white !important
6
+
7
+ .dropdown-menu:before
8
+ position: absolute
9
+ top: -7px
10
+ left: 9px
11
+ display: inline-block
12
+ border-right: 7px solid transparent
13
+ border-bottom: 7px solid #ccc
14
+ border-left: 7px solid transparent
15
+ border-bottom-color: rgba(0, 0, 0, 0.2)
16
+ content: ''
17
+
18
+ .dropdown-menu:after
19
+ position: absolute
20
+ top: -6px
21
+ left: 10px
22
+ display: inline-block
23
+ border-right: 6px solid transparent
24
+ border-bottom: 6px solid #ffffff
25
+ border-left: 6px solid transparent
26
+ content: ''
27
+
28
+ .navbar-right > li > .dropdown-menu:before,
29
+ .nav > li > .dropdown-menu.navbar-right:before
30
+ right: 12px
31
+ left: auto
32
+
33
+ .navbar-right > li > .dropdown-menu:after,
34
+ .nav > li > .dropdown-menu.navbar-right:after
35
+ right: 13px
36
+ left: auto
37
+
38
+ a.navbar-brand, span.navbar-brand, a.navbar-brand:hover, span.navbar-brand:hover
39
+ &.rails-development
40
+ background-color: gold
41
+ color: blue
42
+
43
+ &.rails-quality_assurance
44
+ background-color: blue
45
+ color: gold
46
+
47
+ .sidebar-nav
48
+ .nav-stacked
49
+ li a
50
+ padding: 2px 0
51
+ color: $link-color
@@ -0,0 +1,43 @@
1
+ @font-face
2
+ font-family: 'open_sansbold'
3
+ src: image_path('open-sans/opensans_bold_macroman/OpenSans-Bold-webfont.eot')
4
+ src: image_path('open-sans/opensans_bold_macroman/OpenSans-Bold-webfont.eot?#iefix') format('embedded-opentype'), image_path('open-sans/opensans_bold_macroman/OpenSans-Bold-webfont.woff') format('woff'), image_path('open-sans/opensans_bold_macroman/OpenSans-Bold-webfont.ttf') format('truetype'), image_path('open-sans/opensans_bold_macroman/OpenSans-Bold-webfont.svg#open_sansbold') format('svg')
5
+ font-weight: normal
6
+ font-style: normal
7
+
8
+ @font-face
9
+ font-family: 'open_sanslight'
10
+ src: image_path('open-sans/opensans_bold_macroman/OpenSans-Light-webfont.eot')
11
+ src: image_path('open-sans/opensans_bold_macroman/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'), image_path('open-sans/opensans_bold_macroman/OpenSans-Light-webfont.woff') format('woff'), image_path('open-sans/opensans_bold_macroman/OpenSans-Light-webfont.ttf') format('truetype'), image_path('open-sans/opensans_bold_macroman/OpenSans-Light-webfont.svg#open_sanslight') format('svg')
12
+ font-weight: normal
13
+ font-style: normal
14
+
15
+ @font-face
16
+ font-family: 'open_sansregular'
17
+ src: image_path('open-sans/opensans_regular_macroman/OpenSans-Regular-webfont.eot')
18
+ src: image_path('open-sans/opensans_regular_macroman/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'), image_path('open-sans/opensans_regular_macroman/OpenSans-Regular-webfont.woff') format('woff'), image_path('open-sans/opensans_regular_macroman/OpenSans-Regular-webfont.ttf') format('truetype'), url('open-sans/opensans_regular_macroman/OpenSans-Regular-webfont.svg#open_sansregular') format('svg')
19
+ font-weight: normal
20
+ font-style: normal
21
+
22
+ $bold-family: 'open_sansbold', helvetica, sans-serif
23
+
24
+ .bold
25
+ font-family: $bold-family
26
+ font-weight: 600
27
+
28
+ .thin
29
+ font-weight: 100
30
+
31
+ html body
32
+ h1, h2, h3, h4, h5, h6
33
+ color: $pri-blue
34
+
35
+ body, p, li
36
+ font-family: "open_sansregular", "helvetica", "arial", sans-serif !important
37
+
38
+ h1, h2, h3, h4, h5, h6, .thin
39
+ font-family: "open_sanslight", "helvetica", "arial", sans-serif !important
40
+ font-weight: 100 !important
41
+
42
+ strong
43
+ font-family: "open_sansbold", "helvetica", "arial", sans-serif
@@ -0,0 +1,26 @@
1
+ @import berkeley-colors
2
+
3
+ // $font-size-base: 13px
4
+ $body-bg: #F0F5F8
5
+ $brand-info: $bri-blue
6
+ $danger: #EE1F60
7
+ $brand-danger: $danger
8
+ $brand-primary: $pri-blue
9
+
10
+ $btn-primary-bg: $alt-blue
11
+
12
+ $font-family-sans-serif: "open_sansregular", "helvetica", "arial", sans-serif
13
+ $font-family-base: $font-family-sans-serif
14
+
15
+ $link-color: $vib-blue
16
+
17
+ $dropdown-link-hover-color: #fff
18
+ $dropdown-link-hover-bg: #08c
19
+
20
+ $navbar-height: 55px
21
+ $well-bg: transparent
22
+ $nav-link-hover-bg: $bri-blue
23
+ $headings-font-weight: 100
24
+ $font-size-h5: 15px
25
+ $font-size-h4: 18.25px
26
+
@@ -5,7 +5,7 @@ class UcbRails::Admin::UsersController < UcbRails::Admin::BaseController
5
5
  def index
6
6
  respond_to do |format|
7
7
  format.html { @users = UcbRails::User.all }
8
- format.json { render json: UcbRails::UsersDatatable.new(view_context) }
8
+ format.json { render json: UcbRails::UsersDatatable.new(view_context).as_json }
9
9
  end
10
10
  end
11
11
 
@@ -64,4 +64,4 @@ class UcbRails::Admin::UsersController < UcbRails::Admin::BaseController
64
64
  @user ||= UcbRails::User.find(params.fetch(:id))
65
65
  end
66
66
 
67
- end
67
+ end
@@ -14,7 +14,7 @@ class UcbRails::BootstrapController < ApplicationController
14
14
  UCB::LDAP::Person.find_by_uid(uid).tap do |e|
15
15
  return render_text("Bad uid: #{uid.inspect}") if e.blank?
16
16
  user = UcbRails::UserLdapService.create_user_from_uid(uid)
17
- user.update_attributes({admin: true}, without_protection: true)
17
+ user.update_attributes(admin: true)
18
18
  redirect_to login_path
19
19
  end
20
20
  else
@@ -44,6 +44,8 @@
44
44
  # end
45
45
  #
46
46
  class UcbRails::BaseDatatable
47
+ include ActionView::Helpers::SanitizeHelper
48
+
47
49
 
48
50
  def initialize(view)
49
51
  @view = view
@@ -7,7 +7,7 @@ class UcbRails::UsersDatatable < UcbRails::BaseDatatable
7
7
  end
8
8
 
9
9
  def column_names
10
- @column_names ||= %w[admin inactive first_name last_name email phone last_request_at uid]
10
+ @column_names ||= %w[admin inactive first_name last_name email alternate_email phone last_request_at uid]
11
11
  end
12
12
 
13
13
  def search(search_term)
@@ -16,17 +16,18 @@ class UcbRails::UsersDatatable < UcbRails::BaseDatatable
16
16
 
17
17
  def record_to_data(user)
18
18
  [
19
- bln(user.admin),
20
- bln(user.inactive),
21
- h(user.first_name),
22
- h(user.last_name),
23
- h(user.email),
24
- h(user.phone),
25
- h(user.last_request_at),
26
- h(user.uid),
19
+ user.admin? ? "Yes" : "No",
20
+ user.inactive? ? "Yes" : "No",
21
+ sanitize(user.first_name),
22
+ sanitize(user.last_name),
23
+ sanitize(user.email),
24
+ sanitize(user.alternate_email),
25
+ sanitize(user.phone),
26
+ user.last_request_at.to_s,
27
+ sanitize(user.uid),
27
28
  link_to("Edit", edit_ucb_rails_admin_user_path(user), :id => dom_id(user)),
28
29
  link_to('Delete', ucb_rails_admin_user_path(user), :method => :delete, :confirm => 'Are you sure?'),
29
30
  ]
30
31
  end
31
32
 
32
- end
33
+ end
@@ -42,7 +42,7 @@ module UcbRails
42
42
 
43
43
  def process_default_url_options
44
44
  if hash.has_key?('default_url_options')
45
- ActionMailer::Base.default_url_options = hash.fetch('default_url_options')
45
+ ActionMailer::Base.default_url_options = hash.fetch('default_url_options').symbolize_keys
46
46
  end
47
47
  end
48
48
 
@@ -1,54 +1,61 @@
1
1
  module UcbRails::LdapPerson
2
2
  class Entry
3
-
3
+
4
4
  # include ActiveAttr::Model <--- doesn't work with 4.0 (mass assign. security)
5
5
  include ::ActiveAttr::Attributes
6
6
  include ::ActiveAttr::BasicModel
7
7
  include ::ActiveAttr::BlockInitialization
8
8
  include ::ActiveAttr::MassAssignment
9
-
9
+
10
10
  attribute :uid
11
11
  attribute :calnet_id
12
+ attribute :employee_id
12
13
  attribute :first_name
13
14
  attribute :last_name
14
15
  attribute :email
15
16
  attribute :phone
16
17
  attribute :departments
17
18
  attribute :affiliations
18
-
19
+ attribute :affiliate_id
20
+ attribute :inactive
21
+
19
22
  def full_name
20
23
  "#{first_name()} #{last_name()}"
21
24
  end
22
-
25
+
23
26
  def last_first
24
27
  "#{last_name}, #{first_name}"
25
28
  end
26
-
29
+
27
30
  def last_first_downcase
28
31
  last_first.downcase
29
32
  end
30
-
33
+
31
34
  # Currently only used in rspec
32
35
  def ==(other)
33
36
  uid == other.uid
34
37
  end
35
-
38
+
36
39
  class << self
37
-
40
+
38
41
  def new_from_ldap_entry(ldap_entry)
42
+ p ldap_entry.expired?
39
43
  new(
40
44
  :uid => ldap_entry.uid,
41
45
  :calnet_id => ldap_entry.berkeleyedukerberosprincipalstring.first,
46
+ :employee_id => ldap_entry.employeenumber,
42
47
  :first_name => ldap_entry.givenname.first,
43
48
  :last_name => ldap_entry.sn.first,
44
49
  :email => ldap_entry.mail.first,
45
- :phone => ldap_entry.phone,
50
+ :phone => ldap_entry.phone,
46
51
  :departments => ldap_entry.berkeleyeduunithrdeptname,
47
- :affiliations => ldap_entry.berkeleyeduaffiliations
52
+ :affiliations => ldap_entry.berkeleyeduaffiliations,
53
+ :affiliate_id => ldap_entry.berkeleyeduaffid,
54
+ :inactive => ldap_entry.expired? || false
48
55
  )
49
56
  end
50
-
57
+
51
58
  end
52
-
59
+
53
60
  end
54
- end
61
+ end