scaffolds a tag list to mark tags as featured on the admin section

This commit is contained in:
David Gil
2015-08-15 18:22:29 +02:00
parent ae960bba9f
commit 0a4aafd8de
7 changed files with 60 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
class Admin::TagsController < Admin::BaseController
layout 'admin'
respond_to :html, :js
def index
@tags = ActsAsTaggableOn::Tag.order(featured: :desc)
end
def update
@tag = ActsAsTaggableOn::Tag.find(params[:id])
@tag.update(tag_params)
redirect_to admin_tags_path
end
private
def tag_params
params.require(:tag).permit(:featured)
end
end

View File

@@ -1,3 +1,3 @@
<div id="admin_menu">
Admin links
</div>
<%= link_to t('admin.tags.index.title'), admin_tags_path %>
</div>

View File

@@ -0,0 +1,18 @@
<div class="left">
<h1><%= t("admin.tags.index.title") %></h1>
<ul>
<% @tags.each do |tag| %>
<li>
<strong><%= tag.name %></strong>
<%= form_for(tag, url: admin_tag_path(tag), as: :tag) do |f| %>
<!-- <%= f.check_box :featured %> -->
<%= f.check_box :featured, label: false %>
<%= t("admin.tags.index.mark_as_featured") %>
<%= f.submit(class: "button radius tiny") %>
<% end %>
</li>
<% end %>
</ul>
</div>

View File

@@ -78,6 +78,8 @@ en:
comment_button: Publish comment
reply_link: Reply
reply_button: Publish reply
tags:
featured: Featured
votes:
agree: I agree
disagree: I disagree
@@ -117,3 +119,8 @@ en:
default: "You are not authorized to access this page."
manage:
all: "You are not authorized to %{action} %{subject}."
admin:
tags:
index:
title: 'Debate topics'
mark_as_featured: 'Mark as featured'

View File

@@ -78,6 +78,8 @@ es:
comment_button: Publicar comentario
reply_link: Responder
reply_button: Publicar respuesta
tags:
featured: Destacado
votes:
agree: Estoy de acuerdo
disagree: No estoy de acuerdo
@@ -129,3 +131,8 @@ es:
all: "No tienes permiso para borrar %{subject}"
manage:
all: "No tienes permiso para realizar la acción '%{action}' sobre %{subject}."
admin:
tags:
index:
title: 'Temas de debate'
mark_as_featured: 'Marcar como destacado'

View File

@@ -23,6 +23,8 @@ Rails.application.routes.draw do
namespace :admin do
root to: "dashboard#index"
resources :tags, only: [:index, :update]
end
namespace :moderation do

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150811161459) do
ActiveRecord::Schema.define(version: 20150815154430) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -79,6 +79,7 @@ ActiveRecord::Schema.define(version: 20150811161459) do
create_table "tags", force: :cascade do |t|
t.string "name"
t.integer "taggings_count", default: 0
t.boolean "featured", default: false
end
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree