首页 论坛发帖权限
This commit is contained in:
parent
e7841cb512
commit
46b508be2b
|
@ -5,6 +5,7 @@ class ForumsController < ApplicationController
|
|||
before_filter :find_forum_if_available
|
||||
before_filter :authenticate_user_edit, :only => [:edit, :update]
|
||||
before_filter :authenticate_user_destroy, :only => [:destroy]
|
||||
before_filter :require_login, :only => [:new, :create]
|
||||
|
||||
helper :sort
|
||||
include SortHelper
|
||||
|
|
|
@ -5,6 +5,7 @@ class MemosController < ApplicationController
|
|||
before_filter :find_memo, :except => [:new, :create, :preview]
|
||||
before_filter :authenticate_user_edit, :only => [:edit, :update]
|
||||
before_filter :authenticate_user_destroy, :only => [:destroy]
|
||||
before_filter :require_login, :only => [:new, :create]
|
||||
|
||||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
|
|
|
@ -22,6 +22,24 @@ module WelcomeHelper
|
|||
include CoursesHelper
|
||||
include ProjectsHelper
|
||||
|
||||
# 前略·天国の首页君/Earth has been unable stop to welcomePage's.
|
||||
# sum - 要搜索的项目数量
|
||||
# max_rate - 新项目所占所有项目的比重,10分制
|
||||
#
|
||||
# Examples
|
||||
#
|
||||
# find_miracle_course(10, 7)
|
||||
# # => 前7个项目为新课程,后面三个是参与人数最多的
|
||||
#
|
||||
# Returns project&courses array
|
||||
def find_miracle_course(sum=10, max_rate=7)
|
||||
max = sum*(max_rate.to_f/10)
|
||||
c1 = find_new_course(sum).to_a.dup
|
||||
c2 = find_all_hot_course(sum).to_a.dup
|
||||
c2 = c2 - c1
|
||||
(c1.take(max)+c2).take(sum)
|
||||
end
|
||||
|
||||
def find_new_course limit=15
|
||||
Project.visible.joins(:course_extra).where("#{Project.table_name}.project_type = ? ", 1).order("courses.time DESC, #{Project.table_name}.created_on DESC").limit(limit).all
|
||||
end
|
||||
|
|
|
@ -96,6 +96,14 @@
|
|||
<div class="pagination"><%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %></div>
|
||||
</div>
|
||||
|
||||
<% if User.current.login? %>
|
||||
<div class="reply-box" style="">
|
||||
<%= render :partial => 'reply_box' %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div style="font-size: 14px;margin:20px;">
|
||||
<%= l(:label_user_login_tips) %>
|
||||
<%= link_to l(:label_user_login_new), signin_path %>
|
||||
<hr/>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -110,7 +110,7 @@
|
|||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'projects', :action => 'course', :project_type => 1, :project_sort_type => 1}, :target => "_blank" %></span>
|
||||
<div class="d-p-projectlist-box">
|
||||
<ul class="d-p-projectlist">
|
||||
<% find_new_course(10).map do |project| %>
|
||||
<% find_miracle_course(10, 7).map do |project| %>
|
||||
<li style="background-image:none;">
|
||||
<div style="float: left;">
|
||||
<% if get_avatar?(project)%>
|
||||
|
|
Loading…
Reference in New Issue