Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

37 rader
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()