您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

37 行
1.4 KiB

# -*- coding: utf-8 -*-
"""
:author: Grey Li (李辉)
:url: http://greyli.com
:copyright: © 2018 Grey Li <withlihui@gmail.com>
:license: MIT, see LICENSE for more details.
"""
from flask import url_for
from albumy.extensions import db
from albumy.models import Notification
def push_follow_notification(follower, receiver):
message = 'User <a href="%s">%s</a> followed you.' % \
(url_for('user.index', username=follower.username), follower.username)
notification = Notification(message=message, receiver=receiver)
db.session.add(notification)
db.session.commit()
def push_comment_notification(photo_id, receiver, page=1):
message = '<a href="%s#comments">This photo</a> has new comment/reply.' % \
(url_for('main.show_photo', photo_id=photo_id, page=page))
notification = Notification(message=message, receiver=receiver)
db.session.add(notification)
db.session.commit()
def push_collect_notification(collector, photo_id, receiver):
message = 'User <a href="%s">%s</a> collected your <a href="%s">photo</a>' % \
(url_for('user.index', username=collector.username),
collector.username,
url_for('main.show_photo', photo_id=photo_id))
notification = Notification(message=message, receiver=receiver)
db.session.add(notification)
db.session.commit()