Skip to content

Commit 4a2d3b5

Browse files
committed
Fix bugs on install. Right now that work with the actual version of redmine.
Fix bug: - Add methods "has_risk" and "miss_time" - modify some templates/labels because that doesn't show up nicely Done: - Add label "[RISK]" to an issue where's a risk of overdue
1 parent e6a8ea1 commit 4a2d3b5

File tree

9 files changed

+121
-85
lines changed

9 files changed

+121
-85
lines changed

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
Changelog:
22

3+
09/18/2011 - v.0.0.3 :
4+
- Fix bugs :
5+
- add methods "has_risk" and "miss_time"
6+
- modify some templates/labels because that doesn't show the label up
7+
- Done:
8+
- Modify show template and add label "[RISK]" to the issue where's a risk of overdue
9+
310

411
15/07/2011 - v.0.0.2 :
512
- Cr�ation initiale du projet

README.rdoc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ This plugin add some stuffs into issues.
44

55
# Change time unit for time tracking (day, week...)
66

7+
TODO:
8+
9+
# Write some test!
10+
# Refactoring some stuffs
11+
# Add more flexibility on time unit selection (per project and global)
12+
# Select the good time unit for more visibility

app/views/issues/_edit.rhtml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020
<% fields_for :time_entry, @time_entry, { :builder => TabularFormBuilder, :lang => current_language} do |time_entry| %>
2121
<div class="splitcontentleft">
2222

23-
24-
<p>
25-
<label for="time_entry_hours"><%= l(:field_time_entry_hours) %></label>
26-
<%= text_field_tag 'time_entry[hours]', @time_entry.time, :size => 6 %> <%= l(:field_estimated_default, :unit => @time_entry.default_unit_time) %>
27-
</p>
28-
23+
<p>
24+
<label for="time_entry_hours"><%= l(:field_time_entry_hours) %></label>
25+
<%= text_field_tag 'time_entry[hours]', @time_entry.time, :size => 6 %>
26+
<%= l(:field_estimated_default, :unit => @time_entry.default_unit_time) %>
27+
</p>
2928

3029
</div>
3130
<div class="splitcontentright">

app/views/issues/show.rhtml

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,66 @@
11
<%= render :partial => 'action_menu' %>
22

3-
<h2><%= issue_heading(@issue) %> <%= " - Attention il y a un risque!" if @issue.has_risk? %></h2>
3+
<h2><%= l(:label_warning_risk) if @issue.has_risk? %> <%= issue_heading(@issue) %></h2>
44

55
<div class="<%= @issue.css_classes %> details">
6-
<%= avatar(@issue.author, :size => "50") %>
7-
8-
<div class="subject">
9-
<%= render_issue_subject_with_tree(@issue) %>
10-
</div>
6+
<%= avatar(@issue.author, :size => "50") %>
7+
<div class="subject">
8+
<%= render_issue_subject_with_tree(@issue) %>
9+
</div>
1110

1211
<p class="author">
13-
<%= authoring @issue.created_on, @issue.author %>.
14-
<% if @issue.created_on != @issue.updated_on %>
15-
<%= l(:label_updated_time, time_tag(@issue.updated_on)) %>.
16-
<% end %>
17-
12+
<%= authoring @issue.created_on, @issue.author %>.
13+
<% if @issue.created_on != @issue.updated_on %>
14+
<%= l(:label_updated_time, time_tag(@issue.updated_on)) %>.
15+
<% end %>
1816
</p>
1917

20-
21-
<table class="attributes">
22-
<tr>
23-
<th class="status"><%=l(:field_status)%>:</th><td class="status"><%= @issue.status.name %></td>
24-
<th class="start-date"><%=l(:field_start_date)%>:</th><td class="start-date"><%= format_date(@issue.start_date) %></td>
25-
</tr>
26-
<tr>
27-
<th class="priority"><%=l(:field_priority)%>:</th><td class="priority"><%= @issue.priority.name %></td>
28-
<th class="due-date"><%=l(:field_due_date)%>:</th><td class="due-date"><%= format_date(@issue.due_date) %></td>
29-
</tr>
30-
<tr>
31-
<th class="assigned-to"><%=l(:field_assigned_to)%>:</th><td class="assigned-to"><%= avatar(@issue.assigned_to, :size => "14") %><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
32-
<th class="progress"><%=l(:field_done_ratio)%>:</th><td class="progress"><%= progress_bar @issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%" %></td>
33-
</tr>
34-
<tr>
35-
<th class="category"><%=l(:field_category)%>:</th><td class="category"><%=h @issue.category ? @issue.category.name : "-" %></td>
36-
<% if User.current.allowed_to?(:view_time_entries, @project) %>
37-
<th class="spent-time"><%=l(:label_spent_time)%>:</th>
38-
<td class="spent-time">
39-
<% if @issue.spent_hours > 0 %>
40-
<%= l(:label_estimated, {:value => "%.2f" % @issue.spent_time, :unit => @issue.default_unit_time }) %>
41-
(<%= link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue} %>)
42-
<% end #if %>
43-
</td>
44-
<% end %>
45-
</tr>
46-
<tr>
47-
<th class="fixed-version"><%=l(:field_fixed_version)%>:</th>
48-
<td class="fixed-version"><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
49-
<% if @issue.estimated_hours %>
50-
<th class="estimated-hours"><%=l(:field_estimated_hours)%>:</th>
51-
<td class="estimated-hours"><%= l(:label_estimated, {:value =>@issue.estimated_time, :unit => @issue.default_unit_time } ) %>
52-
(<%= l_hours(@issue.estimated_hours) %>)</td>
53-
<% end %>
54-
</tr>
55-
<%= render_custom_fields_rows(@issue) %>
56-
<%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
57-
</table>
58-
59-
<% if @issue.description? || @issue.attachments.any? -%>
60-
<hr />
61-
<% if @issue.description? %>
62-
<div class="contextual">
63-
<%= link_to_remote_if_authorized(l(:button_quote), { :url => {:controller => 'journals', :action => 'new', :id => @issue} }, :class => 'icon icon-comment') %>
64-
</div>
18+
<table class="attributes">
19+
<tr>
20+
<th class="status"><%=l(:field_status)%>:</th><td class="status"><%= @issue.status.name %></td>
21+
<th class="start-date"><%=l(:field_start_date)%>:</th><td class="start-date"><%= format_date(@issue.start_date) %></td>
22+
</tr>
23+
<tr>
24+
<th class="priority"><%=l(:field_priority)%>:</th><td class="priority"><%= @issue.priority.name %></td>
25+
<th class="due-date"><%=l(:field_due_date)%>:</th><td class="due-date"><%= format_date(@issue.due_date) %></td>
26+
</tr>
27+
<tr>
28+
<th class="assigned-to"><%=l(:field_assigned_to)%>:</th><td class="assigned-to"><%= avatar(@issue.assigned_to, :size => "14") %><%= @issue.assigned_to ? link_to_user(@issue.assigned_to) : "-" %></td>
29+
<th class="progress"><%=l(:field_done_ratio)%>:</th><td class="progress"><%= progress_bar @issue.done_ratio, :width => '80px', :legend => "#{@issue.done_ratio}%" %></td>
30+
</tr>
31+
<tr>
32+
<th class="category"><%=l(:field_category)%>:</th><td class="category"><%=h @issue.category ? @issue.category.name : "-" %></td>
33+
<% if User.current.allowed_to?(:view_time_entries, @project) %>
34+
<th class="spent-time"><%=l(:label_spent_time)%>:</th>
35+
<td class="spent-time">
36+
<% if @issue.spent_hours > 0 %>
37+
<%= l(:label_estimated, {:value => "%.2f" % @issue.spent_time, :unit => @issue.default_unit_time }) %>
38+
(<%= link_to l_hours(@issue.spent_hours), {:controller => 'timelog', :action => 'index', :project_id => @project, :issue_id => @issue} %>)
39+
<% end #if %>
40+
</td>
41+
<% end %>
42+
</tr>
43+
<tr>
44+
<th class="fixed-version"><%=l(:field_fixed_version)%>:</th>
45+
<td class="fixed-version"><%= @issue.fixed_version ? link_to_version(@issue.fixed_version) : "-" %></td>
46+
<% if @issue.estimated_hours %>
47+
<th class="estimated-hours"><%=l(:field_estimated_hours)%>:</th>
48+
<td class="estimated-hours"><%= l(:label_estimated, {:value =>@issue.estimated_time, :unit => @issue.default_unit_time } ) %>
49+
(<%= l_hours(@issue.estimated_hours) %>)</td>
50+
<% end %>
51+
</tr>
52+
<%= render_custom_fields_rows(@issue) %>
53+
<%= call_hook(:view_issues_show_details_bottom, :issue => @issue) %>
54+
</table>
55+
56+
<% if @issue.description? || @issue.attachments.any? -%>
57+
<hr />
58+
<% if @issue.description? %>
59+
<div class="contextual">
60+
<%= link_to_remote_if_authorized(l(:button_quote), { :url => {:controller => 'journals', :action => 'new', :id => @issue} }, :class => 'icon icon-comment') %>
61+
</div>
6562
66-
<p><strong><%=l(:field_description)%></strong></p>
63+
<p><strong><%=l(:field_description)%></strong></p>
6764
<div class="wiki">
6865
<%= textilizable @issue, :description, :attachments => @issue.attachments %>
6966
</div>

config/locales/en.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,18 @@ en:
2828
year: "year"
2929

3030
field_estimated_time: "Hours by default"
31-
field_estimated_default: "%{{unit}} by default"
31+
field_estimated_default: "%{unit} by default"
3232
field_time_entry_hours: "Time spent"
3333

3434
label_settings_unit_default: "Default time unit"
35-
label_estimated: "{{value}} {{unit}}"
35+
label_estimated: "%{value} %{unit}"
3636

3737
label_calculated_spent_hours: Calculated spent hours
3838
label_divergent_hours: Divergent hours
3939
label_remaining_hours: Remaining hours
4040
label_spent_hours: Spent hours
4141

4242
label_divergent_time: Divergent time
43-
label_remaining_time: Remaining time
43+
label_remaining_time: Remaining time
44+
45+
label_warning_risk: [RISK]

config/locales/fr.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ fr:
4141

4242
label_divergent_time: Temps dépassé
4343
label_remaining_time: Temps restant
44+
45+
label_warning_risk: [RISQUE]

init.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
This is a plugin for Redmine, that add some advanced stuffs.
2323
Spent time columns, unit time customize
2424
'
25-
version '0.0.2'
25+
version '0.0.3'
2626
url 'http://blog.spikie.info/'
2727
author_url 'http://blog.spikie.info'
2828

@@ -31,16 +31,16 @@
3131

3232
settings(:default => {
3333
'hours_in_day' => '7.4',
34-
'char_for_day' => 'j',
34+
'char_for_day' => 'd',
3535

3636
'days_in_week' => '5',
37-
'char_for_week' => 's',
37+
'char_for_week' => 'w',
3838

39-
'days_in_month' => '21',
39+
'weeks_in_month' => '21',
4040
'char_for_month' => 'm',
4141

4242
'months_in_year' => '12',
43-
'char_for_year' => 'a',
43+
'char_for_year' => 'y',
4444

4545
'default_unit' => 'hours',
4646

lib/redmine_advanced_issues/patches/issue_patch.rb

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,16 @@ def spent_time_over_estimated?
3535
!spent_hours.nil? && !estimated_hours.nil? && spent_hours > estimated_hours
3636
end #spent_time_over_estimated?
3737

38+
# if the issue has some risk for an overdue
3839
def has_risk?
3940
(spent_time_over_estimated? || miss_time? || behind_schedule?) && !closed?
4041
end #has_risk
42+
43+
# khim: Returns true if the issue will be late...
44+
# khim: ((time_estimated - worked_time) / 7.5) > due_date - Date.today
45+
def miss_time?
46+
!due_date.nil? && ((estimated_hours.to_f - spent_hours.to_f) / 7.5) > (due_date - Date.today)
47+
end
4148

4249
def estimated_days
4350
if !estimated_hours.nil? && !Setting.plugin_redmine_advanced_issues['hours_in_day'].nil?
@@ -51,20 +58,18 @@ def estimated_time
5158

5259
#TODO: refactoring
5360
def default_unit_time
54-
case Setting.plugin_redmine_advanced_issues['default_unit']
55-
when 'hours'
56-
return l(:hours)
57-
when 'days'
58-
return l(:days)
59-
when 'weeks'
60-
return l(:weeks)
61-
when 'months'
62-
return l(:months)
63-
when 'years'
64-
return l(:years)
65-
else
66-
return l(:hours)
67-
end
61+
return RedmineAdvancedIssues::TimeManagement.getDefaultTimeUnit(Setting.plugin_redmine_advanced_issues['default_unit'])
62+
# case Setting.plugin_redmine_advanced_issues['default_unit']
63+
# when 'days'
64+
# return l(:days)
65+
# when 'weeks'
66+
# return l(:weeks)
67+
# when 'months'
68+
# return l(:months)
69+
# when 'years'
70+
# return l(:years)
71+
# end
72+
# return l(:hours)
6873
end #default_unit_time
6974

7075
def spent_time

lib/redmine_advanced_issues/time_management.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def TimeManagement.calculate(value, unit_time)
5151

5252
def TimeManagement.calculateHours(value, unit_time)
5353

54+
if value.nil?
55+
return nil
56+
end
57+
5458
value = value.to_f
5559

5660
return value if unit_time == 'hours'
@@ -94,6 +98,20 @@ def TimeManagement.getUnitTimeFromChar(char)
9498
end #case
9599
end #def
96100

101+
def TimeManagement.getDefaultTimeUnit(unit)
102+
case unit
103+
when 'days'
104+
return I18n.t(:days)
105+
when 'weeks'
106+
return I18n.t(:weeks)
107+
when 'months'
108+
return I18n.t(:months)
109+
when 'years'
110+
return I18n.t(:years)
111+
end
112+
return I18n.t(:hours)
113+
end #def
114+
97115
end #class
98116

99117
end #module

0 commit comments

Comments
 (0)