update_intro_user.rb 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #encoding
  2. module RailsAdmin
  3. module Config
  4. module Actions
  5. class UpdateIntroUser < RailsAdmin::Config::Actions::Base
  6. register_instance_option :visible? do
  7. authorized?
  8. end
  9. register_instance_option :member do
  10. true
  11. end
  12. register_instance_option :link_icon do
  13. 'icon-share'
  14. end
  15. register_instance_option :pjax? do
  16. false
  17. end
  18. register_instance_option :controller do
  19. Proc.new do
  20. require 'rest-client'
  21. wx_user = WxUser.where("id = ? and show_invite_mode = ?",@object.id, 0).first
  22. n = "此状态不支持操作"
  23. if not wx_user.blank?
  24. n = "已成功升级"
  25. url = "#{CONFIG_FILE["api_host"]}/railsadmin/update/intro/#{@object.id}"
  26. begin
  27. ret = RestClient.get url, {} #per_page: 5
  28. rescue Exception => e
  29. n = "升级失败!"
  30. end
  31. end
  32. if wx_user.id==1
  33. n = "已成功整理关系!"
  34. url = "#{CONFIG_FILE["api_host"]}/v1/cron/comb_three_user"
  35. begin
  36. ret = RestClient.get url, {} #per_page: 5
  37. rescue Exception => e
  38. n = "升级失败!"
  39. end
  40. end
  41. redirect_to :back, notice: "#{n}"
  42. end
  43. end
  44. end
  45. end
  46. end
  47. end