Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
finished up user manager plugin, added standard flash display
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Sep 14, 2008
1 parent 56c5a0c commit 11d1152
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 6 deletions.
2 changes: 2 additions & 0 deletions app/views/layouts/admin.html.erb
Expand Up @@ -14,12 +14,14 @@
<%= stylesheet_link_tag 'tables' %>
<%= stylesheet_link_tag 'tree' %>
<%= stylesheet_link_tag 'jqmodal' %>
<%= stylesheet_link_tag 'flashes' %>
<%= javascript_include_tag :defaults, 'jquery', 'jqModal', 'jquery.growl.js', 'ansuz/growls' %>
<%= javascript_include_tag 'show_and_hide' %>
<%= javascript_include_tag 'fckeditor/fckeditor' %>
<!--[if lt IE 7.]><%= javascript_include_tag 'pngfix.js' %><![endif]-->
</head>
<body>
<%= display_standard_flashes -%>
<div id='header'>
<h1>
<span class='logo'></span>
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Expand Up @@ -14,6 +14,7 @@
<%= stylesheet_link_tag 'base' -%>
<%= stylesheet_link_tag 'sprite' -%>
<%= stylesheet_link_tag 'lightbox' -%>
<%= stylesheet_link_tag 'flashes' %>
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery', 'jqModal', 'jquery.growl.js' -%>
<!--[if lt IE 7.]><%= javascript_include_tag 'pngfix.js' %><![endif]-->
</head>
Expand Down
16 changes: 16 additions & 0 deletions public/stylesheets/flashes.css
@@ -0,0 +1,16 @@
div.flash{
padding: 10px;
border-bottom: 2px solid;
}
div.flash.notice{
border-color: #aad2a9;
background-color: #d6ffd5;
}
div.flash.warning{
border-color: #ead3d3;
background-color: #fbe4e4;
}
div.flash.error{
background-color: #faeb9e;
border-color: #d5a23e;
}
@@ -1,20 +1,38 @@
class Admin::UsersController < Admin::BaseController
before_filter :get_users, :only => [:index]
before_filter :get_user, :only => [:edit, :destroy]
before_filter :load_users, :only => [:index]
before_filter :load_user, :only => [:show, :edit, :update, :destroy]
before_filter :load_new_user, :only => [:new, :create]

protected
def get_users
def load_users
@users = User.find(:all)
end

def get_user
def load_user
@user = User.find(params[:id])
end

def load_new_user
@user = User.new(params[:user])
end

public
def index
end

def new
end

def create
if @user.save
flash[:notice] = "User was created successfully."
redirect_to admin_users_path
else
flash.now[:error] = "There was a problem creating this user."
render :action => "new"
end
end

def show
end

Expand Down
@@ -0,0 +1,8 @@
<% submit_text = "Create User" unless local_assigns.include?(:submit_text) -%>
<%= error_messages_for :user -%>
Login: <%= f.text_field :login -%><br />
Password: <%= f.password_field :password -%><br />
Password Confirmation: <%= f.password_field :password_confirmation -%><br />
Email: <%= f.text_field :email -%><br />
Admin? <%= f.check_box(:admin) -%><br />
<%= submit_tag submit_text -%>
@@ -1,5 +1,4 @@
<%= title "Edit User: #{@user.to_s}" -%>
<% form_for [:admin, @user] do |f| -%>
admin? <%= f.check_box(:admin) -%><br />
<%= submit_tag "Update User" -%>
<%= render :partial => 'form', :locals => { :f => f, :submit_text => "Update User" } -%>
<% end -%>
@@ -1,4 +1,7 @@
<%= title "Users" -%>
<% content_for :sidebar do -%>
<%= link_to "Add User", new_admin_user_path -%>
<% end -%>
<table class='subdued'>
<thead>
<tr>
Expand Down
@@ -0,0 +1,7 @@
<%= title "New User" -%>
<% content_for :sidebar do -%>
<%= link_to "All Users", admin_users_path -%>
<% end -%>
<% form_for [:admin, @user] do |f| -%>
<%= render :partial => 'form', :locals => { :f => f } -%>
<% end -%>

0 comments on commit 11d1152

Please sign in to comment.