Skip to content

Develop #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 51 commits into from
Jan 4, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ce18362
added check for project (in case issue is deleted)
nutso Dec 31, 2013
88c7e79
ide files
nutso Jan 1, 2014
8075802
typo
nutso Jan 1, 2014
c161c0f
catching error when issue is deleted even though recurrence still exists
nutso Jan 1, 2014
32812ad
backed out unnecessary error handling -- what i thought was happening…
nutso Jan 1, 2014
be90410
checking for nil issue
nutso Jan 1, 2014
c0e8d76
updated notes with known issues
nutso Jan 1, 2014
aff42c6
removing dependence on localized strings for day/week/month/year sepa…
nutso Jan 1, 2014
4f44004
error message typo
nutso Jan 1, 2014
8e5b8f7
error message typo
nutso Jan 1, 2014
7f40e2a
migrating the data in the database to match the non-localized values …
nutso Jan 1, 2014
c9b6c52
logging
nutso Jan 1, 2014
48890e0
saving changes
nutso Jan 1, 2014
906a503
rolling back migration
nutso Jan 1, 2014
547aae5
checking for nil
nutso Jan 1, 2014
c6f093b
updated error messages to more clearly show where they were generated
nutso Jan 1, 2014
bdd37fd
returning an empty string so at least there are no type errors
nutso Jan 1, 2014
dc3850d
removed a space so definitely calling the right method
nutso Jan 1, 2014
f8d052a
skipping validation on save
nutso Jan 1, 2014
8b11556
removed a space so definitely calling the right method
nutso Jan 1, 2014
19c8b87
referencing generic conversion instead of object based
nutso Jan 1, 2014
2b06ffc
always returning a date value
nutso Jan 1, 2014
c3d4c16
standardized project column display
nutso Jan 1, 2014
523bd0e
localized more strings, updated en to refer to issues instead of tasks
nutso Jan 2, 2014
8446fbd
(#21) localized menu captions
nutso Jan 2, 2014
111f6cd
localized messages
nutso Jan 2, 2014
f3580d9
error messages and TODOs
nutso Jan 2, 2014
9637b7b
updated known issues and resolved for next version
nutso Jan 2, 2014
32c2fff
l function not available at init
nutso Jan 2, 2014
dbfd406
using t instead of l
nutso Jan 2, 2014
1ae47a9
saying irreversible instead of erroring out
nutso Jan 2, 2014
cafa50d
error message contained wrong variable name
nutso Jan 2, 2014
e0c3453
added marker for error
nutso Jan 2, 2014
643a55c
debugging
nutso Jan 2, 2014
7c8270a
calling redmine's l method #21
nutso Jan 2, 2014
3e98a5c
using nonlocalized symbols #21
nutso Jan 2, 2014
cb363d7
checking for errors
nutso Jan 2, 2014
f7927b7
back to raising the exception
nutso Jan 2, 2014
dce1d23
default recurrence pattern
nutso Jan 2, 2014
344f819
better display of error value
nutso Jan 2, 2014
5c1ca48
added section to note known issues with develop branch
nutso Jan 2, 2014
d6bc4ae
better organization for sections
nutso Jan 2, 2014
b00ed9b
centralized interval name to interval conversion
nutso Jan 3, 2014
2e148c5
setting interval from localized name before save
nutso Jan 4, 2014
58eb04d
debug statement and method renamed
nutso Jan 4, 2014
acbc7ef
typo
nutso Jan 4, 2014
5b9f3e7
debug statements
nutso Jan 4, 2014
decd5b7
setting interval before validation instead of before save
nutso Jan 4, 2014
e07028f
workaround to set interval despite update_attributes
nutso Jan 4, 2014
6faf37c
recurrence interval saves
nutso Jan 4, 2014
f109a65
Version 1.2.6
nutso Jan 4, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
removing dependence on localized strings for day/week/month/year sepa…
…ration
  • Loading branch information
nutso committed Jan 1, 2014
commit aff42c680aaeaed6dd98630cf17fbb65ea627364
2 changes: 1 addition & 1 deletion app/controllers/recurring_tasks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ def find_recurring_task
end

def set_interval_units
@interval_units = RecurringTask::INTERVAL_UNITS
@interval_units = RecurringTask::INTERVAL_UNITS_LOCALIZED
end
end
72 changes: 65 additions & 7 deletions app/models/recurring_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,88 @@ class RecurringTask < ActiveRecord::Base
belongs_to :issue, :foreign_key => 'current_issue_id'
has_one :project, through: :issue

attr_accessible :interval_localized_name

# these are the flags used in the database to denote the interval
# the actual text displayed to the user is controlled in the language file
INTERVAL_DAY = 'd'
INTERVAL_WEEK = 'w'
INTERVAL_MONTH = 'm'
INTERVAL_YEAR = 'y'

# must come before validations otherwise unitialized
INTERVAL_UNITS = [l(:interval_day), l(:interval_week), l(:interval_month), l(:interval_year)]
INTERVAL_UNITS_LOCALIZED = [l(:interval_day), l(:interval_week), l(:interval_month), l(:interval_year)]

validates :interval_unit, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS, message: "#{l(:error_invalid_interval)} %{value}" }
validates :interval_localized_name, presence: true, inclusion: { in: RecurringTask::INTERVAL_UNITS_LOCALIZED, message: "#{l(:error_invalid_interval)} %{value}" }
validates :interval_number, presence: true, numericality: {only_integer: true, greater_than: 0}
# cannot validate presence of issue if want to use other features
# validates :issue, presence: true
# validates :fixed_schedule # requiring presence requires true

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

def interval_localized_name
case interval_unit
when INTERVAL_DAY
l(:interval_day)
when INTERVAL_WEEK
l(:interval_week)
when INTERVAL_MONTH
l(:interval_month)
when INTERVAL_YEAR
l(:interval_year)
else
logger.error "#{l(:error_invalid_interval)} %{interval_unit}"
end
end

# text for the interval name
def interval_localized_name=(value)
interval_unit = case value
when l(:interval_day)
INTERVAL_DAY
when l(:interval_week)
INTERVAL_WEEK
when l(:interval_month)
INTERVAL_MONTH
when l(:interval_year)
INTERVAL_YEAR
else
logger.error "Could not find matching value for localized interval name #{interval}." # TODO localize
""
end
end

# interval database name for the localized text
def self.interval_value interval
case interval
when l(:interval_day)
INTERVAL_DAY
when l(:interval_week)
INTERVAL_WEEK
when l(:interval_month)
INTERVAL_MONTH
when l(:interval_year)
INTERVAL_YEAR
else
logger.error "Could not find matching value for localized interval name #{interval}." # TODO localize
""
end
end

# time interval value of the recurrence pattern
def recurrence_pattern
case interval_unit
when l(:interval_day)
when INTERVAL_DAY
interval_number.days
when l(:interval_week)
when INTERVAL_WEEK
interval_number.weeks
when l(:interval_month)
when INTERVAL_MONTH
interval_number.months
when l(:interval_year)
when INTERVAL_YEAR
interval_number.years
else
logger.error "Unsupported interval unit: #{interval_unit}"
logger.error "#{l(:error_invalid_interval)} %{interval_unit}"
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/recurring_tasks/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<p><%= f.hidden_field :id %></p>
<p><%= label(:recurring_task, :current_issue_id, l(:field_issue)) %><%= collection_select('recurring_task', 'current_issue_id', @recurrable_issues, :id, :subj_date) %></p>
<p><%= f.number_field :interval_number %></p>
<p><%= label(:recurring_task, :interval_unit, l(:field_interval_unit)) %><%= select 'recurring_task', 'interval_unit', @interval_units %></p>
<p><%= label(:recurring_task, :interval_localized_name, l(:field_interval_unit)) %><%= select 'recurring_task', 'interval_localized_name', @interval_units %></p>
<p><%= f.check_box :fixed_schedule %> </p>
<p><%= f.submit %></p>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/recurring_tasks/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<!-- TODO Localize -->
<% if !@project %><td><%= rt.project.nil? ? 'N/A' : link_to(rt.project, project_path(rt.project)) %></td><% end %>
<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>
<td><%= pluralize(rt.interval_number, rt.interval_unit) %></td>
<td><%= pluralize(rt.interval_number, rt.interval_localized_name) %></td>
<td><%= rt.fixed_schedule %></td>
<td><%= format_date(rt.next_scheduled_recurrence) %></td>
<td><%= edit_button rt %></td>
Expand Down
2 changes: 1 addition & 1 deletion app/views/recurring_tasks/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<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>

<p><%= l(:label_recurrence_pattern) %> <%= pluralize(@recurring_task.interval_number, @recurring_task.interval_unit) %></p>
<p><%= l(:label_recurrence_pattern) %> <%= pluralize(@recurring_task.interval_number, @recurring_task.interval_localized_name) %></p>
<p><%= @recurring_task.fixed_schedule ? l(:label_recurs_fixed) : l(:label_recurs_dependent) %></p>

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