missing model file
git-svn-id: http://svn.barleysodas.com/barleysodas/trunk@101 0f7b21a7-9e3a-4941-bbeb-ce5c7c368fa7master
parent
68e9d000de
commit
353363c31b
|
@ -0,0 +1,60 @@
|
||||||
|
##
|
||||||
|
# Represents a category that a Beer belongs to.
|
||||||
|
#
|
||||||
|
class Style < ActiveRecord::Base
|
||||||
|
has_one_tuxwiki_page :owner_class => 'Style'
|
||||||
|
belongs_to :parent, :foreign_key => 'parent_id',
|
||||||
|
:class_name => 'Style'
|
||||||
|
has_many :children, :foreign_key => 'parent_id',
|
||||||
|
:class_name => 'Style', :order => 'position ASC'
|
||||||
|
validates_presence_of :position
|
||||||
|
has_many :beers
|
||||||
|
|
||||||
|
##
|
||||||
|
# Top level beer styles.
|
||||||
|
#
|
||||||
|
def self.major_styles
|
||||||
|
self.find(:all, :conditions => [ 'parent_id IS NULL' ],
|
||||||
|
:order => 'position ASC')
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a select compatible array for views.
|
||||||
|
#
|
||||||
|
def self.for_select
|
||||||
|
self.find(:all, :include => [ 'parent' ]).sort { |a,b|
|
||||||
|
if !a.parent.nil? and !b.parent.nil? and
|
||||||
|
a.parent.position == b.parent.position
|
||||||
|
a.position <=> b.position
|
||||||
|
elsif a.parent.nil? and !b.parent.nil? and a.position == b.parent.position
|
||||||
|
-1
|
||||||
|
elsif !a.parent.nil? and b.parent.nil? and a.parent.position == b.position
|
||||||
|
1
|
||||||
|
else
|
||||||
|
(a.parent.nil? ? a.position : a.parent.position) <=>
|
||||||
|
(b.parent.nil? ? b.position : b.parent.position)
|
||||||
|
end
|
||||||
|
}.collect { |s|
|
||||||
|
unless s.parent.nil?
|
||||||
|
[ "* #{s.position}. #{s.title}", s.id.to_s ]
|
||||||
|
else
|
||||||
|
[ "#{s.position}. #{s.title}", s.id.to_s ]
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns a list of attributes for a Page render.
|
||||||
|
#
|
||||||
|
def page_attributes
|
||||||
|
pattr = []
|
||||||
|
unless parent.nil?
|
||||||
|
pattr << "Parent Style: #{parent.title}"
|
||||||
|
pattr << "Category Number: #{parent.position}.#{position}"
|
||||||
|
else
|
||||||
|
pattr << "Category Number: #{position}"
|
||||||
|
end
|
||||||
|
pattr << "Beers in this style: #{beers.size}"
|
||||||
|
pattr
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,6 +1,6 @@
|
||||||
ActionController::Routing::Routes.draw do |map|
|
ActionController::Routing::Routes.draw do |map|
|
||||||
map.resources :beers, :breweries, :pages, :discussions, :peoples, :roles,
|
map.resources :beers, :breweries, :pages, :discussions, :peoples, :roles,
|
||||||
:sessions, :styles
|
:sessions, :styles, :galleries
|
||||||
|
|
||||||
map.connect ':controller/:action/:id.:format'
|
map.connect ':controller/:action/:id.:format'
|
||||||
map.connect ':controller/:action/:id'
|
map.connect ':controller/:action/:id'
|
||||||
|
|
|
@ -4,7 +4,8 @@ base_actions = ApplicationController.action_methods
|
||||||
# i should probably figure out all of the children of ApplicationController
|
# i should probably figure out all of the children of ApplicationController
|
||||||
# rather than defining them here.
|
# rather than defining them here.
|
||||||
controllers = [ PagesController, DiscussionsController, StylesController,
|
controllers = [ PagesController, DiscussionsController, StylesController,
|
||||||
PeoplesController, BeersController, BreweriesController, RolesController ]
|
PeoplesController, BeersController, BreweriesController, RolesController,
|
||||||
|
GalleriesController ]
|
||||||
controllers.each do |c|
|
controllers.each do |c|
|
||||||
actions = c.action_methods - base_actions
|
actions = c.action_methods - base_actions
|
||||||
cname = c.controller_name
|
cname = c.controller_name
|
||||||
|
@ -22,6 +23,11 @@ Permission.find(:all,
|
||||||
next if [ 'new', 'create', 'edit', 'update', 'destroy' ].include?(p.action)
|
next if [ 'new', 'create', 'edit', 'update', 'destroy' ].include?(p.action)
|
||||||
r.permissions << p
|
r.permissions << p
|
||||||
end
|
end
|
||||||
|
Permission.find(:all,
|
||||||
|
:conditions => [ 'controller = ?', 'galleries' ]).each do |p|
|
||||||
|
next if [ 'new', 'create', 'edit', 'update', 'destroy' ].include?(p.action)
|
||||||
|
r.permissions << p
|
||||||
|
end
|
||||||
|
|
||||||
r2 = Role.admin_role
|
r2 = Role.admin_role
|
||||||
Permission.find(:all).each do |p|
|
Permission.find(:all).each do |p|
|
||||||
|
|
|
@ -221,16 +221,16 @@
|
||||||
|
|
||||||
#content li.discussion .author abbr { color: #999; }
|
#content li.discussion .author abbr { color: #999; }
|
||||||
|
|
||||||
#content li.discussion .author .gravatar {
|
#content li.discussion .author .gravatar {
|
||||||
margin: 0 0 0.5em 0.5em;
|
margin: 0 0 0.5em 0.5em;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content li.discussion .author div {
|
#content li.discussion .author div {
|
||||||
margin: 0 0 0.5em 0.5em;
|
margin: 0 0 0.5em 0.5em;
|
||||||
width: 60px; height: 60px;
|
width: 60px; height: 60px;
|
||||||
background: url(/images/gravatar.gif) no-repeat left top;
|
background: url(/images/gravatar.gif) no-repeat left top;
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content form.discussions {
|
#content form.discussions {
|
||||||
|
@ -256,6 +256,22 @@
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* People uploaded Image styling */
|
||||||
|
#content .people_image {
|
||||||
|
border: 1px solid #DDD;
|
||||||
|
background-color: #F2F2F2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .people_image .author {
|
||||||
|
margin: 0 0 0.5em 0.5em;
|
||||||
|
width: 60px; height: 60px;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content .people_image .meta {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------
|
/*--------------------------------------------------------------
|
||||||
Sidebar
|
Sidebar
|
||||||
--------------------------------------------------------------*/
|
--------------------------------------------------------------*/
|
||||||
|
|
Reference in New Issue