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

发帖禁止空内容

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