Project

General

Profile

Feature #13244 » time_entry.diff

Pavel Potcheptsov, 2016-08-30 10:30

View differences:

time_entry.rb (working copy)
24 24
  belongs_to :user
25 25
  belongs_to :activity, :class_name => 'TimeEntryActivity'
26 26

  
27
  attr_protected :user_id, :tyear, :tmonth, :tweek
27
  attr_protected :tyear, :tmonth, :tweek
28 28

  
29 29
  acts_as_customizable
30 30
  acts_as_event :title => Proc.new {|o| "#{l_hours(o.hours)} (#{(o.issue || o.project).event_title})"},
......
54 54
  }
55 55

  
56 56
  safe_attributes 'hours', 'comments', 'project_id', 'issue_id', 'activity_id', 'spent_on', 'custom_field_values', 'custom_fields'
57

  
57
  safe_attributes 'user_id', :if => lambda{ |time_entry, user| user.allowed_to?(:edit_time_entries, time_entry.project) }
58
  
58 59
  # Returns a SQL conditions string used to find all time entries visible by the specified user
59 60
  def self.visible_condition(user, options={})
60 61
    Project.allowed_to_condition(user, :view_time_entries, options) do |role, user|
......
117 118
    errors.add :project_id, :invalid if project.nil?
118 119
    errors.add :issue_id, :invalid if (issue_id && !issue) || (issue && project!=issue.project) || @invalid_issue_id
119 120
    errors.add :activity_id, :inclusion if activity_id_changed? && project && !project.activities.include?(activity)
121
    errors.add :spent_on,  "is too early" if (spent_on < Date.today - 7.day) && ([6,17,95,18].exclude? User.current.id)
120 122
  end
121 123

  
122 124
  def hours=(h)
(2-2/11)