Skip to content
This repository was archived by the owner on Jan 30, 2018. It is now read-only.

Fixes image url and link to project from it for some email notifications. #24

Open
wants to merge 27 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d781ce5
Fixes image url and link to project from it for some email notificati…
Jun 4, 2011
8126b81
Allow tasks to be included in the task list reply via ?include=
jamesu Aug 18, 2011
47d2aaf
Filter out objects from archived projects on global api routes
jamesu Aug 19, 2011
2ee6a49
#447452: add urgent flags to tasks and comments
tokland Aug 19, 2011
9030825
#447452: models: manager urgent flag (transitions, previous setting, …
tokland Aug 19, 2011
7028917
#447452: add urgent flag in task form
tokland Aug 19, 2011
51ab841
#447452: navitation: show urgent in today tasks
tokland Aug 19, 2011
2101ebd
web_steps.rb: [fix] make xpath selector relative to scope node
tokland Aug 19, 2011
08678bf
#447452: add basic urgent feature
tokland Aug 19, 2011
70b59ea
#447452: fix urgent task order + styles for calendar
tokland Aug 19, 2011
1033a20
#447452: styles for urgent flag in tasks and calendar_date_select
tokland Aug 19, 2011
0b2f8b4
#447452: Task: Add urgent flag in API response
tokland Aug 19, 2011
6d04558
#447452: move urgent edit to task_edit and add story to task_create
tokland Aug 19, 2011
f609b2f
#447452: use char ! as the urgent task badge
tokland Aug 19, 2011
25d80ca
#447452: refactor TasksHelper#comment_task_due_on
tokland Aug 21, 2011
3d3f09a
A bit of extra margin for the Urgent checkbox
Aug 22, 2011
50b3cb7
#447452: show urgent flag box for conversation to task conversion form
tokland Aug 22, 2011
0746151
#447452: convert_to_task: set urgent flag to false by default
tokland Aug 22, 2011
dcb9e48
Better upload insertion in the activity stream
jamesu Aug 22, 2011
61d9dab
Add a "More..." dropdown by files in comments
Aug 23, 2011
2daac7d
fix project digests when args are encoded in JSON
jrom Aug 24, 2011
39b4791
Added project route for tasks#create, adds tasks to the Inbox
jamesu Aug 24, 2011
e33d704
#458071: redraw calendar box to show it nearer to the link
tokland Aug 24, 2011
5c2206d
Change name limits for project and organization names
jamesu Aug 24, 2011
9481a2b
When deleting a project, associated watchable tag should be removed. …
unixcharles Aug 25, 2011
7786546
Fixes image url and link to project from it for some email notificati…
Jun 4, 2011
cc6c66e
Merge branch 'patches/notification-emails' of github.com:denisnovikov…
Aug 26, 2011
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
#447452: models: manager urgent flag (transitions, previous setting, …
…validations)
tokland committed Aug 22, 2011

Verified

This commit was signed with the committer’s verified signature.
CristhianF7 Cristhian Fernández
commit 90308259dd3863293c1d2298218babf31056ba36
3 changes: 2 additions & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ def previous_assigned
:reject_if => lambda { |google_docs| google_docs['title'].blank? || google_docs['url'].blank? }

attr_accessible :body, :status, :assigned, :hours, :human_hours, :billable,
:upload_ids, :uploads_attributes, :due_on, :google_docs_attributes, :private_ids, :is_private
:upload_ids, :uploads_attributes, :due_on, :urgent, :google_docs_attributes, :private_ids, :is_private

attr_accessor :is_importing
attr_accessor :private_ids
@@ -246,6 +246,7 @@ def cleanup_task
if @last_comment_in_task
self.target.assigned_id = previous_assigned_id
self.target.due_on = previous_due_on
self.target.urgent = previous_urgent
self.target.status = previous_status || Task::STATUSES[:open]
self.target.save!
end
2 changes: 2 additions & 0 deletions app/models/comment/conversions.rb
Original file line number Diff line number Diff line change
@@ -54,6 +54,8 @@ def to_api_hash(options = {})
base[:status] = status
base[:due_on] = due_on
base[:previous_due_on] = previous_due_on
base[:urgent] = urgent
base[:previous_urgent] = previous_urgent
end

if Array(options[:include]).include?(:uploads) && uploads.any?
8 changes: 6 additions & 2 deletions app/models/comment/tasks.rb
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ def previously_closed?
end

def transition?
status_transition? || assigned_transition? || due_on_change?
status_transition? || assigned_transition? || due_on_change? || urgent_change?
end

def initial_status?
@@ -20,6 +20,10 @@ def due_on_change?
due_on != previous_due_on
end

def urgent_change?
urgent != previous_urgent
end

def assigned_transition?
assigned_id != previous_assigned_id
end
@@ -60,4 +64,4 @@ def previous_status_name
Task::STATUS_NAMES[previous_status]
end

end
end
16 changes: 13 additions & 3 deletions app/models/task.rb
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ class Task < RoleRecord
accepts_nested_attributes_for :comments, :allow_destroy => false,
:reject_if => lambda { |comment| %w[is_private body hours human_hours uploads_attributes google_docs_attributes].all? { |k| comment[k].blank? } }

attr_accessible :name, :assigned_id, :status, :due_on, :comments_attributes, :user, :task_list_id
attr_accessible :name, :assigned_id, :status, :due_on, :comments_attributes, :user, :task_list_id, :urgent

validates_presence_of :user
validates_presence_of :task_list
@@ -49,14 +49,15 @@ class Task < RoleRecord
before_save :save_completed_at
before_validation :remember_comment_created, :on => :update
before_save :update_google_calendar_event, :if => lambda {|t| t.assigned.try(:user) || !t.google_calendar_url_token.blank? }
before_validation :nilize_due_on_for_urgent_tasks

def assigned
@assigned ||= assigned_id ? Person.with_deleted.find_by_id(assigned_id) : nil
end

def track_changes?
(new_record? and not status_new?) or
(updating_user and (status_changed? or assigned_id_changed? or due_on_changed?))
(updating_user and (status_changed? or assigned_id_changed? or due_on_changed? or urgent_changed?))
end

def archived?
@@ -299,7 +300,7 @@ def set_comments_author # before_save
end

def remember_comment_created # before_update
@comment_created = comments.any?(&:new_record?) || assigned_id_changed? || status_changed? || due_on_changed?
@comment_created = comments.any?(&:new_record?) || assigned_id_changed? || status_changed? || due_on_changed? || urgent_changed?
true
end

@@ -331,6 +332,11 @@ def save_changes_to_comment # before_save
comment.previous_due_on = self.due_on_was if due_on_changed?
end

if urgent_changed? or self.new_record?
comment.urgent = self.urgent
comment.previous_urgent = self.urgent_was if urgent_changed?
end

@saved_changes_to_comment = true
true
end
@@ -465,4 +471,8 @@ def delete_old_events_if_required
self.google_calendar_url_token = nil
end
end

def nilize_due_on_for_urgent_tasks
self.due_on = nil if self.urgent?
end
end
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
@@ -260,7 +260,7 @@ def pending_tasks
Rails.cache.fetch("pending_tasks.#{id}") do
active_project_ids.empty? ? [] :
Task.where(:status => Task::ACTIVE_STATUS_CODES).where(:assigned_id => active_project_ids).order('ID desc').includes(:project).
sort { |a,b| (a.due_on || 1.week.from_now.to_date) <=> (b.due_on || 1.year.from_now.to_date) }
sort { |a,b| [a.urgent? ? 0 : 1, (a.due_on || 1.week.from_now.to_date)] <=> [b.urgent? ? 0 : 1, (b.due_on || 1.year.from_now.to_date)] }
end
end

8 changes: 8 additions & 0 deletions spec/models/task_spec.rb
Original file line number Diff line number Diff line change
@@ -57,6 +57,14 @@
task.status_name = 'silly'
}.should raise_error(ArgumentError)
end

it "should nilizie due_on only when urgent flag is set" do
task1 = Factory(:task, :due_on => Time.now, :urgent => false)
task1.due_on.should_not be_nil

task2 = Factory(:task, :due_on => Time.now, :urgent => true)
task2.due_on.should be_nil
end

describe "assigning tasks" do
before do
11 changes: 11 additions & 0 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
@@ -449,6 +449,17 @@
@task.project.update_attribute :archived, true
@user.pending_tasks.should be_empty
end
it "should list active tasks sorted by (urgent, due_on ASC)" do
@task.assign_to(@user)
@task2 = Factory.create(:task, :due_on => 1.minute.from_now)
@task3 = Factory.create(:task, :due_on => 2.days.from_now)
@task4 = Factory.create(:task, :urgent => true)
[@task2, @task3, @task4].each do |task|
task.project.add_user(@user)
task.assign_to(@user)
end
@user.pending_tasks.should == [@task4, @task2, @task3, @task]
end
end

describe "#assigned_tasks_count" do