Beispiel #1
0
def add_milestones(acc_ref):
  logging.error("Had to add a Milestones widget to an account " + str(acc_ref.key().name()))
  new_milestones = Milestones(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_milestones, acc_ref.key().name())
  acc_ref.milestonesWidget = new_milestones
  accounts_dao.save(acc_ref)
  return new_milestones
Beispiel #2
0
def add_trophy_case(acc_ref):
  logging.error("Had to add a Trophy widget to an account " + str(acc_ref.key().name()))
  new_trophy_case= TrophyCase(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_trophy_case, acc_ref.key().name())
  acc_ref.trophyWidget = new_trophy_case
  accounts_dao.save(acc_ref)
  return new_trophy_case
Beispiel #3
0
def add_leader(acc_ref):
  logging.error("Had to add a Leader widget to an account " + str(acc_ref.key().name()))
  new_leader= Leaderboard(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_leader, acc_ref.key().name())
  acc_ref.leaderWidget = new_leader
  accounts_dao.save(acc_ref)
  return new_leader
Beispiel #4
0
def add_rank(acc_ref):
  logging.error("Had to add a Rank widget to an account " + str(acc_ref.key().name()))
  new_rank= Rank(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_rank, acc_ref.key().name())
  acc_ref.rankWidget = new_rank
  accounts_dao.save(acc_ref)
  return new_rank
Beispiel #5
0
def add_points(acc_ref):
  logging.error("Had to add a Points widget to an account " + str(acc_ref.key().name()))
  new_points= Points(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_points, acc_ref.key().name())
  acc_ref.pointsWidget = new_points
  accounts_dao.save(acc_ref)
  return new_points
Beispiel #6
0
def add_milestones(acc_ref):
  logging.error("Had to add a Milestones widget to an account " + str(acc_ref.key().name()))
  new_milestones = Milestones(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_milestones, acc_ref.key().name())
  acc_ref.milestonesWidget = new_milestones
  accounts_dao.save(acc_ref)
  return new_milestones
Beispiel #7
0
def add_notifier(acc_ref):
  logging.error("Had to add a Notifier widget to an account " + str(acc_ref.key().name()))
  new_notifier = Notifier(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_notifier, acc_ref.key().name())
  acc_ref.notifierWidget = new_notifier
  accounts_dao.save(acc_ref)
  return new_notifier
Beispiel #8
0
def add_trophy_case(acc_ref):
  logging.error("Had to add a Trophy widget to an account " + str(acc_ref.key().name()))
  new_trophy_case= TrophyCase(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_trophy_case, acc_ref.key().name())
  acc_ref.trophyWidget = new_trophy_case
  accounts_dao.save(acc_ref)
  return new_trophy_case
Beispiel #9
0
def add_leader(acc_ref):
  logging.error("Had to add a Leader widget to an account " + str(acc_ref.key().name()))
  new_leader= Leaderboard(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_leader, acc_ref.key().name())
  acc_ref.leaderWidget = new_leader
  accounts_dao.save(acc_ref)
  return new_leader
Beispiel #10
0
def add_points(acc_ref):
  logging.error("Had to add a Points widget to an account " + str(acc_ref.key().name()))
  new_points= Points(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_points, acc_ref.key().name())
  acc_ref.pointsWidget = new_points
  accounts_dao.save(acc_ref)
  return new_points
Beispiel #11
0
def add_rank(acc_ref):
  logging.error("Had to add a Rank widget to an account " + str(acc_ref.key().name()))
  new_rank= Rank(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_rank, acc_ref.key().name())
  acc_ref.rankWidget = new_rank
  accounts_dao.save(acc_ref)
  return new_rank
Beispiel #12
0
def add_notifier(acc_ref):
  logging.error("Had to add a Notifier widget to an account " + str(acc_ref.key().name()))
  new_notifier = Notifier(key_name=acc_ref.key().name())
  memcache_db.save_entity(new_notifier, acc_ref.key().name())
  acc_ref.notifierWidget = new_notifier
  accounts_dao.save(acc_ref)
  return new_notifier
Beispiel #13
0
def user_points(user_ref, points, title, acc):
  if not user_ref or not acc:
    return None
  try:
    image = acc.pointsImage
  except:
    acc.pointsImage = constants.IMAGE_PARAMS.POINTS_IMAGE
    accounts_dao.save(acc)
  diction = {'event':'notify_points',
             'user':user_ref.userid,
             'account':acc.key().name(),
             'points':points,
             'widget':'notifier',
             'is_api':'no',
             'details':"title: "+title,
             'success':'true'}
              
  message = {'note':"+" + str(points) + " Points", 'image': image, 'title': title}
  message = json.dumps(message)
  try:
    channel.send_message(user_ref.key().name(), message)
    logs.create(diction)  
  except channel.InvalidChannelClientIdError:
    diction['success'] = "false"
    logging.error("Bad Channel ID for acc %s and user %s"%(acc.key().name(), user_ref.key().name()))
    logs.create(diction)
    return  
Beispiel #14
0
def user_points(user_ref, points, title, acc):
  if not user_ref or not acc:
    return None
  try:
    image = acc.pointsImage
  except:
    acc.pointsImage = constants.IMAGE_PARAMS.POINTS_IMAGE
    accounts_dao.save(acc)
  diction = {'event':'notify_points',
             'user':user_ref.userid,
             'account':acc.key().name(),
             'points':points,
             'widget':'notifier',
             'is_api':'no',
             'details':"title: "+title,
             'success':'true'}
              
  message = {'note':"+" + str(points) + " Points", 'image': image, 'title': title}
  message = json.dumps(message)
  try:
    channel.send_message(user_ref.key().name(), message)
    logs.create(diction)  
  except channel.InvalidChannelClientIdError:
    diction['success'] = "false"
    logging.error("Bad Channel ID for acc %s and user %s"%(acc.key().name(), user_ref.key().name()))
    logs.create(diction)
    return