]> source.dussan.org Git - redmine.git/commitdiff
"me" value is now available in queries for "assigned to" and "author" filters.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 8 May 2007 12:46:15 +0000 (12:46 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 8 May 2007 12:46:15 +0000 (12:46 +0000)
When executing the query, it is replaced by the currently logged in user.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@520 e93f8b46-1217-0410-a6f0-8f06a7374b81

14 files changed:
app/controllers/feeds_controller.rb
app/controllers/projects_controller.rb
app/controllers/queries_controller.rb
app/models/query.rb
lang/bg.yml
lang/de.yml
lang/en.yml
lang/es.yml
lang/fr.yml
lang/it.yml
lang/ja.yml
lang/pt-br.yml
lang/pt.yml
lang/zh.yml

index 9314db5e30cc296c33a689116df25a699b5e2523..214f80c952e5dce2d56a57c9ac95f4de2b1b56ff 100644 (file)
@@ -37,6 +37,7 @@ class FeedsController < ApplicationController
   def issues
     if @project && params[:query_id]
       query = Query.find(params[:query_id])
+      query.executed_by = @user
       # ignore query if it's not valid
       query = nil unless query.valid?
       # override with query conditions
@@ -56,6 +57,7 @@ class FeedsController < ApplicationController
   def history    
     if @project && params[:query_id]
       query = Query.find(params[:query_id])
+      query.executed_by = @user
       # ignore query if it's not valid
       query = nil unless query.valid?
       # override with query conditions
index 82468c21a7b8465e016df453f0979e5df8b3e28a..e901964955e4501e532f05d2cbdade317cbe392d 100644 (file)
@@ -647,11 +647,12 @@ private
   def retrieve_query
     if params[:query_id]
       @query = @project.queries.find(params[:query_id])
+      @query.executed_by = logged_in_user
       session[:query] = @query
     else
       if params[:set_filter] or !session[:query] or session[:query].project_id != @project.id
         # Give it a name, required to be valid
-        @query = Query.new(:name => "_")
+        @query = Query.new(:name => "_", :executed_by => logged_in_user)
         @query.project = @project
         if params[:fields] and params[:fields].is_a? Array
           params[:fields].each do |field|
index 7f7f01fd3d030d121a95acf9ae8ff550ed6d0256..abafd19d47ad29f30d159efe718273936a883c68 100644 (file)
@@ -42,6 +42,7 @@ class QueriesController < ApplicationController
 private
   def find_query
     @query = Query.find(params[:id])
+    @query.executed_by = logged_in_user
     @project = @query.project
     # check if user is allowed to manage queries (same permission as add_query)
     authorize('projects', 'add_query')
index e26e6a68e30848350170530c24bfe7e84c4d8ab3..026e79ea922b10368cabdc1d2981836f8e0aa256 100644 (file)
@@ -21,6 +21,7 @@ class Query < ActiveRecord::Base
   serialize :filters
   
   attr_protected :project, :user
+  attr_accessor :executed_by
   
   validates_presence_of :name, :on => :save
     
@@ -59,6 +60,11 @@ class Query < ActiveRecord::Base
     self.is_public = true
   end
   
+  def executed_by=(user)
+    @executed_by = user
+    set_language_if_valid(user.language) if user
+  end
+  
   def validate
     filters.each_key do |field|
       errors.add label_for(field), :activerecord_error_blank unless 
@@ -81,8 +87,12 @@ class Query < ActiveRecord::Base
                            "due_date" => { :type => :date, :order => 12 } }                          
     unless project.nil?
       # project specific filters
-      @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => @project.users.collect{|s| [s.name, s.id.to_s] } }  
-      @available_filters["author_id"] = { :type => :list, :order => 5, :values => @project.users.collect{|s| [s.name, s.id.to_s] } }  
+      user_values = []
+      user_values << ["<< #{l(:label_me)} >>", "me"] if executed_by
+      user_values += @project.users.collect{|s| [s.name, s.id.to_s] }
+      
+      @available_filters["assigned_to_id"] = { :type => :list_optional, :order => 4, :values => user_values }  
+      @available_filters["author_id"] = { :type => :list, :order => 5, :values => user_values }  
       @available_filters["category_id"] = { :type => :list_optional, :order => 6, :values => @project.issue_categories.collect{|s| [s.name, s.id.to_s] } }
       @available_filters["fixed_version_id"] = { :type => :list_optional, :order => 7, :values => @project.versions.collect{|s| [s.name, s.id.to_s] } }
       unless @project.children.empty?
@@ -162,7 +172,7 @@ class Query < ActiveRecord::Base
     end
     filters.each_key do |field|
       next if field == "subproject_id"
-      v = values_for field
+      v = values_for(field).clone
       next unless v and !v.empty?
         
       sql = sql + " AND " unless sql.empty?      
@@ -179,6 +189,11 @@ class Query < ActiveRecord::Base
         db_field = field
       end
       
+      # "me" value subsitution
+      if %w(assigned_to_id author_id).include?(field)
+        v.push(executed_by ? executed_by.id.to_s : "0") if v.delete("me")
+      end
+      
       case operator_for field
       when "="
         sql = sql + "#{db_table}.#{db_field} IN (" + v.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")"
index e63672cdbb149388e029ff60d82a8dda4be2b56e..fb8e4b8dc540ed1473115661c6c9268c6cfbfc5e 100644 (file)
@@ -384,6 +384,7 @@ label_start_to_end: start to end
 label_stay_logged_in: Stay logged in
 label_disabled: disabled
 label_show_completed_versions: Show completed versions
+label_me: me
 
 button_login: Вход
 button_submit: Изпращане
index 3b3ef2af29c2728bbbef06d0bd8361f7a0a8fe47..fa4125391e8f6e83f3fc1c5723c4dd4d0be9c678 100644 (file)
@@ -384,6 +384,7 @@ label_start_to_end: start to end
 label_stay_logged_in: Stay logged in
 label_disabled: disabled
 label_show_completed_versions: Show completed versions
+label_me: me
 
 button_login: Einloggen
 button_submit: OK
index 887ce699240f6e5d601cbce3d9d852f8e76e89b7..2e1ff6e1b0f1289e3afe9bc66daf9dd5aeedbc77 100644 (file)
@@ -384,6 +384,7 @@ label_start_to_end: start to end
 label_stay_logged_in: Stay logged in
 label_disabled: disabled
 label_show_completed_versions: Show completed versions
+label_me: me
 
 button_login: Login
 button_submit: Submit
index 78ade511d153a6d1a48be9a1ae5cb1313a1b86de..56d251426eb88d2f8f9f524177d3a8b914da9cea 100644 (file)
@@ -384,6 +384,7 @@ label_start_to_end: start to end
 label_stay_logged_in: Stay logged in
 label_disabled: disabled
 label_show_completed_versions: Show completed versions
+label_me: me
 
 button_login: Conexión
 button_submit: Someter
index f843a64add2d73ca51c87044cfde0ca87d52221b..3da0c1cefab3cf2c4e20eb579bfef2d281f91f74 100644 (file)
@@ -384,6 +384,7 @@ label_start_to_end: début à fin
 label_stay_logged_in: Rester connecté
 label_disabled: désactivé
 label_show_completed_versions: Voire les versions passées
+label_me: moi
 
 button_login: Connexion
 button_submit: Soumettre
index ce70d9b23f213fa132dc64b076c081a1c65c4d30..1f61077c927b51e0f4d67aba87dd894ea0e6a42b 100644 (file)
@@ -384,6 +384,7 @@ label_start_to_end: start to end
 label_stay_logged_in: Stay logged in
 label_disabled: disabled
 label_show_completed_versions: Show completed versions
+label_me: me
 
 button_login: Login
 button_submit: Invia
index 4066e869b65efffddbf272c5df3a86c0a9e45bbf..45acde36900ad19a8752ea6c8f47def2a36db5e3 100644 (file)
@@ -385,6 +385,7 @@ label_start_to_end: start to end
 label_stay_logged_in: Stay logged in
 label_disabled: disabled
 label_show_completed_versions: Show completed versions
+label_me: me
 
 button_login: ログイン
 button_submit: 変更
index 5a2e9f5cdf42099ac078a9ed42341b6fc18685a6..6f127a4caf5ec0df2fb18c8221171a6322b9f192 100644 (file)
@@ -384,6 +384,7 @@ label_start_to_end: start to end
 label_stay_logged_in: Stay logged in\r
 label_disabled: disabled\r
 label_show_completed_versions: Show completed versions\r
+label_me: me\r
 \r
 button_login: Login\r
 button_submit: Enviar\r
index 25fc40a3b5b9a7d8fa0bc0d550ef2730fb57421d..0809b3588b55f986920f5a646db5d6b0eeff7add 100644 (file)
@@ -384,6 +384,7 @@ label_start_to_end: inícia ao fim
 label_stay_logged_in: Rester connecté
 label_disabled: désactivé
 label_show_completed_versions: Voire les versions passées
+label_me: me
 
 button_login: Login
 button_submit: Enviar
index bf3469679feb5220e371f57767525d9250946041..4e8e3f38b5a0c7c4c216b95f29c0f0e9f88a0002 100644 (file)
@@ -387,6 +387,7 @@ label_start_to_end: start to end
 label_stay_logged_in: Stay logged in
 label_disabled: disabled
 label_show_completed_versions: Show completed versions
+label_me: me
 
 button_login: 登录
 button_submit: 提交