Commit 4f8d7508 authored by 神楽坂玲奈's avatar 神楽坂玲奈

主题管理还啥都没做..

git-svn-id: http://glupx.googlecode.com/svn/trunk/Reliz@30 189f022a-1064-8ae2-3e6f-c4a67275c50b
parent fed50747
class ModerationsController < ApplicationController
# GET /moderations
# GET /moderations.xml
def index
@moderations = Moderation.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @moderations }
end
end
# GET /moderations/1
# GET /moderations/1.xml
def show
@moderation = Moderation.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @moderation }
end
end
# GET /moderations/new
# GET /moderations/new.xml
def new
@moderation = Moderation.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @moderation }
end
end
# GET /moderations/1/edit
def edit
@moderation = Moderation.find(params[:id])
end
# POST /moderations
# POST /moderations.xml
def create
@moderation = Moderation.new(params[:moderation])
@moderation.user = @correct_user
case params[:moderation][:assocation_type]
when "topic"
#@moderation.association_ = Topic.find params[:moderation][:assocation_id]
case params[:moderation][:action]
when "lock"
@moderation.association.locked = true
end
when "post"
@moderation.association = Post.find params[:moderation][:topic_id]
when "user"
@moderation.association = Post.find params[:moderation][:user_id]
end
respond_to do |format|
if @moderation.save && @moderation.association.save
format.html { redirect_to(@moderation, :notice => 'Moderation was successfully created.') }
format.xml { render :xml => @moderation, :status => :created, :location => @moderation }
else
format.html { render :action => "new" }
format.xml { render :xml => @moderation.errors, :status => :unprocessable_entity }
end
end
end
# PUT /moderations/1
# PUT /moderations/1.xml
def update
@moderation = Moderation.find(params[:id])
respond_to do |format|
if @moderation.update_attributes(params[:moderation])
format.html { redirect_to(@moderation, :notice => 'Moderation was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @moderation.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /moderations/1
# DELETE /moderations/1.xml
def destroy
@moderation = Moderation.find(params[:id])
@moderation.destroy
respond_to do |format|
format.html { redirect_to(moderations_url) }
format.xml { head :ok }
end
end
end
module ModerationsHelper
end
class Moderation < ActiveRecord::Base
belongs_to :user
belongs_to :association, :polymorphic => true
end
<% form_tag :controller => :moderations do %>
<%= text_field_tag "moderation[association_id]" %>
<%= text_field_tag "moderation[association_type]" %>
<%= text_field_tag "moderation[action]" %>
<%= submit_tag "do" %>
<% end %>
\ No newline at end of file
<h1>Editing moderation</h1>
<%= render 'form' %>
<%= link_to 'Show', @moderation %> |
<%= link_to 'Back', moderations_path %>
<h1>Listing moderations</h1>
<table>
<tr>
<th>User</th>
<th>Target</th>
<th>Action</th>
<th>Note</th>
<th></th>
<th></th>
<th></th>
</tr>
<% @moderations.each do |moderation| %>
<tr>
<td><%= moderation.user %></td>
<td><%= moderation.target %></td>
<td><%= moderation.action %></td>
<td><%= moderation.note %></td>
<td><%= link_to 'Show', moderation %></td>
<td><%= link_to 'Edit', edit_moderation_path(moderation) %></td>
<td><%= link_to 'Destroy', moderation, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Moderation', new_moderation_path %>
<h1>New moderation</h1>
<%= render 'form' %>
<%= link_to 'Back', moderations_path %>
<p id="notice"><%= notice %></p>
<p>
<b>User:</b>
<%= @moderation.user %>
</p>
<p>
<b>Target:</b>
<%= @moderation.target %>
</p>
<p>
<b>Action:</b>
<%= @moderation.action %>
</p>
<p>
<b>Note:</b>
<%= @moderation.note %>
</p>
<%= link_to 'Edit', edit_moderation_path(@moderation) %> |
<%= link_to 'Back', moderations_path %>
Reliz::Application.routes.draw do
resources :moderations
resources :boards
root :to => 'boards#index'
......
class CreateModerations < ActiveRecord::Migration
def self.up
create_table :moderations do |t|
t.references :user
t.references :association, :polymorphic => true
t.string :action
t.string :note
t.timestamps
end
end
def self.down
drop_table :moderations
end
end
......@@ -10,51 +10,208 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20101226072024) do
# Could not dump table "boards" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "boards_copy" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "comments" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "comments_copy" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "notices" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "notices_copy" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "pms" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "pms_copy" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "posts" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "posts_copy" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "schema_migrations_copy" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "topics" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "topics_copy" because of following ActiveRecord::StatementInvalid
# Mysql2::Error: Can't create/write to file 'C:\WINDOWS\TEMP\#sql_618_0.MYI' (Errcode: 13): describe `topics_copy`
# Could not dump table "users" because of following Mysql2::Error
# Invalid date: BTREE
# Could not dump table "users_copy" because of following Mysql2::Error
# Invalid date: BTREE
ActiveRecord::Schema.define(:version => 20101226125042) do
create_table "boards", :force => true do |t|
t.string "name"
t.text "introduction"
t.text "notice"
t.string "logo"
t.string "banner"
t.integer "readperm"
t.integer "topicperm"
t.integer "postperm"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "boards_copy", :force => true do |t|
t.integer "super_id"
t.string "name"
t.text "introduction"
t.text "notice"
t.string "logo"
t.string "banner"
t.integer "readperm"
t.integer "topicperm"
t.integer "postperm"
end
create_table "comments", :force => true do |t|
t.integer "post_id"
t.integer "user_id"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "comments_copy", :force => true do |t|
t.integer "post_id"
t.integer "user_id"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "moderations", :force => true do |t|
t.integer "user_id"
t.integer "association_id"
t.string "association_type"
t.string "action"
t.string "note"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "notices", :force => true do |t|
t.integer "user_id"
t.string "type"
t.integer "assocaion_id"
t.string "assocaion_type"
t.integer "from_user_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "notices_copy", :force => true do |t|
t.integer "user_id"
t.string "type"
t.integer "assocaion_id"
t.string "assocaion_type"
t.integer "from_user_id"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "pms", :force => true do |t|
t.integer "user_id"
t.integer "from_user_id"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "pms_copy", :force => true do |t|
t.integer "user_id"
t.integer "from_user_id"
t.text "content"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "posts", :force => true do |t|
t.integer "topic_id"
t.integer "user_id"
t.text "content"
t.integer "displayorder"
t.integer "readperm"
t.boolean "private"
t.boolean "anonymous"
t.boolean "ubb"
t.boolean "html"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "posts_copy", :force => true do |t|
t.integer "topic_id"
t.integer "user_id"
t.text "content"
t.integer "displayorder"
t.integer "readperm"
t.boolean "private"
t.boolean "anonymous"
t.boolean "ubb"
t.boolean "html"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "schema_migrations_copy", :primary_key => "version", :force => true do |t|
end
add_index "schema_migrations_copy", ["version"], :name => "unique_schema_migrations", :unique => true
create_table "topics", :force => true do |t|
t.integer "user_id"
t.integer "type_id"
t.integer "category_id"
t.string "category_type"
t.string "name"
t.integer "displayorder"
t.integer "views"
t.integer "readperm"
t.boolean "locked"
t.boolean "reverse"
t.boolean "private"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "topics_copy", :force => true do |t|
t.integer "user_id"
t.integer "type_id"
t.integer "category_id"
t.string "category_type"
t.string "name"
t.integer "displayorder"
t.integer "views"
t.integer "readperm"
t.boolean "locked"
t.boolean "reverse"
t.boolean "private"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "users", :force => true do |t|
t.string "name"
t.string "nickname"
t.string "password"
t.string "email"
t.integer "usergroup_id"
t.integer "admingroup_id"
t.string "regip"
t.string "lastloginip"
t.integer "readnum"
t.integer "viewnum"
t.integer "onlinetime"
t.integer "credit"
t.integer "credit1"
t.integer "credit2"
t.integer "credit3"
t.integer "credit4"
t.integer "credit5"
t.integer "credit6"
t.integer "credit7"
t.integer "credit8"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "users_copy", :force => true do |t|
t.string "name"
t.string "nickname"
t.string "password"
t.string "email"
t.integer "usergroup_id"
t.integer "admingroup_id"
t.string "regip"
t.string "lastloginip"
t.integer "readnum"
t.integer "viewnum"
t.integer "onlinetime"
t.integer "credit"
t.integer "credit1"
t.integer "credit2"
t.integer "credit3"
t.integer "credit4"
t.integer "credit5"
t.integer "credit6"
t.integer "credit7"
t.integer "credit8"
t.datetime "created_at"
t.datetime "updated_at"
end
end
This diff is collapsed.
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
one:
user:
target:
action:
note: MyString
two:
user:
target:
action:
note: MyString
require 'test_helper'
class ModerationsControllerTest < ActionController::TestCase
setup do
@moderation = moderations(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:moderations)
end
test "should get new" do
get :new
assert_response :success
end
test "should create moderation" do
assert_difference('Moderation.count') do
post :create, :moderation => @moderation.attributes
end
assert_redirected_to moderation_path(assigns(:moderation))
end
test "should show moderation" do
get :show, :id => @moderation.to_param
assert_response :success
end
test "should get edit" do
get :edit, :id => @moderation.to_param
assert_response :success
end
test "should update moderation" do
put :update, :id => @moderation.to_param, :moderation => @moderation.attributes
assert_redirected_to moderation_path(assigns(:moderation))
end
test "should destroy moderation" do
assert_difference('Moderation.count', -1) do
delete :destroy, :id => @moderation.to_param
end
assert_redirected_to moderations_path
end
end
require 'test_helper'
class ModerationsHelperTest < ActionView::TestCase
end
require 'test_helper'
class ModerationTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
5124
\ No newline at end of file
4656
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment