Browse Source

fill out schema

git-svn-id: file:///home/pjones/src/tmp/b2-svn/bugs/trunk@216 637e2b85-2e0a-0410-84ac-bd785500051d
master
pjones 13 years ago
parent
commit
63ccb0da29
6 changed files with 150 additions and 316 deletions
  1. 18
    18
      app/controllers/application.rb
  2. 3
    0
      app/models/user.rb
  3. 3
    14
      config/routes.rb
  4. 63
    6
      db/migrate/001_initial_schema.rb
  5. 63
    1
      db/schema.rb
  6. 0
    277
      public/index.html

+ 18
- 18
app/controllers/application.rb View File

@@ -31,25 +31,25 @@
######################################################################
class ApplicationController < ActionController::Base
######################################################################
before_filter :check_authentication, :check_authorization
# before_filter :check_authentication, :check_authorization
######################################################################
def check_authentication
unless session[:user]
session[:intended_action] = action_name
redirect_to :controller => "auth", :action => "signin"
return false
end
end
######################################################################
def check_authorization
user = User.find(session[:user])
#def check_authentication
# unless session[:user]
# session[:intended_action] = action_name
# redirect_to :controller => "auth", :action => "signin"
# return false
# end
#end
#######################################################################
#def check_authorization
# user = User.find(session[:user])

unless user.can?(controller_name, action_name)
flash[:notice] = "You are not authorized to view the page you requested"
request.env["HTTP_REFERER"] ? (redirect_to :back) : (redirect_to home_url)
return false
end
end
######################################################################
# unless user.can?(controller_name, action_name)
# flash[:notice] = "You are not authorized to view the page you requested"
# request.env["HTTP_REFERER"] ? (redirect_to :back) : (redirect_to home_url)
# return false
# end
#end
#######################################################################
end
######################################################################

+ 3
- 0
app/models/user.rb View File

@@ -49,6 +49,9 @@ class User < ActiveRecord::Base
def can? (controller, action)
return roles.detect do |role|
role.rights.detect do |right|
right.action == '*' && right.controller == controller ||
right.action == action && right.controller == '*' ||
right.action == '*' && right.controller == '*' ||
right.action == action && right.controller == controller
end
end

+ 3
- 14
config/routes.rb View File

@@ -1,18 +1,7 @@
ActionController::Routing::Routes.draw do |map|
# Add your own custom routes here.
# The priority is based upon order of creation: first created -> highest priority.
# Here's a sample route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action

# You can have the root of your site routed by hooking up ''
# -- just remember to delete public/index.html.
# map.connect '', :controller => "welcome"

# Allow downloading Web Service WSDL as a file with an extension
# instead of a file named 'wsdl'
map.connect ':controller/service.wsdl', :action => 'wsdl'
# add named routes
map.home '', :controller => 'products', :action => 'list'
map.connect '', :controller => 'products', :action => 'list'

# Install the default route as the lowest priority.
map.connect ':controller/:action/:id'

+ 63
- 6
db/migrate/001_initial_schema.rb View File

@@ -30,18 +30,75 @@ class InitialSchema < ActiveRecord::Migration
table.column :role_id, :integer
end
######################################################################
create_table :product_groups do |table|
table.column :title, :string
end
######################################################################
create_table :products do |table|
table.column :name, :string
table.column :product_group_id, :integer
table.column :name, :string
table.column :link_url, :string
table.column :icon_url, :string
end
######################################################################
create_table :states do |table|
table.column :title, :string
table.column :weight, :integer
end
######################################################################
create_table :priorities do |table|
table.column :title, :string
table.column :weight, :integer
end
######################################################################
create_table :feedback_types do |table|
table.column :title, :string
table.column :weight, :integer
end
######################################################################
create_table :bugs do |table|
table.column :created_at, :datetime
table.column :updated_at, :datetime
table.column :title, :string
table.column :comments, :text
table.column :creator_id, :integer
table.column :assigned_to, :integer
table.column :product_id, :integer
table.column :state_id, :integer
table.column :priority_id, :integer
table.column :feedback_type_id, :integer
end
######################################################################
create_table :messages do |table|
table.column :bug_id, :integer
table.column :user_id, :integer
table.column :created_at, :datetime
table.column :body, :text
end
######################################################################
create_table :bugs_users, :id => false do |table|
table.column :user_id, :integer
table.column :bug_id, :integer
end
######################################################################
create_table :histories do |table|
table.column :bug_id, :integer
table.column :user_id, :integer
table.column :description, :text
end
######################################################################
create_table :tags do |table|
table.column :title, :string
end
######################################################################
create_table :bugs_tags, :id => false do |table|
table.column :bug_id, :integer
table.column :tag_id, :integer
end
######################################################################
end

def self.down
drop_table :users
drop_table :roles
drop_table :rights
drop_table :roles_users
drop_table :rights_roles
end
end
######################################################################

+ 63
- 1
db/schema.rb View File

@@ -2,10 +2,63 @@
# migrations feature of ActiveRecord to incrementally modify your database, and
# then regenerate this schema definition.

ActiveRecord::Schema.define(:version => 2) do
ActiveRecord::Schema.define(:version => 1) do

create_table "bugs", :force => true do |t|
t.column "created_at", :datetime
t.column "updated_at", :datetime
t.column "title", :string
t.column "comments", :text
t.column "creator_id", :integer
t.column "assigned_to", :integer
t.column "product_id", :integer
t.column "state_id", :integer
t.column "priority_id", :integer
t.column "feedback_type_id", :integer
end

create_table "bugs_tags", :id => false, :force => true do |t|
t.column "bug_id", :integer
t.column "tag_id", :integer
end

create_table "bugs_users", :id => false, :force => true do |t|
t.column "user_id", :integer
t.column "bug_id", :integer
end

create_table "feedback_types", :force => true do |t|
t.column "title", :string
t.column "weight", :integer
end

create_table "histories", :force => true do |t|
t.column "bug_id", :integer
t.column "user_id", :integer
t.column "description", :text
end

create_table "messages", :force => true do |t|
t.column "bug_id", :integer
t.column "user_id", :integer
t.column "created_at", :datetime
t.column "body", :text
end

create_table "priorities", :force => true do |t|
t.column "title", :string
t.column "weight", :integer
end

create_table "product_groups", :force => true do |t|
t.column "title", :string
end

create_table "products", :force => true do |t|
t.column "product_group_id", :integer
t.column "name", :string
t.column "link_url", :string
t.column "icon_url", :string
end

create_table "rights", :force => true do |t|
@@ -28,6 +81,15 @@ ActiveRecord::Schema.define(:version => 2) do
t.column "user_id", :integer
end

create_table "states", :force => true do |t|
t.column "title", :string
t.column "weight", :integer
end

create_table "tags", :force => true do |t|
t.column "title", :string
end

create_table "users", :force => true do |t|
t.column "name", :string
t.column "email", :string

+ 0
- 277
public/index.html View File

@@ -1,277 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Ruby on Rails: Welcome aboard</title>
<style type="text/css" media="screen">
body {
margin: 0;
margin-bottom: 25px;
padding: 0;
background-color: #f0f0f0;
font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
font-size: 13px;
color: #333;
}
h1 {
font-size: 28px;
color: #000;
}
a {color: #03c}
a:hover {
background-color: #03c;
color: white;
text-decoration: none;
}
#page {
background-color: #f0f0f0;
width: 750px;
margin: 0;
margin-left: auto;
margin-right: auto;
}
#content {
float: left;
background-color: white;
border: 3px solid #aaa;
border-top: none;
padding: 25px;
width: 500px;
}
#sidebar {
float: right;
width: 175px;
}

#footer {
clear: both;
}

#header, #about, #getting-started {
padding-left: 75px;
padding-right: 30px;
}


#header {
background-image: url("images/rails.png");
background-repeat: no-repeat;
background-position: top left;
height: 64px;
}
#header h1, #header h2 {margin: 0}
#header h2 {
color: #888;
font-weight: normal;
font-size: 16px;
}
#about h3 {
margin: 0;
margin-bottom: 10px;
font-size: 14px;
}
#about-content {
background-color: #ffd;
border: 1px solid #fc0;
margin-left: -11px;
}
#about-content table {
margin-top: 10px;
margin-bottom: 10px;
font-size: 11px;
border-collapse: collapse;
}
#about-content td {
padding: 10px;
padding-top: 3px;
padding-bottom: 3px;
}
#about-content td.name {color: #555}
#about-content td.value {color: #000}
#about-content.failure {
background-color: #fcc;
border: 1px solid #f00;
}
#about-content.failure p {
margin: 0;
padding: 10px;
}
#getting-started {
border-top: 1px solid #ccc;
margin-top: 25px;
padding-top: 15px;
}
#getting-started h1 {
margin: 0;
font-size: 20px;
}
#getting-started h2 {
margin: 0;
font-size: 14px;
font-weight: normal;
color: #333;
margin-bottom: 25px;
}
#getting-started ol {
margin-left: 0;
padding-left: 0;
}
#getting-started li {
font-size: 18px;
color: #888;
margin-bottom: 25px;
}
#getting-started li h2 {
margin: 0;
font-weight: normal;
font-size: 18px;
color: #333;
}
#getting-started li p {
color: #555;
font-size: 13px;
}
#search {
margin: 0;
padding-top: 10px;
padding-bottom: 10px;
font-size: 11px;
}
#search input {
font-size: 11px;
margin: 2px;
}
#search-text {width: 170px}
#sidebar ul {
margin-left: 0;
padding-left: 0;
}
#sidebar ul h3 {
margin-top: 25px;
font-size: 16px;
padding-bottom: 10px;
border-bottom: 1px solid #ccc;
}
#sidebar li {
list-style-type: none;
}
#sidebar ul.links li {
margin-bottom: 5px;
}
</style>
<script type="text/javascript" src="javascripts/prototype.js"></script>
<script type="text/javascript" src="javascripts/effects.js"></script>
<script type="text/javascript">
function about() {
if (Element.empty('about-content')) {
new Ajax.Updater('about-content', 'rails_info/properties', {
method: 'get',
onFailure: function() {Element.classNames('about-content').add('failure')},
onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
});
} else {
new Effect[Element.visible('about-content') ?
'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
}
}
window.onload = function() {
$('search-text').value = '';
$('search').onsubmit = function() {
$('search-text').value = 'site:rubyonrails.org ' + $F('search-text');
}
}
</script>
</head>
<body>
<div id="page">
<div id="sidebar">
<ul id="sidebar-items">
<li>
<form id="search" action="http://www.google.com/search" method="get">
<input type="hidden" name="hl" value="en" />
<input type="text" id="search-text" name="q" value="site:rubyonrails.org " />
<input type="submit" value="Search" /> the Rails site
</form>
</li>
<li>
<h3>Join the community</h3>
<ul class="links">
<li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>
<li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>
<li><a href="http://lists.rubyonrails.org/">Mailing lists</a></li>
<li><a href="http://wiki.rubyonrails.org/rails/pages/IRC">IRC channel</a></li>
<li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
<li><a href="http://dev.rubyonrails.org/">Bug tracker</a></li>
</ul>
</li>
<li>
<h3>Browse the documentation</h3>
<ul class="links">
<li><a href="http://api.rubyonrails.org/">Rails API</a></li>
<li><a href="http://www.ruby-doc.org/stdlib/">Ruby standard library</a></li>
<li><a href="http://www.ruby-doc.org/core/">Ruby core</a></li>
</ul>
</li>
</ul>
</div>

<div id="content">
<div id="header">
<h1>Welcome aboard</h1>
<h2>You&rsquo;re riding the Rails!</h2>
</div>

<div id="about">
<h3><a href="rails_info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
<div id="about-content" style="display: none"></div>
</div>
<div id="getting-started">
<h1>Getting started</h1>
<h2>Here&rsquo;s how to get rolling:</h2>
<ol>
<li>
<h2>Create your databases and edit <tt>config/database.yml</tt></h2>
<p>Rails needs to know your login and password.</p>
</li>
<li>
<h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
<p>To see all available options, run it without parameters.</p>
</li>
<li>
<h2>Set up a default route and remove or rename this file</h2>
<p>Routes are setup in config/routes.rb.</p>
</li>
</ol>
</div>
</div>
<div id="footer">&nbsp;</div>
</div>
</body>
</html>

Loading…
Cancel
Save