Module: BulkTimeEntryPlugin::Patches::TimeEntryPatch::ClassMethods

Defined in:
lib/bulk_time_entry_plugin/patches/time_entry_patch.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) create_bulk_time_entry(entry)



10
11
12
13
14
15
16
17
18
19
# File 'lib/bulk_time_entry_plugin/patches/time_entry_patch.rb', line 10

def create_bulk_time_entry(entry)
  time_entry = TimeEntry.new(entry)
  time_entry.hours = nil if time_entry.hours.blank? or time_entry.hours <= 0
  if BulkTimeEntriesController.allowed_project?(entry[:project_id])
    time_entry.project_id = entry[:project_id] # project_id is protected from mass assignment
  end
  time_entry.user = User.current
  time_entry.save
  time_entry
end