不好说啊,赶紧结束吧~~~~~~~~~~~~~

This commit is contained in:
fanqiang 2013-11-24 20:02:53 +08:00
parent c6f4dbbafa
commit d77fed5d34
9 changed files with 58 additions and 9 deletions

View File

@ -1,10 +1,18 @@
# added by fq
class ForumsController < ApplicationController
# GET /forums
# GET /forums.json
layout "base_admin"
def index
@forums = Forum.all
@offset, @limit = api_offset_and_limit({:limit => 10})
@forums_all = Forum.all
@forums_count = @forums_all.count
@forums_pages = Paginator.new @forums_count, @limit, params['page']
@offset ||= @forums_pages.offset
# @forums = @forums_all.offset(@offset).limit(@limit).all
@forums = Forum.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @forums }
@ -14,9 +22,14 @@ class ForumsController < ApplicationController
# GET /forums/1
# GET /forums/1.json
def show
@offset, @limit = api_offset_and_limit({:limit => 10})
@forum = Forum.find(params[:id])
@memos = @forum.topics
@memos_all = @forum.topics
@topic_count = @memos_all.count
@topic_pages = Paginator.new @topic_count, @limit, params['page']
@offset ||= @topic_pages.offset
@memos = @memos_all.offset(@offset).limit(@limit).all
respond_to do |format|
format.html {
render :layout => 'base_forums'

View File

@ -24,6 +24,7 @@ class MemosController < ApplicationController
@memo = Memo.new(params[:memo])
@memo.forum_id = params[:forum_id]
@memo.author_id = User.current.id
@forum = Forum.find(params[:forum_id])
if @memo.parent_id
@parent_memo = Memo.find_by_id(@memo.parent_id)
@ -32,11 +33,16 @@ class MemosController < ApplicationController
respond_to do |format|
if @memo.save
@forum.memo_count += 1
@forum.last_memo_id = @memo.id
@back_memo_id = (@memo.parent_id.nil? ? @memo.id : @memo.parent_id)
if @parent_memo
@parent_memo.last_reply_id = @memo.id
@parent_memo.save
else
@forum.topic_count += 1
end
@forum.save
format.html { redirect_to forum_memo_path(@memo.forum_id, @back_memo_id), notice: 'Memo was successfully created.' }
format.json { render json: @memo, status: :created, location: @memo }

View File

@ -1,6 +1,6 @@
class Forum < ActiveRecord::Base
include Redmine::SafeAttributes
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL"
has_many :topics, :class_name => 'Memo', :conditions => "#{Memo.table_name}.parent_id IS NULL", :order => "#{Memo.table_name}.created_at DESC"
has_many :memos, :dependent => :destroy
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
safe_attributes 'name',

View File

@ -1,3 +1,4 @@
<!-- added by fq -->
<!-- %= form_for(@forum) do |f| % -->
<%= labelled_form_for(@forum) do |f| %>
<% if @forum.errors.any? %>

View File

@ -1,3 +1,4 @@
<!-- added by fq -->
<!--display the board-->
<div class="borad-title"><%=h @forum.name %></div>
<div class="borad-topic-count">共有 <%=link_to memos.count %> 个贴子</div>
@ -7,7 +8,7 @@
<table class="content-text-list">
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %></td>
<td>
<table width="650px" border="0">
<table width="630px" border="0">
<tr>
<td valign="top" width="500px"><%= link_to h(topic.subject), forum_memo_path(@forum, topic) %></td>
<td align="right" rowspan="3">
@ -32,6 +33,7 @@
</tr>
</table>
<% end %>
<div class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></div>
<% else %>
<p class="nodata"><%= l(:label_no_data) %></p>
<% end %>

View File

@ -1,3 +1,4 @@
<!-- added by fq -->
<h1>Editing forum</h1>
<%= render 'form' %>

View File

@ -1,4 +1,29 @@
<h1>Listing forums</h1>
<!-- added by fq -->
<div class="top-content">
<table width="940px">
<tr>
<td class="info_font" style="width: 220px; color: #15bccf"">讨论区 </td>
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
<td rowspan="2">
<% if User.current.logged? %>
<%= link_to("新建讨论区", new_forum_path, :class => 'icon icon-add') %>
<% end %>
</td>
<td rowspan="2" >
<!-- 搜索 -->
</td>
</tr>
<tr>
<td style="padding-left: 8px"><a><%= link_to "forge.trustie.net/forums", forums_path %> </a></td>
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to "讨论区", forums_path %></td>
</tr>
</table>
</div>
<%= render :partial => 'forums/forum_list', :locals => {:forums => @forums} %>
<!-- <h1>Listing forums</h1>
<table>
<tr>
@ -22,6 +47,5 @@
<% end %>
</table>
<br />
<br /> -->
<%= link_to 'New Forum', new_forum_path %>

View File

@ -1,3 +1,4 @@
<!-- added by fq -->
<h1>New forum</h1>
<%= render 'form' %>

View File

@ -1,3 +1,4 @@
<!-- added by fq -->
<p id="notice">
<%= notice %>
</p>