[enhancement] add a quote with email digest

This commit is contained in:
Rushabh Mehta 2015-10-19 12:28:49 +05:30
parent d665a07621
commit fe9717cb9c
3 changed files with 48 additions and 5 deletions

View File

@ -70,19 +70,22 @@ class EmailDigest(Document):
def get_msg_html(self):
"""Build email digest content"""
frappe.flags.ignore_account_permission = True
from erpnext.setup.doctype.email_digest.quotes import get_random_quote
context = frappe._dict()
context.update(self.__dict__)
self.set_title(context)
self.set_style(context)
self.set_accounting_cards(context)
context.events = self.get_calendar_events()
context.todo_list = self.get_todo_list()
context.notifications = self.get_notifications()
quote = get_random_quote()
context.quote = {"text": quote[0], "author": quote[1]}
if not (context.events or context.todo_list or context.notifications or context.cards):
return None

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import random
def get_random_quote():
quotes = [
("Start by doing what's necessary; then do what's possible; and suddenly you are doing the impossible.", "Francis of Assisi"),
("The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.", "Hellen Keller"),
("I can't change the direction of the wind, but I can adjust my sails to always reach my destination.", "Jimmy Dean"),
("We know what we are, but know not what we may be.", "William Shakespeare"),
("There are only two mistakes one can make along the road to truth; not going all the way, and not starting.", "Buddha"),
("Always remember that you are absolutely unique. Just like everyone else.", "Margaret Mead"),
("You have to learn the rules of the game. And then you have to play better than anyone else.", "Albert Einstein"),
("Once we accept our limits, we go beyond them.", "Albert Einstein"),
("Quality is not an act, it is a habit.", "Aristotle"),
("The more that you read, the more things you will know. The more that you learn, the more places you'll go.", "Dr. Seuss"),
("From there to here, and here to there, funny things are everywhere.", "Dr. Seuss"),
("The secret of getting ahead is getting started.", "Mark Twain"),
("All generalizations are false, including this one.", "Mark Twain"),
("Don't let schooling interfere with your education.", "Mark Twain"),
("Cauliflower is nothing but cabbage with a college education.", "Mark Twain"),
("It's not the size of the dog in the fight, it's the size of the fight in the dog.", "Mark Twain"),
("Climate is what we expect, weather is what we get.", "Mark Twain"),
("There are lies, damned lies and statistics.", "Mark Twain"),
("Happiness is when what you think, what you say, and what you do are in harmony.", "Mahatma Gandhi"),
("First they ignore you, then they laugh at you, then they fight you, then you win.", "Mahatma Gandhi"),
("There is more to life than increasing its speed.", "Mahatma Gandhi"),
("A small body of determined spirits fired by an unquenchable faith in their mission can alter the course of history.", "Mahatma Gandhi"),
("If two wrongs don't make a right, try three.", "Laurence J. Peter"),
]
return random.choice(quotes)

View File

@ -1,16 +1,15 @@
{% macro show_card(card) %}
<div style="width: 50%; float:left; min-height: 80px; padding-top: 20px;">
<h6 style="color: {{ text_muted }}; font-size: 12px; margin-bottom: 0px; margin-top: 0px;">{{ card.label }}</h6>
<h4 style="margin-top: 7px; font-size: 16px;">{{ card.value }}</h4>
<h4 style="margin-top: 7px; font-size: 16px; margin-botom: 5px;">{{ card.value }}</h4>
{% if card.diff %}
<p style="color: {{ text_muted }}; font-size: 12px;">{{ card.diff }}%</p>
<p style="color: {{ text_muted }}; font-size: 12px; margin-top: 0px;">{{ card.diff }}%</p>
{% endif %}
</div>
{% endmacro %}
<div style="max-width: 500px; margin: auto; padding: 20px 0 40px 0">
{% if cards %}
<h1 style="{{ h1 }}">{{ title }}</h1>
<h4 style="font-weight: normal; color: {{ text_muted }}; margin-top: 7px; font-size: 16px; margin-top: 7px;">
<p>{% if frequency == "Daily "%}
@ -20,6 +19,7 @@
{% endif %}</p>
</h4>
{% if cards %}
<!-- cards -->
<div>
{% for card in cards %}
@ -109,6 +109,13 @@
{% endfor %}
</div>
{% endif %}
</div>
{% endif %}
<div style="text-align: center; margin: 50px; line-height: 1.5">
{{ quote.text }}<br><i>- {{ quote.author }}</i>
<br><br><br>
<span style="color: {{ text_muted }}; font-size: 12px;">Have an intersting thought, quote to share? Email it at hello@erpnext.com</span>
</div>
</div>