oxen_account 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/Gemfile +5 -1
  4. data/app/controllers/oxen/accounts_controller.rb +18 -0
  5. data/app/helpers/oxen/accounts_helper.rb +13 -0
  6. data/app/models/ox_account.rb +13 -0
  7. data/app/policies/oxen/account_policy.rb +51 -0
  8. data/app/views/devise/mailer/invitation_instructions.html.erb +1088 -4
  9. data/app/views/oxen/accounts/_account.html.haml +4 -0
  10. data/app/views/oxen/accounts/_accounts.html.haml +18 -0
  11. data/app/views/oxen/accounts/_form.html.haml +82 -0
  12. data/app/views/oxen/accounts/_show.html.haml +4 -0
  13. data/app/views/{accounts → oxen/accounts}/index.json.jbuilder +0 -0
  14. data/app/views/{accounts → oxen/accounts}/show.json.jbuilder +0 -0
  15. data/app/views/users/_account_user.html.haml +6 -4
  16. data/app/views/users/_account_users.html.haml +21 -2
  17. data/app/views/users/_user.html.haml +9 -0
  18. data/app/views/users/{_user.html.erb → _user_form.html.erb} +0 -0
  19. data/app/views/users/_users.html.haml +15 -0
  20. data/app/views/users/invitations/_new.html.haml +1 -1
  21. data/app/views/users/invitations/create.html.haml +3 -19
  22. data/config/initializers/devise.rb +58 -1
  23. data/config/routes.rb +38 -3
  24. data/lib/generators/oxen_account/account_generator.rb +2 -0
  25. data/lib/oxen_account.rb +4 -3
  26. data/lib/oxen_account/version.rb +1 -1
  27. data/oxen_account.gemspec +2 -0
  28. metadata +16 -22
  29. data/app/assets/javascripts/pw_strength.js.coffee +0 -24
  30. data/app/assets/javascripts/zxcvbn.js +0 -43
  31. data/app/controllers/accounts/base/accounts_controller.rb +0 -90
  32. data/app/controllers/users/base/invitations_controller.rb +0 -61
  33. data/app/controllers/users/base/users_controller.rb +0 -68
  34. data/app/helpers/accounts_helper.rb +0 -7
  35. data/app/models/account.rb +0 -8
  36. data/app/models/user.rb +0 -18
  37. data/app/policies/account_policy.rb +0 -44
  38. data/app/policies/user_policy.rb +0 -36
  39. data/app/views/accounts/_form.html.haml +0 -32
  40. data/app/views/accounts/index.html.haml +0 -37
  41. data/app/views/accounts/show.html.haml +0 -16
  42. data/app/views/users/_form.html.haml +0 -50
  43. data/app/views/users/index.html.haml +0 -43
  44. data/oxen_account-0.1.0.gem +0 -0
@@ -0,0 +1,4 @@
1
+ %tr{ id: "tr-#{resource.id}"}
2
+ %td= link_to resource.name, resource
3
+ %td= show_resource_active resource
4
+ %td= show_resource_delete_icon resource, '/admin/accounts'
@@ -0,0 +1,18 @@
1
+ :css
2
+ a.dropdown-button {
3
+ padding-left: 1em;
4
+ padding-right: 1em;
5
+ }
6
+
7
+ - unless params[:action] == 'print'
8
+ = paginate resources
9
+
10
+ %thead
11
+ %tr
12
+ %th{ :"data-field"=>"name"}= t('.name')
13
+ %th{ :"data-field"=>"active"}= t('.active')
14
+ %th= t(:delete)
15
+
16
+ %tbody.bordered.responsive-table.striped.hoverable.page.resources_list
17
+ - resources.each do |account|
18
+ = render partial: 'account', locals: { resource: account }
@@ -0,0 +1,82 @@
1
+
2
+ = simple_form_for(resource, html: {class: 'col sl12'} ) do |f|
3
+ / - if parent?
4
+ / = render @parent
5
+ = f.error_notification
6
+
7
+ .form-inputs
8
+ .row
9
+ = f.input :name, class: :validate, disabled: @disabled, autofocus: true
10
+
11
+ .row
12
+ = f.input :default_url, class: :validate, disabled: @disabled
13
+
14
+ .row
15
+ = f.input :free_users, class: :validate, disabled: @disabled
16
+
17
+ .row
18
+ .input-field.col.s6
19
+ %label{ style: "margin-top: -20px"}= t('.account_active')
20
+ .switch
21
+ %label
22
+ = t(:passive)
23
+ =f.check_box :active, disabled: @disabled
24
+ %span.lever
25
+ = t(:active)
26
+
27
+ .input-field.col.s6
28
+ %label{ style: "margin-top: -20px"}= t('.account_chargeable')
29
+ .switch
30
+ %label
31
+ = t(:false)
32
+ =f.check_box :chargeable, disabled: @disabled
33
+ %span.lever
34
+ = t(:true)
35
+
36
+ %br
37
+ %br
38
+
39
+ .row
40
+ .input-field.col.s12
41
+ %label= t('.last_charged_at')
42
+ %input{ type: 'date', name: 'account[last_charged_at]', class: 'datepicker', disabled: @disabled}
43
+
44
+ .row
45
+ .col.sl12{ style: "margin-bottom: 30px"}
46
+ %hr
47
+
48
+
49
+
50
+ / from oxen_user/views/accounts/_form.html.haml
51
+ /
52
+ / = simple_form_for(resource, html: {class: 'col sl12'} ) do |f|
53
+ / / - if parent?
54
+ / / = render @parent
55
+ / = f.error_notification
56
+ /
57
+ / .form-inputs
58
+ / .row
59
+ / = f.input :name, class: :validate, disabled: @disabled, autofocus: true
60
+ /
61
+ / .row
62
+ / .input-field.col.s12
63
+ / %label{ style: "margin-top: -20px"}= t('.account_active')
64
+ / .switch
65
+ / %label
66
+ / = t(:passive)
67
+ / =f.check_box :active, disabled: @disabled
68
+ / %span.lever
69
+ / = t(:active)
70
+ /
71
+ / .row
72
+ / .col.sl12{ style: "margin-bottom: 30px"}
73
+ / %hr
74
+ /
75
+ / - unless @disabled
76
+ / .row
77
+ / .form-actions.right-align
78
+ / = f.button :submit, t(".#{params[:action]}.submit")
79
+ /
80
+ / - if %w{ show edit }.include? params[:action]
81
+ / :coffeescript
82
+ / $('form label').addClass('active')
@@ -0,0 +1,4 @@
1
+
2
+ - if %w{ show }.include? params[:action]
3
+ = render partial: 'users/account_users'
4
+ = render partial: 'users/invitations/new', locals: { account_id: resource.id }
@@ -1,12 +1,14 @@
1
1
  %tr{ id: "tr-#{user.id}", class:"#{invited_user? user}"}
2
2
  %td= link_to user.name, user
3
3
  %td= user.email
4
- %td
5
- - if user.active
6
- %i.mdi-action-done.small
4
+ %td= show_resource_active user
7
5
  %td
8
6
  - if user.confirmed?
9
- %i.mdi-action-done.small
7
+ %i.small.material-icons done
8
+ - else
9
+ = link_to url_for(user) + '/confirm', class: "unconfirmed yellow-text" do
10
+ = content_tag :i, 'report_problem', class: "material-icons"
11
+ %td= user.invitations.count
10
12
  %td
11
13
  = link_to user, class: 'delete_link', data: { url: '/admin/users', name: "#{user.name}", id: "#{user.id}", remove: "#tr-#{user.id}" } do
12
14
  %i.mdi-action-delete.small{ title: "#{t('.delete')}"}
@@ -1,15 +1,34 @@
1
1
  .row
2
2
  .col.s12
3
3
  %h5= t('.users')
4
- %table.responsive-table.hoverable.striped
4
+ %table.responsive-table.hoverable.striped.resources_table
5
5
  %thead
6
6
  %tr
7
7
  %th{ :"data-field"=>"name"}= t('.name')
8
8
  %th{ :"data-field"=>"email"}= t('.email')
9
9
  %th{ :"data-field"=>"active"}= t('.active')
10
10
  %th{ :"data-field"=>"active"}= t('.confirmed')
11
+ %th{ :"data-field"=>"invitations"}= t('.invitations')
11
12
  %th= t(:delete)
12
13
 
13
- %tbody#account_users
14
+ %tbody#account_users.resources_list
14
15
  - resource.users.each do |user|
15
16
  = render partial: 'users/account_user', locals: { user: user}
17
+
18
+
19
+ :coffeescript
20
+
21
+ $ ->
22
+ $(document.body).on 'click', '.unconfirmed', (e) ->
23
+ e.preventDefault()
24
+ e.stopPropagation()
25
+ $elem = $(e.currentTarget)
26
+ request = $.ajax
27
+ url: $elem.attr('href'),
28
+ type: "get",
29
+ dataType: 'html'
30
+ .done (data) ->
31
+ $( $elem[0].parentElement).html(data)
32
+
33
+ .error (data) ->
34
+ swal("Oops", "We couldn't connect to the server!", "error")
@@ -0,0 +1,9 @@
1
+ %tr{ id: "tr-#{user.id}", class:"#{invited_user? user}"}
2
+ %td= link_to user.name, user
3
+ %td= link_to( user.account.name, user.account) rescue ''
4
+ %td= user.email rescue ''
5
+ %td= show_resource_active user
6
+ %td= user.invitations.count
7
+ %td
8
+ = link_to user, class: 'delete_link', data: { url: '/admin/users', name: "#{user.name}", id: "#{user.id}", remove: "#tr-#{user.id}" } do
9
+ %i.mdi-action-delete.small{ title: "#{t('.delete')}"}
@@ -0,0 +1,15 @@
1
+ .row
2
+ .col.s12
3
+ %table.responsive-table.hoverable.striped.resources_table
4
+ %thead
5
+ %tr
6
+ %th{ :"data-field"=>"name"}= t('.name')
7
+ %th{ :"data-field"=>"account"}= t('.account')
8
+ %th{ :"data-field"=>"email"}= t('.email')
9
+ %th{ :"data-field"=>"active"}= t('.active')
10
+ %th{ :"data-field"=>"invitations"}= t('.invitations')
11
+ %th= t(:delete)
12
+
13
+ %tbody.resources_list
14
+ - @resources.each do |user|
15
+ = render partial: 'user', locals: { user: user}
@@ -23,6 +23,7 @@
23
23
  $ ->
24
24
  $('input[name="commit"]').on 'click', (e) ->
25
25
  e.preventDefault()
26
+ e.stopPropagation()
26
27
  $form = $(e.target).closest('form')
27
28
  data = $form.serialize()
28
29
  jqxhr = $.ajax
@@ -31,7 +32,6 @@
31
32
  data: data
32
33
  .done (response) ->
33
34
  $('#account_users').append(response)
34
- initializeDeleteLinks()
35
35
  fadeItOut $('.message_container .alert-success')
36
36
  .fail (response) ->
37
37
  $('body').append(response.responseText)
@@ -1,21 +1,5 @@
1
- - if result
1
+ - if (resource.errors.empty? rescue false)
2
2
  = render partial: 'users/account_user', locals: { user: resource }
3
3
 
4
- :coffeescript
5
- $ ->
6
- $('.message_container').append '<div class="alert alert-success">' +
7
- '<a aria-hidden="true" class="btn-floating btn-small close-notice success waves-effect waves-light" data-dismiss="alert" type="button">'+
8
- '<i class="mdi-navigation-close"></i>'+
9
- '</a>'+
10
- '<div id="flash_notice">#{t("devise.invitations.send_instructions", email: resource.email)}</div>'+
11
- '</div>'
12
-
13
- - else
14
- :coffeescript
15
- $ ->
16
- $('.message_container').append '<div class="alert alert-danger">' +
17
- '<a aria-hidden="true" class="btn-floating btn-small close-notice danger waves-effect waves-light" data-dismiss="alert" type="button">'+
18
- '<i class="mdi-navigation-close"></i>'+
19
- '</a>'+
20
- '<div id="flash_notice">#{t("devise.failure.missing_data")}</div>'+
21
- '</div>'
4
+ :javascript
5
+ eval("#{set_toasts}");
@@ -1,4 +1,8 @@
1
1
  require 'devise'
2
+ # require 'devise_invitable'
3
+ # require 'devise_zxcvbn'
4
+ #require 'devise_cas_authenticatable'
5
+
2
6
  # Use this hook to configure devise mailer, warden hooks and so forth.
3
7
  # Many of these configuration options can be set straight in your model.
4
8
  Devise.setup do |config|
@@ -11,7 +15,7 @@ Devise.setup do |config|
11
15
  # Configure the e-mail address which will be shown in Devise::Mailer,
12
16
  # note that it will be overwritten if you use your own mailer class
13
17
  # with default "from" parameter.
14
- # config.mailer_sender = 'no-reply@' + Rails.application.secrets.domain_name
18
+ config.mailer_sender = 'no-reply@' + Rails.application.secrets.domain_name
15
19
 
16
20
  # Configure the class responsible to send e-mails.
17
21
  # config.mailer = 'Devise::Mailer'
@@ -300,4 +304,57 @@ Devise.setup do |config|
300
304
  # When using omniauth, Devise cannot automatically set Omniauth path,
301
305
  # so you need to do it manually. For the users scope, it would be:
302
306
  # config.omniauth_path_prefix = '/my_engine/users/auth'
307
+
308
+ # ==> CAS Authenticatable
309
+ # config.cas_base_url = "https://localhost:3100"
310
+
311
+ # you can override these if you need to, but cas_base_url is usually enough
312
+ # config.cas_login_url = "https://cas.myorganization.com/login"
313
+ # config.cas_logout_url = "https://cas.myorganization.com/logout"
314
+ # config.cas_validate_url = "https://cas.myorganization.com/serviceValidate"
315
+
316
+ # The CAS specification allows for the passing of a follow URL to be displayed when
317
+ # a user logs out on the CAS server. RubyCAS-Server also supports redirecting to a
318
+ # URL via the destination param. Set either of these urls and specify either nil,
319
+ # 'destination' or 'follow' as the logout_url_param. If the urls are blank but
320
+ # logout_url_param is set, a default will be detected for the service.
321
+ # config.cas_destination_url = 'https://cas.myorganization.com'
322
+ # config.cas_follow_url = 'https://cas.myorganization.com'
323
+ # config.cas_logout_url_param = nil
324
+
325
+ # You can specify the name of the destination argument with the following option.
326
+ # e.g. the following option will change it from 'destination' to 'url'
327
+ # config.cas_destination_logout_param_name = 'url'
328
+
329
+ # By default, devise_cas_authenticatable will create users. If you would rather
330
+ # require user records to already exist locally before they can authenticate via
331
+ # CAS, uncomment the following line.
332
+ # config.cas_create_user = false
333
+
334
+ # You can enable Single Sign Out, which by default is disabled.
335
+ # config.cas_enable_single_sign_out = true
336
+
337
+ # If you don't want to use the username returned from your CAS server as the unique
338
+ # identifier, but some other field passed in cas_extra_attributes, you can specify
339
+ # the field name here.
340
+ # config.cas_user_identifier = nil
341
+
342
+ # If you want to use the Devise Timeoutable module with single sign out,
343
+ # uncommenting this will redirect timeouts to the logout url, so that the CAS can
344
+ # take care of signing out the other serviced applocations. Note that each
345
+ # application manages timeouts independently, so one application timing out will
346
+ # kill the session on all applications serviced by the CAS.
347
+ # config.warden do |manager|
348
+ # manager.failure_app = DeviseCasAuthenticatable::SingleSignOut::WardenFailureApp
349
+ # end
350
+
351
+ # If you need to specify some extra configs for rubycas-client, you can do this via:
352
+ # config.cas_client_config_options = {
353
+ # logger: Rails.logger
354
+ # }
355
+
356
+
357
+
358
+
359
+
303
360
  end
data/config/routes.rb CHANGED
@@ -1,8 +1,43 @@
1
1
  Rails.application.routes.draw do
2
2
 
3
- devise_for :users, :controllers => { :invitations => 'users/invitations' }
3
+ concern :printing do
4
+ member do
5
+ get 'print'
6
+ get 'slip'
7
+ end
8
+ collection do
9
+ get 'print'
10
+ end
11
+ end
12
+
13
+ # prefer and defer elements (setting preferred true|false)
14
+ concern :preferring do
15
+ member do
16
+ get 'prefer'
17
+ get 'defer'
18
+ end
19
+ end
20
+
21
+ # attach and detach the route in question to its 'parent'
22
+ concern :attaching do
23
+ member do
24
+ get 'attach'
25
+ get 'detach'
26
+ end
27
+ end
28
+
29
+ # activate and passify the route in question
30
+ concern :activating do
31
+ member do
32
+ get 'activate'
33
+ get 'deactivate'
34
+ end
35
+ end
36
+
37
+ # devise_for :users, :controllers => { :invitations => 'users/invitations', :sessions => 'devise/cas_sessions' }
4
38
  scope '/admin' do
5
- resources :accounts
6
- resources :users
39
+ resources :accounts, concerns: [:activating, :attaching, :printing] do
40
+ resources :users, concerns: [:activating, :printing]
41
+ end
7
42
  end
8
43
  end
@@ -19,6 +19,8 @@ module OxenAccount
19
19
 
20
20
  def create_migration_file
21
21
  migration_template 'account.rb', 'db/migrate/create_accounts.rb'
22
+ # allow the clock to advance 1sec
23
+ sleep 1
22
24
  migration_template 'user_permission.rb', 'db/migrate/create_user_permissions.rb'
23
25
  end
24
26
  end
data/lib/oxen_account.rb CHANGED
@@ -1,8 +1,9 @@
1
+ require 'devise_invitable'
2
+ require 'devise_zxcvbn'
3
+ require 'paper_trail'
4
+
1
5
  require "oxen_account/version"
2
6
  require "oxen_account/engine"
3
- require "devise_zxcvbn"
4
- require "paper_trail"
5
- require "devise_invitable"
6
7
 
7
8
  module OxenAccount
8
9
  # Your code goes here...
@@ -1,3 +1,3 @@
1
1
  module OxenAccount
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/oxen_account.gemspec CHANGED
@@ -30,6 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency "paper_trail"
31
31
  spec.add_dependency 'pundit'
32
32
 
33
+ # spec.add_dependency "devise_cas_authenticatable"
34
+
33
35
  spec.add_development_dependency "bundler", "~> 1.8"
34
36
  spec.add_development_dependency "rake", "~> 10.0"
35
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxen_account
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walther H Diechmann
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-11 00:00:00.000000000 Z
11
+ date: 2015-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -309,21 +309,10 @@ files:
309
309
  - README.md
310
310
  - Rakefile
311
311
  - app/assets/javascripts/oxen_account.js
312
- - app/assets/javascripts/pw_strength.js.coffee
313
- - app/assets/javascripts/zxcvbn.js
314
- - app/controllers/accounts/base/accounts_controller.rb
315
- - app/controllers/users/base/invitations_controller.rb
316
- - app/controllers/users/base/users_controller.rb
317
- - app/helpers/accounts_helper.rb
318
- - app/models/account.rb
319
- - app/models/user.rb
320
- - app/policies/account_policy.rb
321
- - app/policies/user_policy.rb
322
- - app/views/accounts/_form.html.haml
323
- - app/views/accounts/index.html.haml
324
- - app/views/accounts/index.json.jbuilder
325
- - app/views/accounts/show.html.haml
326
- - app/views/accounts/show.json.jbuilder
312
+ - app/controllers/oxen/accounts_controller.rb
313
+ - app/helpers/oxen/accounts_helper.rb
314
+ - app/models/ox_account.rb
315
+ - app/policies/oxen/account_policy.rb
327
316
  - app/views/devise/confirmations/new.html.haml
328
317
  - app/views/devise/mailer/invitation_instructions.html.erb
329
318
  - app/views/devise/passwords/edit.html.haml
@@ -333,11 +322,17 @@ files:
333
322
  - app/views/devise/sessions/new.html.haml
334
323
  - app/views/devise/shared/_links.html.haml
335
324
  - app/views/devise/unlocks/new.html.haml
325
+ - app/views/oxen/accounts/_account.html.haml
326
+ - app/views/oxen/accounts/_accounts.html.haml
327
+ - app/views/oxen/accounts/_form.html.haml
328
+ - app/views/oxen/accounts/_show.html.haml
329
+ - app/views/oxen/accounts/index.json.jbuilder
330
+ - app/views/oxen/accounts/show.json.jbuilder
336
331
  - app/views/users/_account_user.html.haml
337
332
  - app/views/users/_account_users.html.haml
338
- - app/views/users/_form.html.haml
339
- - app/views/users/_user.html.erb
340
- - app/views/users/index.html.haml
333
+ - app/views/users/_user.html.haml
334
+ - app/views/users/_user_form.html.erb
335
+ - app/views/users/_users.html.haml
341
336
  - app/views/users/invitations/_new.html.haml
342
337
  - app/views/users/invitations/create.html.haml
343
338
  - app/views/users/invitations/edit.html.haml
@@ -356,7 +351,6 @@ files:
356
351
  - lib/oxen_account.rb
357
352
  - lib/oxen_account/engine.rb
358
353
  - lib/oxen_account/version.rb
359
- - oxen_account-0.1.0.gem
360
354
  - oxen_account.gemspec
361
355
  homepage: http://gitserver.alco.dk/oxen_account
362
356
  licenses:
@@ -378,7 +372,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
378
372
  version: '0'
379
373
  requirements: []
380
374
  rubyforge_project:
381
- rubygems_version: 2.2.2
375
+ rubygems_version: 2.4.5
382
376
  signing_key:
383
377
  specification_version: 4
384
378
  summary: Offers an account table for customer accounts