Project

General

Profile

Feature #337 » redmine-private_issues.patch

Paul Zubarev, 2009-01-02 04:09

View differences:

redmine-0.8.0/app/controllers/projects_controller.rb 2009-01-02 05:28:24.000000000 +0300
91 91
    
92 92
    cond = @project.project_condition(Setting.display_subprojects_issues?)
93 93
    Issue.visible_by(User.current) do
94
      issue_cond = cond;
95
      if not User.current.allowed_to?(:view_private_issues, @project)
96
        issue_cond += " AND #{Issue.table_name}.private = false"
97
      end
94 98
      @open_issues_by_tracker = Issue.count(:group => :tracker,
95 99
                                            :include => [:project, :status, :tracker],
96
                                            :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false])
100
                                            :conditions => ["(#{issue_cond}) AND #{IssueStatus.table_name}.is_closed=?", false])
101
      @private_issues_by_tracker = Issue.count(:group => :tracker,
102
                                               :include => [:project, :status, :tracker],
103
                                               :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false],
104
                                               :conditions => ["#{Issue.table_name}.private=?",true])
97 105
      @total_issues_by_tracker = Issue.count(:group => :tracker,
98 106
                                            :include => [:project, :status, :tracker],
99 107
                                            :conditions => cond)
redmine-0.8.0/app/models/issue.rb 2009-01-02 02:33:40.000000000 +0300
262 262
      yield
263 263
    end
264 264
  end
265

  
266
  def visible? (usr, project)
267
     private==false || private==true && usr.allowed_to?(:view_private_issues, project)
268
  end
265 269
  
266 270
  def to_s
267 271
    "#{tracker} ##{id}: #{subject}"
redmine-0.8.0/app/views/issues/_form.rhtml 2009-01-02 00:08:51.000000000 +0300
41 41
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
42 42
</div>
43 43

  
44
<% if User.current.allowed_to?(:add_private_issues, @project) %>
45
<p><%=f.check_box :private %></p>
46
<% end%>
47

  
44 48
<div style="clear:both;"> </div>
45 49
<%= render :partial => 'form_custom_fields' %>
46 50

  
redmine-0.8.0/app/views/issues/_list.rhtml 2009-01-02 02:36:16.000000000 +0300
11 11
	</tr></thead>
12 12
	<tbody>
13 13
	<% issues.each do |issue| -%>
14
	<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= css_issue_classes(issue) %>">
15
	    <td class="checkbox"><%= check_box_tag("ids[]", issue.id, false, :id => nil) %></td>
16
		<td><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %></td>
17
        <% query.columns.each do |column| %><%= content_tag 'td', column_content(column, issue), :class => column.name %><% end %>
18
	</tr>
14
          <% if issue.visible? User.current, @project %>
15
        	<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= css_issue_classes(issue) %>">
16
              <td class="checkbox"><%= check_box_tag("ids[]", issue.id, false, :id => nil) %></td>
17
              <td><%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %></td>
18
              <% query.columns.each do |column| %><%= content_tag 'td', column_content(column, issue), :class => column.name %><% end %>
19
            </tr>
20
          <% end %>
19 21
	<% end -%>
20 22
	</tbody>
21 23
</table>
redmine-0.8.0/app/views/issues/_list_simple.rhtml 2009-01-02 03:35:46.000000000 +0300
8 8
		</tr></thead>
9 9
		<tbody>	
10 10
		<% for issue in issues %>
11
		<tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= css_issue_classes(issue) %>">
12
			<td class="id">
13
			    <%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;') %>
14
				<%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %>
15
			</td>
16
			<td><%=h issue.project.name %> - <%= issue.tracker.name %><br />
17
                <%= issue.status.name %> - <%= format_time(issue.updated_on) %></td>
18
			<td class="subject">
19
                <%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %>
20
            </td>
21
		</tr>
11
          <% if issue.visible? User.current, @project %>
12
            <tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= css_issue_classes(issue) %>">
13
                <td class="id">
14
                    <%= check_box_tag("ids[]", issue.id, false, :style => 'display:none;') %>
15
                    <%= link_to issue.id, :controller => 'issues', :action => 'show', :id => issue %>
16
                </td>
17
                <td><%=h issue.project.name %> - <%= issue.tracker.name %><br />
18
                    <%= issue.status.name %> - <%= format_time(issue.updated_on) %></td>
19
                <td class="subject">
20
                    <%= link_to h(issue.subject), :controller => 'issues', :action => 'show', :id => issue %>
21
                </td>
22
            </tr>
23
          <% end %>
22 24
		<% end %>
23 25
		</tbody>
24 26
	</table>
redmine-0.8.0/app/views/issues/show.rhtml 2009-01-02 02:45:22.000000000 +0300
1
<% if @issue.visible? User.current, @project%>
2

  
1 3
<div class="contextual">
2 4
<%= link_to_if_authorized(l(:button_update), {:controller => 'issues', :action => 'edit', :id => @issue }, :onclick => 'showAndScrollTo("update", "notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %>
3 5
<%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :issue_id => @issue}, :class => 'icon icon-time' %>
......
7 9
<%= link_to_if_authorized l(:button_delete), {:controller => 'issues', :action => 'destroy', :id => @issue}, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-del' %>
8 10
</div>
9 11

  
12

  
13

  
10 14
<h2><%= @issue.tracker.name %> #<%= @issue.id %></h2>
11 15

  
12 16
<div class="<%= css_issue_classes(@issue) %>">
......
42 46
    <% if @issue.estimated_hours %>
43 47
    <td class="estimated-hours"><b><%=l(:field_estimated_hours)%>:</b></td><td><%= lwr(:label_f_hour, @issue.estimated_hours) %></td>
44 48
    <% end %>
49
    <% if @issue.private %>
50
    <td class="private-issue"><b><%=l(:field_private)%></b></td>
51
    <% end %>
45 52
</tr>
46 53
<tr>
47 54
<% n = 0 -%>
......
126 133
    <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %>
127 134
    <%= stylesheet_link_tag 'scm' %>
128 135
<% end %>
136

  
137
<% else %>
138
  <p class="nodata"><%=l(:label_access_denied)%> </p>
139
<% end %>
redmine-0.8.0/app/views/projects/show.rhtml 2009-01-02 05:25:04.000000000 +0300
26 26
                                                :set_filter => 1, 
27 27
                                                "tracker_id" => tracker.id %>:
28 28
      <%= @open_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_open_issues, @open_issues_by_tracker[tracker] || 0) %>
29
      (<%= @private_issues_by_tracker[tracker] || 0 %> <%= lwr(:label_private_issues, @private_issues_by_tracker[tracker] || 0)%>)
29 30
      <%= l(:label_on) %> <%= @total_issues_by_tracker[tracker] || 0 %></li>
30 31
    <% end %>
31 32
    </ul>
redmine-0.8.0/db/migrate/102_add_issues_private_flag.rb 2009-01-01 12:47:54.000000000 +0300
1
class AddIssuesPrivateFlag < ActiveRecord::Migration
2
  def self.up
3
    add_column :issues, :private, :boolean, :default => false, :null => false
4
  end
5

  
6
  def self.down
7
    remove_column :issues, :private
8
  end
9
end
redmine-0.8.0/lang/en.yml 2009-01-02 05:36:32.000000000 +0300
184 184
field_default_value: Default value
185 185
field_comments_sorting: Display comments
186 186
field_parent_title: Parent page
187
field_private: Private issue
187 188

  
188 189
setting_app_title: Application title
189 190
setting_app_subtitle: Application subtitle
......
231 232
permission_manage_versions: Manage versions
232 233
permission_manage_categories: Manage issue categories
233 234
permission_add_issues: Add issues
235
permission_add_private_issues: Add private issues
236
permission_view_private_issues: View private issues
234 237
permission_edit_issues: Edit issues
235 238
permission_manage_issue_relations: Manage issue relations
236 239
permission_add_issue_notes: Add notes
......
283 286
project_module_repository: Repository
284 287
project_module_boards: Boards
285 288

  
289
label_access_denied: Access denied
286 290
label_user: User
287 291
label_user_plural: Users
288 292
label_user_new: New user
......
395 399
label_public_projects: Public projects
396 400
label_open_issues: open
397 401
label_open_issues_plural: open
402
label_private_issues: private
403
label_private_issues_plural: private
398 404
label_closed_issues: closed
399 405
label_closed_issues_plural: closed
400 406
label_total: Total
redmine-0.8.0/lang/ru.yml 2009-01-02 05:35:59.000000000 +0300
179 179
field_port: Порт
180 180
field_possible_values: Возможные значения
181 181
field_priority: Приоритет
182
field_private: Конфиденциальная задача
182 183
field_project: Проект
183 184
field_redirect_existing_links: Перенаправить существующие ссылки
184 185
field_regexp: Регулярное выражение
......
227 228
gui_validation_error_plural: %d ошибок
228 229

  
229 230
label_activity: Активность
231
label_access_denied: Доступ запрещен
230 232
label_add_another_file: Добавить ещё один файл
231 233
label_added_time_by: Добавил(а) %s %s назад
232 234
label_added: добавлено
......
430 432
label_open_issues_plural5: открыто
431 433
label_open_issues_plural: открыто
432 434
label_open_issues: открыт
435
label_private_issues_plural2: конфиденциальных
436
label_private_issues_plural5: конфиденциальных
437
label_private_issues_plural: конфиденциальных
438
label_private_issues: конфиденциальная
433 439
label_optional_description: Описание (опционально)
434 440
label_options: Опции
435 441
label_overall_activity: Сводная активность
......
622 628
permission_view_documents: Просмотр документов
623 629
permission_edit_project: Редактирование проектов
624 630
permission_add_issue_notes: Добавление примечаний
631
permission_add_private_issues: Добавление конфиденциальных задач
632
permission_view_private_issues: Просмотр конфиденциальных задач
625 633
permission_save_queries: Сохранение запросов
626 634
permission_view_wiki_pages: Просмотр wiki
627 635
permission_rename_wiki_pages: Переименование страниц wiki
redmine-0.8.0/lib/redmine.rb 2009-01-02 00:47:01.000000000 +0300
35 35
                                  :queries => :index,
36 36
                                  :reports => :issue_report}, :public => true                    
37 37
    map.permission :add_issues, {:issues => :new}
38
    map.permission :add_private_issues, {:issues => :new}
39
    map.permission :view_private_issues, {:projects => [:changelog, :roadmap],
40
                                  :issues => [:index, :changes, :show, :context_menu],
41
                                  :versions => [:show, :status_by],
42
                                  :queries => :index,
43
                                  :reports => :issue_report}
38 44
    map.permission :edit_issues, {:issues => [:edit, :reply, :bulk_edit, :destroy_attachment]}
39 45
    map.permission :manage_issue_relations, {:issue_relations => [:new, :destroy]}
40 46
    map.permission :add_issue_notes, {:issues => [:edit, :reply]}
(1-1/17)