Skip to content

Commit 40d6f84

Browse files
committed
Merge pull request #24 from nutso/develop
Develop
2 parents 6607c24 + 193234e commit 40d6f84

File tree

5 files changed

+40
-29
lines changed

5 files changed

+40
-29
lines changed

ReleaseNotes.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,47 @@
1414
## Resolved in Develop (Next Version)
1515

1616
* Using validates_presence_of instead of validates :x, presence: true for backward Rails compatibility (#20)
17+
* Using validates_inclusion_of and validates_numericality_of instead of stand-alone validates for backward Rails compatibility (#20)
18+
* Creating a new recurrence sets interval_unit properly from localized name
1719

18-
## Version 1.2.7
20+
## Version 1.2.7 (04 Jan 2014)
1921

2022
* Changed to more traditional :through => :issue instead of through: :issue for backward Rails compatibility (#20)
2123

22-
## Version 1.2.6
24+
## Version 1.2.6 (04 Jan 2014)
2325

2426
* After deleting an issue that still has a recurrence, recurrence views generate errors
2527
* Menu captions not localized (#21)
2628
* Changing the interval_day, interval_week, interval_month, or interval_year strings in the locale file, or changing locales, after adding recurrences generates an error
2729

28-
## Version 1.2.5
30+
## Version 1.2.5 (30 Dec 2013)
2931

3032
* resolved nil reference for fixed schedule recurrences with no due date (#16)
3133
* includes german translation contributed by @skolarianer
3234

33-
## Version 1.2.0
35+
## Version 1.2.0 (29 Dec 2013)
3436

3537
* more intuitive management within the issues themselves
3638
* add link to add recurrence when viewing an issue (#7)
3739
* display existing recurrence if application when viewing an issue (#6)
3840

39-
## Version 1.1.0
41+
## Version 1.1.0 (28 Dec 2013)
4042

4143
* Project-specific recurring tasks view (#11)
4244
* Better permissions (managed under issues) (#12)
4345

44-
## Version 1.0.2
46+
## Version 1.0.2 (26 Dec 2013)
4547

4648
* Show next scheduled recurrence when displaying a recurring task (#9)
4749
* Add more than one recurrence to 'catch up' if warranted when recurring (#10)
4850
* Localized date format display
4951

50-
## Version 1.0.1
52+
## Version 1.0.1 (25 Dec 2013)
5153

5254
* Added missing translations
5355
* Fixed missing routes (#1)
5456

55-
## Version 1.0.0
57+
## Version 1.0.0 (21 Dec 2013)
5658

5759
* Initial functionality to configure recurring tasks.
5860
* Any task can be set to recur on a fixed (e.g. every Monday)

app/controllers/recurring_tasks_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def new
2626

2727
# creates a new recurring task
2828
def create
29+
params[:recurring_task][:interval_unit] = RecurringTask.get_interval_from_localized_name(params[:recurring_task][:interval_localized_name])
2930
@recurring_task = RecurringTask.new(params[:recurring_task])
3031
if @recurring_task.save
3132
flash[:notice] = l(:recurring_task_created)

app/models/recurring_task.rb

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,30 @@ class RecurringTask < ActiveRecord::Base
1919
validates_presence_of :interval_localized_name
2020
validates_presence_of :interval_number
2121

22-
validates :interval_localized_name, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} '%{value}' (Validation)" }
23-
validates :interval_number, numericality: {only_integer: true, greater_than: 0}
22+
validates_inclusion_of :interval_localized_name, :in => RecurringTask::INTERVAL_UNITS_LOCALIZED, :message => "#{l(:error_invalid_interval)} '%{value}' (Validation)"
23+
validates_numericality_of :interval_number, :only_integer => true, :greater_than => 0
2424
# cannot validate presence of issue if want to use other features; requiring presence of fixed_schedule requires it to be true
2525

2626
validates_associated :issue # just in case we build in functionality to add an issue at the same time, verify the issue is ok
2727

2828
# text for the interval name
2929
def interval_localized_name
30-
case interval_unit
31-
when INTERVAL_DAY
32-
l(:interval_day)
33-
when INTERVAL_WEEK
34-
l(:interval_week)
35-
when INTERVAL_MONTH
36-
l(:interval_month)
37-
when INTERVAL_YEAR
38-
l(:interval_year)
30+
if new_record?
31+
@interval_localized_name
3932
else
40-
raise "#{l(:error_invalid_interval)} #{interval_unit} (interval_localized_name)"
41-
end
33+
case interval_unit
34+
when INTERVAL_DAY
35+
l(:interval_day)
36+
when INTERVAL_WEEK
37+
l(:interval_week)
38+
when INTERVAL_MONTH
39+
l(:interval_month)
40+
when INTERVAL_YEAR
41+
l(:interval_year)
42+
else
43+
raise "#{l(:error_invalid_interval)} #{interval_unit} (interval_localized_name)"
44+
end
45+
end
4246
end
4347

4448
# interval database name for the localized text

app/views/recurring_tasks/index.html.erb

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,14 @@
2020
<% @recurring_tasks.each do |rt| %>
2121
<tr class="<%= cycle('odd', 'even') %>">
2222
<% begin %>
23-
<% logger.info rt.id %>
24-
<% if @project.nil? %><td><%= rt.project.nil? ? l(:label_recurring_task_project_empty) : link_to(rt.project, project_path(rt.project)) %></td><% end %>
25-
<td><%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %></td>
26-
<td><%= pluralize(rt.interval_number, rt.interval_localized_name) %></td>
27-
<td><%= rt.fixed_schedule %></td>
28-
<td><%= format_date(rt.next_scheduled_recurrence) %></td>
29-
<td><%= edit_button rt %></td>
23+
<% if @project.nil? %><td><%= rt.project.nil? ? l(:label_recurring_task_project_empty) : link_to(rt.project, project_path(rt.project)) %></td><% end %>
24+
<td><%= rt.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(rt.issue.subj_date, {:action => 'show', :id => rt.id, :project_id => rt.project.id}) %></td>
25+
<td><%= pluralize(rt.interval_number, rt.interval_localized_name) %></td>
26+
<td><%= rt.fixed_schedule %></td>
27+
<td><%= format_date(rt.next_scheduled_recurrence) %></td>
28+
<td><%= edit_button rt %></td>
3029
<% rescue => e %>
31-
<td><%= "ERROR: #{e}" %></td>
30+
<td><%= "ERROR: #{e}" %></td>
3231
<% end %>
3332
</tr>
3433
<% end %>

app/views/recurring_tasks/show.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44

55
<h2><%= @recurring_task.issue.nil? ? l(:label_recurring_task_issue_empty) : link_to(@recurring_task.issue.subj_date, {:controller => 'issues', :action => 'show', :id => @recurring_task.issue.id}) %></h2>
66

7+
<% begin %>
78
<p><%= l(:label_recurrence_pattern) %> <%= pluralize(@recurring_task.interval_number, @recurring_task.interval_localized_name) %></p>
89
<p><%= @recurring_task.fixed_schedule ? l(:label_recurs_fixed) : l(:label_recurs_dependent) %></p>
910

1011
<p><%= l(:label_next_scheduled_run) %>: <%= format_date(@recurring_task.next_scheduled_recurrence) %></p>
1112

13+
<% rescue Exception => e
14+
logger.error(e)
15+
end %>
16+
1217
<p><%= edit_button @recurring_task %></p>
1318
<p><%= delete_button @recurring_task %></p>

0 commit comments

Comments
 (0)