admin_follow.py 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/usr/bin/env python
  2. # -*- coding=UTF-8 -*-
  3. # **************************************************************************
  4. # Copyright © 2016 jianglin
  5. # File Name: follows.py
  6. # Author: jianglin
  7. # Email: xiyang0807@gmail.com
  8. # Created: 2016-07-02 20:18:14 (CST)
  9. # Last Update:星期六 2016-7-2 20:19:36 (CST)
  10. # By:
  11. # Description:
  12. # **************************************************************************
  13. from maple import db, app
  14. from maple.forums.models import Board, Count, Notice
  15. from maple.user.models import User, UserInfor, UserSetting, Role
  16. from maple.topic.models import Topic, Tags, Reply, Collect
  17. from .admin import BaseModelView
  18. class FollowView(BaseModelView):
  19. can_create = False
  20. column_searchable_list = ['username']
  21. column_filters = ['following_tags.tagname', 'following_topics.title',
  22. 'following_collects.name']
  23. column_list = ['username', 'following_tags', 'following_topics',
  24. 'following_collects', 'following_users']
  25. form_columns = ['following_tags', 'following_topics', 'following_collects',
  26. 'following_users']
  27. class FollowTagsView(BaseModelView):
  28. can_create = False
  29. column_list = ['tagname', 'followers.username']
  30. column_filters = ['followers.username']
  31. column_searchable_list = ['tagname', 'followers.username']
  32. form_columns = ['tagname', 'followers']
  33. class FollowTopicView(BaseModelView):
  34. can_create = False
  35. column_list = ['title', 'followers.username']
  36. column_filters = ['followers.username']
  37. column_searchable_list = column_list
  38. form_columns = ['title', 'followers']
  39. class FollowCollectView(BaseModelView):
  40. can_create = False
  41. column_list = ['name', 'followers.username']
  42. column_filters = ['followers.username']
  43. column_searchable_list = column_list
  44. form_columns = ['name', 'followers']
  45. class FollowUserView(BaseModelView):
  46. can_create = False
  47. column_list = ['username', 'followers.username']
  48. column_filters = ['followers.username']
  49. column_searchable_list = column_list
  50. # column_labels = {'username': '关注者', 'followers': '被关注者'}
  51. form_columns = ['username', 'followers']
  52. def admin_follow(admin):
  53. admin.add_view(FollowView(User,
  54. db.session,
  55. name='全部关注',
  56. endpoint='admin_follow',
  57. category='管理关注'))
  58. admin.add_view(FollowTagsView(Tags,
  59. db.session,
  60. name='关注节点',
  61. endpoint='admin_follow_tags',
  62. category='管理关注'))
  63. admin.add_view(FollowTopicView(Topic,
  64. db.session,
  65. name='关注问题',
  66. endpoint='admin_follow_topic',
  67. category='管理关注'))
  68. admin.add_view(FollowCollectView(Collect,
  69. db.session,
  70. name='关注收藏',
  71. endpoint='admin_follow_collect',
  72. category='管理关注'))
  73. admin.add_view(FollowUserView(User,
  74. db.session,
  75. name='关注用户',
  76. endpoint='admin_follow_user',
  77. category='管理关注'))