parent
c3f81ba00e
commit
bb5052cf30
|
@ -1,18 +1,22 @@
|
|||
# fq
|
||||
|
||||
class BidsController < ApplicationController
|
||||
|
||||
before_filter :find_bid, :only => [:show, :show_project, :create, :destroy, :more, :back, :add]
|
||||
|
||||
helper :watchers
|
||||
def index
|
||||
|
||||
|
||||
# @requirement_title = "4"
|
||||
@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
|
||||
|
||||
|
@ -98,7 +102,7 @@ class BidsController < ApplicationController
|
|||
# @message_count = a_message.count
|
||||
|
||||
respond_to do |format|
|
||||
# format.html
|
||||
# format.html
|
||||
format.js
|
||||
#format.api { render_api_ok }
|
||||
end
|
||||
|
@ -132,7 +136,7 @@ class BidsController < ApplicationController
|
|||
@bids = Bid.offset(@offset).limit(@limit).all
|
||||
respond_to do |format|
|
||||
# format.html
|
||||
format.html { redirect_to :back }
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
# format.api { render_api_ok }
|
||||
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
|
||||
|
|
|
@ -26,15 +26,14 @@ class UsersController < ApplicationController
|
|||
helper :custom_fields
|
||||
include CustomFieldsHelper
|
||||
include AvatarHelper
|
||||
|
||||
# added by liuping 关注
|
||||
|
||||
|
||||
# added by liuping 关注
|
||||
|
||||
helper :watchers
|
||||
helper :activities
|
||||
|
||||
### added by william
|
||||
include ActsAsTaggableOn::TagsHelper
|
||||
|
||||
|
||||
helper :watchers
|
||||
helper :activities
|
||||
|
@ -61,7 +60,7 @@ class UsersController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
##added by fq
|
||||
def watch_bids
|
||||
@bid = Bid.watched_by(@user)
|
||||
|
@ -73,15 +72,20 @@ class UsersController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def user_activities
|
||||
#####fq
|
||||
# @message = MessagesForUser.find_message(@user.id)
|
||||
# show projects based on current user visibility
|
||||
# @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
||||
|
||||
events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 30)
|
||||
# added by fq
|
||||
def user_activities
|
||||
#####fq
|
||||
# @message = MessagesForUser.find_message(@user.id)
|
||||
# show projects based on current user visibility
|
||||
# @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_by_day = events.group_by(&:event_date)
|
||||
|
||||
unless User.current.admin?
|
||||
|
@ -96,17 +100,19 @@ class UsersController < ApplicationController
|
|||
format.api
|
||||
end
|
||||
end
|
||||
|
||||
# end
|
||||
|
||||
def user_newfeedback
|
||||
@jour = @user.journals_for_messages
|
||||
@jour = @user.journals_for_messages
|
||||
@jour.each_with_index {|j,i| j.indice = i+1}
|
||||
@state = false
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
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 = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 10)
|
||||
@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
|
||||
|
|
|
@ -1,58 +1,78 @@
|
|||
####by fq
|
||||
class Bid < ActiveRecord::Base
|
||||
#attr_accessible :author_id, :budget, :deadline, :name, :description
|
||||
|
||||
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => :author_id
|
||||
has_many :biding_projects, :dependent => :destroy
|
||||
has_many :projects, :through => :biding_projects
|
||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||
|
||||
|
||||
NAME_LENGTH_LIMIT = 60
|
||||
DESCRIPTION_LENGTH_LIMIT = 250
|
||||
|
||||
|
||||
validates_length_of :name, :maximum => NAME_LENGTH_LIMIT
|
||||
validates_length_of :description, :maximum => DESCRIPTION_LENGTH_LIMIT
|
||||
validates_presence_of :author_id, :name, :deadline
|
||||
# validates_format_of :deadline, :with =>
|
||||
# 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)
|
||||
end
|
||||
|
||||
|
||||
def self.creat_bids(budget, deadline, name, description=nil)
|
||||
self.create(:author_id => User.current.id, :budget => budget,
|
||||
:deadline => deadline, :name => name, :description => description, :commit => 0)
|
||||
:deadline => deadline, :name => name, :description => description, :commit => 0)
|
||||
end
|
||||
|
||||
def update_bids(budget, deadline, name, description=nil)
|
||||
if(User.current.id == self.author_id)
|
||||
self.name = name
|
||||
self.budget = budget
|
||||
self.deadline = deadline
|
||||
self.description = description
|
||||
self.save
|
||||
end
|
||||
self.name = name
|
||||
self.budget = budget
|
||||
self.deadline = deadline
|
||||
self.description = description
|
||||
self.save
|
||||
end
|
||||
end
|
||||
|
||||
def delete_bids
|
||||
unless self.nil?
|
||||
if User.current.id == self.author_id
|
||||
self.destroy
|
||||
end
|
||||
end
|
||||
self.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def set_commit(commit)
|
||||
self.update_attribute(:commit, commit)
|
||||
self.update_attribute(:commit, commit)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
||||
def validate_user
|
||||
errors.add :author_id, :invalid if author.nil? || !author.active?
|
||||
end
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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] %>
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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 -->
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,26 +1,36 @@
|
|||
|
||||
<% 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">
|
||||
<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">
|
||||
<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>
|
||||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_activity_day(day) %></span></td>
|
||||
</tr>
|
||||
<!-- <tr><div class="line_under"></div></tr> -->
|
||||
</table></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table><% end %>
|
||||
<% @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>
|
||||
<!-- 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>
|
||||
<% 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>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="left"><a class="font_lighter"></a></td>
|
||||
<td width="200" align="right" class="a"><span class="font_lighter"><%= format_activity_day(day) %></span></td>
|
||||
</tr>
|
||||
<!-- <tr><div class="line_under"></div></tr> -->
|
||||
</table></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
class ChangeTimetempInBidTable < ActiveRecord::Migration
|
||||
rename_column :bids, :created_at, :created_on
|
||||
rename_column :bids, :updated_at, :updated_on
|
||||
end
|
1514
db/schema.rb
1514
db/schema.rb
File diff suppressed because it is too large
Load Diff
|
@ -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|
|
||||
|
|
|
@ -70,7 +70,7 @@ module Redmine
|
|||
def events(from = nil, to = nil, options={})
|
||||
e = []
|
||||
@options[:limit] = options[:limit]
|
||||
|
||||
|
||||
@scope.each do |event_type|
|
||||
constantized_providers(event_type).each do |provider|
|
||||
e += provider.find_events(event_type, @user, from, to, @options)
|
||||
|
|
|
@ -41,7 +41,18 @@ module Redmine
|
|||
def offset
|
||||
(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
|
||||
|
|
Loading…
Reference in New Issue