Add devise gem and panel/users controller

This commit is contained in:
Wen-Tien Chang committed 2010-03-04 16:33:26 +08:00
1 parent e87b3c1d61
commit 13065aa85a
23 files changed
+331 -4

No files matched your search

@@ -1,6 +1,7 @@
class Admin::AssetsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
def show
@asset = Asset.find(params[:id])
@@ -1,6 +1,7 @@
class Admin::ComponentsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
def show
@@ -1,6 +1,9 @@
class Admin::ItemsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
before_filter :find_snippets, :only => :index
@@ -1,6 +1,7 @@
class Admin::LayoutsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
def index
@layouts = Layout.all
@@ -1,6 +1,7 @@
class Admin::LinksController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
def show
@@ -1,6 +1,7 @@
class Admin::PagesController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
def show
@@ -1,6 +1,7 @@
class Admin::SnippetsController < ApplicationController
layout "admin"
before_filter :authenticate_user!
before_filter :find_parent_item
def show
+47
View File
@@ -0,0 +1,47 @@
class Panel::UsersController < ApplicationController
layout "panel"
before_filter :authenticate_user!
def index
@users = User.all
end
def show
@user = User.find(params[:id])
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to :action => :index
else
render :action => :new
end
end
def edit
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
if @user.update_attributes(params[:user])
redirect_to :action => :index
else
render :action => :edit
end
end
def destroy
@user = User.find(params[:id])
@user.destroy
redirect_to :action => :index
end
end
+1 -1
View File
@@ -47,7 +47,7 @@ class Item
def setup_default_value
if self.position.blank?
max_page = Page.find(:last, :order => 'position')
max_page = Page.last(:order => 'position')
self.position = (max_page)? max_page.position.to_i + 1 : 1
end
+6
View File
@@ -0,0 +1,6 @@
class User
include MongoMapper::Document
devise :authenticatable, :recoverable, :rememberable, :trackable
end
+1 -1
View File
@@ -16,7 +16,7 @@
<div id="container">
<div id="header">
<h1>RulingSite</h1>
<h1>RulingSite Admin</h1>
<ul id="nav">
<li><%= link_to t(:home, :scope => :admin), root_path %></li>
+45
View File
@@ -0,0 +1,45 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>R4</title>
<link rel="shortcut icon" href="/favicon.ico">
<%= yield :page_specific_link %>
<%= stylesheet_link_tag "easy", "main", :media => "screen, projection" %>
<%= stylesheet_link_tag "easyprint", :media => "print" %>
<!--[if IE]>
<%= stylesheet_link_tag "ie", :media => "screen, projection" %>
<![endif]-->
<%= yield :page_specific_css %>
</head>
<body>
<div id="container">
<div id="header">
<h1>RulingSite Panel</h1>
<ul id="nav">
<li><%= link_to t(:home, :scope => :panel), root_path %></li>
<li><%= link_to t(:users, :scope => :panel), panel_users_path %></li>
</ul>
</div>
<div class="content">
<div class="main"><%= yield %></div>
<div class="secondary"><%= yield :secondary %></div>
<div class="tertiary"><%= yield :tertiary %></div>
</div>
<div id="footer">
<p>Rulingcom</p>
</div>
</div>
<%= javascript_include_tag "jquery",
"jquery-ui",
"jrails",
"easy",
"application", :cache => 'all' %>
<%= yield :page_specific_javascript %>
</body>
</html>
+9
View File
@@ -0,0 +1,9 @@
<p>
<%= label_tag :name %>
<%= text_field_tag "user[name]" %>
</p>
<p>
<%= f.label :email %>
<%= f.text_field :email %>
</p>
+18
View File
@@ -0,0 +1,18 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t(:new_user, :scope => :panel), new_panel_user_path, :class => 'button positive' %></li>
</ul>
<% end -%>
<h1>Users panel</h1>
<% form_for @user, :url => panel_user_path(@user) do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<p>
<%= f.submit %>
</p>
<% end -%>
+24
View File
@@ -0,0 +1,24 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t(:new_user, :scope => :panel), new_panel_user_path, :class => 'button positive' %></li>
</ul>
<% end -%>
<h1>Users panel</h1>
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>Action</th>
</tr>
<% @users.each do |user| %>
<tr>
<td><%#= user.name %></td>
<td><%= user.email %></td>
<td><%= link_to 'Edit', edit_panel_user_path(user) %> | <%= link_to 'Destroy', panel_user_path(user), :method => :delete %></td>
</tr>
<% end %>
</table>
+18
View File
@@ -0,0 +1,18 @@
<% content_for :secondary do %>
<ul class="list">
<li><%= link_to t(:new_user, :scope => :panel), new_panel_user_path, :class => 'button positive' %></li>
</ul>
<% end -%>
<h1>Users panel</h1>
<% form_for @user, :url => panel_users_path do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<p>
<%= f.submit %>
</p>
<% end -%>