修改了用户活动,可以查看关注好友的活动,并且将需求加入到活动中

修复了一些需求中的BUG
This commit is contained in:
fanqiang 2013-08-05 22:47:01 +08:00
parent c3f81ba00e
commit bb5052cf30
17 changed files with 920 additions and 842 deletions

View File

@ -1,5 +1,4 @@
# fq
class BidsController < ApplicationController
before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add]
@ -11,8 +10,13 @@ class BidsController < ApplicationController
@limit = 5
@bid_count = Bid.count
@bid_pages = Paginator.new @bid_count, @limit, params['page']
@offset ||= @bid_pages.offset
@bids = Bid.offset(@offset).limit(@limit).all
@offset ||= @bid_pages.reverse_offset
unless @offset == 0
@bids = Bid.offset(@offset).limit(@limit).all.reverse
else
limit = @bid_count%@limit
@bids = Bid.offset(@offset).limit(limit).all.reverse
end
end
@ -165,8 +169,8 @@ class BidsController < ApplicationController
private
def find_bid
if params[:bid_id]
@bid = Bid.find(params[:bid_id])
if params[:id]
@bid = Bid.find(params[:id])
end
rescue
render_404

View File

@ -35,7 +35,6 @@ class UsersController < ApplicationController
### added by william
include ActsAsTaggableOn::TagsHelper
helper :watchers
helper :activities
@ -74,14 +73,19 @@ class UsersController < ApplicationController
end
end
# added by fq
def user_activities
#####fq
# @message = MessagesForUser.find_message(@user.id)
# @message = MessagesForUser.find_message(@user.id)
# show projects based on current user visibility
# @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
# @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
@watcher = User.watched_by_id(@user)
events = []
for user in @watcher
events << Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 30)
end
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 30)
@events_by_day = events.group_by(&:event_date)
unless User.current.admin?
@ -96,6 +100,7 @@ class UsersController < ApplicationController
format.api
end
end
# end
def user_newfeedback
@jour = @user.journals_for_messages
@ -107,6 +112,7 @@ class UsersController < ApplicationController
def user_comments
end
#end
def index
sort_init 'login', 'asc'
@ -125,7 +131,6 @@ class UsersController < ApplicationController
}
# @count = Redmine::Activity::Fetcher.new(User.current, :author => @user).scope_select {|t| !has["show_#{t}"].nil?}.events(nil, nil).count
scope = User.logged.status(@status)
scope = scope.like(params[:name]) if params[:name].present?
scope = scope.in_group(params[:group_id]) if params[:group_id].present?
@ -144,13 +149,23 @@ class UsersController < ApplicationController
end
end
### modified by fq
def show
#####fq
@message = MessagesForUser.find_message(@user.id)
# show projects based on current user visibility
@memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
if @user == User.current
events = []
events += Redmine::Activity::Fetcher.new(User.current, :author => User.current).events(nil, nil, :limit => 10)
@watcher = User.watched_by(@user)
for user in @watcher
events += Redmine::Activity::Fetcher.new(User.current, :author => user).events(nil, nil, :limit => 10)
end
else
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
end
@events_by_day = events.group_by(&:event_date)
unless User.current.admin?
@ -166,6 +181,8 @@ class UsersController < ApplicationController
end
end
##end fq
def new
@user = User.new(:language => Setting.default_language, :mail_notification => Setting.default_notification_option)
@auth_sources = AuthSource.all

View File

@ -16,9 +16,29 @@ class Bid < ActiveRecord::Base
# validates_format_of :deadline, :with =>
validate :validate_user
scope :visible, lambda {|*args|
nil
}
scope :like, lambda {|arg|
if arg.blank?
where(nil)
else
pattern = "%#{arg.to_s.strip.downcase}%"
where("LOWER(identifier) LIKE :p OR LOWER(name) LIKE :p OR LOWER(description) LIKE :p", :p => pattern)
end
}
acts_as_watchable
acts_as_taggable
acts_as_event :title => Proc.new {|o| "#{l(:label_requirement)} ##{o.id}: #{o.name}" },
:description => :description,
:author => :author,
:url => Proc.new {|o| {:controller => 'bids', :action => 'show', :id => o.id}}
acts_as_activity_provider :find_options => {:include => [:author]},
:author_key => :author_id
def add_jour(user, notes)
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes)

View File

@ -3,7 +3,7 @@
<td width="100px" class="font_lighter" style="font-size: 16px;">需求列表</td>
<td>
<div class='icon icon-add' >
<%= toggle_link l(:button_bidding), 'put-bid-form', {:focus => 'project_id'} %>
<%= toggle_link l(:button_new_bid), 'put-bid-form', {:focus => 'project_id'} %>
</div></td>
</table>
@ -27,7 +27,7 @@
<td class="font_lighter">(<%= link_to bid.watcher_users.count, respond_path(bid)%>)关注</td>
</tr>
</table></td>
<td width="200" align="right" class="a"><a class="font_lighter"> <%= format_time bid.created_at %></a></td>
<td width="200" align="right" class="a"><a class="font_lighter"> <%= format_time bid.created_on %></a></td>
</tr>
<tr>
<td>

View File

@ -20,6 +20,11 @@
<% end %>
<% end %><td>
</tr></table>
<div id='leave-message'>
<%= render :partial => 'new', :locals => {:bid => @bid, :sta => @state} %>
</div>
<% unless state%>
<% if journals.size > 5 %>
<% journals = journals[0, 5] %>

View File

@ -11,6 +11,6 @@ border-top: 2px solid #acaeb1; border-bottom: 2px solid #acaeb1;">
</tr></table>
<table border="0" width="525px" align="center">
<tr><td align="right"><%= submit_tag l(:button_leave_meassge), :name => nil %>
<%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('user_message_message');", :type => 'button' %></td></tr>
<%= submit_tag l(:button_clear), :name => nil, :onclick => "clearMessage('bid_message_message');", :type => 'button' %></td></tr>
</table>
<% end %>

View File

@ -1,4 +1,9 @@
<!-- fq -->
<table width="200px" border="0" style="padding-left: 15px">
<td class="font_lighter" style="font-size: 18px;">应标项目(<%= @bidding_project.count%>)</td>
</table>
<% @bidding_project.each do |b_project|%>
<table width="90%" border="0" align='center'>
<tr>

View File

@ -20,12 +20,12 @@
<tr><td style="font-size: 15px; color: rgb(0,0,0);"><%= @bid.description %></td></tr>
</table>
</div>
<!-- added by fq -->
<div id="history">
<%= render :partial => 'history', :locals => { :bid => @bid, :journals => @jour, :state => false} %>
</div>
<div id='leave-message'>
<%= render :partial => 'new', :locals => {:bid => @bid, :sta => @state} %>
</div>
<!-- end -->

View File

@ -27,9 +27,6 @@ border-top: 1px solid #acaeb1; border-bottom: 1px solid #acaeb1; margin-left: 45
<% end %>
</div>
<table width="200px" border="0" style="padding-left: 15px">
<td class="font_lighter" style="font-size: 18px;">应标项目(<%= @bidding_project.count%>)</td>
</table>
<div id='bidding_project_list'>
<%= render :partial => 'project_list', :locals => {:bidding_project => @bidding_project} %>
</div>

View File

@ -1,17 +1,26 @@
<% unless @events_by_day.empty? %>
<div id="activity">
<% @events_by_day.keys.sort.reverse.each do |day| %>
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<table width="660" border="0" align="left">
<% @events_by_day.keys.sort.reverse.each do |day| %>
<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%>
<table width="660" border="0" align="left" style="border-bottom: 1px solid rgb(225, 225, 225); margin-bottom: 10px;">
<tr>
<td colspan="2" valign="top" width="50" ><img src="/images/new/news.png" width="40" height="40"/></td>
<td><table width="580" border="0">
<!-- fq -->
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(e.event_author), :class => "avatar"), user_path(e.event_author), :class => "avatar" %></td>
<td>
<table width="580" border="0">
<tr>
<td colspan="2" valign="top"><strong> <%= content_tag('span', h(e.project), :class => 'project') %></strong> <span class="font_lighter">有了最新动态</span> <%= link_to format_activity_title(e.event_title), e.event_url %></td>
<% if e.event_author == User.current%>
<td colspan="2" valign="top"><strong> <%= link_to("我", user_path(e.event_author)) %></strong><span class="font_lighter">有了最新动态</span> <%= link_to format_activity_title(e.event_title), e.event_url %></td>
<% else %>
<td colspan="2" valign="top"><strong> <%= link_to(h(e.event_author), user_path(e.event_author)) %></strong><span class="font_lighter">有了最新动态</span> <%= link_to format_activity_title(e.event_title), e.event_url %></td>
<% end %>
</tr>
<tr>
<td colspan="2" width="580" ><p class="font_description"><%= textilizable e.event_description %></p></td>
<td colspan="2" width="580" >
<p class="font_description">
<%= textilizable e.event_description %>
</p></td>
</tr>
<tr>
<td align="left"><a class="font_lighter"></a></td>
@ -21,6 +30,7 @@
</table></td>
</tr>
<% end %>
</table><% end %>
</table>
<% end %>
</div>
<% end %>

View File

@ -1,3 +1,5 @@
<!-- fq -->
<table width="200px" border="0" style="padding-left: 10px; margin-bottom: 15px;">
<td class="font_lighter" style="font-size: 18px;">需求列表</td>
</table>
@ -22,7 +24,7 @@
<td class="font_lighter">(<%= bid.watcher_users.count%>)关注</td>
</tr>
</table></td>
<td width="200" align="right" class="a"><a class="font_lighter"> <%= format_time bid.created_at %></a></td>
<td width="200" align="right" class="a"><a class="font_lighter"> <%= format_time bid.created_on %></a></td>
</tr>
<tr>
<td>

View File

@ -412,13 +412,13 @@ RedmineApp::Application.routes.draw do
delete 'bids/destroy', :to => 'bids#destroy'
get 'bids/more', :to => 'bids#more'
get 'bids/back', :to=> 'bids#back'
match 'bids/:bid_id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid'
match 'bids/:bid_id/add', :controller => 'bids', :action => 'add'
match 'bids/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid'
match 'bids/:id/add', :controller => 'bids', :action => 'add'
match 'bids/new_bid', :controller => 'bids', :action => 'new_bid'
# added by young
match 'bids', :controller => 'bids', :action => 'index'
match 'bids/:bid_id/show', :controller => 'bids', :action => 'show', :as => 'respond'
match 'bids/:id', :controller => 'bids', :action => 'show', :as => 'respond'
match 'bids/new', :controller => 'bids', :action => 'new', :via => [:get , :post]

View File

@ -0,0 +1,4 @@
class ChangeTimetempInBidTable < ActiveRecord::Migration
rename_column :bids, :created_at, :created_on
rename_column :bids, :updated_at, :updated_on
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130802011758) do
ActiveRecord::Schema.define(:version => 20130805131602) do
create_table "a_user_watchers", :force => true do |t|
t.string "name"
@ -83,8 +83,8 @@ ActiveRecord::Schema.define(:version => 20130802011758) do
t.integer "author_id"
t.date "deadline"
t.string "description"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_on", :null => false
t.datetime "updated_on", :null => false
t.integer "commit"
end

View File

@ -282,6 +282,9 @@ Redmine::Activity.map do |activity|
activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false
activity.register :messages, :default => false
activity.register :time_entries, :default => false
# added by fq
activity.register :bids, :class_name => 'Bid'
# end
end
Redmine::Search.map do |search|

View File

@ -42,6 +42,17 @@ module Redmine
(page - 1) * per_page
end
## fq
def reverse_offset
offset = @item_count-@per_page*page
if offset < 0
offset = 0
end
offset
end
## end
def first_page
if item_count > 0
1