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