Merge remote-tracking branch 'origin/forum' into forum
This commit is contained in:
commit
bc76ed2f4b
|
@ -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'
|
||||
|
|
|
@ -25,6 +25,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)
|
||||
|
@ -33,11 +34,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 }
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!-- added by fq -->
|
||||
<!-- %= form_for(@forum) do |f| % -->
|
||||
<%= labelled_form_for(@forum) do |f| %>
|
||||
<% if @forum.errors.any? %>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<!-- added by fq -->
|
||||
<div style="padding-top: 10px">
|
||||
<% if forums.any? %>
|
||||
<% forums.each do |forum| %>
|
||||
<table class="content-text-list">
|
||||
<tr>
|
||||
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator) %></td>
|
||||
<td>
|
||||
<table width="650px" border="0">
|
||||
<tr>
|
||||
<td valign="top" width="500px"><%= link_to h(forum.name), forum_path(forum) %></td>
|
||||
<td align="right" rowspan="3">
|
||||
<table class="borad-count">
|
||||
<tr>
|
||||
<td align="center" class="borad-count-digit"><%= link_to (forum.topic_count), forum_path(forum) %></td>
|
||||
<td align="center" class="borad-count-digit"><%= link_to (forum.memo_count), forum_path(forum) %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">帖子</td>
|
||||
<td align="center">回答</td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" ><span class="font_description"><%= forum.description%></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" ><span class="font_description">标签~~~~~~~~~~</span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left" colspan="2" ><span class="font_lighter"><%= authoring forum.created_at, forum.creator %>
|
||||
<br />
|
||||
</span></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
</table>
|
||||
<% end %>
|
||||
<div class="pagination"><%= pagination_links_full @forums_pages, @forums_count %></div>
|
||||
<% else %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -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 %>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!-- added by fq -->
|
||||
<h1>Editing forum</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!-- added by fq -->
|
||||
<h1>New forum</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!-- added by fq -->
|
||||
<p id="notice">
|
||||
<%= notice %>
|
||||
</p>
|
||||
|
|
Loading…
Reference in New Issue