Пример #1
0
  def send_question_email(self, transaction):
    email = Email(to_user_id = transaction.buyer.id,
      transaction_id = transaction.id,
      email_hash = random_email_hash(), # We need it b/c we use it before commit
      purpose = "ask")

    db.session.add(email)

    args = {"buyer": transaction.buyer.display_name,
        "seller": transaction.seller.display_name,
        "hash": email.email_hash }

    if self._send_email(transaction.buyer, "You won '%s' attention, ask him a question" % (transaction.seller.display_name), """
Hi %(buyer)s,

You won '%(seller)s' attention.

Ask this person a question by replying to this email.

Be concise, the question should be answerable in ~ 5 minutes.

You will get an email once we get an answer to your question.  

Thanks for buying the attention,
Ozaur

PS: Please try to write your question within 48 hours.

Hash: %(hash)s (please don't remove it)""" % args):
      db.session.commit()
    else:
      db.session.rollback()
Пример #2
0
  def send_answer_email(self, transaction, question):
    email = Email(to_user_id = transaction.seller.id,
      transaction_id = transaction.id,
      email_hash = random_email_hash(), # We need it b/c we use it before commit
      purpose = "answer")

    db.session.add(email)

    args = {"buyer": transaction.buyer.display_name,
        "seller": transaction.seller.display_name,
        "question": question,
        "hash": email.email_hash }

    if self._send_email(transaction.seller, "Answer the question from '%s', earn bitcoin!" % (transaction.buyer.display_name), """
Hi %(seller)s,

'%(buyer)s' have a question for you, please answer it by replying to this email. You will earn bitcoins for this response.

Please concentrate and try to spend at least 5 minutes on it. It is ok to decline requests, but please be as helpful as possible.

Question: '''
%(question)s
'''

Thanks for selling your attention,
Ozaur

PS: Please try to write your answer within 48 hours. Otherwise you may not earn bitcoin...

Hash: %(hash)s (please don't remove it)""" % args):
      db.session.commit()
    else:
      db.session.rollback()
Пример #3
0
  def send_invitation_email(self, user):
    if user.active:
      app.logger.warn("User '%s' is already activate" % (user.email))
      return

    previous_email = Email.query.filter(Email.to_user_id == user.id, Email.purpose == "verify").first()
    if previous_email:
      app.logger.warn("We already sent email to '%s'" % (user.email))
      return

    email = Email(to_user_id = user.id,
      email_hash = random_email_hash(), # We need it b/c we use it before commit
      purpose = "verify")

    db.session.add(email) 
    if self._send_email(user, "Join the Ozaur! Buy and sell attention using bitcoin.", """
Welcome %(name)s!

You're about to join the attention marketplace!

If you have registered, please confirm by replying "JOIN OZAUR" to this email.
If you don't reply we can't proceed further.

Yours truly,
Ozaur

PS: If you didn't register to Ozaur, please ignore this message.

Hash: %(hash)s (please don't remove it)
""" % {"name": user.display_name, "hash": email.email_hash }):
      db.session.commit()
    else:
      db.session.rollback()