课程通知增加置顶
This commit is contained in:
parent
3f60893591
commit
ab868d7b65
|
@ -74,10 +74,10 @@ class NewsController < ApplicationController
|
|||
@q = params[:subject]
|
||||
if params[:subject].nil? || params[:subject].blank?
|
||||
scope_order = scope.all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC")
|
||||
else
|
||||
scope_order = scope.where("#{News.table_name}.title like '#{'%' << params[:subject].to_s << '%'}'").all(:include => [:author, :course],
|
||||
:order => "#{News.table_name}.created_on DESC")
|
||||
:order => "#{News.table_name}.sticky DESC, #{News.table_name}.created_on DESC")
|
||||
end
|
||||
|
||||
# :offset => @offset,
|
||||
|
|
|
@ -66,7 +66,7 @@ class News < ActiveRecord::Base
|
|||
scope :course_visible, lambda {|*args|
|
||||
includes(:course).where(Course.allowed_to_condition(args.shift || User.current, :view_course_news, *args))
|
||||
}
|
||||
safe_attributes 'title', 'summary', 'description'
|
||||
safe_attributes 'title', 'summary', 'description', 'sticky'
|
||||
|
||||
def visible?(user=User.current)
|
||||
!user.nil? && user.allowed_to?(:view_news, project)
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
<input type="text" name="news[title]" class="hwork_input" id="news_title" size="60" onkeyup="regexTitle();" maxlength="60" placeholder="60个字符以内" value="<%= is_new ? '' : @news.title %>">
|
||||
<p id="title_notice_span" class="ml55"></p>
|
||||
</li>
|
||||
<li style="margin-left: 45px;">
|
||||
<%= f.check_box :sticky, :value => is_new ? 0 : @news.sticky %>
|
||||
<%= label_tag 'news_sticky', l(:label_board_sticky) %>
|
||||
</li>
|
||||
<li class="mb10">
|
||||
<% if is_new %>
|
||||
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<%= l(:label_release_news) %>:
|
||||
</span>
|
||||
<%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %>
|
||||
<% if news.sticky == 1%>
|
||||
<span class="sticky_btn_cir ml10">置顶</span>
|
||||
<% end%>
|
||||
<%=link_to "<span class = 'pic_mes'>#{news.comments.all.count}</span>".html_safe, news_path(news.id), :class => "pro_mes_w" %>
|
||||
<br />
|
||||
<div class="cl mb5"></div>
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
<h4 class="r_txt_tit mb5">
|
||||
<%=h @news.title %>
|
||||
</h4>
|
||||
<% if @news.sticky == 1%>
|
||||
<span class="sticky_btn_cir ml10 fl">置顶</span>
|
||||
<% end%>
|
||||
<%= link_to(l(:button_edit),
|
||||
edit_news_path(@news),
|
||||
:class => 'talk_edit fr') if User.current.allowed_to?(:manage_news, @course) %>
|
||||
|
|
|
@ -12,9 +12,13 @@
|
|||
<% end %> TO <!--+"(课程名称)"-->
|
||||
<%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
|
||||
</div>
|
||||
<div class="homepagePostTitle break_word"> <!--+"(通知标题)"-->
|
||||
<div class="homepagePostTitle break_word hidden fl m_w600"> <!--+"(通知标题)"-->
|
||||
<%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
|
||||
</div>
|
||||
<% if activity.sticky == 1%>
|
||||
<span class="sticky_btn_cir ml10">置顶</span>
|
||||
<% end%>
|
||||
<div class="cl"></div>
|
||||
<div class="homepagePostDate">
|
||||
发布时间:<%= format_time(activity.created_on) %>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class AddNewsSticky < ActiveRecord::Migration
|
||||
def up
|
||||
add_column :news, :sticky, :integer, :default => 0
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :news, :sticky
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20151109080256) do
|
||||
ActiveRecord::Schema.define(:version => 20151112072948) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -953,6 +953,7 @@ ActiveRecord::Schema.define(:version => 20151109080256) do
|
|||
t.datetime "created_on"
|
||||
t.integer "comments_count", :default => 0, :null => false
|
||||
t.integer "course_id"
|
||||
t.integer "sticky", :default => 0
|
||||
end
|
||||
|
||||
add_index "news", ["author_id"], :name => "index_news_on_author_id"
|
||||
|
|
|
@ -555,7 +555,6 @@ a:hover.st_add{ color:#ff8e15;}
|
|||
|
||||
a.link_file{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; }
|
||||
a:hover.link_file{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;}
|
||||
.r_txt_tit{width:510px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;color:#15bccf; float:left; color:#09658c; font-size:14px;}
|
||||
|
||||
blockquote {background: #e8e8e8;padding: 10px;margin-bottom: 5px;word-break: break-all;word-wrap: break-word;}
|
||||
.respond-form{display: none;margin: auto;clear: both;}
|
||||
|
@ -987,6 +986,7 @@ a:hover.icon_remove{background:url(../images/course/icons.png) -20px -338px no-r
|
|||
.m_w505{max-width: 505px;}
|
||||
.m_w500{max-width: 500px;}
|
||||
.m_w530{max-width: 530px;}
|
||||
.m_w600{max-width: 600px;}
|
||||
.ProResultTable{ color:#888888;}
|
||||
.T_C{ text-align:center;}
|
||||
.SearchIcon{background:url(../images/homepage_icon2.png) 676px -393px no-repeat; }
|
||||
|
|
|
@ -1082,6 +1082,7 @@ a:hover.icon_remove{background:url(../images/course/icons.png) -20px -338px no-r
|
|||
.m_w460{max-width: 460px;}
|
||||
.m_w505{max-width: 505px;}
|
||||
.m_w530{max-width: 530px;}
|
||||
.m_w600{max-width: 600px;}
|
||||
.ProResultTable{ color:#888888;}
|
||||
.T_C{ text-align:center;}
|
||||
.SearchIcon{background:url(../images/homepage_icon2.png) 676px -393px no-repeat; }
|
||||
|
|
Loading…
Reference in New Issue