コード例 #1
0
def send_notification_digest(notifications: [Notification]):
    user = notifications[0].user

    sub = get_email_subscription(user.email)
    if sub.blacklisted:
        return

    msg = Message("{} new notifications".format(len(notifications)),
                  recipients=[user.email])

    msg.body = "".join([
        "<{}> {}\nView: {}\n\n".format(notification.causer.display_name,
                                       notification.title,
                                       abs_url(notification.url))
        for notification in notifications
    ])

    msg.body += "Manage email settings: {}\nUnsubscribe: {}".format(
        abs_url_for("users.email_notifications", username=user.username),
        abs_url_for("users.unsubscribe", token=sub.token))

    msg.html = render_template("emails/notification_digest.html",
                               notifications=notifications,
                               user=user,
                               sub=sub)
    mail.send(msg)
コード例 #2
0
ファイル: packages.py プロジェクト: xenonca/contentdb
    def getMainScreenshotURL(self, absolute=False):
        screenshot = self.main_screenshot
        if screenshot is None:
            return None

        if absolute:
            from app.utils import abs_url
            return abs_url(screenshot.url)
        else:
            return screenshot.url
コード例 #3
0
    def getMainScreenshotURL(self, absolute=False):
        screenshot = self.screenshots.filter_by(approved=True).order_by(
            db.asc(PackageScreenshot.id)).first()
        if screenshot is None:
            return None

        if absolute:
            from app.utils import abs_url
            return abs_url(screenshot.url)
        else:
            return screenshot.url
コード例 #4
0
ファイル: emails.py プロジェクト: xenonca/contentdb
def send_single_email(notification):
	sub = get_email_subscription(notification.user.email)
	if sub.blacklisted:
		return

	msg = Message(notification.title, recipients=[notification.user.email])

	msg.body = """
			New notification: {}
			
			View: {}
			
			Manage email settings: {}
			Unsubscribe: {}
		""".format(notification.title, abs_url(notification.url),
					abs_url_for("users.email_notifications", username=notification.user.username),
					abs_url_for("users.unsubscribe", token=sub.token))

	msg.html = render_template("emails/notification.html", notification=notification, sub=sub)
	mail.send(msg)