系统消息增加长度

This commit is contained in:
huang 2015-09-14 15:33:11 +08:00
parent afda693e71
commit 4a7d3c9072
6 changed files with 20 additions and 14 deletions

View File

@ -38,14 +38,14 @@ class SystemMessagesController < ApplicationController
return
end
@system_messages = SystemMessage.new
@system_messages.content = params[:system_message][:content]
@system_messages.description = params[:system_message][:description]
@system_messages.user_id = User.current.id
respond_to do |format|
if @system_messages.save
format.html {redirect_to user_message_path(User.current, :type => "system_messages")}
flash[:notice] = l(:notice_successful_message)
else
if params[:system_message][:content].empty?
if params[:system_message][:description].empty?
flash[:error] = l(:label_content_blank_fail)
else
flash[:error] = l(:label_admin_message_fail)

View File

@ -1,7 +1,7 @@
class SystemMessage < ActiveRecord::Base
attr_accessible :content, :id, :user_id
attr_accessible :content, :id, :user_id, :description
belongs_to :user
validates :content, presence: true
validates_length_of :content, maximum: 255
validates :description, presence: true
validates_length_of :description, maximum: 10000
end

View File

@ -5,7 +5,7 @@
<div style="padding-top: 20px; padding-left: 5px;">
<%= form_for(@admin_messages, :html => {:id =>'system_message-form'}) do |f| %>
<div class="field">
<%= f.kindeditor :content,:width=>'87%',:editor_id=>'system_message_editor' %>
<%= f.kindeditor :description,:width=>'87%',:editor_id=>'system_message_editor' %>
<p id="content_notice_span" class="ml55"></p>
</div>
<div>
@ -25,7 +25,7 @@
$("#content_notice_span").focus();
return false;
}
else if (obj.length > 255) {
else if (obj.length > 10000) {
$("#content_notice_span").text("内容过长超过255个字符");
$("#content_notice_span").css('color', '#ff0000');
$("#content_notice_span").focus();

View File

@ -56,14 +56,14 @@
<span class="newsBlue homepageNewsPublisher">Trustie平台</span><span class="homepageNewsType fl">发布新消息:</span>
</li>
<li class="homepageNewsContent fl">
<%= link_to usm.content.html_safe, user_message_path(User.current, :type => "system_messages"),
<%= link_to usm.content.nil? ? usm.description.html_safe : usm.content.html_safe, user_message_path(User.current, :type => "system_messages"),
:class => "newsRed",
:onmouseover => "message_titile_show($(this),event);",
:onmouseout => "message_titile_hide($(this));"
%>
</li>
<div style="display:none;" class="message_title_red">
<%= usm.content.html_safe %>
<%= usm.content.nil? ? usm.description.html_safe : usm.content.html_safe %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(usm.created_at).html_safe %> </li>
</ul>
@ -350,14 +350,14 @@
</li>
<li class="homepageNewsPubType fl"><span class="newsBlue homepageNewsPublisher" >Trustie平台</span><span class="homepageNewsType fl">发布新消息:</span></li>
<li class="homepageNewsContent fl">
<%= link_to ma.content.html_safe, user_message_path(User.current, :type => "system_messages"),
<%= link_to ma.content.nil? ? ma.description.html_safe : ma.content.html_safe, user_message_path(User.current, :type => "system_messages"),
:class => "#{params[:type]=="unviewed" ? "newsBlack" : "newsRed"}",
:onmouseover =>"message_titile_show($(this),event);",
:onmouseout => "message_titile_hide($(this));"
%>
</li>
<div style="display:none;" class="message_title_red">
<%= ma.content.html_safe%>
<%= ma.content.nil? ? ma.description.html_safe : ma.content.html_safe %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>

View File

@ -0,0 +1,5 @@
class AddDescriptionToSystemMessage < ActiveRecord::Migration
def change
add_column :system_messages, :description, :text
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150909062619) do
ActiveRecord::Schema.define(:version => 20150914063751) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@ -1361,8 +1361,9 @@ ActiveRecord::Schema.define(:version => 20150909062619) do
create_table "system_messages", :force => true do |t|
t.integer "user_id"
t.string "content"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.text "description"
end
create_table "taggings", :force => true do |t|