noodall-devise 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- noodall-devise (0.0.1)
4
+ noodall-devise (0.1.0)
5
5
  devise (~> 1.1.3)
6
6
  mm-devise (~> 1.1.6)
7
7
 
8
8
  PATH
9
9
  remote: /Users/steve/Gems/noodall-ui
10
10
  specs:
11
- noodall-ui (0.0.2)
11
+ noodall-ui (0.0.5)
12
12
  dynamic_form
13
13
  noodall-core
14
14
  thoughtbot-sortable_table (= 0.0.6)
@@ -124,7 +124,7 @@ GEM
124
124
  jnunemaker-validatable (~> 1.8.4)
125
125
  plucky (~> 0.3.5)
126
126
  nokogiri (1.4.3.1)
127
- noodall-core (0.1.0)
127
+ noodall-core (0.1.1)
128
128
  canable (= 0.1.1)
129
129
  mongo_mapper (= 0.8.4)
130
130
  ramdiv-mongo_mapper_acts_as_tree (= 0.1.1)
@@ -1,6 +1,8 @@
1
1
  class Admin::UsersController < Noodall::Admin::BaseController
2
2
  include SortableTable::App::Controllers::ApplicationController
3
+ include Canable::Enforcers
3
4
  sortable_attributes :name, :email, :role
5
+ before_filter :enforce_admin_permission, :except => :index
4
6
 
5
7
  # GET /users
6
8
  # GET /users.xml
@@ -28,12 +30,7 @@ class Admin::UsersController < Noodall::Admin::BaseController
28
30
  # POST /users
29
31
  # POST /users.xml
30
32
  def create
31
- @user = User.new(params[:user]) do |user|
32
- # No need for email confirmation
33
- user.email_confirmed = true
34
- # Because mass assignment is protected
35
- user.role = params[:user][:role]
36
- end
33
+ @user = User.new(params[:user])
37
34
  respond_to do |format|
38
35
  if @user.save
39
36
  flash[:notice] = 'User was successfully created.'
@@ -73,6 +70,7 @@ class Admin::UsersController < Noodall::Admin::BaseController
73
70
  # DELETE /users/1.xml
74
71
  def destroy
75
72
  @user = User.find(params[:id])
73
+
76
74
  @user.destroy
77
75
  flash[:notice] = 'User was successfully deleted.'
78
76
 
@@ -82,4 +80,15 @@ class Admin::UsersController < Noodall::Admin::BaseController
82
80
  end
83
81
  end
84
82
 
83
+ # Uses tag cloud to render all groups
84
+ def groups
85
+ render :json => User.tag_cloud
86
+ end
87
+
88
+ private
89
+
90
+ def enforce_admin_permission
91
+ raise Canable::Transgression unless current_user.admin?
92
+ end
93
+
85
94
  end
data/app/models/user.rb CHANGED
@@ -2,20 +2,24 @@ class User
2
2
  include MongoMapper::Document
3
3
  # Include default devise modules. Others available are:
4
4
  # :token_authenticatable, :confirmable, :lockable and :timeoutable
5
- devise :database_authenticatable,
5
+ devise :database_authenticatable,
6
6
  :recoverable, :rememberable, :trackable, :validatable
7
7
 
8
8
  include Canable::Cans
9
- key :name, String
10
- key :groups, Array
9
+ plugin Noodall::Tagging
11
10
 
11
+ key :name, String
12
12
  timestamps!
13
13
 
14
+ alias_attribute :groups, :tags
15
+ alias_attribute :group_list, :tag_list
16
+
14
17
  def full_name
15
18
  name || email
16
19
  end
17
20
 
18
21
  def admin?
19
- groups.include?('admin')
22
+ tags.include?('admin')
20
23
  end
24
+
21
25
  end
@@ -1,7 +1,7 @@
1
1
  <h1>Listing Users</h1>
2
2
 
3
3
  <ul class="choices">
4
- <li><%= link_to 'Create New User', new_admin_user_path %></li>
4
+ <li><%= link_to 'Create New User', new_admin_user_path, :class => 'button' %></li>
5
5
  </ul>
6
6
 
7
7
  <a class="tooltip" href="/cms_help.pdf">&nbsp;</a>
@@ -20,8 +20,8 @@
20
20
  <% for user in @users -%>
21
21
  <tr>
22
22
  <td><%= link_to user.name, [:admin, user], :class => 'edit', :title => 'Edit this user' %></td>
23
- <td><%= user.email %></td>
24
- <td><%= user.groups %></td>
23
+ <td><%= mail_to user.email %></td>
24
+ <td><%= user.group_list %></td>
25
25
  <td><%= link_to 'Delete', [:admin, user], :confirm => 'Are you sure?', :method => :delete, :class => 'delete', :title => 'Delete this user' %></td>
26
26
  </tr>
27
27
  <% end %>
@@ -4,33 +4,38 @@
4
4
  <%= f.error_messages %>
5
5
 
6
6
  <p>
7
+ <span class="tooltip" title="Enter the name of this user">&nbsp;</span>
7
8
  <%= f.label :name %><br/>
8
- <%= f.text_field :name %>
9
+ <span class="input-wrap"><%= f.text_field :name %></span>
9
10
  </p>
10
11
 
11
12
  <p>
13
+ <span class="tooltip" title="Enter the email address the user will use to login">&nbsp;</span>
12
14
  <%= f.label :email %><br/>
13
- <%= f.text_field :email %>
15
+ <span class="input-wrap"><%= f.text_field :email %></span>
14
16
  </p>
15
17
 
16
18
  <p>
19
+ <span class="tooltip" title="Enter the a password for the user">&nbsp;</span>
17
20
  <%= f.label :password %><br/>
18
- <%= f.password_field :password, :onKeyUp => "updateStrength(this.value)" %>
19
- <div id="password-meter"><strong>Strength</strong><div id = "psContainer"><div id = "psStrength"></div></div></div>
21
+ <span class="input-wrap"><%= f.password_field :password, :onKeyUp => "updateStrength(this.value)" %></span>
20
22
  </p>
21
23
 
22
24
  <p>
25
+ <span class="tooltip" title="Enter the password again to confirm it is correct">&nbsp;</span>
23
26
  <%= f.label :password_confirmation %><br/>
24
- <%= f.password_field :password_confirmation %>
27
+ <span class="input-wrap"><%= f.password_field :password_confirmation %></span>
25
28
  </p>
26
29
 
27
30
  <p>
28
- <%= f.label :groups %><br/>
29
- <%= f.text_field :groups %>
31
+ <span class="tooltip" title="Enter the groups this user belongs to (comma seperated)">&nbsp;</span>
32
+ <%= f.label :group_list, "Groups" %><br/>
33
+ <span class="input-wrap"><%= f.text_field :group_list %></span>
30
34
  </p>
31
35
 
32
- <p>
33
- <%= f.submit @user.new_record? ? 'Create' : 'Update', :disable_with => 'Submitting...' %> or <%= link_to 'Cancel', admin_users_path %>
36
+ <p class="fixed-form">
37
+ <%= f.submit @user.new_record? ? 'Create' : 'Update', :disable_with => 'Submitting...', :class => 'update' %>
38
+ <%= link_to 'Cancel', admin_users_path, :class => 'cancel' %>
34
39
  </p>
35
40
  <% end %>
36
41
 
@@ -6,7 +6,8 @@ Feature: Manage users
6
6
 
7
7
  Scenario: List Users
8
8
  Given 20 users exist
9
- And I am on the users admin page
9
+ And I am in the cms
10
+ When I follow "Users" within "ul#topnav"
10
11
  Then I should see a list of users
11
12
 
12
13
  Scenario: Create a User
@@ -10,6 +10,10 @@ Then /^I should see a list of users$/ do
10
10
  page.should have_css('tbody tr', :count => 20)
11
11
  end
12
12
 
13
+ Given /^I am in the cms$/ do
14
+ visit noodall_admin_nodes_path
15
+ end
16
+
13
17
  # Database
14
18
 
15
19
  Given /^a user exists with the attrubutes:$/ do |fields|
@@ -1,9 +1,9 @@
1
1
  module Noodall
2
2
  module Devise
3
3
  class Engine < Rails::Engine
4
- # initializer "static assets" do |app|
5
- # app.middleware.use ::ActionDispatch::Static, "#{root}/public"
6
- # end
4
+ initializer "static assets" do |app|
5
+ Noodall::UI.menu_items['Users'] = :admin_users_path
6
+ end
7
7
  end
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  module Noodall
2
2
  module Devise
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -2,8 +2,6 @@
2
2
  <html>
3
3
  <head>
4
4
  <title>Dummy</title>
5
- <%= stylesheet_link_tag :all %>
6
- <%= javascript_include_tag :defaults %>
7
5
  <%= csrf_meta_tag %>
8
6
  </head>
9
7
  <body>
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noodall-devise
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors: []
13
13
 
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-02 00:00:00 +00:00
18
+ date: 2010-11-05 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency