Example #1
0
 def invite(email, extra_data={}):
   """
   Send an invitation to this mail with this extra_data
   TODO: maybe we should do a bulk operation?
   """
   # Email
   prof.start('inviter-add')
   notif = Notif(email=email,
                 type=const.NotifConst.INVITE,
                 extra_data=json.dumps(extra_data))
   notif.save()
   prof.stop('inviter-add')
   
Example #2
0
  def create(user, type, extra_data={}):
    # Email notification
    prof.start('create-notif-email')
    try:
      notif = Notif(email=user.email, 
                    type=type,
                    extra_data=json.dumps(extra_data))
      notif.save()
    except:
      # TODO: log here
      raise
    prof.stop('create-notif-email')

    # User notification
    prof.start('create-notif-user')
    try:
      profile = user.get_profile()
      profile.notif |= type
      profile.save()
    except:
      # TODO: log here
      raise
    prof.stop('create-notif-user')