Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Commit

Permalink
Added reports functionality for admin viewing with the limited abilit…
Browse files Browse the repository at this point in the history
…y to see the number of domains and domains owned by a user for now. [#37 state:resolved ]
  • Loading branch information
cplotter committed Oct 9, 2008
1 parent d4d214b commit 360e5b3
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/role.rb 100644 → 100755
@@ -1,3 +1,3 @@
class Role < ActiveRecord::Base

has_and_belongs_to_many :users
end
18 changes: 18 additions & 0 deletions app/models/user.rb 100644 → 100755
Expand Up @@ -59,6 +59,20 @@ def authenticate(login, password)
def encrypt(password, salt)
Digest::SHA1.hexdigest("--#{salt}--#{password}--")
end

# For our lookup purposes
def search( params, page )
paginate :per_page => 50, :page => page,
:conditions => ['login LIKE ?', "%#{params.chomp}%"]
end

# Users with User role
def find_owners(page)
r = Role.find_by_name("owner")
users = r.users.collect {|u| u.id }.join(',')
paginate :per_page => 50, :page => page,
:conditions => "id IN (#{ users })"
end
end

# Encrypts the password with the user salt
Expand Down Expand Up @@ -122,6 +136,10 @@ def admin=( value )
end
end

def <=>(user)
user.login <=> self.login
end

protected
# before filter
def encrypt_password
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.haml 100644 → 100755
Expand Up @@ -20,6 +20,8 @@
%li= link_to "Templates", zone_templates_path
%li= link_to "Logs", audits_path
%li= link_to "Users", users_path
- if current_user.admin?
%li= link_to "Reports" , reports_path
%li= link_to "Logout", logout_path

#Body
Expand Down
4 changes: 3 additions & 1 deletion app/views/users/show.html.haml 100644 → 100755
Expand Up @@ -23,4 +23,6 @@
&nbsp;&nbsp;&nbsp;
= link_to image_tag('user_delete.png'), user_path( @user ), :method => :delete, :confirm => 'Are you sure you want to remove this user?'
= link_to "Remove", user_path( @user ), :method => :delete, :confirm => 'Are you sure you want to remove this user?'

&nbsp;&nbsp;&nbsp;
= link_to image_tag('help.png') , :controller => :reports , :action => :view , :id => @user
= link_to "More Detail" , :controller => :reports , :action => :view , :id => @user
1 change: 1 addition & 0 deletions config/routes.rb 100644 → 100755
Expand Up @@ -44,6 +44,7 @@

# Audits
map.audits '/audits/:action/:id', :controller => 'audits', :action => 'index'
map.reports '/reports/:action/:id' , :controller => 'reports' , :action => 'index'

# AuthTokens
map.resources :auth_tokens
Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/application.css
Expand Up @@ -139,7 +139,7 @@ a img {
background-color: #FFC;
}
.generic-warning img {
maring-left: - 25px;
margin-left: -25px;
}

input {
Expand Down

0 comments on commit 360e5b3

Please sign in to comment.