Skip to content
Browse files

Admin site

  • Loading branch information...
1 parent eaaa4cd commit 501b49caf4615b5926892f5c58fa0f050e63fe53 faithfulgeek committed Mar 13, 2009
View
36 app/controllers/locations_controller.rb
@@ -1,20 +1,24 @@
class LocationsController < ResourceController::Base
- new_action.wants.html do
- for_admin_only do
- render :html => @location
- end
- end
+ new_action.wants.html do
+ for_admin_only do
+ render :html => @location
+ end
+ end
- show.wants.html do
- @map = GMap.new("map_div")
- @map.control_init(:large_map => true)
- @map.center_zoom_init([@location.latitude, @location.longitude],13)
- @map.overlay_init(GMarker.new([@location.latitude, @location.longitude],:title => @location.name, :info_window => @location.name))
- @gmaps_needed = true
- end
-
- def object
- @location ||= Location.find_by_permalink params[:id]
- end
+ show.wants.html do
+ @map = GMap.new("map_div")
+ @map.control_init(:large_map => true)
+ @map.center_zoom_init([@location.latitude, @location.longitude],13)
+ @map.overlay_init(GMarker.new([@location.latitude, @location.longitude],:title => @location.name, :info_window => @location.name))
+ @gmaps_needed = true
+ end
+
+ def object
+ if params[:action] == "new"
+ @location ||= Location.new
+ else
+ @location ||= Location.find_by_permalink params[:id]
+ end
+ end
end
View
2 app/controllers/posts_controller.rb
@@ -78,7 +78,7 @@ def layout_for_user
when :admin
"admin"
else
- "posts"
+ "application"
end
end
end
View
26 app/helpers/posts_helper.rb
@@ -1,13 +1,17 @@
module PostsHelper
- def textilize(value)
- value = value.body if value.respond_to?(:body)
- RedCloth.new(value, [:filter_html, :filter_styles]).to_html
- end
-
- def tags_for(post)
- tags = post.tag_list.map do |t|
- link_to t, tag_url(t)
- end
- tags.join " &ndash; "
- end
+ def textilize(value)
+ value = value.body if value.respond_to?(:body)
+ RedCloth.new(value, [:filter_html, :filter_styles]).to_html
+ end
+
+ def tags_for(post)
+ tags = post.tag_list.map do |t|
+ link_to t, tag_url(t)
+ end
+ tags.join " &ndash; "
+ end
+
+ def locations_for_select_list
+ Location.all.map { |location| [location.name, location.id] }
+ end
end
View
3 app/models/event.rb
@@ -2,5 +2,4 @@ class Event < Post
belongs_to :location
validates_presence_of :start_time
validates_presence_of :location
- named_scope :old, :conditions => ['start_time < ?', DateTime.now]
-end
+end
View
4 app/models/post.rb
@@ -1,11 +1,15 @@
class Post < ActiveRecord::Base
belongs_to :author, :class_name => 'User'
+ belongs_to :location
has_permalink :title, :override_to_param => true
acts_as_commentable :order => 'created_at desc', :conditions => "is_spam = 'f'"
acts_as_taggable
named_scope :sticky, :conditions => {:sticky => true}, :order => 'start_time desc'
named_scope :not_sticky, :conditions => {:sticky => false}
+ named_scope :old, :conditions => ['start_time < ?', DateTime.now]
named_scope :published#not respecting draft status yet, :conditions => {:is_published => true, :is_published => false, :is_published => nil}
+ validates_presence_of :start_time, :if => Proc.new { |post| post.post_type == "event" }
+ validates_presence_of :location, :if => Proc.new { |post| post.post_type == "event" }
def self.posts_per_date
published.to_set.classify { |post| post.created_at.to_date }
View
1 app/views/admin/posts/_creation_tools.html.haml
@@ -1,5 +1,4 @@
#creation-tools
%p
=link_to "add new article", new_post_path, :class => "icon add-new-post", :title => "add new article"
- =link_to "add new event", new_event_path, :class => "icon add-new-event", :title => "add new event"
=link_to "add new location", new_location_path, :class => "icon add-new-location", :title => "add new location"
View
2 app/views/admin/posts/index.html.haml
@@ -12,5 +12,3 @@
= link_to '[delete]', post_url(post), :method => :delete, :confirm => "Are you sure you want to delete this post?", :class => "icon delete", :title => 'Delete'
.title= link_to post.title, post_url(post)
= render :partial => 'admin/posts/creation_tools'
-
-
View
1 app/views/layouts/admin.html.haml
@@ -18,7 +18,6 @@
%ul
%li= link_to 'overview', '/'
%li= link_to 'posts', posts_path
- %li= link_to 'events', events_path
- if User.current_user
#welcome_message
%em= User.current_user.name
View
2 app/views/locations/new.html.haml
@@ -4,4 +4,4 @@
= f.field :city
= f.field :state
= f.field :zip_code
- = f.submit
+ = f.submit
View
4 app/views/posts/edit.html.haml
@@ -1,8 +1,8 @@
-%h2
+%h1
Editing Post
= @post.title
-= render_partial 'new'
+= render :partial => 'form'
= link_to 'Show', @post
|
View
1 config/environment.rb
@@ -61,7 +61,6 @@
config.gem 'haml'
config.gem 'ruby-openid'
- config.gem 'RedCloth'
end
require "#{File.expand_path(RAILS_ROOT)}/lib/string"
View
11 db/migrate/20090201015513_rename_type_column_to_post_type.rb
@@ -0,0 +1,11 @@
+class RenameTypeColumnToPostType < ActiveRecord::Migration
+ def self.up
+ remove_column :posts, :type
+ add_column :posts, :post_type, :string
+ end
+
+ def self.down
+ remove_column :posts, :post_type
+ add_column :posts, :type, :string
+ end
+end

0 comments on commit 501b49c

Please sign in to comment.
Something went wrong with that request. Please try again.