Merge branch 'welcome' into develop

exceptionHandle
yanxd 12 years ago
commit f14f73414e

@ -19,8 +19,8 @@ class WelcomeController < ApplicationController
caches_action :robots
def index
@news = News.latest User.current
@projects = Project.latest User.current
# @news = News.latest User.current
# @projects = Project.latest User.current
#by young
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
if request.get?
@ -60,10 +60,10 @@ class WelcomeController < ApplicationController
end
#add by huang
@memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
# @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
@events_by_day = events.group_by(&:event_date)
# events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20)
# @events_by_day = events.group_by(&:event_date)
#
end

@ -19,18 +19,18 @@
module WelcomeHelper
def newbieTopiclist
find_all_topic_by_board_id
end
# def newbieTopiclist
# find_all_topic_by_board_id
# end
def newbieTopicStickyList
find_all_topic_by_board_id 1
end
# def newbieTopicStickyList
# find_all_topic_by_board_id 1
# end
def find_project_by_topic topic
board = find_board_by_topic(topic)
find_project_by_board board
end
# def find_project_by_topic topic
# board = find_board_by_topic(topic)
# find_project_by_board board
# end
def find_all_hot_project
sort_project_by_hot
@ -47,78 +47,95 @@ module WelcomeHelper
def find_all_hot_contest
sort_contest_by_hot
end
private
def search_project
Project.find_by_identifier "newbie_faq"
def find_all_event_type event
case event.event_type
when 'news'
'新闻'
when 'issue'
'缺陷'
when 'attachment'
'附件'
when 'message'
'主题'
when 'reply'
'回复'
when 'bid'
'众包'
else
event.event_type
end
end
def find_all_topic_by_board_id sticky = 0, limit = 30
project = search_project
return [] if(project.nil? or project.boards.nil?)
board_id = project.boards.first.id
logger.debug "[WelcomeHelper] ===> find_all_topic_by_board_id=> project.id:#{project.id}, board_id:#{board_id}, sticky:#{sticky}"
Message.where("board_id = :board_id and sticky=:sticky", :board_id => board_id, :sticky => sticky ).limit(limit)
def time_tag_welcome(time)
text = distance_of_time_in_words(Time.now, time)
content_tag('span', text, :title => format_time(time))
end
def find_board_by_topic topic
Board.find_by_id(topic.board_id)
end
def find_project_by_board board
Project.find_by_id(board.project_id)
end
private
# def search_project
# Project.find_by_identifier "newbie_faq"
# end
# def find_all_topic_by_board_id sticky = 0, limit = 30
# project = search_project
# return [] if(project.nil? or project.boards.nil?)
# board_id = project.boards.first.id
# logger.debug "[WelcomeHelper] ===> find_all_topic_by_board_id=> project.id:#{project.id}, board_id:#{board_id}, sticky:#{sticky}"
# Message.where("board_id = :board_id and sticky=:sticky", :board_id => board_id, :sticky => sticky ).limit(limit)
# end
# def find_board_by_topic topic
# Board.find_by_id(topic.board_id)
# end
# def find_project_by_board board
# Project.find_by_id(board.project_id)
# end
def sort_project_by_hot
return sort_project_by_hot_rails 0
sort_project_by_hot_rails 0, 'grade DESC'
end
def sort_course_by_hot
return sort_project_by_hot_rails 1
sort_project_by_hot_rails 1, 'course_ac_para DESC'
end
def sort_bid_by_hot
return sort_bid_by_hot_rails 1
sort_bid_by_hot_rails 1
end
def sort_contest_by_hot
return sort_bid_by_hot_rails 2
sort_bid_by_hot_rails 2
end
#取得所有活动
def find_all_activities limit=10
users = []
activities = Activity.find_by_sql("select distinct user_id from activities order by id DESC limit #{limit}" )
activities.each { |activity|
users << activity.user_id
}
user_objs = User.find_by_sql("SELECT * FROM users WHERE (users.id IN #{"(" << users.join(',') << ")"} )")
activity = Redmine::Activity::Fetcher.new(user_objs)
def find_all_activities limit=5
# users = []
# activities = Activity.find_by_sql("select distinct user_id from activities order by id DESC limit #{limit}" )
# activities.each { |activity|
# users << activity.user_id
# }
# user_objs = User.find_by_sql("SELECT * FROM users WHERE (users.id IN #{"(" << users.join(',') << ")"} )")
activity = Redmine::Activity::Fetcher.new(nil)
activity.events_welcome(nil, nil, {:limit => limit})
end
#取得论坛数据
def find_hot_forum_topics limit=10
Memo.order('replies_count DESC').where('replies_count <> 0').limit(limit)
Memo.order('replies_count DESC').where('replies_count <> 0').limit(limit)
end
def sort_project_by_hot_rails project_type
limit = 10
project_type == 0 ? Project.find_by_sql("
SELECT p.id, p.name, p.description, p.identifier, t.project_id
FROM projects AS p RIGHT OUTER JOIN (
SELECT project_id,grade FROM project_statuses
WHERE project_type = #{project_type} ORDER BY grade DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
: Project.find_by_sql("
def sort_project_by_hot_rails project_type=0, order_by='grade DESC', limit=15
Project.find_by_sql("
SELECT p.id, p.name, p.description, p.identifier, t.project_id
FROM projects AS p RIGHT OUTER JOIN (
SELECT project_id,grade FROM project_statuses
WHERE project_type = #{project_type} ORDER BY course_ac_para DESC LIMIT #{limit} ) AS t ON p.id = t.project_id ")
WHERE project_type = #{project_type} ORDER BY #{order_by} LIMIT #{limit} ) AS t ON p.id = t.project_id ")
end
def sort_bid_by_hot_rails reward_type
limit = 10
Bid.visible.where('reward_type = ?', reward_type).reorder('bids.commit desc').limit(limit).all
def sort_bid_by_hot_rails reward_type, limit = 10
Bid.visible.where('reward_type = ?', reward_type).reorder('bids.commit desc').limit(limit)
end
end

@ -4,11 +4,11 @@ class Forum < ActiveRecord::Base
has_many :memos, :dependent => :destroy
belongs_to :creator, :class_name => "User", :foreign_key => 'creator_id'
safe_attributes 'name',
'description',
'topic_count',
'memo_count',
'last_memo_id',
'creator_id'
'description',
'topic_count',
'memo_count',
'last_memo_id',
'creator_id'
validates_presence_of :name, :creator_id
validates_length_of :name, maximum: 50
validates_length_of :description, maximum: 255
@ -16,5 +16,17 @@ class Forum < ActiveRecord::Base
acts_as_taggable
scope :by_join_date, order("created_at DESC")
def reset_counters!
self.class.reset_counters!(id)
end
# Updates topic_count, memo_count and last_memo_id attributes for +board_id+
def self.reset_counters!(forum_id)
forum_id = forum_id.to_i
update_all("topic_count = (SELECT COUNT(*) FROM #{Memo.table_name} WHERE forum_id=#{forum_id} AND parent_id IS NULL)," +
" memo_count = (SELECT COUNT(*) FROM #{Memo.table_name} WHERE forum_id=#{forum_id} AND parent_id IS NOT NULL)," +
" last_memo_id = (SELECT MAX(id) FROM #{Memo.table_name} WHERE forum_id=#{forum_id})",
["id = ?", forum_id])
end
end

@ -1,6 +1,6 @@
class Memo < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :forums
belongs_to :forum
belongs_to :author, :class_name => "User", :foreign_key => 'author_id'
validates_presence_of :author_id, :forum_id, :subject
@ -13,10 +13,10 @@ class Memo < ActiveRecord::Base
acts_as_attachable
belongs_to :last_reply_id, :class_name => 'Memo', :foreign_key => 'last_reply_id'
# acts_as_searchable :column => ['subject', 'content'],
# #:include => { :forums => :p}
# #:include => { :forum => :p}
# #:project_key => "#{Forum.table_name}.project_id"
# :date_column => "#{table_name}.created_at"
# acts_as_event :title => Proc.new {|o| "#{o.forums.name}: #{o.subject}"},
# acts_as_event :title => Proc.new {|o| "#{o.forum.name}: #{o.subject}"},
# :description => :content,
# :group => :parent,
# :type => Proc.new {|o| o.parent_id.nil? ? 'message' : 'reply'},
@ -29,7 +29,7 @@ class Memo < ActiveRecord::Base
"subject",
"content",
"forum_id",
"last_reply_id",
"last_memo_id",
"lock",
"parent_id",
"replies_count",
@ -39,8 +39,8 @@ class Memo < ActiveRecord::Base
# after_update :update_memos_forum
after_destroy :reset_counters!
# after_create :send_notification
after_save :plusParentAndForum
after_destroy :minusParentAndForum
# after_save :plusParentAndForum
# after_destroy :minusParentAndForum
# scope :visible, lambda { |*args|
# includes(:forum => ).where()
@ -62,7 +62,7 @@ class Memo < ActiveRecord::Base
if parent && parent.id
Memo.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id})
end
# forums.reset_counters!
forum.reset_counters!
end
def sticky=(arg)

@ -32,16 +32,16 @@
<th></th>
</tr>
<% @forums.each do |forum| %>
< % @forums.each do |forum| %>
<tr>
<td><%= forum.name %></td>
<td><%= forum.description %></td>
<td><%= forum.creator.show_name %></td>
<td><%= link_to 'Show', forum %></td>
<td><%= link_to 'Edit', edit_forum_path(forum) %></td>
<td><%= link_to 'Destroy', forum, method: :delete, data: { confirm: 'Are you sure?' } %></td>
<td>< %= forum.name %></td>
<td>< %= forum.description %></td>
<td>< %= forum.creator.show_name %></td>
<td>< %= link_to 'Show', forum %></td>
<td>< %= link_to 'Edit', edit_forum_path(forum) %></td>
<td>< %= link_to 'Destroy', forum, method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
< % end %>
</table>
<br /> -->

File diff suppressed because it is too large Load Diff

@ -103,7 +103,7 @@ module Redmine
end
if provider_options.has_key?(:permission)
user1 = User.find_by_login('user')
user1 = User.find_by_admin(true)
scope = scope.scoped(:conditions => Project.allowed_to_condition(user1, provider_options[:permission] || :view_project, options))
elsif respond_to?(:visible)
scope = scope.visible(user1, options)

@ -203,7 +203,7 @@ Redmine::MenuManager.map :top_menu do |menu|
menu.push :software_user, {:controller => 'users', :action => 'index'}
menu.push :contest_innovate, {:controller => 'bids', :action => 'contest', :project_type => 1}
menu.push :requirement_enterprise, {:controller => 'bids', :action => 'index'}
menu.push :project_module_forums, {:controller => 'forums', :action => 'index'}
menu.push :project_module_forums, :forums_path
# menu.push :investor, :home_path

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@ -155,7 +155,7 @@ li {
color: #999999;
background: center -1px no-repeat;
line-height: 20px;
padding: 0px 9px;
padding: 5px 5px 0px 9px;
width: 440px;
cursor: pointer;
font: 12px/1.5 tahoma,arial,\5b8b\4f53;
@ -191,6 +191,19 @@ p.layout {
margin-bottom: 6px;
}
.avatar-3 {
width: 40px;
height: 40px;
margin-top: 5px;
}
.message-brief-intro .gray{
color: gray;
}
.avatar-4 {
width: 45px;
height: 45px;
}
/*p.clr, .clr { clear:both; padding:0; margin:0; background:none;}*/

Loading…
Cancel
Save