Skip to content

Commit

Permalink
[codeforamerica#18] Formatting Admin panels, remove commented out sec…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
Philip Hale committed Sep 1, 2013
1 parent 4cdafe0 commit bff4d7e
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 104 deletions.
11 changes: 2 additions & 9 deletions app/admin/categories.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
ActiveAdmin.register Category do
# This will authorize the Foobar class
# The authorization is done using the AdminAbility class
controller.authorize_resource

# View
index do
#column :id
column :name, :sortable => :name
column "Created", :created_at
column "Updated", :updated_at
column "Description", :description
#column "Slug", :slug
default_actions # Add show, edit, delete column
end

show do

attributes_table do
row :name
row :access_count
Expand All @@ -25,7 +21,6 @@

div do
panel("Articles with this category") do

table_for(category.articles) do
column "" do |article|
if article.is_a? QuickAnswer
Expand All @@ -36,10 +31,11 @@
link_to( "Edit", admin_guide_path(article))
end
end

column "" do |article|
if article.status=="Published"
link_to "View", article
else
else
"Draft"
end
end
Expand All @@ -50,10 +46,7 @@
column :user
column :status
end

end #panel
end #div

end #show

end
13 changes: 2 additions & 11 deletions app/admin/contacts.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
ActiveAdmin.register Contact do
# This will authorize the Foobar class
# The authorization is done using the AdminAbility class
controller.authorize_resource
controller.authorize_resource


# View
# View
index do
#column :id
column "Name", :name
column :department
column :url
column "Created", :created_at
# column :tags
default_actions # Add show, edit, delete column
end

show :title => proc { contact.name } do
end

show do |contact|

attributes_table do
row :name
row :subname
Expand All @@ -32,7 +27,6 @@

div do
panel("Articles with this contact") do

table_for(contact.articles) do
column "" do |article|
if article.is_a? QuickAnswer
Expand All @@ -57,10 +51,7 @@
column :user
column :status
end

end
end

end

end
43 changes: 0 additions & 43 deletions app/admin/dashboards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,7 @@
column "User", :email do |user|
link_to user.email, [:admin, user]
end
#column "Moderator", :is_moderator
end
strong { link_to "View All Users", admin_users_path }
end

# Define your dashboard sections here. Each block will be
# rendered on the dashboard in the context of the view. So just
# return the content which you would like to display.

# == Simple Dashboard Section
# Here is an example of a simple dashboard section
#
# section "Recent Posts" do
# ul do
# Post.recent(5).collect do |post|
# li link_to(post.title, admin_post_path(post))
# end
# end
# end

# == Render Partial Section
# The block is rendered within the context of the view, so you can
# easily render a partial rather than build content in ruby.
#
# section "Recent Posts" do
# div do
# render 'recent_posts' # => this will render /app/views/admin/dashboard/_recent_posts.html.erb
# end
# end

# == Section Ordering
# The dashboard sections are ordered by a given priority from top left to
# bottom right. The default priority is 10. By giving a section numerically lower
# priority it will be sorted higher. For example:
#
# section "Recent Posts", :priority => 10
# section "Recent User", :priority => 1
#
# Will render the "Recent Users" then the "Recent Posts" sections on the dashboard.

# == Conditionally Display
# Provide a method name or Proc object to conditionally render a section at run time.
#
# section "Membership Summary", :if => :memberships_enabled?
# section "Membership Summary", :if => Proc.new { current_admin_user.account.memberships.any? }

end
6 changes: 3 additions & 3 deletions app/admin/guide_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# as per https://github.com/gregbell/active_admin/wiki/Enforce-CanCan-constraints
controller do
load_and_authorize_resource :except => :index
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
end

menu :parent => "Articles"
Expand Down
20 changes: 6 additions & 14 deletions app/admin/guides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,21 @@
# as per https://github.com/gregbell/active_admin/wiki/Enforce-CanCan-constraints
controller do
load_and_authorize_resource :except => :index
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
end

# Add to :parent Dropdown menu
menu :parent => "Articles"
# menu :priority => 3
# Initialize tinymce
# tinymce_assets
# tinymce


# Filterable attributes
filter :title
filter :tags
filter :contact_id
filter :status

# View
index do
#column :id
column "Guide Title", :title do |guide|
link_to guide.title, [:admin, guide]
end
Expand All @@ -36,14 +30,12 @@ def scoped_collection
(article.user.try(:email) || "")
end
end
# column :tags
column :slug
column "Status", :status
default_actions # Add show, edit, delete column
end

form :partial => "shared/admin/article_form"

form :partial => "shared/admin/article_form"

show do |guide|
attributes_table do
Expand Down
17 changes: 7 additions & 10 deletions app/admin/quick_answers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,35 @@
# as per https://github.com/gregbell/active_admin/wiki/Enforce-CanCan-constraints
controller do
load_and_authorize_resource :except => :index
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
end

# Add to :parent Dropdown menu
menu :parent => "Articles"
# menu :priority => 2


# Filterable attributes
filter :title
filter :tags
filter :contact_id
filter :status

# View
index do
#column :id
column "Quick Answer Title", :title do |article|
link_to article.title, [:admin, article]
end
column :category
column :contact
column "Created", :created_at
column "Author", :user do |article|
if(article.user.try(:department))
if article.user.try(:department)
(article.user.try(:email) || "") + ", " + (article.user.try(:department).name || "")
else
(article.user.try(:email) || "")
article.user.try(:email) || ""
end
end
# column :tags
column :slug
column "Status", :status
default_actions # Add show, edit, delete column
Expand Down
8 changes: 2 additions & 6 deletions app/admin/users.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
ActiveAdmin.register User do

menu :if => proc{ current_user.is_admin? || current_user.is_editor? }, :label => 'Users'

# This will authorize the Foobar class
# The authorization is done using the AdminAbility class
controller.authorize_resource

index do # Display only specific article db columns
#column :id
index do
column :email
column :is_admin
column :is_editor
Expand All @@ -16,7 +13,7 @@
default_actions # View/Edit/Delete column
end

form do |f| # create/edit user form
form do |f|
f.inputs "User Details" do
f.input :email
f.input :password
Expand Down Expand Up @@ -48,5 +45,4 @@
member_action :create, :method => :post, &create_or_edit
member_action :update, :method => :put, &create_or_edit


end
12 changes: 4 additions & 8 deletions app/admin/web_services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# as per https://github.com/gregbell/active_admin/wiki/Enforce-CanCan-constraints
controller do
load_and_authorize_resource :except => :index
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
def scoped_collection
end_of_association_chain.accessible_by(current_ability)
end
end

# Add to :parent Dropdown menu
Expand All @@ -18,7 +18,6 @@ def scoped_collection

# View
index do
#column :id
column "Web Service Title", :title do |article|
link_to article.title, [:admin, article]
end
Expand All @@ -32,13 +31,10 @@ def scoped_collection
(article.user.try(:email) || "")
end
end
# column :tags
column :slug
column "Status", :status
default_actions # Add show, edit, delete column
end

form :partial => "shared/admin/article_form"


form :partial => "shared/admin/article_form"
end

0 comments on commit bff4d7e

Please sign in to comment.