留言不能是空字符
This commit is contained in:
parent
775f07a89d
commit
99686ec269
|
@ -630,7 +630,7 @@ class ApplicationController < ActionController::Base
|
|||
obj[@obj_pages.offset, @obj_pages.per_page]
|
||||
else
|
||||
logger.error "[ApplicationController] Error : application_controller#paginateHelper ===> unknow category: #{obj.class}"
|
||||
nil
|
||||
raise RuntimeError, 'unknow type, Please input you type into this helper.'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -129,10 +129,16 @@ class WordsController < ApplicationController
|
|||
def leave_project_message
|
||||
user = User.current
|
||||
message = params[:new_form][:project_message]
|
||||
Project.add_new_jour(user, message, params[:id])
|
||||
feedback = Project.add_new_jour(user, message, params[:id])
|
||||
if(feedback.errors.empty?)
|
||||
redirect_to project_feedback_path(params[:id]), notice: l(:label_feedback_success)
|
||||
else
|
||||
flash[:error] = feedback.errors.full_messages[0]
|
||||
redirect_to project_feedback_path(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def add_brief_introdution
|
||||
user = User.current
|
||||
message = params[:new_form][:user_introduction]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
class JournalsForMessage < ActiveRecord::Base
|
||||
attr_accessible :jour_id, :jour_type, :notes, :reply_id, :status, :user_id
|
||||
attr_accessor :indice
|
||||
|
||||
validates :notes, presence: true
|
||||
belongs_to :jour, :polymorphic => true
|
||||
belongs_to :user
|
||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||
|
|
|
@ -160,12 +160,18 @@ class Project < ActiveRecord::Base
|
|||
# 项目留言 added by fq
|
||||
def self.add_jour(user, notes)
|
||||
project = Project.find('trustie')
|
||||
project.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => 0)
|
||||
# project.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => 0)
|
||||
pjfm = project.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0)
|
||||
pjfm.save
|
||||
pjfm
|
||||
end
|
||||
|
||||
def self.add_new_jour(user, notes, id)
|
||||
project = Project.find(id)
|
||||
project.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => 0)
|
||||
# project.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => 0)
|
||||
pjfm = project.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0)
|
||||
pjfm.save
|
||||
pjfm
|
||||
end
|
||||
# end
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<!-- fq -->
|
||||
<h3><%= l(:label_user_response) %></h3>
|
||||
<%= render_flash_messages %>
|
||||
|
||||
<%= form_for('new_form', :method => :post,
|
||||
:url => {:controller => 'words', :action => 'leave_project_message'}) do |f|%>
|
||||
|
|
|
@ -847,6 +847,8 @@ zh:
|
|||
label_user_commits: "代码提交"
|
||||
label_user_watchered: "关注" # huang添加的
|
||||
label_user_newfeedback: "留言" ## huang添加的
|
||||
label_feedback_success: "留言成功"
|
||||
label_feedback_fail: "留言失败"
|
||||
label_user_login: "最后登录"
|
||||
label_user_mail: "邮件地址"
|
||||
label_user_joinin: "加入时间"
|
||||
|
|
Loading…
Reference in New Issue