Commit 516e1baf authored by 神楽坂玲奈's avatar 神楽坂玲奈

发帖禁止空内容

parent 0de03d13
......@@ -45,7 +45,7 @@ class PostsController < ApplicationController
def edit
@post = Post.find(params[:id])
@post.attachments.build
@actions = [@post, :edit]
@actions = [@post, "发表回复"]
end
# POST /posts
......@@ -58,6 +58,8 @@ class PostsController < ApplicationController
end
@post.user = @current_user
@post.displayorder = @post.topic.floor
@post.attachments.build
@actions = [@post, "发表回复"]
respond_to do |format|
if @post.save
format.html { redirect_to(@post.topic, :notice => 'Post was successfully created.') }
......@@ -73,7 +75,8 @@ class PostsController < ApplicationController
# PUT /posts/1.xml
def update
@post = Post.find(params[:id])
@post.attachments.build
@actions = [@post, "编辑帖子"]
respond_to do |format|
if @post.update_attributes(params[:post])
format.html { redirect_to(@post.topic, :notice => 'Post was successfully updated.') }
......
class TopicsController < ApplicationController
# ApplicationHelper::addon_header.push "zh_header"
# ApplicationHelper::addon_top.push "zh_top"
# ApplicationHelper::addon_footer.push "zh_footer"
# ApplicationHelper::addon_header.push "zh_header"
# ApplicationHelper::addon_top.push "zh_top"
# ApplicationHelper::addon_footer.push "zh_footer"
=begin
查看主题: GET /topic/1
......@@ -63,13 +63,11 @@ class TopicsController < ApplicationController
# GET /forum/id/new
# GET /forum/id/new.xml
def new
#@topic = Topic.new
if params[:board_id].blank? || (@board = Board.find params[:board_id]).nil?
return render( :text => :board_not_exist )
end
#p @board
#p '---------------------------------------------'
@actions = [:new_topic]
@topic = Topic.new
@post = Post.new(topic: @topic)
@post.attachments.build
@actions = [@topic.category, @topic, "发表主题"]
@actions = ["发表主题"]
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @topic }
......@@ -79,24 +77,20 @@ class TopicsController < ApplicationController
# GET /topics/1/edit
def edit
@topic = Topic.find(params[:id])
@post = @topic.posts.first
@post.attachments.build
@actions = [@topic.category, @topic, "编辑"]
end
# POST /board/id
# POST /board/id.xml
def create
#TODO: 验证category_id有效性
@topic = Topic.new(params[:topic])
#@topic.category_id = Board.find(params[:topic][:category_id])
@topic.user = @current_user
@topic.displayorder = 0
@topic.posts.first.displayorder = 1
@topic.posts.first.user = @current_user
#@post = Post.new(params[:post])
#@post.displayorder = 1
#@post.topic = @topic
#@post.user = @current_user
@actions = [@topic.category, @topic, "发表主题"]
respond_to do |format|
if @topic.save
format.html { redirect_to(@topic, :notice => 'Topic was successfully created.') }
......@@ -112,7 +106,9 @@ class TopicsController < ApplicationController
# PUT /topics/1.xml
def update
@topic = Topic.find(params[:id])
@post = @topic.posts.first
@post.attachments.build
@actions = [@topic.category, @topic, "编辑"]
respond_to do |format|
if @topic.update_attributes(params[:topic])
format.html { redirect_to(@topic, :notice => 'Topic was successfully updated.') }
......
......@@ -52,6 +52,7 @@
<%= f.label :html %><br />
<%= f.check_box :html %>
</div>-->
<div class="field">
<%= f.label "附件" %><br />
<%= f.fields_for :attachments do |attachment_form| %>
<div class="asset field">
......@@ -62,6 +63,7 @@
<% end %>
</div>
<% end %>
</div>
<div class="actions">
<%= f.submit %>
</div>
......
<%= form_tag :controller => :posts do %>
<p>
<%= @topic %>
</p>
<p>
<%= render 'topics/editor' %>
</p>
<%= hidden_field_tag "post[topic_id]", @topic.id %>
<%= submit_tag t("topic.submit") %>
<% end %>
\ No newline at end of file
<h1>发表回复</h1>
<%= render 'form' %>
<%= link_to 'Back', posts_path %>
......@@ -13,28 +13,44 @@
<div class="field">
<%= f.label :board %><br />
<%= f.select :category_id, Board.all.collect{|board|[board.name, board.id]} %>
<!--<%= f.select :category_id, Board.all.collect{|board|[board.name, board.id]} %>-->
<%= f.hidden :category_id %>
</div>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :displayorder %><br />
<%= f.text_field :displayorder %>
</div>
<%= f.fields_for :posts, @post do |post_fields| %>
<%= post_fields.text_area :content, :id => :fastpostmessage %>
<div class="field">
<%= post_fields.label "附件" %><br />
<%= post_fields.fields_for :attachments do |attachment_form| %>
<div class="asset field">
<% if attachment_form.object.data.exists? %>
<%= attachment_form.object.data.original_filename %>
<% else %>
<%= attachment_form.file_field :data %>
<% end %>
</div>
<% end %>
</div>
<% end %>
<script type="text/javascript">
$(document).ready(function() {
$('#fastpostmessage').markItUp(mySettings);
});
</script>
</div>
<!--<div class="field">
<%= f.label :readperm %><br />
<%= f.text_field :readperm %>
</div>
<div class="field">
<%= f.label :reverse %><br />
<%= f.check_box :reverse %>
</div>
<div class="field">
<%= f.label :private %><br />
<%= f.check_box :private %>
</div>
</div>-->
<%= f.hidden_field :displayorder %>
<%= f.hidden_field :category_type %>
<div class="actions">
<%= f.submit %>
......
......@@ -133,6 +133,10 @@ zh-CN:
create: 提交
submit: 提交
update: 提交
#label:
# topic:
# posts:
# content: "正文"
number:
currency:
format:
......@@ -202,6 +206,7 @@ zh-CN:
models:
user: "用户"
topic: "主题"
post: "帖子"
attributes:
pm:
to_user: "收件人"
......@@ -262,7 +267,8 @@ zh-CN:
index: "论坛"
topic:
name: "标题"
posts: "帖子"
#post:
# content: "正文"
post:
attachments: "附件"
content: "正文"
......
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