* Refactored PostSet, splitting it into PostSets::Post and PostSets::Favorite

* Additional functional tests
This commit is contained in:
albert
2010-12-01 17:21:05 -05:00
parent f8ab736677
commit 39dd2e277a
20 changed files with 342 additions and 198 deletions

View File

@@ -1,4 +1,6 @@
class AdvertisementsController < ApplicationController
before_filter :advertiser_only
def new
@advertisement = Advertisement.new(
:ad_type => "vertical",
@@ -12,18 +14,8 @@ class AdvertisementsController < ApplicationController
def index
@advertisements = Advertisement.all
if params[:start_date]
@start_date = Date.parse(params[:start_date])
else
@start_date = 1.month.ago.to_date
end
if params[:end_date]
@end_date = Date.parse(params[:end_date])
else
@end_date = Date.today
end
@start_date = 1.month.ago.to_date
@end_date = Date.today
end
def show
@@ -55,4 +47,12 @@ class AdvertisementsController < ApplicationController
@advertisement.destroy
redirect_to advertisements_path, :notice => "Advertisement destroyed"
end
private
def advertiser_only
if !Danbooru.config.is_user_advertiser?(CurrentUser.user)
redirect_to "/static/access_denied"
return false
end
end
end

View File

@@ -2,8 +2,8 @@ class ArtistVersionsController < ApplicationController
respond_to :html, :xml, :json
def index
@search = Artist.search(params[:search])
@artist_versions = @search.paginate :order => "version desc", :per_page => 25, :page => params[:page]
@search = ArtistVersion.search(params[:search])
@artist_versions = @search.paginate :order => "id desc", :per_page => 25, :page => params[:page]
respond_with(@artist_versions)
end
end

View File

@@ -1,6 +1,10 @@
class FavoritesController < ApplicationController
def index
@posts = CurrentUser.favorite_posts(params)
if params[:tags]
redirect_to(posts_path(:tags => "fav:#{CurrentUser.name} #{params[:tags]}"))
else
@posts = PostSets::Favorite.new(CurrentUser.user)
end
end
def create

View File

@@ -4,7 +4,7 @@ class PostsController < ApplicationController
respond_to :html, :xml, :json
def index
@post_set = PostSet.new(params[:tags], params[:page], params[:before_id])
@post_set = PostSets::Post.new(params[:tags], :page => params[:page], :before_id => params[:before_id])
respond_with(@post_set)
end