From 074e8adfddfb8d12a150da1f6d9f2601dafef623 Mon Sep 17 00:00:00 2001 From: baiyu <316257774@qq.com> Date: Thu, 22 Aug 2013 20:26:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9C=80=E6=B1=82=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=9A=84=E4=B8=80=E4=BA=9B=E7=BB=86=E8=8A=82=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E7=9A=84=E6=9D=83=E9=99=90=EF=BC=8C=E7=8E=B0=E5=9C=A8=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E9=97=AE=E9=A2=98=E7=9A=84=E8=A7=92=E8=89=B2=E5=8C=85?= =?UTF-8?q?=E6=8B=AC=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98=EF=BC=8C?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=EF=BC=8C=E9=97=AE=E9=A2=98=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E8=80=85=EF=BC=8C=E9=97=AE=E9=A2=98=E6=8C=87=E6=B4=BE?= =?UTF-8?q?=E4=BA=BA=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/bids_controller.rb | 5 +++++ app/controllers/issues_controller.rb | 9 ++++++++- app/models/project_info.rb | 11 ++++++++++- app/views/bids/_bid_show.html.erb | 4 ++-- app/views/bids/_history.html.erb | 2 +- app/views/bids/index.html.erb | 2 +- app/views/bids/show.html.erb | 4 ++-- app/views/issues/_edit.html.erb | 2 +- app/views/layouts/base_bids.html.erb | 2 +- config/routes.rb | 24 ++++++++++++------------ 10 files changed, 43 insertions(+), 22 deletions(-) diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 73e9b4ab8..43b24d1e0 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -228,6 +228,11 @@ class BidsController < ApplicationController @bid.author_id = User.current.id @bid.commit = 0 if @bid.save + unless @bid.watched_by?(User.current) + if @bid.add_watcher(User.current) + flash[:notice] = l(:label_bid_succeed) + end + end redirect_to respond_path(@bid) else @bid.safe_attributes = params[:bid] diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 605d78b26..33193f300 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -114,7 +114,14 @@ class IssuesController < ApplicationController @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } @allowed_statuses = @issue.new_statuses_allowed_to(User.current) - @edit_allowed = User.current.allowed_to?(:edit_issues, @project) + # @edit_allowed = User.current.allowed_to?(:edit_issues, @project) + if User.current.admin? || User.current.id == @issue.author_id || User.current.id == @issue.assigned_to_id || ProjectInfo.manager?(User.current.id, @project) + @edit_allowed = true + # elsif User.current.id == @issue.author.id + else + @edit_allowed = false + end + # @edit_allowed = User.current.allowed_to?(:edit_issues, @project) @priorities = IssuePriority.active @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) diff --git a/app/models/project_info.rb b/app/models/project_info.rb index 1327d2040..c6edab81c 100644 --- a/app/models/project_info.rb +++ b/app/models/project_info.rb @@ -1,8 +1,17 @@ class ProjectInfo < ActiveRecord::Base attr_accessible :project_id, :user_id - + belongs_to :project belongs_to :user validates_presence_of :project_id, :user_id validates_uniqueness_of :project_id, :scope => :user_id + + def self.manager? (user_id, project) + for project_info in project.project_infos + if project_info.user_id == user_id + return true + end + end + return false + end end diff --git a/app/views/bids/_bid_show.html.erb b/app/views/bids/_bid_show.html.erb index 36e8e9dd5..c033a7357 100644 --- a/app/views/bids/_bid_show.html.erb +++ b/app/views/bids/_bid_show.html.erb @@ -15,11 +15,11 @@ - + diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index e915dbd79..a59b0786f 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -2,7 +2,7 @@ <%= error_messages_for 'issue', 'time_entry' %> <%= render :partial => 'conflict' if @conflict %>
- <% if @edit_allowed || !@allowed_statuses.empty? %> + <% if @edit_allowed && !@allowed_statuses.empty? %>
<%= l(:label_change_properties) %>
<%= render :partial => 'form', :locals => {:f => f} %> diff --git a/app/views/layouts/base_bids.html.erb b/app/views/layouts/base_bids.html.erb index 6c0b7e77f..4e38fe754 100644 --- a/app/views/layouts/base_bids.html.erb +++ b/app/views/layouts/base_bids.html.erb @@ -49,7 +49,7 @@
<% if @bid.reward_type.nil? or @bid.reward_type == 1%> - + <% elsif @bid.reward_type == 2%> <% else %> diff --git a/config/routes.rb b/config/routes.rb index fb4184d76..f0e692fe3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -82,7 +82,7 @@ RedmineApp::Application.routes.draw do match 'user_projects', :to => 'users#user_projects', :via => :get, :as => "user_projects" match 'user_activities', :to => 'users#show', :via => :get, :as => "user_activities" match 'user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "user_newfeedback" - match 'watch_bids', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] + match 'watch_calls', :controller => 'users', :action => 'watch_bids', :via => [:get , :post] match 'info', :to => 'users#info', :via => [:get , :post], :as => 'user_info' match 'user_watchlist', :to => 'users#user_watchlist', :via => :get, :as => "user_watchlist" #add by huang match 'user_fanslist', :to => 'users#user_fanslist', :via => :get, :as => "user_fanslist" #add by huang @@ -429,23 +429,23 @@ RedmineApp::Application.routes.draw do get 'words/more', :to => 'words#more' get 'words/back', :to=> 'words#back' ############## fq - post 'bids/create', :to => 'bids#create' - delete 'bids/destroy', :to => 'bids#destroy' - match 'bids/new', :controller => 'bids', :action => 'new', :via => [:get , :post] - get 'bids/more', :to => 'bids#more' - get 'bids/back', :to=> 'bids#back' - match 'bids/new_bid', :controller => 'bids', :action => 'new_bid' - match 'bids/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' - match 'bids/:id/add', :controller => 'bids', :action => 'add' + post 'calls/create', :to => 'bids#create' + delete 'calls/destroy', :to => 'bids#destroy' + match 'calls/new', :controller => 'bids', :action => 'new', :via => [:get , :post] + get 'calls/more', :to => 'bids#more' + get 'calls/back', :to=> 'bids#back' + match 'calls/new_bid', :controller => 'bids', :action => 'new_bid' + match 'calls/:id/show_project', :controller => 'bids', :action => 'show_project', :as => 'project_for_bid' + match 'calls/:id/add', :controller => 'bids', :action => 'add' match 'words/add_project_respond', :controller => 'words', :action => 'add_project_respond' match 'projects/:id/feedback', :to => 'projects#feedback', :via => :get, :as => 'project_feedback' - match 'bids/create_bid', :to => 'bids#create_bid' + match 'calls/create_bid', :to => 'bids#create_bid' ## 测试用 # match 'test/index', :controller => 'test', :action => 'index' # added by young - match 'bids', :controller => 'bids', :action => 'index' + match 'calls', :controller => 'bids', :action => 'index' - match 'bids/:id', :controller => 'bids', :action => 'show', :as => 'respond' + match 'calls/:id', :controller => 'bids', :action => 'show', :as => 'respond' ######added by nie match 'tags/show_projects_tags',:to => 'tags#show_projects_tags'
<% if bid.reward_type.nil? or bid.reward_type == 1%> - <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= bid.budget%><%= l(:label_RMB_sign) %> + <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%> <% elsif bid.reward_type == 2%> <%= l(:label_bids_reward_method) %><%= bid.budget%> <% else %> - <%= l(:label_bids_reward_method) %><%= l(:label_bids_grade) %> <%= bid.budget%><%= l(:label_bids_grade_number) %> + <%= l(:label_bids_reward_method) %><%= l(:label_bids_grade) %> <%= bid.budget%><%= l(:label_bids_grade_number) %> <% end %> (<%= link_to bid.biding_projects.count, project_for_bid_path(bid)%>)<%= l(:label_biding_project) %> (<%= link_to bid.commit, respond_path(bid)%>)<%= l(:label_responses) %> diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb index 00ad850fd..ebb047089 100644 --- a/app/views/bids/_history.html.erb +++ b/app/views/bids/_history.html.erb @@ -24,7 +24,7 @@

<%= textilizable journal.notes%>

<%= journal.created_on %>发布于 <%= time_tag(journal.created_on).html_safe %>之前 <%= link_to(image_tag('comment.png'), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true, :method => 'post', :title => l(:button_quote))%> <%= link_to(image_tag('delete.png'), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm), diff --git a/app/views/bids/index.html.erb b/app/views/bids/index.html.erb index e0b9139e3..32ab5e1b1 100644 --- a/app/views/bids/index.html.erb +++ b/app/views/bids/index.html.erb @@ -1,5 +1,5 @@ -<%= form_tag(bids_path, :method => :get) do %> +<%= form_tag(calls_path, :method => :get) do %>
diff --git a/app/views/bids/show.html.erb b/app/views/bids/show.html.erb index 4313cfb1d..a99f75ab6 100644 --- a/app/views/bids/show.html.erb +++ b/app/views/bids/show.html.erb @@ -8,11 +8,11 @@ <% if @bid.reward_type.nil? or @bid.reward_type == 1%> - + <% elsif @bid.reward_type == 2%> <% else %> - + <% end %>
<%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= @bid.budget%><%= l(:label_RMB_sign) %><%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= @bid.budget%><%= l(:label_bids_reward_method) %><%= @bid.budget%><%= l(:label_bids_reward_method) %><%= l(:label_bids_grade) %> <%= @bid.budget%><%= l(:label_bids_grade_number) %><%= l(:label_bids_reward_method) %><%= l(:label_bids_grade) %> <%= @bid.budget%><%= l(:label_bids_grade_number) %>
<%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= @bid.budget%><%= l(:label_RMB_sign) %><%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= @bid.budget%><%= l(:label_bids_reward_method) %><%= @bid.budget%>