lyb_devise_admin 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  class AuthorizedController < InheritedResources::Base
2
4
  # Authorization
3
5
  authorize_resource
@@ -1,19 +1,11 @@
1
+ # encoding: utf-8
2
+
1
3
  # Users Controller
2
4
  #
3
5
  # Provides a user/account management interface.
4
6
  class UsersController < AuthorizedController
5
7
  helper :devise
6
8
 
7
- # Scopes
8
- has_scope :tagged_with
9
-
10
- # def create
11
- # @user = User.new(params[:user])
12
- # @user.person = Person.create(:type => params[:user]['role_texts'].first.to_s.camelcase) if params[:user]['role_texts'].first
13
- #
14
- # create!{ users_path }
15
- # end
16
-
17
9
  # Actions
18
10
  def update
19
11
  @user = resource
@@ -40,6 +32,14 @@ class UsersController < AuthorizedController
40
32
  redirect_to users_path, :notice => t('crud.flash.unlocked', :user => @user.to_s)
41
33
  end
42
34
 
35
+ def lock
36
+ @user = resource
37
+
38
+ @user.locke_access!
39
+
40
+ redirect_to users_path, :notice => t('crud.flash.locked', :user => @user.to_s)
41
+ end
42
+
43
43
  def current
44
44
  redirect_to current_user
45
45
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module DeviseHelper
2
4
  # Prepare roles to show in select inputs etc.
3
5
  def roles_for_collection
@@ -1,11 +1,8 @@
1
- = semantic_form_for @user do |f|
2
- = f.semantic_errors
3
- = f.inputs do
4
- = f.input :email
5
- = f.input :password, :hint => !f.object.new_record?, :input_html => {:autocomplete => "off"}
6
- = f.input :password_confirmation
7
- -# f.input :current_password, :required => true unless can?(:manage, User)
8
- = f.input :role_texts, :as => :select, :collection => roles_for_collection, :include_blank => false, :input_html => {:multiple => 'multiple'}, :required => true if can?(:manage, Role)
1
+ = simple_form_for @user do |f|
2
+ = f.input :email
3
+ = f.input :password, :hint => !f.object.new_record?, :input_html => {:autocomplete => "off"}
4
+ = f.input :password_confirmation
5
+ = f.input :current_password, :required => true unless can?(:manage, User)
6
+ = f.input :role_texts, :as => :select, :collection => Ability.roles_for_collection, :include_blank => false, :input_html => {:multiple => 'multiple'}, :required => true if can?(:manage, Role)
9
7
 
10
- = f.buttons do
11
- = f.commit_button
8
+ = f.button :submit
@@ -0,0 +1,12 @@
1
+ %table.table
2
+ %thead
3
+ %tr
4
+ %th= t_attr :login
5
+ %th= t_attr :name
6
+ %th= t_attr :email
7
+ %th= t_attr :role_texts
8
+ %th= t_attr :last_sign_in_at if Devise.mappings[:user].trackable?
9
+ %th= t_attr :locked if Devise.mappings[:user].lockable?
10
+ %th.action-links
11
+ %tbody
12
+ = render @users
@@ -0,0 +1,13 @@
1
+ %tr
2
+ %td= link_to user.login, user, 'data-href-container' => 'tr'
3
+ %td= user.to_s
4
+ %td= user.email
5
+ %td= user.roles.join(', ')
6
+ %td= user.last_sign_in_at if Devise.mappings[:user].trackable?
7
+ %td= user.locked_at if Devise.mappings[:user].lockable?
8
+
9
+ %td.action-links
10
+ =link_to t_action(:edit), edit_resource_url(user)
11
+ =link_to t_action(:lock), lock_user_path(user), :method => :post if Devise.mappings[:user].lockable? && !user.locked_at?
12
+ =link_to t_action(:unlock), unlock_user_path(user), :method => :post if Devise.mappings[:user].lockable? && user.locked_at?
13
+ =link_to t_action(:delete), resource_url(user), :confirm => t_confirm_delete(user), :method => :delete
@@ -1,6 +1,7 @@
1
1
  de:
2
2
  activerecord:
3
3
  models:
4
+ user: Benutzer
4
5
  attributes:
5
6
  user:
6
7
  email: E-Mail
@@ -8,8 +9,14 @@ de:
8
9
  password_confirmation: Passwort Bestätigung
9
10
  current_password: Aktuelles Passwort
10
11
  remember_me: Angemeldet bleiben
12
+ last_sign_in_at: Letzte Anmeldung
11
13
  created_at: Registriert seit
12
14
  roles: Rollen
13
15
  role_texts: Rollen
14
16
  locked: Gesperrt
15
17
  name: Name
18
+
19
+ crud:
20
+ flash:
21
+ locked: "Benutzer %{user} gesperrt."
22
+ unlocked: "Benutzer %{user} freigeschaltet."
data/config/routes.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  Rails.application.routes.draw do
2
4
  resources :users do
3
5
  member do
@@ -1,10 +1,12 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'lyb_devise_admin'
2
4
  require 'rails'
3
5
 
4
6
  module LybDeviseAdmin
5
7
  class Railtie < Rails::Engine
6
- config.to_prepare do
7
- ApplicationController.helper(DeviseHelper)
8
+ initializer 'lyb_devise_admin.helpers' do
9
+ ActionView::Base.send :include, DeviseHelper
8
10
  end
9
11
  end
10
12
  end
@@ -1,3 +1,5 @@
1
+ # encoding: utf-8
2
+
1
3
  module LybDeviseAdmin
2
- VERSION="0.2.1"
4
+ VERSION="0.3.0"
3
5
  end
@@ -1 +1,3 @@
1
+ # encoding: utf-8
2
+
1
3
  require 'lyb_devise_admin/railtie' if defined?(::Rails::Railtie)
metadata CHANGED
@@ -1,83 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: lyb_devise_admin
3
- version: !ruby/object:Gem::Version
4
- hash: 21
5
- prerelease: false
6
- segments:
7
- - 0
8
- - 2
9
- - 1
10
- version: 0.2.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
13
- - "Simon H\xC3\xBCrlimann (CyT)"
7
+ authors:
8
+ - Simon Hürlimann (CyT)
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-08-12 00:00:00 +02:00
19
- default_executable:
12
+ date: 2012-11-07 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
- description: LybDeviseAdmin provides a ready-to-use admin interface for device.
23
- email:
14
+ description: LybDeviseAdmin provides a ready-to-use admin interface for devise.
15
+ email:
24
16
  - simon.huerlimann@cyt.ch
25
17
  executables: []
26
-
27
18
  extensions: []
28
-
29
- extra_rdoc_files:
19
+ extra_rdoc_files:
30
20
  - README.rdoc
31
- files:
21
+ files:
32
22
  - app/controllers/authorized_controller.rb
33
23
  - app/controllers/users_controller.rb
34
24
  - app/helpers/devise_helper.rb
35
- - app/views/users/_collection_table.html.haml
36
25
  - app/views/users/_form.html.haml
37
- - app/views/users/_resource_detail.html.haml
38
- - app/views/users/edit.html.haml
39
- - app/views/users/index.html.haml
40
- - app/views/users/new.html.haml
41
- - app/views/users/show.html.haml
42
- - config/locales/lyb_devise_admin.yml
26
+ - app/views/users/_list.html.haml
27
+ - app/views/users/_user.html.haml
28
+ - config/locales/de.yml
43
29
  - config/routes.rb
44
30
  - lib/lyb_devise_admin.rb
45
31
  - lib/lyb_devise_admin/railtie.rb
46
32
  - lib/lyb_devise_admin/version.rb
47
33
  - README.rdoc
48
- has_rdoc: true
49
34
  homepage: https://github.com/huerlisi/has_accounts
50
35
  licenses: []
51
-
52
36
  post_install_message:
53
37
  rdoc_options: []
54
-
55
- require_paths:
38
+ require_paths:
56
39
  - lib
57
- required_ruby_version: !ruby/object:Gem::Requirement
40
+ required_ruby_version: !ruby/object:Gem::Requirement
58
41
  none: false
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 3
63
- segments:
64
- - 0
65
- version: "0"
66
- required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
47
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
75
52
  requirements: []
76
-
77
53
  rubyforge_project:
78
- rubygems_version: 1.3.7
54
+ rubygems_version: 1.8.23
79
55
  signing_key:
80
56
  specification_version: 3
81
57
  summary: Admin interface for device.
82
58
  test_files: []
83
-
59
+ has_rdoc:
@@ -1,21 +0,0 @@
1
- = contextual_links
2
-
3
- %h2= t_title
4
-
5
- = paginated_section collection do
6
- - @attributes = ['name', 'email', 'role_texts', 'created_at', 'locked']
7
- %table.list{:class => "#{collection.first.class.to_s.downcase.pluralize} collection"}
8
- %thead
9
- %tr
10
- - @attributes.each do |field|
11
- %th= t_attr field, collection.first.class
12
- %th.action-links
13
- %tbody
14
- - collection.each do |r|
15
- %tr
16
- - @attributes.each do |field|
17
- %td= r.send(field) if r.respond_to?(field)
18
- %td.action-links
19
- =link_to t_action(:show), resource_url(r), 'data-href-container' => 'tr'
20
- =link_to t_action(:edit), edit_resource_url(r)
21
- =link_to t_action(:delete), resource_url(r), :confirm => t_confirm_delete(r), :method => :delete
@@ -1,9 +0,0 @@
1
- %p= resource.to_s
2
-
3
- #user
4
- %h2= t_attr(:roles)
5
-
6
- %ul#roles
7
- - resource.roles.each do |role|
8
- %li
9
- = role.to_s
@@ -1,5 +0,0 @@
1
- = contextual_links
2
-
3
- %h2= t_title
4
-
5
- = render 'form'
@@ -1,21 +0,0 @@
1
- = contextual_links
2
-
3
- %h2= t_title
4
-
5
- = paginated_section collection do
6
- - @attributes = ['name', 'email', 'role_texts', 'created_at', 'locked']
7
- %table.list{:class => "#{collection.first.class.to_s.downcase.pluralize} collection"}
8
- %thead
9
- %tr
10
- - @attributes.each do |field|
11
- %th= t_attr field, collection.first.class
12
- %th.action-links
13
- %tbody
14
- - collection.each do |r|
15
- %tr
16
- - @attributes.each do |field|
17
- %td= r.send(field) if r.respond_to?(field)
18
- %td.action-links
19
- =link_to t_action(:show), resource_url(r), 'data-href-container' => 'tr'
20
- =link_to t_action(:edit), edit_resource_url(r)
21
- =link_to t_action(:delete), resource_url(r), :confirm => t_confirm_delete(r), :method => :delete
@@ -1,5 +0,0 @@
1
- = contextual_links
2
-
3
- %h2= t_title
4
-
5
- = render 'form'
@@ -1,8 +0,0 @@
1
- = contextual_links
2
-
3
- %h2= resource.to_s
4
-
5
- #user
6
- %ul#roles
7
- - resource.roles.each do |role|
8
- %li= role.to_s