Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
Categories can now be blog, podcast or calendar categories…or all of …
Browse files Browse the repository at this point in the history
…them together
  • Loading branch information
bitboxer committed Nov 18, 2012
1 parent 1d19575 commit 779713a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 9 deletions.
14 changes: 13 additions & 1 deletion app/admin/category.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# encoding: utf-8
ActiveAdmin.register Category do
menu priority: 8
config.sort_order = "title_asc"

index do
column :id
column :title do |p|
Expand All @@ -9,7 +11,17 @@
column :color do |p|
span p.color, style: "color: #{p.color}"
end
column :podcast_category
column :blog_category do |p|
p.blog_category ? "✓" : "-"
end
column :calendar_category do |p|
p.calendar_category ? "✓" : "-"
end
column :podcast_category do |p|
p.podcast_category ? "✓" : "-"
end
default_actions
end


end
2 changes: 1 addition & 1 deletion app/models/category.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Category < ActiveRecord::Base

scope :calendar, where(podcast_category: false)
scope :calendar, where(calendar_category: true)

has_many :blog_posts

Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/blog_posts/_post_form.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= semantic_form_for [:admin, @blog_post] do |f|
= f.inputs "Details" do
= f.input :category
= f.input :category, collection: Category.where(blog_category: true).order("title")
= f.input :user, collection: User.where(admin: true)
= f.input :headline
= f.input :publishable_from
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/events/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
= form.input :description, input_html: { class: 'autogrow preview-base', rows: 10 }, wrapper_html: { class: 'previewable' }
= form.input :venue
= form.input :venue_info
= form.input :category
= form.input :category, collection: Category.where(calendar_category: true).order("title")
= form.input :picture
= form.input :url
= form.input :twitter
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/single_events/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
Ort der Veranstaltungsreihe:
= @single_event.event.venue.location
= form.input :venue_info, placeholder: @single_event.event.venue_info
= form.input :category
= form.input :category, collection: Category.where(calendar_category: true).order("title")
= form.input :picture
%li
%label.label &nbsp;
Expand Down
6 changes: 6 additions & 0 deletions db/migrate/20121118100252_add_more_settings_to_categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddMoreSettingsToCategories < ActiveRecord::Migration
def change
add_column :categories, :blog_category, :boolean, default: true
add_column :categories, :calendar_category, :boolean, default: true
end
end
10 changes: 6 additions & 4 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20121101081556) do
ActiveRecord::Schema.define(:version => 20121118100252) do

create_table "active_admin_comments", :force => true do |t|
t.string "resource_id", :null => false
Expand Down Expand Up @@ -111,9 +111,11 @@
create_table "categories", :force => true do |t|
t.string "title"
t.string "color"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "podcast_category", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "podcast_category", :default => false
t.boolean "blog_category", :default => true
t.boolean "calendar_category", :default => true
end

create_table "comments", :force => true do |t|
Expand Down

0 comments on commit 779713a

Please sign in to comment.