Esempio n. 1
0
    def post(self):
        key_name = self.data.kwargs["key_name"]
        statistic = GSoCStatisticInfo.getInstance().getStatisticByName(key_name)

        value = simplejson.loads(self.data.POST.get("value"))
        if not isinstance(value, bool):
            raise AccessViolation("Unsupported value sent to the server")

        if statistic.getVisible() != value:
            statistic.setVisible(value)
            GSoCStatisticInfo.getInstance().updateStatistic(statistic)
Esempio n. 2
0
  def processRequest(self, request, args, kwargs):
    statisticInfo = GSoCStatisticInfo.getInstance()

    # create Statistic instances based on mapping file
    # by default all the statistic will be hidden
    for statistic_name in mapping.STATISTIC_NAMES:
      statisticInfo.appendStatistic(
          StatisticInfo.Statistic(statistic_name, False))
    statisticInfo.put()
Esempio n. 3
0
    def context(self):
        if self.isHost:
            infos = GSoCStatisticInfo.getInstance().getStatistics()
        else:
            infos = GSoCStatisticInfo.getInstance().getVisibleStatistics()
        names = [i.name for i in infos]

        statistics = [s for s in mapping.STATISTICS if s["name"] in names]
        visualizations = dict(filter(lambda (k, v): k in names, mapping.VISUALIZATIONS.items()))

        return {
            "fetch_urls": self._constructFetchUrls(),
            "manage_urls": self._constructManageUrls(),
            "statistics": statistics,
            "visualizations": visualizations,
            "manage_actions": self._constructManageActions(),
            "visibilities": self._constructVisibilities(infos),
        }