You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user_queries_helper.rb 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2023 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. module UserQueriesHelper
  19. def column_value(column, object, value)
  20. if object.is_a?(User) && column.name == :status
  21. user_status_label(column.value_object(object))
  22. else
  23. super
  24. end
  25. end
  26. def csv_value(column, object, value)
  27. if object.is_a?(User)
  28. case column.name
  29. when :status
  30. user_status_label(column.value_object(object))
  31. when :twofa_scheme
  32. twofa_scheme_label value
  33. else
  34. super
  35. end
  36. else
  37. super
  38. end
  39. end
  40. def user_status_label(value)
  41. case value.to_i
  42. when User::STATUS_ACTIVE
  43. l(:status_active)
  44. when User::STATUS_REGISTERED
  45. l(:status_registered)
  46. when User::STATUS_LOCKED
  47. l(:status_locked)
  48. end
  49. end
  50. def twofa_scheme_label(value)
  51. if value
  52. ::I18n.t :"twofa__#{value}__name"
  53. else
  54. ::I18n.t :label_disabled
  55. end
  56. end
  57. end