openstax_accounts 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +15 -0
  2. data/README.md +20 -0
  3. data/app/controllers/openstax/accounts/dev/base_controller.rb +19 -0
  4. data/app/controllers/openstax/accounts/dev/users_controller.rb +10 -9
  5. data/app/handlers/openstax/accounts/dev/users_index.rb +39 -0
  6. data/app/handlers/openstax/accounts/sessions_omniauth_authenticated.rb +2 -1
  7. data/app/models/openstax/accounts/application_user.rb +7 -0
  8. data/app/models/openstax/accounts/user.rb +15 -3
  9. data/app/representers/openstax/accounts/api/v1/application_user_representer.rb +5 -1
  10. data/app/representers/openstax/accounts/api/v1/application_user_search_representer.rb +19 -0
  11. data/app/representers/openstax/accounts/api/v1/application_users_representer.rb +16 -0
  12. data/app/representers/openstax/accounts/api/v1/user_representer.rb +2 -6
  13. data/app/routines/openstax/accounts/dev/create_user.rb +4 -4
  14. data/app/routines/openstax/accounts/dev/search_users.rb +27 -0
  15. data/app/routines/openstax/accounts/search_users.rb +174 -32
  16. data/app/routines/openstax/accounts/sync_users.rb +44 -0
  17. data/app/views/openstax/accounts/dev/users/_search_results.html.erb +50 -0
  18. data/app/views/openstax/accounts/dev/users/index.js.erb +3 -0
  19. data/app/views/openstax/accounts/dev/users/login.html.erb +6 -5
  20. data/app/views/openstax/accounts/shared/_attention.html.erb +1 -1
  21. data/app/views/openstax/accounts/shared/users/_index.html.erb +24 -0
  22. data/config/routes.rb +5 -4
  23. data/lib/generators/openstax/accounts/schedule/USAGE +8 -0
  24. data/lib/generators/openstax/accounts/schedule/schedule_generator.rb +18 -0
  25. data/lib/generators/openstax/accounts/schedule/templates/schedule.rb +3 -0
  26. data/lib/omniauth/strategies/openstax.rb +1 -1
  27. data/lib/openstax/accounts/engine.rb +2 -0
  28. data/lib/openstax/accounts/version.rb +1 -1
  29. data/lib/openstax_accounts.rb +69 -26
  30. data/spec/controllers/openstax/accounts/dev/users_controller_spec.rb +4 -3
  31. data/spec/dummy/app/controllers/api/application_users_controller.rb +12 -0
  32. data/spec/dummy/config/application.rb +3 -0
  33. data/spec/dummy/config/initializers/openstax_accounts.rb +1 -0
  34. data/spec/dummy/config/routes.rb +5 -4
  35. data/spec/lib/openstax_accounts_spec.rb +19 -11
  36. data/spec/routines/openstax/accounts/dev/create_user_spec.rb +26 -0
  37. data/spec/routines/openstax/accounts/search_users_spec.rb +129 -0
  38. metadata +47 -68
  39. data/app/controllers/openstax/accounts/dev/dev_controller.rb +0 -13
  40. data/app/handlers/openstax/accounts/dev/users_search.rb +0 -38
  41. data/app/representers/openstax/accounts/api/v1/contact_info_representer.rb +0 -23
  42. data/app/representers/openstax/accounts/api/v1/email_address_representer.rb +0 -9
  43. data/app/views/openstax/accounts/dev/users/search.js.erb +0 -21
  44. data/app/views/openstax/accounts/users/_action_create_form.html.erb +0 -9
  45. data/app/views/openstax/accounts/users/_action_dialog.html.erb +0 -10
  46. data/app/views/openstax/accounts/users/_action_list.html.erb +0 -33
  47. data/app/views/openstax/accounts/users/_action_search.html.erb +0 -25
  48. data/app/views/openstax/accounts/users/action_search.js.erb +0 -8
  49. data/spec/dummy/app/controllers/api/users_controller.rb +0 -7
@@ -1,13 +0,0 @@
1
- module OpenStax
2
- module Accounts
3
- module Dev
4
- class DevController < OpenStax::Accounts::ApplicationController
5
-
6
- before_filter Proc.new{
7
- raise SecurityTransgression if Rails.env.production?
8
- }
9
-
10
- end
11
- end
12
- end
13
- end
@@ -1,38 +0,0 @@
1
- module OpenStax
2
- module Accounts
3
- module Dev
4
- class UsersSearch
5
-
6
- lev_handler transaction: :no_transaction
7
-
8
- paramify :search do
9
- attribute :search_type, type: String
10
- validates :search_type, presence: true,
11
- inclusion: { in: %w(Name Username Any),
12
- message: "is not valid" }
13
-
14
- attribute :search_terms, type: String
15
- validates :search_terms, presence: true
16
- end
17
-
18
- uses_routine OpenStax::Accounts::SearchUsers,
19
- as: :search_users,
20
- translations: { outputs: {type: :verbatim} }
21
-
22
- protected
23
-
24
- def authorized?
25
- !Rails.env.production? || caller.is_administrator?
26
- end
27
-
28
- def handle
29
- terms = search_params.search_terms
30
- type = search_params.search_type
31
-
32
- run(:search_users, terms, type.downcase.to_sym)
33
- end
34
-
35
- end
36
- end
37
- end
38
- end
@@ -1,23 +0,0 @@
1
- module OpenStax
2
- module Accounts
3
- module Api
4
- module V1
5
- class ContactInfoRepresenter < Roar::Decorator
6
- include Roar::Representer::JSON
7
-
8
- property :id,
9
- type: Integer
10
-
11
- property :type,
12
- type: String
13
-
14
- property :value,
15
- type: String
16
-
17
- property :verified
18
-
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,9 +0,0 @@
1
- module OpenStax
2
- module Accounts
3
- module Api
4
- module V1
5
- class EmailAddressRepresenter < ContactInfoRepresenter; end
6
- end
7
- end
8
- end
9
- end
@@ -1,21 +0,0 @@
1
-
2
- <%= render template: 'openstax/accounts/users/action_search',
3
- locals: {
4
- users: @handler_result.outputs[:users],
5
- list: OpenStax::Accounts::ActionList.new(
6
- headings: ['First Name', 'Last Name', 'Username', ''],
7
- widths: ['25%', '25%', '25%', '25%'],
8
- data_procs:
9
- [
10
- Proc.new { |user| user.first_name },
11
- Proc.new { |user| user.last_name },
12
- Proc.new { |user| user.username },
13
- Proc.new { |user|
14
- link_to 'Sign in as',
15
- become_dev_users_path(:user_id => user.id),
16
- method: :post
17
- }
18
- ]
19
- )
20
- }
21
- %>
@@ -1,9 +0,0 @@
1
- <%# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
2
- License version 3 or later. See the COPYRIGHT file for details. %>
3
-
4
- <%# Callers must supply a 'user' local variable %>
5
-
6
- <%= form_for target, :method => :post, :remote => true do |f| %>
7
- <%= f.hidden_field :user_id, :value => user.id %>
8
- <%= f.submit "Add", :onclick => please_wait_js %>
9
- <% end %>
@@ -1,10 +0,0 @@
1
- <%# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
2
- License version 3 or later. See the COPYRIGHT file for details. %>
3
-
4
- <div id="user_action_dialog" style="display:none" title="<%= @action_dialog_title %>">
5
- <div id="user_action_dialog_errors"></div>
6
-
7
- <%= render :partial => 'users/action_search',
8
- :locals => { :action_search_path => @action_search_path } %>
9
-
10
- </div>
@@ -1,33 +0,0 @@
1
- <%# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
2
- License version 3 or later. See the COPYRIGHT file for details. %>
3
-
4
- <%
5
- users ||= []
6
- %>
7
-
8
- <% if list.num_columns > 0 %>
9
- <table class="list" width="100%">
10
- <% if list.has_headings? %>
11
- <tr>
12
- <% for ii in 0..list.num_columns - 1 %>
13
- <th><%= list.get_heading(ii) %></th>
14
- <% end %>
15
- </tr>
16
- <% end %>
17
-
18
- <% if users.empty? %>
19
- <tr>
20
- <td colspan="<%= list.num_columns %>">No results</td>
21
- </tr>
22
- <% else %>
23
- <% users.all.each_with_index do |user, uu| %>
24
- <tr>
25
- <% for cc in 0..list.num_columns - 1 %>
26
- <% width = uu == 0 ? list.get_width(cc) : nil %>
27
- <td <%= "width=#{width}" if width %>><%= list.get_data(cc, user) %></td>
28
- <% end %>
29
- </tr>
30
- <% end %>
31
- <% end %>
32
- </table>
33
- <% end %>
@@ -1,25 +0,0 @@
1
- <%# Copyright 2011-2012 Rice University. Licensed under the Affero General Public
2
- License version 3 or later. See the COPYRIGHT file for details. %>
3
-
4
- <%
5
- # Clients of this partial must supply the following variables:
6
- # action_search_path
7
- %>
8
-
9
- <div id="action-search-errors"></div>
10
-
11
- <%= lev_form_for :search,
12
- url: action_search_path,
13
- html: {id: 'action-search-form'},
14
- remote: true do |f| %>
15
-
16
- Search for
17
- <%= f.text_field :search_terms, style: 'width:300px' %>
18
- in
19
- <%= f.select :search_type, options_for_select(['Any', 'Name', 'Username']) %>
20
-
21
- <%= submit_tag 'Search' %>
22
-
23
- <% end %>
24
-
25
- <div id="action-search-results-list"></div>
@@ -1,8 +0,0 @@
1
- <%= unless_errors errors_html_id: (errors_html_id ||= 'action-search-errors') do %>
2
- <% contents = render 'openstax/accounts/users/action_list',
3
- users: users,
4
- list: list %>
5
-
6
- $("#action-search-results-list").html("<%= j(contents) %>");
7
- <% end %>
8
-
@@ -1,7 +0,0 @@
1
- module Api
2
- class UsersController < DummyController
3
- def search
4
- dummy(:search)
5
- end
6
- end
7
- end