kadmin 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/helpers/kadmin/pagination_helper.rb +1 -1
  4. data/lib/kadmin.rb +3 -0
  5. data/lib/kadmin/finder.rb +57 -0
  6. data/lib/kadmin/form.rb +1 -1
  7. data/lib/kadmin/pager.rb +82 -0
  8. data/lib/kadmin/version.rb +1 -1
  9. data/test/dummy/app/controllers/admin/application_controller.rb +11 -0
  10. data/test/dummy/app/controllers/admin/groups_controller.rb +0 -0
  11. data/test/dummy/app/controllers/admin/persons_controller.rb +86 -0
  12. data/test/dummy/app/views/admin/persons/_form.html.erb +0 -0
  13. data/test/dummy/app/views/admin/persons/edit.html.erb +0 -0
  14. data/test/dummy/app/views/admin/persons/index.html.erb +0 -0
  15. data/test/dummy/app/views/admin/persons/new.html.erb +0 -0
  16. data/test/dummy/config/routes.rb +7 -3
  17. data/test/dummy/log/development.log +393 -0
  18. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-2/-2HjYbMRby-CwTDE7jk4lgNd3X-l5tHSk4A5UzXzrz0.cache +2 -0
  19. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-E/-E8hxZ6OimFAVoaq-ht5ACFfHh65ARRQ9Mb-zTeA5H8.cache +1 -0
  20. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-_/-_GyWOMxsUj1Vcwf_522X6jS5CyLaFUziq4bW17lZAw.cache +0 -0
  21. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-r/-r0OPtWop7e-i6aqm5Z9zWo9gHXFypWEP1MYcBokwMA.cache +0 -0
  22. data/test/dummy/tmp/cache/assets/sprockets/v3.0/11/11SrJ22TDT3o5ArL97bHJR-ITSG0RNL-Ea36RCQV0XQ.cache +0 -0
  23. data/test/dummy/tmp/cache/assets/sprockets/v3.0/1v/1vA0wPw0oVAyJv-VQobqbmEDrLurYRWV4THCWLfzLoQ.cache +3 -0
  24. data/test/dummy/tmp/cache/assets/sprockets/v3.0/3c/3cghbNCfivQK44JxoMoCPOiw1Vcc07mUX8AsN0nfdGg.cache +1 -0
  25. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5E/5EK4YMOiNjfof61fycHKHeTg9YQvAvkhSKjWLEjuglk.cache +0 -0
  26. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
  27. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5X/5X5Ap1XOYPJqjTBnphJksdHxO2xnQXMmoILKMllPuFU.cache +1 -0
  28. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5m/5mtdWqMi8vbaQoUKpJ6h58QXzdOfczoeIbu_2VY6kEk.cache +0 -0
  29. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6K/6KVInstMdXQzYrg2I6GWoOxR7U_0wWzeBnsWEvg8J3M.cache +0 -0
  30. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6S/6SHOn6gX8LwD8NmftjKNw-BtmJBgL4Xx0hmW1RgBxdk.cache +0 -0
  31. data/test/dummy/tmp/cache/assets/sprockets/v3.0/7v/7vp0pszBWSYyAY0Tz4ZHI9eX6GU4etWfK0D6GF7gLTY.cache +0 -0
  32. data/test/dummy/tmp/cache/assets/sprockets/v3.0/8F/8FV04EdmYtfXyf3Ktwdfqj5SJ-kEEQQOmvrzE-hrqig.cache +0 -0
  33. data/test/dummy/tmp/cache/assets/sprockets/v3.0/8F/8FXsR_p1ch9E_ae2wsJWUnHL6MxAbITe2I14tExB3Ec.cache +1 -0
  34. data/test/dummy/tmp/cache/assets/sprockets/v3.0/8P/8PiD2jpkOTKwCqmTucDpZfcaYIoDaLpRmCTDikmBAMk.cache +0 -0
  35. data/test/dummy/tmp/cache/assets/sprockets/v3.0/AD/ADjuF7qlW-VJcrkl1TCQhPDGvPeugjWk0reLQCK2gDI.cache +1 -0
  36. data/test/dummy/tmp/cache/assets/sprockets/v3.0/AK/AKh8PXD1zgb2pdxirj252TVteTypvd4JLXRf_dQfmKk.cache +2 -0
  37. data/test/dummy/tmp/cache/assets/sprockets/v3.0/B4/B4E3KRrOxNPSEX-9Ugyv9uaAY3gIW2c2730GkDSdEtE.cache +1 -0
  38. data/test/dummy/tmp/cache/assets/sprockets/v3.0/EM/EMa_S-cjtjY8YOtd4L6izIK8FNfQPBISCjmwrYeilXk.cache +0 -0
  39. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Eo/Eo00KDTHIwB2VlsZf4O0IHAC0zp8jSuVqe-scWtAjn0.cache +2 -0
  40. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fj/Fj9wk3WG0X_LuTI9jEPYY2HU5btm59aOpbx1afwZy4M.cache +0 -0
  41. data/test/dummy/tmp/cache/assets/sprockets/v3.0/GF/GF3FBYfVQk64OkuJbBl2h63bZN9hYzPIBtVhNwVs4MY.cache +0 -0
  42. data/test/dummy/tmp/cache/assets/sprockets/v3.0/GI/GILdEr9hblYezO2NmQP4NzxoA1pW2P-_HWZcr0IwNe8.cache +1 -0
  43. data/test/dummy/tmp/cache/assets/sprockets/v3.0/JR/JRLYN2dARxj66xZ7WU5-LfR8WCTxOw21DHHpwVNlu8k.cache +5 -0
  44. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Jc/JcSljJd7QjwNSL4TRtvRNz65r3PiRZ8VJ_itLYWgiw0.cache +1 -0
  45. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Je/Je2odU6RuxXpO5e6xD_7Vm3_QKBj21A4Eb5Xe_3tcmE.cache +1 -0
  46. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Jf/Jf8eGGgzDrZIH9psuQTMsOXOfSnfXnkuFyWLTd2TbEk.cache +1 -0
  47. data/test/dummy/tmp/cache/assets/sprockets/v3.0/KM/KM9biR7CwnS-iyvtFSieT4mpV0Yq3PAzDPh4BkBuitk.cache +0 -0
  48. data/test/dummy/tmp/cache/assets/sprockets/v3.0/LJ/LJN964xN-evJQCr_R906196saBvCUBqdNEo1HbeKoqo.cache +0 -0
  49. data/test/dummy/tmp/cache/assets/sprockets/v3.0/LU/lUq0r6fdSX67R3L3fN37itzZ8ThNiKY2pSz4mt0hhHQ.cache +1 -0
  50. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Le/LeUQdG0D7O4lxvySURbAaoGowjdY-WmNqf3Mfqrfxyg.cache +0 -0
  51. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Mr/MrTfw8APk-gyKkw845UfDSHEmjSmlyecpb4qghVCsJc.cache +0 -0
  52. data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
  53. data/test/dummy/tmp/cache/assets/sprockets/v3.0/QR/QRwUeu2lR_fh0S1COd57cS_0HzJLvVvAfX2b7wdgq9E.cache +0 -0
  54. data/test/dummy/tmp/cache/assets/sprockets/v3.0/QW/QWTzvJsN-St1M5X7c0iPtNpfrg3jbt6DKvSIfrvg1Xo.cache +1 -0
  55. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Re/ReGBPYTMVGc5UsM5L7KB0_3B13aNUqF-fsr2inoeNsE.cache +0 -0
  56. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Rp/Rpze3DS02RzORY0sa58XN-eCPxEpCNWzdMzJHX3PPCc.cache +0 -0
  57. data/test/dummy/tmp/cache/assets/sprockets/v3.0/SM/SMgGnRKtH1iPOR1Rr4jeYv8FXJD6NfEInNJkgh44-h0.cache +2 -0
  58. data/test/dummy/tmp/cache/assets/sprockets/v3.0/TS/TSxUS1m35WV62C8Ns3ZFB34VDTAJZFE9j8sIvFjJ34g.cache +5 -0
  59. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Tr/TrpGZkuLXDxCiZNsH9rPQUuPXTiKIHKtPFEkVvqUSdU.cache +4 -0
  60. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UB/UBqrW0q1xgxd0LgpdhEN2rIkgx311VLn1E4J8xTehS8.cache +1 -0
  61. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UY/UYkqW8Qk-RYuenP9AA1t0qrUGElEFrX70S5Z98vIf-o.cache +3 -0
  62. data/test/dummy/tmp/cache/assets/sprockets/v3.0/U_/U_4FnN2FfvOfugPWddXzWbw4DHmvFBUs5OsmFiPkiOE.cache +0 -0
  63. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Vw/Vw4dSgF0h0cmaCSTiVWdLSTRFpOKkeU3pHBBdvxMFtQ.cache +0 -0
  64. data/test/dummy/tmp/cache/assets/sprockets/v3.0/WN/WN9LSGmlySXuqyBDltZaSgTQId_fBr7tszD5QBdx6as.cache +4 -0
  65. data/test/dummy/tmp/cache/assets/sprockets/v3.0/X9/X9q2gGamGd5n5DLvpqdgA0yXRVz9_DWFChihiNYYFMo.cache +1 -0
  66. data/test/dummy/tmp/cache/assets/sprockets/v3.0/XF/XFAZTK0FYqKi-VAo7wBhb0qmjdyryXXZ-7ngyMKtpfk.cache +1 -0
  67. data/test/dummy/tmp/cache/assets/sprockets/v3.0/XG/XG2LAoElu3yFQXjnrTK-AHdNi5aX19chAKrEfMKFtTU.cache +1 -0
  68. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Y9/Y9nCQQIgQsTdjgKu5AciGNFhclfbFHR7_sZ3-1meqxY.cache +0 -0
  69. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ZL/ZL89Pj7x95nCdeZtpp_31rhNpmaOS1YY6vaNZP2WtIY.cache +0 -0
  70. data/test/dummy/tmp/cache/assets/sprockets/v3.0/aa/aaI8WDVOjLkqpVJtZyxmaV0Ru-gx2JOYGNJN3DruFlY.cache +1 -0
  71. data/test/dummy/tmp/cache/assets/sprockets/v3.0/bH/bHLekJe4OFtBYonKEfS65V6aWHD2knMb-ClTgZOip-g.cache +2 -0
  72. data/test/dummy/tmp/cache/assets/sprockets/v3.0/bS/bSgsBjtu-Y7WrxesKqith5xy2XjVTuWXEGghmr4rivk.cache +0 -0
  73. data/test/dummy/tmp/cache/assets/sprockets/v3.0/br/br7hrpCNcrm7KR7vVkj13rI-f1RiauXbXgD9VbBI6RE.cache +0 -0
  74. data/test/dummy/tmp/cache/assets/sprockets/v3.0/br/brn0WV626bUtP2mU86iYCgWpaHzMFJQ13RgmXaDjeq4.cache +1 -0
  75. data/test/dummy/tmp/cache/assets/sprockets/v3.0/c9/C9xBy-OdhnODNhOzAOFhLTbcYOoB4EioR5LptxwvkUQ.cache +0 -0
  76. data/test/dummy/tmp/cache/assets/sprockets/v3.0/eQ/eQWn4vC7aRx4Y2aDQRmUvCE5wEWZz6exOeDUs3bTYN4.cache +1 -0
  77. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ed/edWZZcjeQS8RikaC_mEOMPS3UouUuaWUTLs_xITZyIs.cache +1 -0
  78. data/test/dummy/tmp/cache/assets/sprockets/v3.0/f6/f6M3kAL7aMbibGjJss7EfrMqNY_B2aLlGidMK-F9QFY.cache +1 -0
  79. data/test/dummy/tmp/cache/assets/sprockets/v3.0/g5/g561cCJ02dyuteLibfkiC5SNvKXoYe-pYktOT6C__70.cache +1 -0
  80. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
  81. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ha/haYOUyt5JRK5bGjubStgXfKTHFnf8_2iv0iN-Y30aHc.cache +1 -0
  82. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hv/hv0lgWWTtx1-VMIag9WFrPh-lQol_RVLcJA6EznjGRk.cache +2 -0
  83. data/test/dummy/tmp/cache/assets/sprockets/v3.0/iA/iAUmEEgZxyXBF7Q3JUzYO6VF_hUcAy9WBGWrO8FBs94.cache +0 -0
  84. data/test/dummy/tmp/cache/assets/sprockets/v3.0/lY/LYL55Pi6vnSDQ3iOktqbsTgZEaKIno8IBN3be_nwM5c.cache +0 -0
  85. data/test/dummy/tmp/cache/assets/sprockets/v3.0/lY/LYb7LJEULabV45Z9punrLTmjttI1vKPMoIeWQndAmaU.cache +1 -0
  86. data/test/dummy/tmp/cache/assets/sprockets/v3.0/m2/m2ooo6C8yP1WOv12MfbvdH6OYOArlpVmrWYcWXXW4aQ.cache +0 -0
  87. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mq/mqXDp-fAKgt19ulbEzOXo6DdsDq2Sq8mUjERjj_ubeY.cache +1 -0
  88. data/test/dummy/tmp/cache/assets/sprockets/v3.0/o0/o0fvPxdmhDOI8sS59RdhHJauHXfn15Fkyj3IamJoCSc.cache +0 -0
  89. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
  90. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pL/pLFfHJgRLnMnJCB5QltUHOjJbtA2wjXXyDGPZedbyRA.cache +1 -0
  91. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pa/paqNgBYCkw0rEQFxOkV0hAQm4EE8TMsjcOsITksk_2M.cache +0 -0
  92. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pd/PDCyll73DKdKcTnGTebiyoY4BhSMElDW378tTa8eHSc.cache +1 -0
  93. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pd/pdUxdFTgb3YAZKNEVaEeQnZb97lA1Ew2o5PybzVUm4A.cache +0 -0
  94. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pw/pw-vQJukxf5ufqJunKWowupXuYv2XV1kAOxKltIkSuM.cache +0 -0
  95. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ri/riMaEi70pbOAROVA_sDeCIgDUQHNLgZ0CcFtaoPQUN8.cache +1 -0
  96. data/test/dummy/tmp/cache/assets/sprockets/v3.0/rs/rs29jYXdRVDaE8LFpPP5sue1m6VBOjzSSSmbj3w0R7g.cache +0 -0
  97. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sK/sKfUi0-HbSWcqtguY1lJhNdX-evf5_LMTcOOdFhOIco.cache +4 -0
  98. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sz/szmBNR1H1DygmcGPID8zNIcbmrO1vGqzHYRGuc5u7-c.cache +0 -0
  99. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tU/tU-Tu9-noE-IHLvRNqvK_woXM1aNYteaOPgUhxs6YLU.cache +0 -0
  100. data/test/dummy/tmp/cache/assets/sprockets/v3.0/tq/tqXoYuJiHJnkCpau1HYEYtY2-wDz7t8r5iGWAbGMlu0.cache +0 -0
  101. data/test/dummy/tmp/cache/assets/sprockets/v3.0/wD/wDcCsc6hXZcj30Tt2oEu81vheWFzK0QaFnvQMZMGR4A.cache +0 -0
  102. data/test/dummy/tmp/cache/assets/sprockets/v3.0/wQ/wQZeIXz8XzLJqkIuny4tEGMxrqJttMCiiPe5sg2kV4U.cache +1 -0
  103. data/test/dummy/tmp/cache/assets/sprockets/v3.0/wo/woi16qt5oc0y3TT4Wynsah4txzpgkIum8AqwR8-eSW0.cache +1 -0
  104. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xJ/xJB6l0maG-NSSTY2ojO_ISRuAnQQ3XH9HoBS1BTecMc.cache +0 -0
  105. data/test/dummy/tmp/cache/assets/sprockets/v3.0/y7/y7rODAuztmvstdGLcihv_rSwUM0unmpxshTZ2NYl9EQ.cache +1 -0
  106. data/test/dummy/tmp/cache/assets/sprockets/v3.0/zQ/zQfrKzck6RKqYFUfKWT4m168XkPB0bFfxD-vJFHwzBs.cache +0 -0
  107. metadata +163 -2
  108. data/app/controllers/rails_admin/application_controller.rb +0 -58
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb56dd82a58af0513f1751486f88ae71c8f1ccca
4
- data.tar.gz: 185d7e43f4054b4fa0faca6c73f1aeea269088fb
3
+ metadata.gz: e9d50b4cc493eab605ce1ba63e1652c57f4cebda
4
+ data.tar.gz: 916d45a69e5a1e2a751a8bae2e87237e42ea2e15
5
5
  SHA512:
6
- metadata.gz: 0c9e04906af2c774c40cc1369736ac1b06a4f6faa9a1bfb5f87925b9bc109e858a08cab2b5b64ba2fed32cb58eeeaa0201b5972435f4a37e3aaae9fa7d2c95f1
7
- data.tar.gz: 66664bea60096063a4acbb3669c6af0e4cfe15f8e9f908801eab71b37134d57de71636369a91ec57aa9882213619538b4fbb850bcf63e136221c32bd234c914a
6
+ metadata.gz: 8ce32466d84c80136a4bc37543bb5d34c1b73792a02a8d7b6cfc2022b924aff030d90a7f0d2126658f8166b7d5a8264f145907dd94effac247404f33ca5a4dac
7
+ data.tar.gz: 861b60839df2cf82d6e338869d4157d35a641eab80d05680aa7a8672ed0968ecc1ed277bdbe22667309207cb49a0c2189c25da1ff7c31940934ab4a37300f6e3
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Kadmin
2
2
 
3
- [![GitHub release](https://img.shields.io/badge/release-0.1.6-blue.png)](https://github.com/barcoo/kadmin/releases/tag/0.1.6)
3
+ [![GitHub release](https://img.shields.io/badge/release-0.1.7-blue.png)](https://github.com/barcoo/kadmin/releases/tag/0.1.7)
4
4
 
5
5
  Collection of utility, configuration, etc., for admin areas in different projects.
6
6
 
@@ -1,6 +1,6 @@
1
1
  module Kadmin
2
2
  module PaginationHelper
3
- # @param [Kadmin::Finder::Pager] pager context to paginate
3
+ # @param [Kadmin::Pager] pager context to paginate
4
4
  # @param [Array<Integer>] sizes array of page sizes
5
5
  def paginate(pager, sizes)
6
6
  return content_tag(:div, pagination_page_list(pager) + pagination_size_list(pager, sizes), class: 'btn-toolbar')
@@ -2,6 +2,9 @@ require 'kadmin/configuration'
2
2
  require 'kadmin/error'
3
3
  require 'kadmin/engine'
4
4
  require 'kadmin/auth'
5
+ require 'kadmin/form'
6
+ require 'kadmin/finder'
7
+ require 'kadmin/pager'
5
8
 
6
9
  module Kadmin
7
10
  class << self
@@ -0,0 +1,57 @@
1
+ module Kadmin
2
+ class Finder
3
+ # @return [Kadmin::Pager] the pager to use (if any)
4
+ attr_reader :pager
5
+
6
+ # @return [Array<Kadmin::Finder::Filter>] array of filters applied to the finder
7
+ attr_reader :filters
8
+
9
+ # @return [ActiveRecord::Relation] the base relation to find items from
10
+ attr_reader :scope
11
+
12
+ # Simple filter structure
13
+ Filter = Struct.new(:column, :value)
14
+
15
+ # @param [ActiveRecord::Relation] scope base relation to page/filter on
16
+ def initialize(scope)
17
+ @scope = scope
18
+ @pager = nil
19
+ @filters = {}
20
+ end
21
+
22
+ # @param [String] name the filter name (should be unique)
23
+ # @param [String, Array<String>] column the column(s) name to filter on
24
+ # @param [String, Array<String>] value the value or values to look for (OR'd)
25
+ def filter(name:, column:, value:)
26
+ if column.present? && value.present? && !@filters.key?(name)
27
+ @filters[name] = Kadmin::Finder::Filter.new(column, value)
28
+ @scope = @scope.where("#{@scope.table_name}.`#{column}` LIKE ?", value.tr('*', '%'))
29
+ @pager&.total = @scope.count
30
+ end
31
+
32
+ return self
33
+ end
34
+
35
+ # @param [Integer] offset optional; offset/index for the current page
36
+ # @param [Integer] size optional; size of a page
37
+ # @return [Kadmin::Finder] itself
38
+ def paginate(offset: nil, size: nil)
39
+ offset = offset.to_i
40
+ size = size.to_i
41
+
42
+ if size.positive? && offset >= 0
43
+ @pager = Kadmin::Pager.new(size: size, offset: offset)
44
+ end
45
+
46
+ return self
47
+ end
48
+
49
+ # @return [ActiveRecord::Relation] the filtered (and optionally paginated) results
50
+ def find
51
+ results = @scope
52
+ results = @pager.page(results) unless @pager.nil?
53
+
54
+ return results
55
+ end
56
+ end
57
+ end
@@ -64,7 +64,7 @@ module Kadmin
64
64
 
65
65
  # @!group Validation
66
66
 
67
- validates :model_valid?
67
+ validate :model_valid?
68
68
 
69
69
  # Validates the models and merge errors back into our own errors if they
70
70
  # are invalid.
@@ -0,0 +1,82 @@
1
+ module Kadmin
2
+ # Simple Pager structure, used to paginate collections
3
+ class Pager
4
+ # @return [Integer] number of items per page
5
+ attr_reader :size
6
+
7
+ # @return [Integer] current index offset (determines current page)
8
+ attr_reader :offset
9
+
10
+ # @return [Integer] total number of pages
11
+ attr_reader :pages
12
+
13
+ # @return [Integer] the current page
14
+ attr_reader :current_page
15
+
16
+ # @return [Integer] total number of items in the collection
17
+ attr_reader :total
18
+
19
+ # @param [Integer] size size of a page
20
+ # @param [Integer] offset offset/index for the current page
21
+ def initialize(size:, offset:)
22
+ @size = size
23
+ @offset = offset
24
+
25
+ raise(Kadmin::Error, 'Page size must be greater than 0!') unless @size.positive?
26
+ raise(Kadmin::Error, 'Offset must be at least 0!') unless @offset >= 0
27
+
28
+ @current_page = (@offset / @size.to_f).floor
29
+ self.total = @size # assume page size is maximum initially
30
+ end
31
+
32
+ # @param [ActiveRecord::Relation] collection relation to paginate
33
+ # @return [ActiveRecord::Relation] paginated collection
34
+ def page(collection)
35
+ self.total = collection.count
36
+
37
+ collection = collection.offset(@offset)
38
+ collection = collection.limit(@size)
39
+
40
+ return collection
41
+ end
42
+
43
+ # @param [Integer] page the page to get the offset for
44
+ # @return [Integer] start offset for the given page
45
+ def offset_at(page)
46
+ return @size * page
47
+ end
48
+
49
+ # @param [Integer] page the page to check for
50
+ # @return [Boolean] true if `page` is the current page
51
+ def current_page?(page)
52
+ return page == @current_page
53
+ end
54
+
55
+ # @param [Integer] page the page to check for
56
+ # @return [Boolean] true if `page` exists (i.e. would have any data)
57
+ def contains?(page)
58
+ page.in?(0...@pages)
59
+ end
60
+
61
+ # @param [Integer] total sets the number of total collection items (not total loaded)
62
+ def total=(total)
63
+ @total = total
64
+ @pages = (@total / @size.to_f).ceil
65
+ end
66
+
67
+ # @param [Integer] page optional; if given, checks if the page after would have any data, otherwise checks based on the current page
68
+ # @return [Boolean] true if there is a next page
69
+ def next_page?(page = nil)
70
+ page ||= @current_page
71
+ return offset_at(page.to_i + 1) < @total
72
+ end
73
+
74
+ # @param [Integer] page optional; if given, checks if the page after would have any data, otherwise checks based on the current page
75
+ # @return [Boolean] true if there is a previous page
76
+ def previous_page?(page = nil)
77
+ page ||= @current_page
78
+
79
+ return page.to_i.positive?
80
+ end
81
+ end
82
+ end
@@ -1,3 +1,3 @@
1
1
  module Kadmin
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.7'.freeze
3
3
  end
@@ -0,0 +1,11 @@
1
+ module Admin
2
+ class ApplicationController < Kadmin::ApplicationController
3
+ def set_navbar_links
4
+ super
5
+ @layout_navbar_links += [
6
+ { title: 'Persons', path: admin_persons_path },
7
+ { title: 'Groups', path: admin_groups_path }
8
+ ]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,86 @@
1
+ module Admin
2
+ class PersonsController < Admin::ApplicationController
3
+ MAX_PAGE_SIZE = 200
4
+
5
+ # GET /admin/jobs
6
+ def index
7
+ params.permit(:page_size, :page_offset, :filter_name, :format)
8
+
9
+ page_size = [params.fetch(:page_size, 15).to_i, MAX_PAGE_SIZE].min # fix 200 as maximum size
10
+
11
+ @finder = Kadmin::Finder.new(Kadmin::Person.includes(:groups, :owned_groups).order(created_at: :desc))
12
+ @persons = @finder.filter(name: :name, column: [:first_name, :last_name], value: params[:filter_name])
13
+ .paginate(size: page_size, offset: params.fetch(:page_offset, 0))
14
+ .find
15
+ end
16
+
17
+ # GET /admin/persons/:id
18
+ def show
19
+ @person = load_person
20
+ end
21
+
22
+ # GET /admin/persons/edit/:id
23
+ def edit
24
+ @person ||= load_person
25
+ @person_form ||= person_form
26
+ end
27
+
28
+ # PUT /admin/persons/:id
29
+ # PATCH /admin/persons/:id
30
+ def update
31
+ @person = load_person
32
+ @person_form = person_form
33
+
34
+ if form.valid?
35
+ redirect_to(admin_person_path(person.id))
36
+ else
37
+ edit
38
+ end
39
+ end
40
+
41
+ # GET /admin/persons/new
42
+ def new
43
+ @person ||= Person.new
44
+ @person_form ||= person_form
45
+ end
46
+
47
+ # POST /admin/persons
48
+ def create
49
+ @person = Person.new
50
+ @person_form = person_form
51
+
52
+ if @person_form.valid?
53
+ redirect_to(admin_person_path(@person.id))
54
+ else
55
+ new
56
+ end
57
+ end
58
+
59
+ # DELETE /admin/persons/:id
60
+ def destroy
61
+ @person = Person.new
62
+ name = [@person.last_name, @person.first_name].join(', ')
63
+
64
+ @person.destroy # only fails when it raises an exception
65
+ flash[:success] = "Successfully deleted #{name}"
66
+
67
+ redirect_to admin_persons_path
68
+ end
69
+
70
+ # @!group Helpers
71
+
72
+ def load_person
73
+ params.require(:id)
74
+ id = params[:id].to_i
75
+ return Person.includes(:groups, :owned_groups).find(id)
76
+ end
77
+ private :load_person
78
+
79
+ def person_form
80
+ return Forms::PersonForm.new(@person)
81
+ end
82
+ private :person_form
83
+
84
+ # @!endgroup
85
+ end
86
+ end
@@ -1,10 +1,14 @@
1
1
  Rails.application.routes.draw do
2
2
  mount Kadmin::Engine => Kadmin.config.mount_path, as: :kadmin
3
3
 
4
- get '/', to: -> (_env) do
5
- [200, { 'Content-Type' => 'text/plain' }, ['Sup my guy']]
4
+ get '/', to: -> (_env) do # rubocop: disable Style/Lambda
5
+ [200, { 'Content-Type' => 'text/plain' }, ['Howdy']]
6
+ end
7
+
8
+ namespace :admin do
9
+ resources :persons
10
+ resources :groups
6
11
  end
7
12
 
8
- get '/admin', controller: :admin, action: :index
9
13
  get '/authorized', controller: :authorized, action: :index
10
14
  end
@@ -9425,3 +9425,396 @@ Migrating to CreateGroupPeople (20161006134746)
9425
9425
  SQL (0.4ms) INSERT INTO "group_people" ("group_id", "person_id", "created_at", "updated_at") VALUES (?, ?, ?, ?) [["group_id", 1], ["person_id", 1], ["created_at", "2016-10-06 14:07:40.650822"], ["updated_at", "2016-10-06 14:07:40.650822"]]
9426
9426
   (1.1ms) commit transaction
9427
9427
  Person Load (0.2ms) SELECT "people".* FROM "people" INNER JOIN "group_people" ON "people"."id" = "group_people"."person_id" WHERE "group_people"."group_id" = ? [["group_id", 1]]
9428
+
9429
+
9430
+ Started GET "/admin" for 127.0.0.1 at 2016-10-06 19:05:06 +0200
9431
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
9432
+
9433
+ ActionController::RoutingError (No route matches [GET] "/admin"):
9434
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
9435
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
9436
+ railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
9437
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `block in call'
9438
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
9439
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:26:in `tagged'
9440
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `tagged'
9441
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `call'
9442
+ quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
9443
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
9444
+ rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
9445
+ rack (1.6.4) lib/rack/runtime.rb:18:in `call'
9446
+ activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
9447
+ rack (1.6.4) lib/rack/lock.rb:17:in `call'
9448
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
9449
+ rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
9450
+ railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
9451
+ railties (4.2.7.1) lib/rails/application.rb:165:in `call'
9452
+ rack (1.6.4) lib/rack/content_length.rb:15:in `call'
9453
+ puma (3.6.0) lib/puma/configuration.rb:225:in `call'
9454
+ puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
9455
+ puma (3.6.0) lib/puma/server.rb:415:in `process_client'
9456
+ puma (3.6.0) lib/puma/server.rb:275:in `block in run'
9457
+ puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
9458
+
9459
+
9460
+ Rendered /Users/npepinpe/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.0ms)
9461
+ Rendered /Users/npepinpe/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/routes/_route.html.erb (1.1ms)
9462
+ Rendered /Users/npepinpe/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/routes/_route.html.erb (0.3ms)
9463
+ Rendered /Users/npepinpe/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/routes/_table.html.erb (7.9ms)
9464
+ Rendered /Users/npepinpe/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (39.9ms)
9465
+ Rendered /Users/npepinpe/.rvm/gems/ruby-2.3.1/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (103.1ms)
9466
+
9467
+
9468
+ Started GET "/admin/persons" for 127.0.0.1 at 2016-10-06 19:05:16 +0200
9469
+
9470
+ ActionController::RoutingError - uninitialized constant PersonsController:
9471
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:63:in `rescue in controller'
9472
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:58:in `controller'
9473
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:39:in `serve'
9474
+ actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:43:in `block in serve'
9475
+ actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:30:in `serve'
9476
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:817:in `call'
9477
+ omniauth (1.3.1) lib/omniauth/strategy.rb:186:in `call!'
9478
+ omniauth (1.3.1) lib/omniauth/strategy.rb:164:in `call'
9479
+ omniauth (1.3.1) lib/omniauth/builder.rb:63:in `call'
9480
+ rack (1.6.4) lib/rack/etag.rb:24:in `call'
9481
+ rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
9482
+ rack (1.6.4) lib/rack/head.rb:13:in `call'
9483
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
9484
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
9485
+ rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
9486
+ rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
9487
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
9488
+ activerecord (4.2.7.1) lib/active_record/query_cache.rb:36:in `call'
9489
+ activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
9490
+ activerecord (4.2.7.1) lib/active_record/migration.rb:377:in `call'
9491
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
9492
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
9493
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
9494
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
9495
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
9496
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
9497
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
9498
+ better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
9499
+ better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
9500
+ better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
9501
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
9502
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
9503
+ railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
9504
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `block in call'
9505
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
9506
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:26:in `tagged'
9507
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `tagged'
9508
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `call'
9509
+ quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
9510
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
9511
+ rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
9512
+ rack (1.6.4) lib/rack/runtime.rb:18:in `call'
9513
+ activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
9514
+ rack (1.6.4) lib/rack/lock.rb:17:in `call'
9515
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
9516
+ rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
9517
+ railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
9518
+ railties (4.2.7.1) lib/rails/application.rb:165:in `call'
9519
+ rack (1.6.4) lib/rack/content_length.rb:15:in `call'
9520
+ puma (3.6.0) lib/puma/configuration.rb:225:in `call'
9521
+ puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
9522
+ puma (3.6.0) lib/puma/server.rb:415:in `process_client'
9523
+ puma (3.6.0) lib/puma/server.rb:275:in `block in run'
9524
+ puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
9525
+
9526
+
9527
+
9528
+ Started POST "/__better_errors/17ffe00a9f0959fd/variables" for 127.0.0.1 at 2016-10-06 19:05:16 +0200
9529
+
9530
+
9531
+ Started GET "/admin/persons" for 127.0.0.1 at 2016-10-06 19:06:09 +0200
9532
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
9533
+
9534
+ ActionController::RoutingError - undefined method `load_job' for class `Admin::PersonsController':
9535
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:63:in `rescue in controller'
9536
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:58:in `controller'
9537
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:39:in `serve'
9538
+ actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:43:in `block in serve'
9539
+ actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:30:in `serve'
9540
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:817:in `call'
9541
+ omniauth (1.3.1) lib/omniauth/strategy.rb:186:in `call!'
9542
+ omniauth (1.3.1) lib/omniauth/strategy.rb:164:in `call'
9543
+ omniauth (1.3.1) lib/omniauth/builder.rb:63:in `call'
9544
+ rack (1.6.4) lib/rack/etag.rb:24:in `call'
9545
+ rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
9546
+ rack (1.6.4) lib/rack/head.rb:13:in `call'
9547
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
9548
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
9549
+ rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
9550
+ rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
9551
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
9552
+ activerecord (4.2.7.1) lib/active_record/query_cache.rb:36:in `call'
9553
+ activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
9554
+ activerecord (4.2.7.1) lib/active_record/migration.rb:377:in `call'
9555
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
9556
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
9557
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
9558
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
9559
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
9560
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
9561
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
9562
+ better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
9563
+ better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
9564
+ better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
9565
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
9566
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
9567
+ railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
9568
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `block in call'
9569
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
9570
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:26:in `tagged'
9571
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `tagged'
9572
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `call'
9573
+ quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
9574
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
9575
+ rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
9576
+ rack (1.6.4) lib/rack/runtime.rb:18:in `call'
9577
+ activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
9578
+ rack (1.6.4) lib/rack/lock.rb:17:in `call'
9579
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
9580
+ rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
9581
+ railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
9582
+ railties (4.2.7.1) lib/rails/application.rb:165:in `call'
9583
+ rack (1.6.4) lib/rack/content_length.rb:15:in `call'
9584
+ puma (3.6.0) lib/puma/configuration.rb:225:in `call'
9585
+ puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
9586
+ puma (3.6.0) lib/puma/server.rb:415:in `process_client'
9587
+ puma (3.6.0) lib/puma/server.rb:275:in `block in run'
9588
+ puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
9589
+
9590
+
9591
+
9592
+ Started POST "/__better_errors/f8b9d9e00b78f837/variables" for 127.0.0.1 at 2016-10-06 19:06:09 +0200
9593
+
9594
+
9595
+ Started GET "/admin/persons" for 127.0.0.1 at 2016-10-06 19:06:23 +0200
9596
+ Processing by Admin::PersonsController#index as HTML
9597
+ Redirected to http://0.0.0.0:3000/kadmin/auth/login?origin=%2Fadmin%2Fpersons
9598
+ Filter chain halted as :authorize rendered or redirected
9599
+ Completed 302 Found in 15ms (ActiveRecord: 0.0ms)
9600
+
9601
+
9602
+ Started GET "/kadmin/auth/login?origin=%2Fadmin%2Fpersons" for 127.0.0.1 at 2016-10-06 19:06:23 +0200
9603
+ Processing by Kadmin::AuthController#login as HTML
9604
+ Parameters: {"origin"=>"/admin/persons"}
9605
+ Rendered /Users/npepinpe/work/github/barcoo/kadmin/app/views/kadmin/auth/login.html.erb within layouts/kadmin/application (4.5ms)
9606
+ Rendered /Users/npepinpe/work/github/barcoo/kadmin/app/views/kadmin/_alerts.html.erb (0.7ms)
9607
+ Completed 200 OK in 2251ms (Views: 2250.7ms | ActiveRecord: 0.0ms)
9608
+
9609
+
9610
+ Started GET "/kadmin/auth/developer?origin=%2Fadmin%2Fpersons" for 127.0.0.1 at 2016-10-06 19:06:29 +0200
9611
+ (developer) Request phase initiated.
9612
+
9613
+
9614
+ Started POST "/kadmin/auth/developer/callback" for 127.0.0.1 at 2016-10-06 19:06:33 +0200
9615
+ (developer) Callback phase initiated.
9616
+ Processing by Kadmin::AuthController#save as HTML
9617
+ Parameters: {"email"=>"admin@test.com", "provider"=>"developer"}
9618
+ Redirected to http://0.0.0.0:3000/admin/persons
9619
+ Completed 302 Found in 1ms (ActiveRecord: 0.0ms)
9620
+
9621
+
9622
+ Started GET "/admin/persons" for 127.0.0.1 at 2016-10-06 19:06:33 +0200
9623
+ Processing by Admin::PersonsController#index as HTML
9624
+ Completed 500 Internal Server Error in 5ms (ActiveRecord: 0.0ms)
9625
+
9626
+ NameError - uninitialized constant Kadmin::Finder:
9627
+ activesupport (4.2.7.1) lib/active_support/dependencies.rb:533:in `load_missing_constant'
9628
+ activesupport (4.2.7.1) lib/active_support/dependencies.rb:184:in `const_missing'
9629
+ app/controllers/admin/persons_controller.rb:11:in `index'
9630
+ actionpack (4.2.7.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
9631
+ actionpack (4.2.7.1) lib/abstract_controller/base.rb:198:in `process_action'
9632
+ actionpack (4.2.7.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
9633
+ actionpack (4.2.7.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
9634
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:117:in `call'
9635
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
9636
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:505:in `call'
9637
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
9638
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
9639
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
9640
+ actionpack (4.2.7.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
9641
+ actionpack (4.2.7.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
9642
+ actionpack (4.2.7.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
9643
+ activesupport (4.2.7.1) lib/active_support/notifications.rb:164:in `block in instrument'
9644
+ activesupport (4.2.7.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
9645
+ activesupport (4.2.7.1) lib/active_support/notifications.rb:164:in `instrument'
9646
+ actionpack (4.2.7.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
9647
+ actionpack (4.2.7.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
9648
+ activerecord (4.2.7.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
9649
+ actionpack (4.2.7.1) lib/abstract_controller/base.rb:137:in `process'
9650
+ actionview (4.2.7.1) lib/action_view/rendering.rb:30:in `process'
9651
+ actionpack (4.2.7.1) lib/action_controller/metal.rb:196:in `dispatch'
9652
+ actionpack (4.2.7.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
9653
+ actionpack (4.2.7.1) lib/action_controller/metal.rb:237:in `block in action'
9654
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
9655
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:43:in `serve'
9656
+ actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:43:in `block in serve'
9657
+ actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:30:in `serve'
9658
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:817:in `call'
9659
+ omniauth (1.3.1) lib/omniauth/strategy.rb:186:in `call!'
9660
+ omniauth (1.3.1) lib/omniauth/strategy.rb:164:in `call'
9661
+ omniauth (1.3.1) lib/omniauth/builder.rb:63:in `call'
9662
+ rack (1.6.4) lib/rack/etag.rb:24:in `call'
9663
+ rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
9664
+ rack (1.6.4) lib/rack/head.rb:13:in `call'
9665
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
9666
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
9667
+ rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
9668
+ rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
9669
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
9670
+ activerecord (4.2.7.1) lib/active_record/query_cache.rb:36:in `call'
9671
+ activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
9672
+ activerecord (4.2.7.1) lib/active_record/migration.rb:377:in `call'
9673
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
9674
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
9675
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
9676
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
9677
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
9678
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
9679
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
9680
+ better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
9681
+ better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
9682
+ better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
9683
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
9684
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
9685
+ railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
9686
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `block in call'
9687
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
9688
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:26:in `tagged'
9689
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `tagged'
9690
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `call'
9691
+ quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
9692
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
9693
+ rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
9694
+ rack (1.6.4) lib/rack/runtime.rb:18:in `call'
9695
+ activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
9696
+ rack (1.6.4) lib/rack/lock.rb:17:in `call'
9697
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
9698
+ rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
9699
+ railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
9700
+ railties (4.2.7.1) lib/rails/application.rb:165:in `call'
9701
+ rack (1.6.4) lib/rack/content_length.rb:15:in `call'
9702
+ puma (3.6.0) lib/puma/configuration.rb:225:in `call'
9703
+ puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
9704
+ puma (3.6.0) lib/puma/server.rb:415:in `process_client'
9705
+ puma (3.6.0) lib/puma/server.rb:275:in `block in run'
9706
+ puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
9707
+
9708
+
9709
+
9710
+ Started POST "/__better_errors/c90cb465f623da6b/variables" for 127.0.0.1 at 2016-10-06 19:06:33 +0200
9711
+
9712
+
9713
+ Started GET "/admin/persons" for 127.0.0.1 at 2016-10-06 19:07:21 +0200
9714
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
9715
+ Processing by Admin::PersonsController#index as HTML
9716
+  (0.1ms) SELECT COUNT(*) FROM "people"
9717
+ Person Load (0.2ms) SELECT "people".* FROM "people" ORDER BY "people"."created_at" DESC LIMIT 15 OFFSET 0
9718
+ GroupPerson Load (0.1ms) SELECT "group_people".* FROM "group_people" WHERE "group_people"."person_id" IN (1)
9719
+ Group Load (0.1ms) SELECT "groups".* FROM "groups" WHERE "groups"."id" IN (1)
9720
+ Group Load (0.1ms) SELECT "groups".* FROM "groups" WHERE "groups"."owner_id" IN (1)
9721
+ Completed 500 Internal Server Error in 659ms (ActiveRecord: 0.2ms)
9722
+
9723
+ NoMethodError - undefined method `decorate' for #<Person::ActiveRecord_Relation:0x007f9fed693e00>
9724
+ Did you mean? create:
9725
+ activerecord (4.2.7.1) lib/active_record/relation/delegation.rb:136:in `method_missing'
9726
+ activerecord (4.2.7.1) lib/active_record/relation/delegation.rb:99:in `method_missing'
9727
+ app/controllers/admin/persons_controller.rb:15:in `index'
9728
+ actionpack (4.2.7.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
9729
+ actionpack (4.2.7.1) lib/abstract_controller/base.rb:198:in `process_action'
9730
+ actionpack (4.2.7.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
9731
+ actionpack (4.2.7.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
9732
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:117:in `call'
9733
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
9734
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:505:in `call'
9735
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
9736
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
9737
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
9738
+ actionpack (4.2.7.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
9739
+ actionpack (4.2.7.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
9740
+ actionpack (4.2.7.1) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
9741
+ activesupport (4.2.7.1) lib/active_support/notifications.rb:164:in `block in instrument'
9742
+ activesupport (4.2.7.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
9743
+ activesupport (4.2.7.1) lib/active_support/notifications.rb:164:in `instrument'
9744
+ actionpack (4.2.7.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
9745
+ actionpack (4.2.7.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
9746
+ activerecord (4.2.7.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
9747
+ actionpack (4.2.7.1) lib/abstract_controller/base.rb:137:in `process'
9748
+ actionview (4.2.7.1) lib/action_view/rendering.rb:30:in `process'
9749
+ actionpack (4.2.7.1) lib/action_controller/metal.rb:196:in `dispatch'
9750
+ actionpack (4.2.7.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
9751
+ actionpack (4.2.7.1) lib/action_controller/metal.rb:237:in `block in action'
9752
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
9753
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:43:in `serve'
9754
+ actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:43:in `block in serve'
9755
+ actionpack (4.2.7.1) lib/action_dispatch/journey/router.rb:30:in `serve'
9756
+ actionpack (4.2.7.1) lib/action_dispatch/routing/route_set.rb:817:in `call'
9757
+ omniauth (1.3.1) lib/omniauth/strategy.rb:186:in `call!'
9758
+ omniauth (1.3.1) lib/omniauth/strategy.rb:164:in `call'
9759
+ omniauth (1.3.1) lib/omniauth/builder.rb:63:in `call'
9760
+ rack (1.6.4) lib/rack/etag.rb:24:in `call'
9761
+ rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
9762
+ rack (1.6.4) lib/rack/head.rb:13:in `call'
9763
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
9764
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/flash.rb:260:in `call'
9765
+ rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
9766
+ rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
9767
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
9768
+ activerecord (4.2.7.1) lib/active_record/query_cache.rb:36:in `call'
9769
+ activerecord (4.2.7.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
9770
+ activerecord (4.2.7.1) lib/active_record/migration.rb:377:in `call'
9771
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
9772
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
9773
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
9774
+ activesupport (4.2.7.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
9775
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
9776
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
9777
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
9778
+ better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
9779
+ better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
9780
+ better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
9781
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
9782
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
9783
+ railties (4.2.7.1) lib/rails/rack/logger.rb:38:in `call_app'
9784
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `block in call'
9785
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
9786
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:26:in `tagged'
9787
+ activesupport (4.2.7.1) lib/active_support/tagged_logging.rb:68:in `tagged'
9788
+ railties (4.2.7.1) lib/rails/rack/logger.rb:20:in `call'
9789
+ quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
9790
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
9791
+ rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
9792
+ rack (1.6.4) lib/rack/runtime.rb:18:in `call'
9793
+ activesupport (4.2.7.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
9794
+ rack (1.6.4) lib/rack/lock.rb:17:in `call'
9795
+ actionpack (4.2.7.1) lib/action_dispatch/middleware/static.rb:120:in `call'
9796
+ rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
9797
+ railties (4.2.7.1) lib/rails/engine.rb:518:in `call'
9798
+ railties (4.2.7.1) lib/rails/application.rb:165:in `call'
9799
+ rack (1.6.4) lib/rack/content_length.rb:15:in `call'
9800
+ puma (3.6.0) lib/puma/configuration.rb:225:in `call'
9801
+ puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
9802
+ puma (3.6.0) lib/puma/server.rb:415:in `process_client'
9803
+ puma (3.6.0) lib/puma/server.rb:275:in `block in run'
9804
+ puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
9805
+
9806
+
9807
+
9808
+ Started POST "/__better_errors/598d81f28c342168/variables" for 127.0.0.1 at 2016-10-06 19:07:22 +0200
9809
+ Person Load (0.2ms) SELECT "people".* FROM "people" ORDER BY "people"."created_at" DESC
9810
+ GroupPerson Load (0.1ms) SELECT "group_people".* FROM "group_people" WHERE "group_people"."person_id" IN (1)
9811
+ Group Load (0.1ms) SELECT "groups".* FROM "groups" WHERE "groups"."id" IN (1)
9812
+ Group Load (1.0ms) SELECT "groups".* FROM "groups" WHERE "groups"."owner_id" IN (1)
9813
+
9814
+
9815
+ Started GET "/admin/persons" for 127.0.0.1 at 2016-10-06 19:07:33 +0200
9816
+ Processing by Admin::PersonsController#index as HTML
9817
+  (0.1ms) SELECT COUNT(*) FROM "people"
9818
+ Rendered admin/persons/index.html.erb within layouts/kadmin/application (1.1ms)
9819
+ Rendered /Users/npepinpe/work/github/barcoo/kadmin/app/views/kadmin/_alerts.html.erb (0.7ms)
9820
+ Completed 200 OK in 281ms (Views: 270.7ms | ActiveRecord: 0.4ms)