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|
|
||||
map.resources :beers, :breweries, :pages, :discussions, :peoples, :roles,
|
||||
:sessions, :styles
|
||||
:sessions, :styles, :galleries
|
||||
|
||||
map.connect ':controller/:action/:id.:format'
|
||||
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
|
||||
# rather than defining them here.
|
||||
controllers = [ PagesController, DiscussionsController, StylesController,
|
||||
PeoplesController, BeersController, BreweriesController, RolesController ]
|
||||
PeoplesController, BeersController, BreweriesController, RolesController,
|
||||
GalleriesController ]
|
||||
controllers.each do |c|
|
||||
actions = c.action_methods - base_actions
|
||||
cname = c.controller_name
|
||||
|
@ -22,6 +23,11 @@ Permission.find(:all,
|
|||
next if [ 'new', 'create', 'edit', 'update', 'destroy' ].include?(p.action)
|
||||
r.permissions << p
|
||||
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
|
||||
Permission.find(:all).each do |p|
|
||||
|
|
|
@ -256,6 +256,22 @@
|
|||
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
|
||||
--------------------------------------------------------------*/
|
||||
|
|
Reference in New Issue