@@ -0,0 +1,29 | |||
|
1 | <div class="contextual"> | |
|
2 | <% if loggedin? %> | |
|
3 | <%= link_to l(:label_query_new), {:controller => 'queries', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> | |
|
4 | <% end %> | |
|
5 | </div> | |
|
6 | ||
|
7 | <h2><%= l(:label_query_plural) %></h2> | |
|
8 | ||
|
9 | <% if @queries.empty? %> | |
|
10 | <p><i><%=l(:label_no_data)%></i></p> | |
|
11 | <% else %> | |
|
12 | <table class="list"> | |
|
13 | <% @queries.each do |query| %> | |
|
14 | <tr class="<%= cycle('odd', 'even') %>"> | |
|
15 | <td> | |
|
16 | <%= link_to query.name, :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => query %> | |
|
17 | </td> | |
|
18 | <td align="right"> | |
|
19 | <small> | |
|
20 | <% if query.editable_by?(@logged_in_user) %> | |
|
21 | <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => query}, :class => 'icon icon-edit' %> | |
|
22 | <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
|
23 | </small> | |
|
24 | <% end %> | |
|
25 | </td> | |
|
26 | </tr> | |
|
27 | <% end %> | |
|
28 | </table> | |
|
29 | <% end %> |
@@ -0,0 +1,6 | |||
|
1 | <h2><%= l(:label_query_new) %></h2> | |
|
2 | ||
|
3 | <% form_tag({:action => 'new', :project_id => @query.project}) do %> | |
|
4 | <%= render :partial => 'form', :locals => {:query => @query} %> | |
|
5 | <%= submit_tag l(:button_save) %> | |
|
6 | <% end %> |
@@ -288,8 +288,7 class ProjectsController < ApplicationController | |||
|
288 | 288 | :conditions => @query.statement, |
|
289 | 289 | :limit => @issue_pages.items_per_page, |
|
290 | 290 | :offset => @issue_pages.current.offset |
|
291 |
end |
|
|
292 | @trackers = Tracker.find :all, :order => 'position' | |
|
291 | end | |
|
293 | 292 | render :layout => false if request.xhr? |
|
294 | 293 | end |
|
295 | 294 | |
@@ -400,22 +399,6 class ProjectsController < ApplicationController | |||
|
400 | 399 | end |
|
401 | 400 | end |
|
402 | 401 | |
|
403 | def add_query | |
|
404 | @query = Query.new(params[:query]) | |
|
405 | @query.project = @project | |
|
406 | @query.user = logged_in_user | |
|
407 | ||
|
408 | params[:fields].each do |field| | |
|
409 | @query.add_filter(field, params[:operators][field], params[:values][field]) | |
|
410 | end if params[:fields] | |
|
411 | ||
|
412 | if request.post? and @query.save | |
|
413 | flash[:notice] = l(:notice_successful_create) | |
|
414 | redirect_to :controller => 'reports', :action => 'issue_report', :id => @project | |
|
415 | end | |
|
416 | render :layout => false if request.xhr? | |
|
417 | end | |
|
418 | ||
|
419 | 402 | # Add a news to @project |
|
420 | 403 | def add_news |
|
421 | 404 | @news = News.new(:project => @project) |
@@ -1,5 +1,5 | |||
|
1 | 1 | # redMine - project management software |
|
2 | # Copyright (C) 2006 Jean-Philippe Lang | |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
@@ -16,9 +16,35 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class QueriesController < ApplicationController |
|
19 | layout 'base' | |
|
20 |
before_filter :require_login, : |
|
|
19 | layout 'base' | |
|
20 | before_filter :require_login, :except => :index | |
|
21 | before_filter :find_project, :check_project_privacy | |
|
21 | 22 | |
|
23 | def index | |
|
24 | @queries = @project.queries.find(:all, | |
|
25 | :order => "name ASC", | |
|
26 | :conditions => ["is_public = ? or user_id = ?", true, (logged_in_user ? logged_in_user.id : 0)]) | |
|
27 | end | |
|
28 | ||
|
29 | def new | |
|
30 | @query = Query.new(params[:query]) | |
|
31 | @query.project = @project | |
|
32 | @query.user = logged_in_user | |
|
33 | @query.executed_by = logged_in_user | |
|
34 | @query.is_public = false unless logged_in_user.authorized_to(@project, 'projects/add_query') | |
|
35 | ||
|
36 | params[:fields].each do |field| | |
|
37 | @query.add_filter(field, params[:operators][field], params[:values][field]) | |
|
38 | end if params[:fields] | |
|
39 | ||
|
40 | if request.post? and @query.save | |
|
41 | flash[:notice] = l(:notice_successful_create) | |
|
42 | redirect_to :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => @query | |
|
43 | return | |
|
44 | end | |
|
45 | render :layout => false if request.xhr? | |
|
46 | end | |
|
47 | ||
|
22 | 48 | def edit |
|
23 | 49 | if request.post? |
|
24 | 50 | @query.filters = {} |
@@ -26,6 +52,7 class QueriesController < ApplicationController | |||
|
26 | 52 | @query.add_filter(field, params[:operators][field], params[:values][field]) |
|
27 | 53 | end if params[:fields] |
|
28 | 54 | @query.attributes = params[:query] |
|
55 | @query.is_public = false unless logged_in_user.authorized_to(@project, 'projects/add_query') | |
|
29 | 56 | |
|
30 | 57 | if @query.save |
|
31 | 58 | flash[:notice] = l(:notice_successful_update) |
@@ -36,16 +63,19 class QueriesController < ApplicationController | |||
|
36 | 63 | |
|
37 | 64 | def destroy |
|
38 | 65 | @query.destroy if request.post? |
|
39 |
redirect_to :controller => ' |
|
|
66 | redirect_to :controller => 'queries', :project_id => @project | |
|
40 | 67 | end |
|
41 | 68 | |
|
42 | 69 | private |
|
43 |
def find_ |
|
|
44 | @query = Query.find(params[:id]) | |
|
45 | @query.executed_by = logged_in_user | |
|
46 | @project = @query.project | |
|
47 | # check if user is allowed to manage queries (same permission as add_query) | |
|
48 | authorize('projects', 'add_query') | |
|
70 | def find_project | |
|
71 | if params[:id] | |
|
72 | @query = Query.find(params[:id]) | |
|
73 | @query.executed_by = logged_in_user | |
|
74 | @project = @query.project | |
|
75 | render_403 unless @query.editable_by?(logged_in_user) | |
|
76 | else | |
|
77 | @project = Project.find(params[:project_id]) | |
|
78 | end | |
|
49 | 79 | rescue ActiveRecord::RecordNotFound |
|
50 | 80 | render_404 |
|
51 | 81 | end |
@@ -60,7 +60,6 class ReportsController < ApplicationController | |||
|
60 | 60 | @report_title = l(:field_subproject) |
|
61 | 61 | render :template => "reports/issue_report_details" |
|
62 | 62 | else |
|
63 | @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)] | |
|
64 | 63 | @trackers = Tracker.find(:all, :order => 'position') |
|
65 | 64 | @versions = @project.versions.sort |
|
66 | 65 | @priorities = Enumeration::get_values('IPRI') |
@@ -57,7 +57,6 class Query < ActiveRecord::Base | |||
|
57 | 57 | def initialize(attributes = nil) |
|
58 | 58 | super attributes |
|
59 | 59 | self.filters ||= { 'status_id' => {:operator => "o", :values => [""]} } |
|
60 | self.is_public = true | |
|
61 | 60 | end |
|
62 | 61 | |
|
63 | 62 | def executed_by=(user) |
@@ -75,6 +74,12 class Query < ActiveRecord::Base | |||
|
75 | 74 | end if filters |
|
76 | 75 | end |
|
77 | 76 | |
|
77 | def editable_by?(user) | |
|
78 | return false unless user | |
|
79 | return true if !is_public && self.user_id == user.id | |
|
80 | is_public && user.authorized_to(project, "projects/add_query") | |
|
81 | end | |
|
82 | ||
|
78 | 83 | def available_filters |
|
79 | 84 | return @available_filters if @available_filters |
|
80 | 85 | @available_filters = { "status_id" => { :type => :list_status, :order => 1, :values => IssueStatus.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] } }, |
@@ -125,10 +125,17 class User < ActiveRecord::Base | |||
|
125 | 125 | end |
|
126 | 126 | |
|
127 | 127 | def role_for_project(project) |
|
128 | return nil unless project | |
|
128 | 129 | member = memberships.detect {|m| m.project_id == project.id} |
|
129 | 130 | member ? member.role : nil |
|
130 | 131 | end |
|
131 | 132 | |
|
133 | def authorized_to(project, action) | |
|
134 | return true if self.admin? | |
|
135 | role = role_for_project(project) | |
|
136 | role && Permission.allowed_to_role(action, role) | |
|
137 | end | |
|
138 | ||
|
132 | 139 | def pref |
|
133 | 140 | self.preference ||= UserPreference.new(:user => self) |
|
134 | 141 | end |
@@ -77,6 +77,9 | |||
|
77 | 77 | <%= link_to l(:label_calendar), {:controller => 'projects', :action => 'calendar', :id => @project }, :class => "menuItem" %> |
|
78 | 78 | <%= link_to l(:label_gantt), {:controller => 'projects', :action => 'gantt', :id => @project }, :class => "menuItem" %> |
|
79 | 79 | <%= link_to l(:label_issue_plural), {:controller => 'projects', :action => 'list_issues', :id => @project }, :class => "menuItem" %> |
|
80 | <% if @project && authorize_for('projects', 'add_issue') %> | |
|
81 | <a class="menuItem" href="#" onmouseover="menuItemMouseover(event,'menuNewIssue');" onclick="this.blur(); return false;"><span class="menuItemText"><%= l(:label_issue_new) %></span><span class="menuItemArrow">▶</span></a> | |
|
82 | <% end %> | |
|
80 | 83 | <%= link_to l(:label_report_plural), {:controller => 'reports', :action => 'issue_report', :id => @project }, :class => "menuItem" %> |
|
81 | 84 | <%= link_to l(:label_activity), {:controller => 'projects', :action => 'activity', :id => @project }, :class => "menuItem" %> |
|
82 | 85 | <%= link_to l(:label_news_plural), {:controller => 'projects', :action => 'list_news', :id => @project }, :class => "menuItem" %> |
@@ -91,6 +94,14 | |||
|
91 | 94 | <%= link_to_if_authorized l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project }, :class => "menuItem" %> |
|
92 | 95 | </div> |
|
93 | 96 | <% end %> |
|
97 | ||
|
98 | <% if @project && authorize_for('projects', 'add_issue') %> | |
|
99 | <div id="menuNewIssue" class="menu" onmouseover="menuMouseover(event)"> | |
|
100 | <% Tracker.find(:all, :order => 'position').each do |tracker| %> | |
|
101 | <%= link_to tracker.name, {:controller => 'projects', :action => 'add_issue', :id => @project, :tracker_id => tracker}, :class => "menuItem" %> | |
|
102 | <% end %> | |
|
103 | </div> | |
|
104 | <% end %> | |
|
94 | 105 | |
|
95 | 106 | <% if loggedin? and @logged_in_user.memberships.any? %> |
|
96 | 107 | <div id="menuAllProjects" class="menu" onmouseover="menuMouseover(event)"> |
@@ -1,6 +1,6 | |||
|
1 | 1 | <% if @query.new_record? %> |
|
2 | 2 | <div class="contextual"> |
|
3 | <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> | |
|
3 | <%= link_to l(:label_query_plural), :controller => 'queries', :project_id => @project %> | |
|
4 | 4 | </div> |
|
5 | 5 | <h2><%=l(:label_issue_plural)%></h2> |
|
6 | 6 | |
@@ -19,9 +19,9 | |||
|
19 | 19 | :update => "content", |
|
20 | 20 | }, :class => 'icon icon-reload' %> |
|
21 | 21 | |
|
22 | <% if authorize_for('projects', 'add_query') %> | |
|
22 | <% if loggedin? %> | |
|
23 | 23 | <%= link_to_remote l(:button_save), |
|
24 |
{ :url => { :controller => ' |
|
|
24 | { :url => { :controller => 'queries', :action => 'new', :project_id => @project }, | |
|
25 | 25 | :method => 'get', |
|
26 | 26 | :update => "content", |
|
27 | 27 | :with => "Form.serialize('query_form')" |
@@ -31,12 +31,8 | |||
|
31 | 31 | <br /> |
|
32 | 32 | <% else %> |
|
33 | 33 | <div class="contextual"> |
|
34 | <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> | |
|
35 |
<%= link_to l(: |
|
|
36 | <% if authorize_for('projects', 'add_query') %> | |
|
37 | <%= link_to l(:button_edit), {:controller => 'queries', :action => 'edit', :id => @query}, :class => 'icon icon-edit' %> | |
|
38 | <%= link_to l(:button_delete), {:controller => 'queries', :action => 'destroy', :id => @query}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %> | |
|
39 | <% end %> | |
|
34 | <%= link_to l(:label_query_plural), {:controller => 'queries', :project_id => @project} %> | | |
|
35 | <%= link_to l(:label_issue_view_all), {:controller => 'projects', :action => 'list_issues', :id => @project, :set_filter => 1} %> | |
|
40 | 36 | </div> |
|
41 | 37 | <h2><%= @query.name %></h2> |
|
42 | 38 | <% end %> |
@@ -20,9 +20,6 | |||
|
20 | 20 | </ul> |
|
21 | 21 | |
|
22 | 22 | <div class="box"> |
|
23 | <div class="contextual"> | |
|
24 | <%= render :partial => 'issues/add_shortcut', :locals => {:trackers => @trackers } %> | |
|
25 | </div> | |
|
26 | 23 | <h3 class="icon22 icon22-tracker"><%=l(:label_issue_tracking)%></h3> |
|
27 | 24 | <ul> |
|
28 | 25 | <% for tracker in @trackers %> |
@@ -55,7 +55,7 function toggle_multi_select(field) { | |||
|
55 | 55 | //]]> |
|
56 | 56 | </script> |
|
57 | 57 | |
|
58 |
<fieldset |
|
|
58 | <fieldset><legend><%= l(:label_filter_plural) %></legend> | |
|
59 | 59 | <table width="100%"> |
|
60 | 60 | <tr> |
|
61 | 61 | <td> |
@@ -1,12 +1,15 | |||
|
1 | 1 | <%= error_messages_for 'query' %> |
|
2 | 2 | |
|
3 | <!--[form:query]--> | |
|
4 | 3 | <div class="box"> |
|
5 | 4 | <div class="tabular"> |
|
6 | 5 | <p><label for="query_name"><%=l(:field_name)%></label> |
|
7 | 6 | <%= text_field 'query', 'name', :size => 80 %></p> |
|
7 | ||
|
8 | <% if authorize_for('projects', 'add_query') %> | |
|
9 | <p><label for="query_is_public"><%=l(:field_is_public)%></label> | |
|
10 | <%= check_box 'query', 'is_public' %></p> | |
|
11 | <% end %> | |
|
8 | 12 | </div> |
|
9 | 13 | |
|
10 | 14 | <%= render :partial => 'queries/filters', :locals => {:query => query}%> |
|
11 | 15 | </div> |
|
12 | <!--[eoform:query]--> No newline at end of file |
@@ -3,4 +3,4 | |||
|
3 | 3 | <% form_tag({:action => 'edit', :id => @query}) do %> |
|
4 | 4 | <%= render :partial => 'form', :locals => {:query => @query} %> |
|
5 | 5 | <%= submit_tag l(:button_save) %> |
|
6 | <% end %> No newline at end of file | |
|
6 | <% end %> |
@@ -1,27 +1,10 | |||
|
1 | 1 | <h2><%=l(:label_report_plural)%></h2> |
|
2 | 2 | |
|
3 | <div class="splitcontentleft"> | |
|
4 | <div class="contextual"> | |
|
5 | <%= link_to_if_authorized l(:label_query_new), {:controller => 'projects', :action => 'add_query', :id => @project}, :class => 'icon icon-add' %> | |
|
6 | </div> | |
|
7 | <h3><%= l(:label_query_plural) %></h3> | |
|
8 | ||
|
9 | <% if @queries.empty? %><p><i><%=l(:label_no_data)%></i></p><% end %> | |
|
10 | <ul> | |
|
11 | <% @queries.each do |query| %> | |
|
12 | <li><%= link_to query.name, :controller => 'projects', :action => 'list_issues', :id => @project, :query_id => query %></li> | |
|
13 | <% end %> | |
|
14 | </ul> | |
|
15 | </div> | |
|
16 | <div class="splitcontentright"> | |
|
17 | 3 | <% if @total_hours %> |
|
18 | 4 | <h3 class="textright"><%= l(:label_spent_time) %>: |
|
19 | 5 | <%= link_to(lwr(:label_f_hour, @total_hours), {:controller => 'timelog', :action => 'details', :project_id => @project}, :class => 'icon icon-time') %> |
|
20 | 6 | </h3> |
|
21 | 7 | <% end %> |
|
22 | </div> | |
|
23 | ||
|
24 | <div class="clear"></div> | |
|
25 | 8 | |
|
26 | 9 | <div class="splitcontentleft"> |
|
27 | 10 | <h3><%=l(:field_tracker)%> <%= link_to image_tag('zoom_in.png'), :detail => 'tracker' %></h3> |
|
1 | NO CONTENT: modified file, binary diff hidden |
|
1 | NO CONTENT: file was removed |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now