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.

37 regels
1.4 KiB

3 jaren geleden
  1. # -*- coding: utf-8 -*-
  2. """
  3. :author: Grey Li ()
  4. :url: http://greyli.com
  5. :copyright: © 2018 Grey Li <withlihui@gmail.com>
  6. :license: MIT, see LICENSE for more details.
  7. """
  8. from flask import url_for
  9. from albumy.extensions import db
  10. from albumy.models import Notification
  11. def push_follow_notification(follower, receiver):
  12. message = 'User <a href="%s">%s</a> followed you.' % \
  13. (url_for('user.index', username=follower.username), follower.username)
  14. notification = Notification(message=message, receiver=receiver)
  15. db.session.add(notification)
  16. db.session.commit()
  17. def push_comment_notification(photo_id, receiver, page=1):
  18. message = '<a href="%s#comments">This photo</a> has new comment/reply.' % \
  19. (url_for('main.show_photo', photo_id=photo_id, page=page))
  20. notification = Notification(message=message, receiver=receiver)
  21. db.session.add(notification)
  22. db.session.commit()
  23. def push_collect_notification(collector, photo_id, receiver):
  24. message = 'User <a href="%s">%s</a> collected your <a href="%s">photo</a>' % \
  25. (url_for('user.index', username=collector.username),
  26. collector.username,
  27. url_for('main.show_photo', photo_id=photo_id))
  28. notification = Notification(message=message, receiver=receiver)
  29. db.session.add(notification)
  30. db.session.commit()