Class: Project
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Project
- Includes:
- GuidReferenced
- Defined in:
- app/models/project.rb
Instance Method Summary collapse
- #allows_access?(user) ⇒ Boolean
- #files_and_comments ⇒ Object
- #hours ⇒ Object
- #hours_this_month ⇒ Object
- #hours_this_week ⇒ Object
- #to_s ⇒ Object
- #uninvoiced_hours ⇒ Object
- #work_units ⇒ Object
Instance Method Details
#allows_access?(user) ⇒ Boolean
64 65 66 |
# File 'app/models/project.rb', line 64 def allows_access?(user) accepts_roles_by?(user) || user.admin? end |
#files_and_comments ⇒ Object
68 69 70 |
# File 'app/models/project.rb', line 68 def files_and_comments [comments, ].flatten.sort_by {|x| x.created_at} end |
#hours ⇒ Object
40 41 42 |
# File 'app/models/project.rb', line 40 def hours WorkUnit.for_project(self).sum(:effective_hours) end |
#hours_this_month ⇒ Object
44 45 46 |
# File 'app/models/project.rb', line 44 def hours_this_month WorkUnit.for_project(self).scheduled_between(Time.zone.now.beginning_of_month, Time.zone.now.end_of_month).sum(:effective_hours) end |
#hours_this_week ⇒ Object
48 49 50 |
# File 'app/models/project.rb', line 48 def hours_this_week WorkUnit.for_project(self).scheduled_between(Time.zone.now.beginning_of_week, Time.zone.now.end_of_week).sum(:effective_hours) end |
#to_s ⇒ Object
56 57 58 59 60 61 62 |
# File 'app/models/project.rb', line 56 def to_s if new_record? I18n.t(:new_project) else name end end |
#uninvoiced_hours ⇒ Object
36 37 38 |
# File 'app/models/project.rb', line 36 def uninvoiced_hours WorkUnit.for_project(self).not_invoiced.sum(:effective_hours) end |
#work_units ⇒ Object
52 53 54 |
# File 'app/models/project.rb', line 52 def work_units WorkUnit.for_project(self) end |