1.增加帖子回复时间查询语句

2.帖子回复的数量在数据库中有字段
3.新建帖子失败错误提示
4.下载里程碑top_menu删掉,
5.学生分页,分页方法封装
This commit is contained in:
yanxd 2013-12-02 17:27:15 +08:00
parent b4fb17a467
commit 0609c5c7ea
12 changed files with 80 additions and 65 deletions

View File

@ -618,4 +618,23 @@ class ApplicationController < ActionController::Base
def _include_layout?(*args)
api_request? ? false : super
end
## Please added code in html.
# <div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
def paginateHelper obj, pre_size=20
# current_count = pre_size * (params['page'].to_i - 1) if params['page'].to_i > 0
offset, limit = api_offset_and_limit({:limit => pre_size})
objs_all = obj
@obj_count = objs_all.count
@obj_pages = Paginator.new @obj_count, limit, params['page']
offset ||= @obj_pages.offset
if obj.kind_of? ActiveRecord::Base or obj.kind_of? ActiveRecord::Relation
obj.offset(offset).limit(limit).all
elsif obj.kind_of? Array
obj[offset..(offset+limit-1)]
else
logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
nil
end
end
end

View File

@ -44,8 +44,9 @@ class MemosController < ApplicationController
format.html { redirect_to back_memo_url, notice: "#{l :label_memo_create_succ}" }
format.json { render json: @memo, status: :created, location: @memo }
else
flash[:error] = "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}"
# back_error_page = @memo.parent_id.nil? ? forum_path(@forum) : forum_memo_path(@forum, @memo.parent_id)
format.html { redirect_to back_memo_or_forum_url, notice: "#{l :label_memo_create_fail}" }
format.html { redirect_to back_memo_or_forum_url}#, error: "#{l :label_memo_create_fail}: #{@memo.errors.full_messages[0]}" }
format.json { render json: @memo.errors, status: :unprocessable_entity }
end
end

View File

@ -793,7 +793,7 @@ class ProjectsController < ApplicationController
@members = @project.member_principals.includes(:roles, :principal).all
@members = sort_project_members(@project, @members)
end
@members = paginateHelper @members
render :layout => 'base_courses' if @project.project_type == 1
end

View File

@ -131,7 +131,15 @@ module WelcomeHelper
#取得论坛数据
def find_hot_forum_topics limit=10
#Memo.order('replies_count DESC').where('replies_count <> 0').limit(limit)
Memo.order('replies_count DESC').where('parent_id IS NULL').limit(limit)
Memo.order('replies_count DESC, created_at DESC').where('parent_id IS NULL').limit(limit)
## 以下语句会内链接自身查询出最后一条回复时间,没有回复的帖子不会显示
# Memo.find_by_sql("
# SELECT memos.*, reply.created_at AS last_reply_date FROM memos AS memos
# INNER JOIN memos
# AS reply ON memos.last_reply_id=reply.id
# WHERE memos.parent_id IS NULL
# ORDER BY memos.replies_count DESC, memos.created_at DESC
# LIMIT #{limit}")
end
def sort_project_by_hot_rails project_type=0, order_by='grade DESC', limit=15

View File

@ -1,20 +1,32 @@
<!-- added by fq -->
<!-- %= form_for(@forum) do |f| % -->
<%= labelled_form_for(@forum) do |f| %>
<div id="share_new" style = "width: 500px; margin:0 auto; " >
<%= labelled_form_for(@forum) do |f| %>
<% if @forum.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
<div id="error_explanation">
<h2><%= pluralize(@forum.errors.count, "error") %> prohibited this forum from being saved:</h2>
<ul>
<ul>
<% @forum.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="actions">
<p><%= f.text_field :name, :required => true %></p>
<p><%= f.text_field :description, :required => true, :size => 80 %></p>
<%= f.submit :value => (l :label_board_new) %>
</ul>
</div>
<% end %>
<% end %>
<div class="actions" style="margin:10px">
<div class="field">
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share' %>
</div>
<div class="field">
<%= f.text_area :description, :required => true, :rows => 4, :style => 'width: 100%;resize: none;', :class => 'create-share' %>
</div>
<div class="actions" style=" padding-top: 10px; float:right">
<%= f.submit :value=>(l :label_board_new) ,:class => 'nyan-clean-gray', :style => 'font-size: 14px; padding: 0px 3px' %>
<%= link_to l(:button_back), forums_path,:class => 'nyan-clean-gray',:style => 'font-size: 14px; padding: 0px 3px; color: #000' %>
</div>
<p><%#= f.text_field :name, :required => true %></p>
<p><%#= f.text_field :description, :required => true, :size => 80 %></p>
<%#= f.submit :value => (l :label_board_new) %>
</div>
<% end %>
</div>

View File

@ -6,7 +6,7 @@
<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') %>
<%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %>
<% end %>
</td>
<td rowspan="2" ><!-- 搜索 --></td>
@ -19,30 +19,3 @@
</div>
<%= render :partial => 'forums/forum_list', :locals => {:forums => @forums} %>
<!-- <h1>Listing forums</h1>
<table>
<tr>
<th>name</th>
<th>description</th>
<th>creator</th>
<th></th>
<th></th>
<th></th>
</tr>
< % @forums.each do |forum| %>
<tr>
<td>< %= forum.name %></td>
<td>< %= forum.description %></td>
<td>< %= forum.creator.show_name %></td>
<td>< %= link_to 'Show', forum %></td>
<td>< %= link_to 'Edit', edit_forum_path(forum) %></td>
<td>< %= link_to 'Destroy', forum, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
< % end %>
</table>
<br /> -->

View File

@ -1,6 +1,6 @@
<!-- added by fq -->
<h1><%= l :label_board_new%></h1>
<h3><%= l :label_forum_new %></h1>
<%= render 'form' %>
<%= link_to l(:button_back), forums_path %>
<%#= link_to l(:button_back), forums_path %>

View File

@ -148,20 +148,20 @@
</td>
</tr>
<tr>
<!-- td align="left" width="190px" valign="left"><%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %>
<%= link_to l(:project_module_boards) ,project_boards_path(@project) %>
</td -->
<td align="left" width="190px" valign="left"><%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %>
<%= link_to l(:project_module_files) ,project_files_path(@project) %>
</td>
<td align="left" width="190px" valign="left"><%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %>
<%= link_to l(:label_roadmap) ,project_roadmap_path(@project) %>
</td>
</tr>
<tr>
<td align="left" width="190px" valign="left"><%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %>
<%= link_to l(:label_module_share) ,share_show_path(@project) %>
</td>
<td align="left" width="190px" valign="left"><%=image_tag("/images/sidebar/tool_tag.png", weight:"15px", height:"15px") %>
<%= link_to l(:label_project_tool_response) ,project_feedback_path(@project) %>
</td>
</tr>
<tr>
</tr>
</table>
</div>

View File

@ -30,6 +30,7 @@
<%= call_hook(:view_projects_settings_members_table_row, { :project => @project, :member => member}) %>
</div>
<% end; reset_cycle %>
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
<% else %>
<p class="nodata">
<%= l(:label_no_data) %>

View File

@ -513,7 +513,7 @@ zh:
label_software_user: 软件创客
label_contest_innovate: 创新竞赛
label_requirement_enterprise: 软件众包
label_project_module_forums: 讨论
label_project_module_forums: 讨论
label_new_homework: 作业
label_new_contest: 竞赛
label_requirement_focus: 关注需求
@ -1735,6 +1735,7 @@ zh:
label_borad_project: 项目讨论区
label_borad_course: 课程讨论区
label_memo_new_from_forum: 发布帖子
label_forum: 讨论区
label_tags_forum_description: 讨论区描述
label_tags_forum: 讨论区名称
label_forum: 讨论吧
label_forum_new: 新建讨论吧
label_tags_forum_description: 讨论吧描述
label_tags_forum: 讨论吧名称

View File

@ -301,7 +301,7 @@ end
Redmine::MenuManager.map :project_menu do |menu|
menu.push :overview, { :controller => 'projects', :action => 'show' }
# menu.push :activity, { :controller => 'activities', :action => 'index' }
menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id
#menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id
# :if => Proc.new { |p| p.shared_versions.any? }
menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
# menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
@ -314,7 +314,7 @@ Redmine::MenuManager.map :project_menu do |menu|
# :if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
menu.push :files, { :controller => 'files', :action => 'index' }, :param => :project_id, :caption => :label_file_new
#menu.push :files, { :controller => 'files', :action => 'index' }, :param => :project_id, :caption => :label_file_new
menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil },
:if => Proc.new { |p| p.repository && !p.repository.new_record? && !( !User.current.member_of?(p) && p.hidden_repo ) }
menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true

View File

@ -32,7 +32,7 @@ input[class='whiteButton'], .whiteButton {
text-shadow:0px 1px 0px #ffffff;
}
input[class='whiteButton'], .whiteButton:hover {
input[class='whiteButton']:hover, .whiteButton:hover {
background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f6f6f6), color-stop(1, #ffffff));
background:-moz-linear-gradient(top, #f6f6f6 5%, #ffffff 100%);
@ -46,7 +46,7 @@ input[class='whiteButton'], .whiteButton:hover {
}
input[class='whiteButton'], .whiteButton:active {
input[class='whiteButton']:active, .whiteButton:active {
position:relative;
top:1px;
}
@ -110,7 +110,7 @@ input[class='nyan-clean-gray'], .nyan-clean-gray {
padding-left:10px;
padding-right:10px;
}
input[class='nyan-clean-gray'], .nyan-clean-gray:hover {
input[class='nyan-clean-gray']:hover, .nyan-clean-gray:hover {
background-color: #dddddd;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #dddddd), color-stop(100%, #bbbbbb));
background-image: -webkit-linear-gradient(top, #dddddd, #bbbbbb);
@ -123,7 +123,7 @@ input[class='nyan-clean-gray'], .nyan-clean-gray:hover {
cursor: pointer;
text-shadow: 0 1px 0 #ddd;
}
input[class='nyan-clean-gray'], .nyan-clean-gray:active {
input[class='nyan-clean-gray']:active, .nyan-clean-gray:active {
border: 1px solid #aaa;
border-bottom: 1px solid #888;
-webkit-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;