views.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. # **************************************************************************
  4. # Copyright © 2016 jianglin
  5. # File Name: views.py
  6. # Author: jianglin
  7. # Email: xiyang0807@gmail.com
  8. # Created: 2016-12-22 21:49:05 (CST)
  9. # Last Update:星期四 2016-12-29 21:18:30 (CST)
  10. # By:
  11. # Description:
  12. # **************************************************************************
  13. from flask.views import MethodView
  14. from flask import (render_template, request, redirect, url_for, jsonify,
  15. current_app)
  16. from flask_login import current_user
  17. from common.views import ViewListMixin
  18. from api.tag.models import Tags
  19. from api.topic.models import Topic, Collect
  20. class FollowingTagsView(MethodView, ViewListMixin):
  21. def get(self):
  22. page, number = self.page_info
  23. filter_dict = {'followers__username': current_user.username}
  24. tags = Tags.get_list(page, number, filter_dict)
  25. data = {'tags': tags}
  26. return render_template('follow/following_tags.html', **data)
  27. class FollowingTopicsView(MethodView, ViewListMixin):
  28. def get(self):
  29. page, number = self.page_info
  30. filter_dict = {'followers__username': current_user.username}
  31. topics = Topic.get_list(page, number, filter_dict)
  32. data = {'topics': topics}
  33. return render_template('follow/following_topics.html', **data)
  34. class FollowingUsersView(MethodView, ViewListMixin):
  35. def get(self):
  36. page, number = self.page_info
  37. users = current_user.following_users.paginate(page, number, True)
  38. data = {'users': users}
  39. return render_template('follow/following_users.html', **data)
  40. class FollowingCollectsView(MethodView, ViewListMixin):
  41. def get(self):
  42. page, number = self.page_info
  43. filter_dict = {'followers__username': current_user.username}
  44. collects = Collect.get_list(page, number, filter_dict)
  45. data = {'collects': collects}
  46. return render_template('follow/following_collects.html', **data)