Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

time_entry_activity.rb 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2022 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. class TimeEntryActivity < Enumeration
  19. has_many :time_entries, :foreign_key => 'activity_id'
  20. OptionName = :enumeration_activities
  21. def option_name
  22. OptionName
  23. end
  24. def objects
  25. TimeEntry.where(:activity_id => self_and_descendants(1).map(&:id))
  26. end
  27. def objects_count
  28. objects.count
  29. end
  30. def transfer_relations(to)
  31. objects.update_all(:activity_id => to.id)
  32. end
  33. end