예제 #1
0
 def get(self):
   """ Ask for which widget, and then render that widget """
   widget = self.request.get("widget")
   current_session = Session().get_current_session(self)
   account = current_session.get_account_entity()
   
   if widget == "rank":
     widget_ref = account.rankWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_RANK
   elif widget == "points":
     widget_ref = account.pointsWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_POINTS
   elif widget == "leaderboard":
     widget_ref = account.leaderWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_LEADERBOARD
   elif widget == "notifier":
     widget_ref = account.notifierWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_NOTIFIER
   elif widget == "milestones":
     widget_ref = account.milestoneWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_MILESTONES
   else:
     widget = "trophycase"
     widget_ref = account.trophyWidget
     render_path = constants.TEMPLATE_PATHS.RENDER_TROPHY_CASE  
     
   values = {"status":"success"}
   properties = widget_ref.properties()
   for property in properties:
     values[property] = getattr(widget_ref, property)
   
   
   show_with_data = self.request.get("withdata")
   if(show_with_data == "yes"):
     """ add appropriate dummy data """
     if widget == "trophycase":
       values["badges"] = self.getDummyBadges()
     elif widget == "rank":
       values["rank"] = str(format_integer(random.randint(1,1000)))
     elif widget == "points":
       values["points"] = str(format_integer(random.randint(1,10000)))
     elif widget == "leaderboard":
       pass
     elif widget == "notifier":
       pass
     elif widget == "milestones":
       pass  
     
   
   self.response.out.write(template.render(render_path, values))
예제 #2
0
    def get(self):
        """ Ask for which widget, and then render that widget """
        widget = self.request.get("widget")
        current_session = Session().get_current_session(self)
        account = current_session.get_account_entity()

        if widget == "rank":
            widget_ref = account.rankWidget
            render_path = constants.TEMPLATE_PATHS.RENDER_RANK
        elif widget == "points":
            widget_ref = account.pointsWidget
            render_path = constants.TEMPLATE_PATHS.RENDER_POINTS
        elif widget == "leaderboard":
            widget_ref = account.leaderWidget
            render_path = constants.TEMPLATE_PATHS.RENDER_LEADERBOARD
        elif widget == "notifier":
            widget_ref = account.notifierWidget
            render_path = constants.TEMPLATE_PATHS.RENDER_NOTIFIER
        elif widget == "milestones":
            widget_ref = account.milestoneWidget
            render_path = constants.TEMPLATE_PATHS.RENDER_MILESTONES
        else:
            widget = "trophycase"
            widget_ref = account.trophyWidget
            render_path = constants.TEMPLATE_PATHS.RENDER_TROPHY_CASE

        values = {"status": "success"}
        properties = widget_ref.properties()
        for property in properties:
            values[property] = getattr(widget_ref, property)

        show_with_data = self.request.get("withdata")
        if (show_with_data == "yes"):
            """ add appropriate dummy data """
            if widget == "trophycase":
                values["badges"] = self.getDummyBadges()
            elif widget == "rank":
                values["rank"] = str(format_integer(random.randint(1, 1000)))
            elif widget == "points":
                values["points"] = str(format_integer(random.randint(1,
                                                                     10000)))
            elif widget == "leaderboard":
                pass
            elif widget == "notifier":
                pass
            elif widget == "milestones":
                pass

        self.response.out.write(template.render(render_path, values))
예제 #3
0
 def points_values(self, user_ref, acc_ref, height, width):
   points = 0
   if user_ref:
     points = user_ref.points
   points_ref = None
   if not acc_ref:
     points_ref = Points()
   else:
     try:
       points_ref = acc_ref.pointsWidget
     except:
       points_ref = widgets_dao.add_points(acc_ref)
   ret = {"status":"success"}
    
   # here we get the custom points settings
   for ii in points_ref.properties():
     ret[ii] = getattr(points_ref, ii)
   points = format_integer(points) 
   ret['points'] = points
  
   # Internal div's need to be slighy smaller than the iframe
   if width and height:
     try:
       width = int(width)
       height = int(height)
       # How did I get this equation? Trial and error.
       height = height - 2 *int(ret['borderThickness']) - 8
       width = width - 2 *int(ret['borderThickness']) - 8
       ret['height'] = height
       ret['width'] = width
     except:
       pass
   return ret
예제 #4
0
 def points_values(self, user_ref, acc_ref, height, width):
   points = 0
   if user_ref:
     points = user_ref.points
   points_ref = None
   if not acc_ref:
     points_ref = Points()
   else:
     try:
       points_ref = acc_ref.pointsWidget
     except:
       points_ref = widgets_dao.add_points(acc_ref)
   ret = {"status":"success"}
    
   # here we get the custom points settings
   for ii in points_ref.properties():
     ret[ii] = getattr(points_ref, ii)
   points = format_integer(points) 
   ret['points'] = points
  
   # Internal div's need to be slighy smaller than the iframe
   if width and height:
     try:
       width = int(width)
       height = int(height)
       # How did I get this equation? Trial and error.
       height = height - 2 *int(ret['borderThickness']) - 8
       width = width - 2 *int(ret['borderThickness']) - 8
       ret['height'] = height
       ret['width'] = width
     except:
       pass
   return ret
예제 #5
0
  def rank_values(self, user_ref, acc_ref, height, width):
    rank = 0
    if user_ref:
      rank = user_ref.rank
    rank_ref = None
    if not acc_ref:
      rank_ref = Rank()
    else: 
      try:
        rank_ref = acc_ref.rankWidget
      except:
        rank_ref = widgets_dao.add_rank(acc_ref)

    # here we get the custom rank settings
    ret = {"status":"success"}
     
    for ii in rank_ref.properties():
      ret[ii] = getattr(rank_ref, ii)
    rank = calculate_rank(user_ref, acc_ref)
    if rank == constants.NOT_RANKED:
      ret['rank'] = "Unranked"
    else:
      ret['rank']= "&#35 " + format_integer(rank)
    # Internal div's need to be slighy smaller than the iframe
    if width and height:
      try:
        width = int(width)
        height = int(height)
        # How did I get this equation? Trial and error.
        height = height - 2 *int(ret['borderThickness']) - 8
        width = width - 2 *int(ret['borderThickness']) - 8
        ret['height'] = height
        ret['width'] = width
      except:
        pass
    
    return ret
예제 #6
0
  def rank_values(self, user_ref, acc_ref, height, width):
    rank = 0
    if user_ref:
      rank = user_ref.rank
    rank_ref = None
    if not acc_ref:
      rank_ref = Rank()
    else: 
      try:
        rank_ref = acc_ref.rankWidget
      except:
        rank_ref = widgets_dao.add_rank(acc_ref)

    # here we get the custom rank settings
    ret = {"status":"success"}
     
    for ii in rank_ref.properties():
      ret[ii] = getattr(rank_ref, ii)
    rank = calculate_rank(user_ref, acc_ref)
    if rank == constants.NOT_RANKED:
      ret['rank'] = "Unranked"
    else:
      ret['rank']= "&#35 " + format_integer(rank)
    # Internal div's need to be slighy smaller than the iframe
    if width and height:
      try:
        width = int(width)
        height = int(height)
        # How did I get this equation? Trial and error.
        height = height - 2 *int(ret['borderThickness']) - 8
        width = width - 2 *int(ret['borderThickness']) - 8
        ret['height'] = height
        ret['width'] = width
      except:
        pass
    
    return ret