1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Added "enabled" for photos so I can disable them without deleting.

This commit is contained in:
Dan Barber 2010-12-02 12:33:44 -05:00
parent 9ac87c80a9
commit 6b26a58497
10 changed files with 94 additions and 80 deletions

View File

@ -7,7 +7,7 @@ class CategoriesController < ApplicationController
@num_categories = @categories.count
@photos = Photo.all(:limit => 2, :order => 'RANDOM()', :conditions => { :featured => true })
@photos = Photo.all(:limit => 2, :order => 'RANDOM()', :conditions => { :featured => true, :enabled => true })
respond_to do |format|
format.html # index.html.erb
@ -26,63 +26,4 @@ class CategoriesController < ApplicationController
end
end
# GET /categories/new
# GET /categories/new.xml
def new
@category = Category.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @category }
end
end
# GET /categories/1/edit
def edit
@category = Category.find(params[:id])
end
# POST /categories
# POST /categories.xml
def create
@category = Category.new(params[:category])
respond_to do |format|
if @category.save
format.html { redirect_to(@category, :notice => 'Category was successfully created.') }
format.xml { render :xml => @category, :status => :created, :location => @category }
else
format.html { render :action => "new" }
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
end
end
end
# PUT /categories/1
# PUT /categories/1.xml
def update
@category = Category.find(params[:id])
respond_to do |format|
if @category.update_attributes(params[:category])
format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /categories/1
# DELETE /categories/1.xml
def destroy
@category = Category.find(params[:id])
@category.destroy
respond_to do |format|
format.html { redirect_to(categories_url) }
format.xml { head :ok }
end
end
end

View File

@ -2,7 +2,7 @@ class PagesController < ApplicationController
layout "photos"
def index
@photo = Photo.first(:order => 'RANDOM()', :conditions => { :featured => true })
@photo = Photo.first(:order => 'RANDOM()', :conditions => { :featured => true, :enabled => true })
end
def about

View File

@ -7,7 +7,7 @@ class PhotosController < ApplicationController
def index
if params[:category_id]
@category = Category.find_by_id(params[:category_id])
@photos = @category.photos.paginate :page => params[:page], :per_page => 11
@photos = @category.photos.paginate :page => params[:page], :conditions => { :enabled => true }, :per_page => 11
@num_photos = @photos.count
else
@photos = Photo.paginate :all, :page => params[:page], :per_page => 11
@ -18,16 +18,6 @@ class PhotosController < ApplicationController
end
end
def create
@photo = Photo.new(params[:photo])
if @photo.save
flash[:notice] = 'Photo was successfully saved'
redirect_to photo_url(@photo)
else
render :action => :new
end
end
def show
@photo = Photo.find(params[:id])
end

View File

@ -10,6 +10,7 @@
<%= stylesheet_link_tag "squaregrid", :media => "all" %>
<%= stylesheet_link_tag "photos", :media => "all" %>
<%= stylesheet_link_tag "fancybox", :media => "all" %>
<%= stylesheet_link_tag "scrollbars", :media => "screen" %>
<%= javascript_include_tag 'jquery', 'jquery.validate', 'jrails', 'fancybox', 'photos' %>
</head>

View File

@ -14,8 +14,8 @@ Category:
Photo:
fields:
default: title, sort, featured
form: photo, title, description, flickr_url, featured, sort
default: title, sort, enabled, featured
form: photo, title, description, flickr_url, enabled, featured, sort
order_by:
relationships: categories
filters:

View File

@ -0,0 +1,9 @@
class AddEnabledToPhotos < ActiveRecord::Migration
def self.up
add_column :photos, :enabled, :boolean, :default => true
end
def self.down
remove_column :photos, :enabled
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20101013165208) do
ActiveRecord::Schema.define(:version => 20101202155552) do
create_table "admin_users", :force => true do |t|
t.string "first_name", :default => "", :null => false
@ -61,6 +61,7 @@ ActiveRecord::Schema.define(:version => 20101013165208) do
t.text "description"
t.integer "sort"
t.boolean "featured", :default => false
t.boolean "enabled", :default => true
end
end

View File

@ -183,13 +183,14 @@ img {
.about-content {
background: #444;
color: #ccc;
overflow: auto;
}
.about-content div {
padding: 15px 20px;
}
.about-content div p {
margin-bottom: 0.6em;
line-height: 1.4em;
line-height: 1.35em;
}
/* FORM */
.contact-form {

View File

@ -0,0 +1,71 @@
/* Shamelessly stolen from elliottkember.com, which in turn was shamelessly stolen from maxvoltar.com, which in turn was shamelessly stolen from chatrboxapp.com. */
::-webkit-scrollbar {
width: 6px;
height: 6px;
}
::-webkit-scrollbar-button:start:decrement,
::-webkit-scrollbar-button:end:increment {
display: block;
height: 4px;
}
::-webkit-scrollbar-button:vertical:increment {
background-color: #fff;
background: transparent;
}
::-webkit-scrollbar-track {
-webkit-border-radius: 3px;
}
::-webkit-scrollbar-track-piece {
-webkit-border-radius: 3px;
}
::-webkit-scrollbar-thumb:vertical {
height: 50px;
background-color: #666;
opacity: 0.5;
-webkit-border-radius: 3px;
position: relative;
}
::-webkit-scrollbar-thumb:horizontal {
width: 50px;
background-color: #999;
-webkit-border-radius: 3px;
}
::-webkit-scrollbar-thumb:vertical:hover {
background-color: #999;
}
::-webkit-scrollbar-thumb:vertical:active, ::-webkit-scrollbar-thumb:vertical:focus{
background-color: #ddd;
}
html {
/*overflow-y: scroll;*/
overflow: auto;
/*width: 100% !important;*/
}
/* @group default */
#wrapper {
margin: 0 auto;
}
html {
overflow-x: hidden;
}
#turn_wrapper {
left: 10px !important;
}