首页用户动态加入讨论区内容,点击之后定位到帖子。
This commit is contained in:
parent
6a2a82d30e
commit
28978b88b2
|
@ -63,7 +63,7 @@ class ForumsController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @forum.save
|
if @forum.save
|
||||||
format.html { redirect_to @forum, notice: 'Forum was successfully created.' }
|
format.html { redirect_to @forum, notice: l(:label_forum_create_succ) }
|
||||||
format.json { render json: @forum, status: :created, location: @forum }
|
format.json { render json: @forum, status: :created, location: @forum }
|
||||||
else
|
else
|
||||||
format.html { render action: "new" }
|
format.html { render action: "new" }
|
||||||
|
|
|
@ -125,7 +125,7 @@ module WelcomeHelper
|
||||||
# user_objs = User.find_by_sql("SELECT * FROM users WHERE (users.id IN #{"(" << users.join(',') << ")"} )")
|
# user_objs = User.find_by_sql("SELECT * FROM users WHERE (users.id IN #{"(" << users.join(',') << ")"} )")
|
||||||
activity = Redmine::Activity::Fetcher.new(nil)
|
activity = Redmine::Activity::Fetcher.new(nil)
|
||||||
|
|
||||||
activity.events_welcome(nil, nil, {:limit => limit})
|
activity.events_welcome(nil, nil, {:limit => limit, :types => 'welcome'})
|
||||||
end
|
end
|
||||||
|
|
||||||
#取得论坛数据
|
#取得论坛数据
|
||||||
|
|
|
@ -1,131 +1,131 @@
|
||||||
####by fq
|
####by fq
|
||||||
class Bid < ActiveRecord::Base
|
class Bid < ActiveRecord::Base
|
||||||
attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password
|
attr_accessible :author_id, :budget, :deadline, :name, :description, :homework_type, :password
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
|
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
|
||||||
belongs_to :course
|
belongs_to :course
|
||||||
has_many :biding_projects, :dependent => :destroy
|
has_many :biding_projects, :dependent => :destroy
|
||||||
has_many :projects, :through => :biding_projects
|
has_many :projects, :through => :biding_projects
|
||||||
has_many :projects_member, :class_name => 'User', :through => :projects
|
has_many :projects_member, :class_name => 'User', :through => :projects
|
||||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||||
has_many :homework_for_courses, :dependent => :destroy
|
has_many :homework_for_courses, :dependent => :destroy
|
||||||
has_many :courses, :through => :homework_for_courses, :source => :project
|
has_many :courses, :through => :homework_for_courses, :source => :project
|
||||||
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
|
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
|
||||||
has_many :join_in_contests, :dependent => :destroy
|
has_many :join_in_contests, :dependent => :destroy
|
||||||
# has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}"
|
# has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}"
|
||||||
|
|
||||||
|
|
||||||
acts_as_attachable
|
acts_as_attachable
|
||||||
|
|
||||||
NAME_LENGTH_LIMIT = 60
|
NAME_LENGTH_LIMIT = 60
|
||||||
DESCRIPTION_LENGTH_LIMIT = 250
|
DESCRIPTION_LENGTH_LIMIT = 250
|
||||||
|
|
||||||
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
|
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
|
||||||
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
|
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
|
||||||
validates_presence_of :author_id, :name, :deadline
|
validates_presence_of :author_id, :name, :deadline
|
||||||
# validates_presence_of :deadline, :message => 'test'
|
# validates_presence_of :deadline, :message => 'test'
|
||||||
# validates_format_of :deadline, :with =>
|
# validates_format_of :deadline, :with =>
|
||||||
validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
|
validates_format_of :deadline, :with => /^[\d]{4}[-][\d]{1,2}[-][\d]{1,2}$/
|
||||||
validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/,
|
validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{2})|^(\d+).([0-9]{1})$/,
|
||||||
:if => Proc.new { |p| p.reward_type == 1 }
|
:if => Proc.new { |p| p.reward_type == 1 }
|
||||||
validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{1})$/, :if => Proc.new { |p| p.reward_type == 3 }
|
validates_format_of :budget, :with => /^(\d+)$|^(\d+).([0-9]{1})$/, :if => Proc.new { |p| p.reward_type == 3 }
|
||||||
validate :validate_user
|
validate :validate_user
|
||||||
validate :validate_reward_type
|
validate :validate_reward_type
|
||||||
after_create :act_as_activity
|
after_create :act_as_activity
|
||||||
|
|
||||||
scope :visible, lambda {|*args|
|
scope :visible, lambda {|*args|
|
||||||
nil
|
nil
|
||||||
}
|
}
|
||||||
|
|
||||||
scope :like, lambda {|arg|
|
scope :like, lambda {|arg|
|
||||||
if arg.blank?
|
if arg.blank?
|
||||||
where(nil)
|
where(nil)
|
||||||
else
|
else
|
||||||
pattern = "%#{arg.to_s.strip.downcase}%"
|
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||||
where("LOWER(id) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern)
|
where("LOWER(id) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
acts_as_taggable
|
acts_as_taggable
|
||||||
|
|
||||||
acts_as_event :title => Proc.new {|o| "#{l(:label_requirement)} ##{o.id}: #{o.name}" },
|
acts_as_event :title => Proc.new {|o| "#{l(:label_requirement)} ##{o.id}: #{o.name}" },
|
||||||
:description => :description,
|
:description => :description,
|
||||||
:author => :author,
|
:author => :author,
|
||||||
:url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}}
|
:url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}}
|
||||||
|
|
||||||
acts_as_activity_provider :find_options => {:include => [:projects, :author]},
|
acts_as_activity_provider :find_options => {:include => [:projects, :author]},
|
||||||
:author_key => :author_id
|
:author_key => :author_id
|
||||||
|
|
||||||
safe_attributes 'name',
|
safe_attributes 'name',
|
||||||
'description',
|
'description',
|
||||||
'budget',
|
'budget',
|
||||||
'deadline',
|
'deadline',
|
||||||
'homework_type',
|
'homework_type',
|
||||||
'reward_type',
|
'reward_type',
|
||||||
'password'
|
'password'
|
||||||
|
|
||||||
|
|
||||||
# safe_attributes 'name',
|
# safe_attributes 'name',
|
||||||
# 'description',
|
# 'description',
|
||||||
# 'deadline'
|
# 'deadline'
|
||||||
def add_jour(user, notes, reference_user_id = 0)
|
def add_jour(user, notes, reference_user_id = 0)
|
||||||
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
|
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.creat_bids(budget, deadline, name, description=nil, reward_type)
|
def self.creat_bids(budget, deadline, name, description=nil, reward_type)
|
||||||
self.create(:author_id => User.current.id, :budget => budget,
|
self.create(:author_id => User.current.id, :budget => budget,
|
||||||
:deadline => deadline, :name => name, :description => description, :commit => 0, :reward_type => reward_type)
|
:deadline => deadline, :name => name, :description => description, :commit => 0, :reward_type => reward_type)
|
||||||
# self.acts << Activity.new(:user_id => self.author_id)
|
# self.acts << Activity.new(:user_id => self.author_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_bids(budget, deadline, name, description=nil)
|
def update_bids(budget, deadline, name, description=nil)
|
||||||
if(User.current.id == self.author_id)
|
if(User.current.id == self.author_id)
|
||||||
self.name = name
|
self.name = name
|
||||||
self.budget = budget
|
self.budget = budget
|
||||||
self.deadline = deadline
|
self.deadline = deadline
|
||||||
self.description = description
|
self.description = description
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete_bids
|
def delete_bids
|
||||||
unless self.nil?
|
unless self.nil?
|
||||||
if User.current.id == self.author_id
|
if User.current.id == self.author_id
|
||||||
self.destroy
|
self.destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def set_commit(commit)
|
def set_commit(commit)
|
||||||
self.update_attribute(:commit, commit)
|
self.update_attribute(:commit, commit)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def validate_user
|
def validate_user
|
||||||
errors.add :author_id, :invalid if author.nil? || !author.active?
|
errors.add :author_id, :invalid if author.nil? || !author.active?
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate_reward_type
|
def validate_reward_type
|
||||||
errors.add :reward_type, :invalid if self.reward_type == 0
|
errors.add :reward_type, :invalid if self.reward_type == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def act_as_activity
|
def act_as_activity
|
||||||
self.acts << Activity.new(:user_id => self.author_id)
|
self.acts << Activity.new(:user_id => self.author_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# used to validate weather the user is the creater of the bid
|
# used to validate weather the user is the creater of the bid
|
||||||
# added by william
|
# added by william
|
||||||
def validate_bid_manager(user_id)
|
def validate_bid_manager(user_id)
|
||||||
unless user_id.nil?
|
unless user_id.nil?
|
||||||
if self.author_id == user_id
|
if self.author_id == user_id
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,14 +16,16 @@ class Memo < ActiveRecord::Base
|
||||||
# #:include => { :forum => :p}
|
# #:include => { :forum => :p}
|
||||||
# #:project_key => "#{Forum.table_name}.project_id"
|
# #:project_key => "#{Forum.table_name}.project_id"
|
||||||
# :date_column => "#{table_name}.created_at"
|
# :date_column => "#{table_name}.created_at"
|
||||||
# acts_as_event :title => Proc.new {|o| "#{o.forum.name}: #{o.subject}"},
|
acts_as_event :title => Proc.new {|o| "#{o.forum.name}: #{o.subject}"},
|
||||||
# :description => :content,
|
:datetime => :created_at,
|
||||||
# :group => :parent,
|
:description => :content,
|
||||||
# :type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
|
:author => :author,
|
||||||
# :url => Proc.new {|o| {:controller => 'memos', :action => 'show', :forum_id => o.forum_id}.merge(o.parent_id.nil? ? {:id => o.id} : {:id => o.parent_id, :r => o.id, :anchor => "memo-#{o.id}"})}
|
:type => Proc.new {|o| o.parent_id.nil? ? 'Forum' : 'Memo'},
|
||||||
acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
|
:url => Proc.new {|o| {:controller => 'memos', :action => 'show', :forum_id => o.forum_id}.merge(o.parent_id.nil? ? {:id => o.id} : {:id => o.parent_id, :anchor => "reply-#{o.id}"})}
|
||||||
:author_key => :author_id
|
acts_as_activity_provider :author_key => :author_id,
|
||||||
acts_as_watchable
|
:func => 'memos'
|
||||||
|
# :find_options => {:type => 'memos'}
|
||||||
|
# acts_as_watchable
|
||||||
|
|
||||||
safe_attributes "author_id",
|
safe_attributes "author_id",
|
||||||
"subject",
|
"subject",
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
<!-- added by fq -->
|
<!-- added by fq -->
|
||||||
<p id="notice">
|
|
||||||
<%= notice %>
|
|
||||||
</p>
|
|
||||||
<div id="add-memo" style="display:none;">
|
<div id="add-memo" style="display:none;">
|
||||||
<h3><%=l(:label_memo_new)%></h3>
|
<h3><%=l(:label_memo_new)%></h3>
|
||||||
<% if User.current.logged? %>
|
<% if User.current.logged? %>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><a><%= link_to "forge.trustie.net/projects", :controller => 'projects', :action => 'index', :project_type => 0 %></a></td>
|
<td style="padding-left: 8px"><a><%= link_to "forge.trustie.net/forums", forums_path %></a></td>
|
||||||
<td><p
|
<td><p
|
||||||
class="top-content-list"><%=link_to l(:label_home),home_path %> > <%=link_to '讨论区', :controller => 'forums', :action => 'index' %> > <%=link_to @forum.name, forum_path(@forum) %></p></td>
|
class="top-content-list"><%=link_to l(:label_home),home_path %> > <%=link_to '讨论区', :controller => 'forums', :action => 'index' %> > <%=link_to @forum.name, forum_path(@forum) %></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><a><%= link_to "forge.trustie.net/projects", :controller => 'projects', :action => 'index', :project_type => 0 %></a></td>
|
<td style="padding-left: 8px"><a><%= link_to "forge.trustie.net/forums", forums_path %></a></td>
|
||||||
<td><p class="top-content-list"><%=link_to l(:label_home),home_path %> > <%=link_to '讨论区', :controller => 'forums', :action => 'index' %> > <%=link_to @forum.name, forum_path(@forum) %> > <%=link_to @memo.subject, forum_memo_path(@forum, @memo) %></p></td>
|
<td><p class="top-content-list"><%=link_to l(:label_home),home_path %> > <%=link_to '讨论区', :controller => 'forums', :action => 'index' %> > <%=link_to @forum.name, forum_path(@forum) %> > <%=link_to @memo.subject, forum_memo_path(@forum, @memo) %></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -115,8 +115,8 @@
|
||||||
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @replies.nil? ? 0 : @replies.size %>)</h3>
|
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @replies.nil? ? 0 : @replies.size %>)</h3>
|
||||||
<% reply_count = @current_count.to_i %>
|
<% reply_count = @current_count.to_i %>
|
||||||
<% @replies.each do |reply| %>
|
<% @replies.each do |reply| %>
|
||||||
<p class="font_lighter"><%= reply_count += 1 %>楼 :</p>
|
|
||||||
<div class="reply" id="<%= "reply-#{reply.id}" %>">
|
<div class="reply" id="<%= "reply-#{reply.id}" %>">
|
||||||
|
<p class="font_lighter"><%= reply_count += 1 %>楼 :</p>
|
||||||
<div class="contextual-borad">
|
<div class="contextual-borad">
|
||||||
<%= link_to(
|
<%= link_to(
|
||||||
image_tag('comment.png'),
|
image_tag('comment.png'),
|
||||||
|
|
|
@ -1567,6 +1567,8 @@ en:
|
||||||
label_hot_project: 'HOT Projects'
|
label_hot_project: 'HOT Projects'
|
||||||
label_memo_create_succ: Memo was successfully created.
|
label_memo_create_succ: Memo was successfully created.
|
||||||
label_memo_create_fail: Memo was failures created.
|
label_memo_create_fail: Memo was failures created.
|
||||||
|
label_forum_create_succ: Forum was successfully created.
|
||||||
|
label_forum_create_fail: Forum was failures created.
|
||||||
label_memo_create: publish
|
label_memo_create: publish
|
||||||
label_memo_new: new memo
|
label_memo_new: new memo
|
||||||
label_memo_edit: edit memo
|
label_memo_edit: edit memo
|
||||||
|
|
|
@ -1729,6 +1729,8 @@ zh:
|
||||||
label_hot_project: '热门项目'
|
label_hot_project: '热门项目'
|
||||||
label_memo_create_succ: 发布成功
|
label_memo_create_succ: 发布成功
|
||||||
label_memo_create_fail: 发布失败
|
label_memo_create_fail: 发布失败
|
||||||
|
label_forum_create_succ: 讨论吧新建成功
|
||||||
|
label_forum_create_fail: 讨论吧新建失败
|
||||||
label_memo_create: 发布
|
label_memo_create: 发布
|
||||||
label_memo_new: 新建主题
|
label_memo_new: 新建主题
|
||||||
label_memo_edit: 修改主题
|
label_memo_edit: 修改主题
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Redmine
|
||||||
send :include, Redmine::Acts::ActivityProvider::InstanceMethods
|
send :include, Redmine::Acts::ActivityProvider::InstanceMethods
|
||||||
end
|
end
|
||||||
|
|
||||||
options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options)
|
options.assert_valid_keys(:type, :permission, :timestamp, :author_key, :find_options, :func)
|
||||||
self.activity_provider_options ||= {}
|
self.activity_provider_options ||= {}
|
||||||
|
|
||||||
# One model can provide different event types
|
# One model can provide different event types
|
||||||
|
@ -87,7 +87,6 @@ module Redmine
|
||||||
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
|
raise "#{self.name} can not provide #{event_type} events." if provider_options.nil?
|
||||||
|
|
||||||
scope = self
|
scope = self
|
||||||
|
|
||||||
if from && to
|
if from && to
|
||||||
scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
|
scope = scope.scoped(:conditions => ["#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to])
|
||||||
end
|
end
|
||||||
|
@ -102,16 +101,18 @@ module Redmine
|
||||||
scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])
|
scope = scope.scoped(:order => "#{table_name}.id DESC", :limit => options[:limit])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
user1 = User.find_by_admin(true)
|
||||||
if provider_options.has_key?(:permission)
|
if provider_options.has_key?(:permission)
|
||||||
user1 = User.find_by_admin(true)
|
|
||||||
scope = scope.scoped(:conditions => Project.allowed_to_condition(user1, provider_options[:permission] || :view_project, options))
|
scope = scope.scoped(:conditions => Project.allowed_to_condition(user1, provider_options[:permission] || :view_project, options))
|
||||||
elsif respond_to?(:visible)
|
elsif respond_to?(:visible)
|
||||||
scope = scope.visible(user1, options)
|
scope = scope.visible(user1, options)
|
||||||
|
elsif provider_options.has_key?(:func) && provider_options[:func].eql?('memos')
|
||||||
|
scope = scope
|
||||||
else
|
else
|
||||||
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
|
ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :permission option is deprecated. Add a visible scope to the #{self.name} model or use explicit :permission option."
|
||||||
|
# scope = scope
|
||||||
scope = scope.scoped(:conditions => Project.allowed_to_condition(user1, "view_#{self.name.underscore.pluralize}".to_sym, options))
|
scope = scope.scoped(:conditions => Project.allowed_to_condition(user1, "view_#{self.name.underscore.pluralize}".to_sym, options))
|
||||||
end
|
end
|
||||||
|
|
||||||
scope.all(provider_options[:find_options].dup)
|
scope.all(provider_options[:find_options].dup)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -371,6 +371,7 @@ Redmine::Activity.map do |activity|
|
||||||
activity.register :time_entries, :default => false
|
activity.register :time_entries, :default => false
|
||||||
# added by fq
|
# added by fq
|
||||||
activity.register :bids, :class_name => 'Bid'
|
activity.register :bids, :class_name => 'Bid'
|
||||||
|
activity.register :memos, :class_name => 'Memo'
|
||||||
# end
|
# end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue